Hi! I just stumbled over a possible bug in 0.7.5.1: `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. bye, Tobias
David Chelimsky
2007-Jan-29 02:33 UTC
[rspec-users] Bug in should_not_be - What else to use?
On 1/28/07, Tobi <listaccount at e-tobi.net> wrote:> Hi! > > I just stumbled over a possible bug in 0.7.5.1: > > `1.should_not_be == 1` does not fail.Try should_not == 1> > 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. > > bye, > > Tobias > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Chelimsky wrote:> Try should_not == 1 >Ok. It just gives me a not so nice to read failure message: "1 should not == 1" compared to "1 should not be == 1" Maybe the "Gone for 0.9"-methods should print a deprecation warning in one of the next releases. Tobias
David Chelimsky
2007-Jan-29 12:31 UTC
[rspec-users] Bug in should_not_be - What else to use?
On 1/29/07, Tobi <listaccount at e-tobi.net> wrote:> David Chelimsky wrote: > > Try should_not == 1 > > > > Ok. It just gives me a not so nice to read failure message: > > "1 should not == 1" compared to "1 should not be == 1" > > Maybe the "Gone for 0.9"-methods should print a deprecation warning in > one of the next releases.Already in the plan. It won''t print warnings in 0.8.0, but it will be shortly thereafter, and well before the deprecated methods are removed.> > Tobias > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >