我有以下代码:
require_relative '../spec_helper'
describe PaymentProcessor do
before(:each) do
@processor = PaymentProcessor.new
end
describe '#process' do
context 'payment accepted, sha digest valid' do
it 'should return true and have no errors' do
GamePlayResult.stub(:new).and_return(mock('GamePlayResult'))
ticket = stub_model(Ticket, player: stub_model(Player, has_funds?: true))
Ticket.stub(:find).and_return ticket
game = stub_model(Game, play: ticket, tolerance: 10)
query = 'orderID=1060&STATUS=5&PAYID=17314217&NCERROR=0&SHASIGN=E969563B64ED6F93F5DC47A86B1B04DFC884B4A7'
@processor.process(query, game).should_not be_false
game.should_receive(:play)
@processor.error.should equal nil
end
end
end
end
除此以外的所有断言game.should_receive(:play)
都得到满足。但是我知道它:play
正在被调用,因为a)如果它不是,其他断言将失败,并且b)如果我不存根它,我会收到一个意外的消息错误。
提前致谢。