[rspec-users] Bug in should_not_be - What else to use?

Tobi listaccount at e-tobi.net
Sun Jan 28 19:58:00 EST 2007


I just stumbled over a possible bug in

`1.should_not_be == 1` does not fail.

I took a look into the code and figured out, that this is caused by
Not.be() using :no_arg instead of :___no_arg. The expected argument of
the method be() in Not is passed from should_not_be() with :___no_arg.

Not.be() is marked with "Gone for 0.9", so I assume that "should_not_be
==" shouldn't be used at all, right? So what else to use, when testing
of "==" is required?

1.should_not == 1

...gives a "not so nice" failure message: "1 should not == 1 nil" - this
would read nicer as "1 should not be == 1"

Where is the "nil" in the failure message coming from anyway? I digged a
little bit deeper into the sources and figured that out too:

In the Not class, instead of passing the not expected value as the
second argument to default_message, it gets appended to the message text,
so the missing argument will then be added by default_message() as nil.
I've already added a bug report.



More information about the rspec-users mailing list