class Mocha::AnyInstanceMethod
Public Instance Methods
mock()
click to toggle source
# File lib/mocha/any_instance_method.rb, line 6 def mock stubbee.any_instance.mocha end
reset_mocha()
click to toggle source
# File lib/mocha/any_instance_method.rb, line 10 def reset_mocha stubbee.any_instance.reset_mocha end
restore_original_method()
click to toggle source
# File lib/mocha/any_instance_method.rb, line 14 def restore_original_method return if use_prepended_module_for_stub_method? return unless stub_method_overwrites_original_method? original_method_owner.send(:define_method, method_name, original_method) Module.instance_method(original_visibility).bind(original_method_owner).call(method_name) end
Private Instance Methods
original_method_owner()
click to toggle source
# File lib/mocha/any_instance_method.rb, line 36 def original_method_owner stubbee end
store_original_method()
click to toggle source
# File lib/mocha/any_instance_method.rb, line 23 def store_original_method @original_method = original_method_owner.instance_method(method_name) end
stub_method_definition()
click to toggle source
# File lib/mocha/any_instance_method.rb, line 27 def stub_method_definition method_implementation = <<-CODE def #{method_name}(*args, &block) self.class.any_instance.mocha.method_missing(:#{method_name}, *args, &block) end CODE [method_implementation, __FILE__, __LINE__ - 4] end