Skip to content

Instantly share code, notes, and snippets.

@jonatas
Last active April 20, 2018 02:45
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 jonatas/bf9387bbc8ba2f0f6f9267cef5751802 to your computer and use it in GitHub Desktop.
Save jonatas/bf9387bbc8ba2f0f6f9267cef5751802 to your computer and use it in GitHub Desktop.
class Account
def withdraw(value)
if @total >= value
@total -= value
:ok
else
:not_allowed
end
end
end
# bad
allow(Account).to receive(:withdraw).and_return(:ok)
# good
allow(Account).to receive(:withdraw).with(100).and_return(:ok)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment