Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

don't re-observe methods that are already being observed

Experimental fix for #96.
  • Loading branch information...
commit fe27fe233cae0320759c18a0b96a57a74a01ceb7 1 parent 49ce496
@dchelimsky dchelimsky authored
Showing with 10 additions and 9 deletions.
  1. +10 −9 lib/rspec/mocks/any_instance/recorder.rb
View
19 lib/rspec/mocks/any_instance/recorder.rb
@@ -170,15 +170,16 @@ def already_observing?(method_name)
end
def observe!(method_name)
- stop_observing!(method_name) if already_observing?(method_name)
- @observed_methods << method_name
- backup_method!(method_name)
- @klass.class_eval(<<-EOM, __FILE__, __LINE__)
- def #{method_name}(*args, &blk)
- self.class.__recorder.playback!(self, :#{method_name})
- self.__send__(:#{method_name}, *args, &blk)
- end
- EOM
+ unless already_observing?(method_name)
+ @observed_methods << method_name
+ backup_method!(method_name)
+ @klass.class_eval(<<-EOM, __FILE__, __LINE__)
+ def #{method_name}(*args, &blk)
+ self.class.__recorder.playback!(self, :#{method_name})
+ self.__send__(:#{method_name}, *args, &blk)
+ end
+ EOM
+ end
end
def mark_invoked!(method_name)
Please sign in to comment.
Something went wrong with that request. Please try again.