Read more

RSpec claims nil to be false

Arne Hartherz
June 29, 2012Software engineer at makandra GmbH

RSpec's be_false behaves unexpectedly:

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

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

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

Posted by Arne Hartherz to makandra dev (2012-06-29 12:19)