Question

After updating rspec-rails from version 2.14.0 to 3.0.0.beta2, all tests that uses be_true or be_false fails.

 Failure/Error: user.new_record?.should be_true
 NoMethodError:
   undefined method `true?' for true:TrueClass

Any suggestion? Google returns anything about this!

Was it helpful?

Solution

As of version 3.0, RSpec renamed be_true to be_truthy and be_false to be_falsey as documented in https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/be-matchers and discussed in https://github.com/rspec/rspec-expectations/issues/283.

be_true and be_false were deprecated in 2.99 and dropped in 3.00 because they didn't just match true and false, respectively and were therefore misleading. The error message you're getting is because absent any specific be_xxxx method definition, be_xxxx will look for and invoke xxxx? on the actual.

Note that if you want to match just true, you can use be true (or be(true)).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top