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 UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
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)