我試圖在Rspec的一個塊中測試消息的預期:如何測試Rspec中的塊內的消息期望?
def a_method
ALibrary.execute do |batch|
batch.execute if a == 1
end
end
如果我在ALibrary
磕碰出execute
方法,我怎麼測試的消息被送到內execute
?
allow(ALibrary).to receive(:execute).and_return(a_library_execute)
let(:a_library_execute) {double(execute:true)}
謝謝!