デポ アプリケーションのテスト ケースを作成しようとしています。以下はコードです
モデル:
class Product < ActiveRecord::Base
attr_accessible :description, :image_url, :price, :title
validates :title, :description, :image_url, :presence => true
validates :price, :numericality => {:greater_than_or_equal_to => 0.01}
end
テストケース:
require 'spec_helper'
describe Product do
before :each do
@product = Product.new "Title", "Description", "Image Url", "Price"
end
describe "#new" do
it "takes four parameters and returns a product" do
@product.should be_an_instance_of Product
end
end
describe "#title" do
it "returns the correct title" do
@product.title.should eql "Title"
end
end
describe "#description" do
it "returns the correct description" do
@product.description.should eql "Description"
end
end
describe "#image_url" do
it "returns the correct image_url" do
@product.image_url.should eql "Image Url"
end
end
describe "#price" do
it "returns the correct price" do
@product.price.should eql "Price"
end
end
end
エラーが発生しています
undefined method `has_key?' for nil:NilClass
と
ArgumentError:←[0m
1mwrong number of arguments (4 for 2)←[0m
./spec/product_spec.rb:5:in `new'←[0m
./spec/product_spec.rb:5:in `block (2 levels) \
in <top (required)>'" for all examples.
修正方法を教えてください