简体   繁体   中英

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM