rspec检查'with'参数为true

时间:2013-10-04 10:25:10

标签: ruby unit-testing rspec

我有以下rspec示例:

describe "with spike" do
  it "succeeds" do
    a = double('whatever')

    a.should_receive(:b).with(true)

    a.b('not false')
  end
end

如何让with接受任何非假参数?

1 个答案:

答案 0 :(得分:1)

只需编写一个任意的消息处理程序:

describe "with spike" do
  it "succeeds" do
    a = double('whatever')

    a.should_receive(:b) { |x|
      x.should_not be_false
    }

    a.b('not false')
  end
end