Skip to content

Instantly share code, notes, and snippets.

@themoxman
Created May 10, 2014 17:53
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 themoxman/683edb07a3f42a982549 to your computer and use it in GitHub Desktop.
Save themoxman/683edb07a3f42a982549 to your computer and use it in GitHub Desktop.
# example from: https://relishapp.com/rspec/rspec-mocks/v/2-14/docs/
# wrote the code to make their example spec pass
class Account
attr_accessor :logger
def close
logger.account_closed(self)
end
def account_closed(something)
end
end
describe Account do
context "when closed" do
it "logs an 'account closed' message" do
logger = double()
account = Account.new
account.logger = logger
logger.should_receive(:account_closed).with(account)
account.close
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment