diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-01-29 21:07:46 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-01-29 21:23:14 -0200 |
commit | 049a10d4051a48136199fcdfd77bf35df9e9ad11 (patch) | |
tree | 2dd01c6e327739cd1154fe845dfafd832654f9b2 /activesupport/lib/active_support/testing | |
parent | b2bb1aaf66673a4d5bcb63ed0f5c15023c99d3c8 (diff) | |
download | rails-049a10d4051a48136199fcdfd77bf35df9e9ad11.tar.gz rails-049a10d4051a48136199fcdfd77bf35df9e9ad11.tar.bz2 rails-049a10d4051a48136199fcdfd77bf35df9e9ad11.zip |
Alias the original method first to avoid warnings
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 |