diff options
Diffstat (limited to 'activesupport/lib/active_support/testing')
-rw-r--r-- | activesupport/lib/active_support/testing/time_helpers.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/testing/time_helpers.rb b/activesupport/lib/active_support/testing/time_helpers.rb index 0e48456715..cd56ae1883 100644 --- a/activesupport/lib/active_support/testing/time_helpers.rb +++ b/activesupport/lib/active_support/testing/time_helpers.rb @@ -14,8 +14,11 @@ module ActiveSupport unstub_object(stub) end - @stubs[key] = Stub.new(object, method_name, object.method(method_name)) + new_name = "__simple_stub__#{method_name}" + @stubs[key] = Stub.new(object, method_name, new_name) + + object.singleton_class.send :alias_method, new_name, method_name object.define_singleton_method(method_name) { return_value } end @@ -27,7 +30,9 @@ module ActiveSupport end def unstub_object(stub) - stub.object.define_singleton_method(stub.method_name, stub.original_method) + stub.object.singleton_class.send :undef_method, stub.method_name + stub.object.singleton_class.send :alias_method, stub.method_name, stub.original_method + stub.object.singleton_class.send :undef_method, stub.original_method end end |