測試模塊Rspec的should_receive的模塊不能正常工作,擴展自
module Notifications
extend self
def notify(push_id, platform, message, event, args)
puts "hello"
...
end
end
Notifications.should_receive(:notify)
Rspec的說,通知是不叫,但「你好」被打印到日誌中。
您沒有包含應該引起此調用的代碼。我想如果這個模塊被包含在一個類中,那麼在該類的一個實例上調用'#notify',那麼應該打印出「hello」,但Notifications絕不會是消息的接收者。 –