lib/bogus/stubbing/overwrites_methods.rb in bogus-0.1.4 vs lib/bogus/stubbing/overwrites_methods.rb in bogus-0.1.5

- old
+ new

@@ -4,11 +4,11 @@ takes :makes_substitute_methods def overwrite(object, name) raise "wut?" if name == :__shadow__ - return if object.is_a?(FakeObject) + return if already_delegates_to_shadow?(object, name) object.extend RecordInteractions object.extend HasOverwritenMethods method = method_by_name(object, name) @@ -22,9 +22,14 @@ object.__reset__ end private + + def already_delegates_to_shadow?(object, name) + return false unless object.is_a?(FakeObject) + !Fake.instance_methods.include?(name) + end def method_by_name(object, name) object.method(name) if object.methods.include?(name) end