我磕碰這樣的方法在我的測試中採用摩卡存根方法,無需任何期望
def setup
super
#blah, blah
GoogleIdentity.stubs(:new).with(google_identity).returns(google_account)
end
一個的設置的問題是,不是每個測試將調用方法和返回的對象。
在不調用該方法的方法,我得到這個錯誤:
allowed any number of times, not yet invoked: GoogleIdentity.new()
好像摩卡抱怨因爲該方法已經不被調用。
如何指定一個不指望它爲calle的存根?
摩卡改變了嗎? 「一個存根就是對零個或多個調用的期望。」 http://gofreerange.com/mocha/docs/ – mahemoff