[Rspec-users] 1 should be 2. huh?

Micah Martin micah at 8thlight.com
Tue Oct 24 09:43:31 EDT 2006

There's another quirk I wanted to bring up.  It's about the failure  
message with should_equal and should_be.

x.should_equal 2
a.should_not_be nil

When they fail they yield messages like:

1 should equal 2
nil should not be nil

When I'm caught off guard, which can be often, these messages confuse  
me.  1 should equal 2?  No it shouldn't.  nil should not be nil?  But  
they are the same!
You get my drift?  When taken out side the context of a  
specification, these statements are just absurd.

In my humble opinion, these messages should include their context and  
read like this:

x should equal 2 but was 1
a should not be nil but was nil

I realize there might be an issue printing the expression that gets  
evaluated, but you guys have done some cool magic to this point.   
Have you got a bit more up your sleeves?

Micah Martin
8th Light, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061024/21a37e7b/attachment.html 

More information about the Rspec-users mailing list