【发布时间】:2013-06-22 09:10:35
【问题描述】:
考虑以下测试:
class A
def print(args)
puts args
end
end
describe A do
let(:a) {A.new}
it "receives print" do
a.should_receive(:print).with("World").and_call_original
a.print("Hello")
a.print("World")
end
end
使用 should_receive() 设置接收者应该收到的期望 示例完成前的消息。
所以我期待这个测试通过,但事实并非如此。它失败并显示以下消息:
Failures:
1) A receives print
Failure/Error: a.print("Hello")
#<A:0x007feb46283190> received :print with unexpected arguments
expected: ("World")
got: ("Hello")
这是预期的行为吗?有没有办法让这个测试通过?
我正在使用 ruby 1.9.3p374 和 rspec 2.13.1
【问题讨论】:
-
您遵循什么文档?你会分享链接吗?这是我要求自学... :))
-
问题中有链接。 :)