RSpec claims nil to be false

Updated . Posted . Visible to the public.

RSpec's be_false behaves unexpectedly:

nil.should be_false
# passes, as the expectation returns true

If you want to check for false, you need to do it like this:

nil.should == false
# fails as expected

Wat? Show archive.org snapshot

See also

RSpec: be_true does not actually check if a value is true

Profile picture of Arne Hartherz
Arne Hartherz
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2012-06-29 10:19)