Skip to content

Instantly share code, notes, and snippets.

@patmaddox
Created February 27, 2009 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patmaddox/71689 to your computer and use it in GitHub Desktop.
Save patmaddox/71689 to your computer and use it in GitHub Desktop.
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