Hi all,
I am trying to test that a view file in Rails is being sent a new
empty model (Product.new) in my rspec test, below is my code. I’ve
tried comparing them with ==, ===, equal, eql none work. I just get an
error (see below code). I guess it’s the condition tester (e.g. ==)
that is incorrect, can anyone help?
Code:
it “should assign the new product for the view” do
do_get
assigns[:product].should == Product.new
end
Error:
‘ProductsController handling GET /products/new should assign the new
product for the view’ FAILED
expected: #<Product id: nil, name: nil, permalink: nil, description:
nil, price: nil, is_enabled: nil, created_at: nil, updated_at: nil,
manufacturer_id: nil>,
got: #<Product id: nil, name: nil, permalink: nil, description:
nil, price: nil, is_enabled: nil, created_at: nil, updated_at: nil,
manufacturer_id: nil> (using ==)
./spec/controllers/products_controller_spec.rb:118: