Permalink
Browse files

Cleans up the implementation after feedback from @myronmarston

  • Loading branch information...
1 parent 763dda3 commit e3ab91c86b1414c80e1f88b7b0c58c6605d9d6af @alindeman alindeman committed Jan 7, 2013
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/rspec/mocks/method_double.rb
@@ -174,16 +174,18 @@ def restore_original_method
object_singleton_class.__send__(:remove_method, @method_name)
@method_stasher.restore
- object_singleton_class.class_eval <<-EOF, __FILE__, __LINE__ + 1
- if method_defined?(:#{@method_name}) || private_method_defined?(:#{@method_name})
- #{@original_visibility}
- end
- EOF
+ restore_original_visibility
@method_is_proxied = false
end
# @private
+ def restore_original_visibility
+ return unless object_singleton_class.method_defined?(@method_name) || object_singleton_class.private_method_defined?(@method_name)
+ object_singleton_class.class_eval(@original_visibility, __FILE__, __LINE__)
+ end
+
+ # @private
def verify
expectations.each {|e| e.verify_messages_received}
end

0 comments on commit e3ab91c

Please sign in to comment.