Created
December 22, 2011 15:23
-
-
Save RStankov/1510673 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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