Posted almost 10 years ago. Visible to the public.

RSpec claims nil to be false

RSpec's be_false behaves unexpectedly:

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

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

Copy
nil.should == false # fails as expected

Wat? Archive

See also

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

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Arne Hartherz
Last edit:
over 6 years ago
by Henning Koch
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more