Created
September 9, 2014 06:30
-
-
Save dgreenway/a9b1757c5e465c413de6 to your computer and use it in GitHub Desktop.
Adds a property to a class instance and redefines the method we want to check to update the property which we can then check
This file contains 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
describe 'tests the thing' | |
it 'tests the thing' do | |
foo = ClassUnderTest.new | |
# monkeypatch an attribute onto our class | |
class << foo | |
attr_accessor :the_thing_was_called | |
end | |
# redefine the the_thing method | |
def fa.the_thing | |
self.the_thing_was_called = true | |
end | |
foo.some_method_that_calls_the_thing | |
assert foo.the_thing_was_called | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment