49

我将我的升级rspec-rails到 3.0.1,现在我在所有测试中都看到了这个错误

 Failure/Error: Sidekiq::Status::complete?(json.jid).should be_true
  expected true to respond to `true?`

我找不到解决方案,也找不到我所缺少的。

4

2 回答 2

96

从 rspec 3.0 开始,be_true被重命名为be_truthybe_falsebe_falsey

行为没有改变。所以

(nil).should be_falsey
(false).should be_falsey

将通过,并且

(anything other than nil or false).should be_truthy

也会通过

更新日志 3.0.0.beta1 / 2013-11-07

将 be_true 和 be_false 重命名为 be_truthy 和 be_falsey。(山姆·菲蓬)

于 2014-06-06T12:37:38.187 回答
1

为了不重写很多现有的规范,您可以将其添加到 spec_helper (它损害了我的和谐感但节省了时间):

def true.true?
  true
end

def true.false?
  false
end

def false.true?
  false
end

def false.false?
  true
end
于 2014-12-04T12:51:21.527 回答