[Rspec-users] 1 should be 2. huh?
aslak.hellesoy at gmail.com
Tue Oct 24 19:45:54 EDT 2006
On 10/24/06, David Chelimsky <dchelimsky at gmail.com> wrote:
> Can you please submit an RFE on this one?
> On 10/24/06, Micah Martin <micah at 8thlight.com> wrote:
> > 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:
The simple solution would be:
> > 1 should equal 2
1 (actual value) should equal 2 (expected value)
> > 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?
I'll pick up the glove on this. It will be a fun exercise in parsing
the source file to extract the variable names. We have all the info
available (file, line number) in the stack trace.
Could you file an RFE in the form of failing specs expressing what you
want the error message to be? Hint:
x = 1
end.should_raise(ExpectationNotMetError, "x should equal 2 but was 1")
-enough to cover all the cases you can think of?
> > Micah Martin
> > 8th Light, Inc.
> > www.8thlight.com
> > _______________________________________________
> > Rspec-users mailing list
> > Rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> Rspec-users mailing list
> Rspec-users at rubyforge.org
More information about the Rspec-users