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

StackOverflow https://stackoverflow.com/questions/22303068

質問

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top