将rspec-rails从2.14.0版本更新到3.0.0.beta2之后,所有使用be_true
or be_false的测试均失败。
Failure/Error: user.new_record?.should be_true
NoMethodError:
undefined method `true?' for true:TrueClass
有什么建议吗?Google返回有关此的任何信息!
作为版本3.0,RSpec的更名be_true
到be_truthy
和be_false
到be_falsey
作为记录在https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/be-matchers和讨论https://github.com / rspec / rspec-expectations / issues / 283。
be_true
而be_false
在2.99已过时,在3.00丢弃,因为他们不只是匹配true
和false
分别,因此被误导。您收到的错误消息是因为缺少任何特定的be_xxxx
方法定义,be_xxxx
将xxxx?
在实际情况下查找并调用。
需要注意的是,如果你想匹配正好 true
,你可以使用be true
(或be(true)
)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句