Skip to content

Instantly share code, notes, and snippets.

@RStankov
Created December 22, 2011 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save RStankov/1510673 to your computer and use it in GitHub Desktop.
Save RStankov/1510673 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