[rspec-users] FAILED: "test" should equal "test" - what?

aslak hellesoy aslak.hellesoy at gmail.com
Mon Dec 11 03:35:43 EST 2006


On 12/11/06, Adam Roth <adamjroth at gmail.com> wrote:
> I'm trying out rspec_on_rails with a very simple test:
>
> ...
>   specify "product name should be 'test'" do
>     Product.find( :all ).first.name.should_equal 'test'
>   end
> ...
>
> with this fixture:
>
> first:
>   id: 1
>   name: test
>
> When I run it:
>
> .F
>
> 1)
> 'Given a generated product_spec.rb with fixtures loaded product name should
> be test' FAILED
> "test" should equal "test"
> ./spec/models/product_spec.rb:12:
>
> Finished in 0.015563 seconds
>
> 2 specifications, 1 failure
> rake aborted!
>
> -------------------------
>
> "test" should equal "test", well, it does. Why is this failing?

Because "test" is not *equal* to "test" - according to Ruby.
Use should_eql or should == instead.

http://rspec.rubyforge.org/documentation/expectations.html

>
> (Installed rspec gem, installed 0_7_4 of rspec on rails plugin)
>
>
> Thanks
> Adam
>
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
>


More information about the rspec-users mailing list