module RSpec::Mocks::AnyInstance

def __recorder

Other tags:
    Private: -
def __recorder
  @__recorder ||= AnyInstance::Recorder.new(self)
end

def __rspec_dup

def __rspec_dup
  __remove_mock_proxy
  __rspec_original_dup
end

def any_instance

Returns:
  • (Recorder) -
def any_instance
  RSpec::Mocks::space.add(self)
  modify_dup_to_remove_mock_proxy_when_invoked
  __recorder
end

def modify_dup_to_remove_mock_proxy_when_invoked

def modify_dup_to_remove_mock_proxy_when_invoked
  if self.method_defined?(:dup) and !self.method_defined?(:__rspec_original_dup)
    self.class_eval do
      def __rspec_dup
        __remove_mock_proxy
        __rspec_original_dup
      end
      
      alias_method  :__rspec_original_dup, :dup
      alias_method  :dup, :__rspec_dup
    end
  end
end

def restore_dup

def restore_dup
  if self.method_defined?(:__rspec_original_dup)
    self.class_eval do
      alias_method  :dup, :__rspec_original_dup
      remove_method :__rspec_original_dup
      remove_method :__rspec_dup
    end
  end
end

def rspec_reset

Other tags:
    Private: -
def rspec_reset
  restore_dup
  __mock_proxy.reset
end

def rspec_verify

Other tags:
    Private: -
def rspec_verify
  __recorder.verify
  super
ensure
  __recorder.stop_all_observation!
  restore_dup
  @__recorder = nil
end