Class: RSpec::Mocks::VerifyingExistingMethodDouble

Inherits:
VerifyingMethodDouble show all
Defined in:
lib/rspec/mocks/verifying_proxy.rb

Overview

A VerifyingMethodDouble fetches the method to verify against from the original object, using a MethodReference. This works for pure doubles, but when the original object is itself the one being modified we need to collapse the reference and the method double into a single object so that we can access the original pristine method definition.

Constant Summary

Instance Attribute Summary

Attributes inherited from MethodDouble

#expectations, #method_name, #object, #stubs

Instance Method Summary (collapse)

Methods inherited from VerifyingMethodDouble

#add_expectation, #message_expectation_class, #proxy_method_invoked

Methods inherited from MethodDouble

#add_default_stub, #add_expectation, #add_simple_expectation, #add_simple_stub, #add_stub, #build_expectation, #clear, #configure_method, #define_proxy_method, #message_expectation_class, #object_singleton_class, #original_method, #proxy_method_invoked, #raise_method_not_stubbed_error, #remove_stub, #remove_stub_if_present, #reset, #restore_original_method, #restore_original_visibility, #setup_simple_method_double, #show_frozen_warning, #verify, #visibility

Constructor Details

- (VerifyingExistingMethodDouble) initialize(object, method_name, proxy)



151
152
153
154
155
156
157
158
159
# File 'lib/rspec/mocks/verifying_proxy.rb', line 151

def initialize(object, method_name, proxy)
  super(object, method_name, proxy, self)

  @valid_method = object.respond_to?(method_name, true)

  # Trigger an eager find of the original method since if we find it any
  # later we end up getting a stubbed method with incorrect arity.
  save_original_method!
end

Instance Method Details

- (Boolean) unimplemented?



165
166
167
# File 'lib/rspec/mocks/verifying_proxy.rb', line 165

def unimplemented?
  !@valid_method
end

- (Object) with_signature {|Support::MethodSignature.new(original_method)| ... }

Yields:

  • (Support::MethodSignature.new(original_method))


161
162
163
# File 'lib/rspec/mocks/verifying_proxy.rb', line 161

def with_signature
  yield Support::MethodSignature.new(original_method)
end