Created
February 27, 2009 20:55
-
-
Save patmaddox/71689 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
describe AccountService, "#transfer" do | |
before(:each) do | |
@from = Account.new 500 | |
@to = Account.new 100 | |
@service = AccountService.new | |
end | |
def do_transfer | |
@service.transfer @from, @to, 150 | |
end | |
it "state-based" do | |
do_transfer | |
@from.balance.should == 350 | |
@to.balance.should == 250 | |
end | |
it "interaction-based" do | |
@from.should_receive(:debit).with(150) | |
@to.should_receive(:credit).with(150) | |
do_transfer | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment