2011-02-03 39 views

回答

24

看摩卡的never或RSpec中的should_not_receiveshould_receive(:selector).exactly(n).times

+1

摩卡鏈接已經過期。 [永不刪除新文檔](http://gofreerange.com/mocha/docs/Mocha/Expectation.html#never-instance_method) – 2014-10-01 03:19:05

2

我不是摩卡專家,但我懷疑你需要什麼可以由never修飾符提供的期望。

0

RSpec的3.6現在expect(...).not_to receive(...)處理此。

從鏈接:

RSpec.describe "A negative message expectation" do 
    it "passes if the message is never received" do 
    dbl = double("Some Collaborator").as_null_object 
    expect(dbl).not_to receive(:foo) 
    end 
end 
相關問題