Skip to content

Instantly share code, notes, and snippets.

@phosphene
Forked from RStankov/gist:1510673
Created January 29, 2013 21:59
Show Gist options
  • Save phosphene/4668345 to your computer and use it in GitHub Desktop.
Save phosphene/4668345 to your computer and use it in GitHub Desktop.
# http://blog.firsthand.ca/2011/12/example-using-rspec-double-mock-and.html
describe Transfer do
context "transfer with amount of 10" do
let(:source_account) { double :source_account, :decrease => nil }
let(:destination_account) { double :destination_account, :increase => nil }
def transfer_amount(amount)
Transfer.new(source_account, destination_account, amount).call
end
it "should decrease source account by 10" do
source_account.should_receive(:decrease).with 10
transfer_amount 10
end
it "should increase destination account by 10" do
destination_account.should_receive(:increase).with 10
transfer_amount 10
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment