Class: RSpec::Mocks::VerifyingExistingMethodDouble

Inherits:
VerifyingMethodDouble show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/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.

Direct Known Subclasses

VerifyingExistingClassNewMethodDouble

Constant Summary

Constants inherited from MethodDouble

MethodDouble::FROZEN_ERROR_MSG

Instance Attribute Summary

Attributes inherited from MethodDouble

#expectations, #method_name, #method_stasher, #object, #stubs

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from VerifyingMethodDouble

#add_expectation, #add_stub, #message_expectation_class, #proxy_method_invoked, #validate_arguments!

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_implementation_callable, #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

#initialize(object, method_name, proxy) ⇒ VerifyingExistingMethodDouble

Returns a new instance of VerifyingExistingMethodDouble.



181
182
183
184
185
186
187
188
189
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/verifying_proxy.rb', line 181

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_implementation_callable!
end

Class Method Details

.for(object, method_name, proxy) ⇒ Object



199
200
201
202
203
204
205
206
207
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/verifying_proxy.rb', line 199

def self.for(object, method_name, proxy)
  if ClassNewMethodReference.applies_to?(method_name) { object }
    VerifyingExistingClassNewMethodDouble
  elsif Mocks.configuration.temporarily_suppress_partial_double_verification
    MethodDouble
  else
    self
  end.new(object, method_name, proxy)
end

Instance Method Details

#unimplemented?Boolean

Returns:

  • (Boolean)


195
196
197
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/verifying_proxy.rb', line 195

def unimplemented?
  !@valid_method
end

#with_signature {|Support::MethodSignature.new(original_implementation_callable)| ... } ⇒ Object



191
192
193
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/verifying_proxy.rb', line 191

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