dgreenway
9/9/2014 - 6:30 AM

Adds a property to a class instance and redefines the method we want to check to update the property which we can then check

Adds a property to a class instance and redefines the method we want to check to update the property which we can then check

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