[rspec-users] [rspec] be_something accepts nils

Pat Maddox pat.maddox at gmail.com
Fri Mar 13 11:42:19 EDT 2009


On Mar 13, 2009, at 5:17 AM, Ashley Moran wrote:

> Hi
>
> Just noticed that the behaviour of
>
>  @cow.should_not be_hungry
>
> is not the same as
>
>  @cow.hungry?.should == false # nil also passes
>
> Don't know how this has escaped me for so long =)
>
> What's the thinking behind this?  You can already do
>
>  @cow.hungry?.should(_not) be_nil
>
> so surely it makes more sense for be_true and be_false to check for  
> booleans?

be_true and be_false do check for booleans :)  but you didn't use  
either of them.

The expanded form of
@cow.should_not be_hungry
is
@cow.hungry?.should_not be

Pat


More information about the rspec-users mailing list