Created
June 22, 2015 15:30
-
-
Save ktheory/caba3d3f2cce0ae2dd12 to your computer and use it in GitHub Desktop.
Minitest mock method question
This file contains hidden or 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
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