次のコードがあります。
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) スタブしない場合、予期しないメッセージ エラーが発生します。
前もって感謝します。