Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rspec-rails: undefined method `true?' for true:TrueClass after updating to 3.0.0.beta2 version

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!

like image 790
Rodrigo Avatar asked Mar 10 '14 14:03

Rodrigo


1 Answers

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)).

like image 93
Peter Alfvin Avatar answered Nov 02 '22 17:11

Peter Alfvin