should_receive`行爲請看下面的測試:RSpec的`有多個方法調用
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
Use should_receive() to set an expectation that a receiver should receive a message before the example is completed.
所以我期待這個測試通過,但事實並非如此。它與以下消息失敗:
Failures:
1) A receives print
Failure/Error: a.print("Hello")
#<A:0x007feb46283190> received :print with unexpected arguments
expected: ("World")
got: ("Hello")
這是預期的行爲?有沒有辦法讓這個測試通過?
我使用紅寶石1.9.3p374和rspec的2.13.1
您正在關注哪些文檔?你會分享鏈接嗎?這是我要求我的自學...... :)) –
問題中有一個鏈接。 :) – tdgs