Skip to content

Instantly share code, notes, and snippets.

@ktheory
Created June 22, 2015 15:30
Show Gist options
  • Save ktheory/caba3d3f2cce0ae2dd12 to your computer and use it in GitHub Desktop.
Save ktheory/caba3d3f2cce0ae2dd12 to your computer and use it in GitHub Desktop.
Minitest mock method question
class MyClass
# How do I test #run without actually invoking `do_thing1` and `do_thing2`?
# I'd like to mock them. But Minitest only allows stubbing entire objects,
# so I can't mock the methods without changing the object under test.
def run
do_thing1
do_thing2
end
def do_thing1
sleep 1
puts 'thing1'
end
def do_thing2
sleep 1
puts 'thing2'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment