diff --git a/lib/mocha/any_instance_method.rb b/lib/mocha/any_instance_method.rb index 305ee2e14..8a3afb3c4 100644 --- a/lib/mocha/any_instance_method.rb +++ b/lib/mocha/any_instance_method.rb @@ -16,11 +16,11 @@ def reset_mocha def hide_original_method if @original_visibility = method_visibility(method) begin - @original_method = stubbee.instance_method(method) if RUBY_V2_PLUS @definition_target = PrependedModule.new stubbee.__send__ :prepend, @definition_target else + @original_method = stubbee.instance_method(method) if @original_method && @original_method.owner == stubbee stubbee.send(:remove_method, method) end