Class: RSpec::Matchers::BuiltIn::RespondTo::ArityCheck Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/respond_to.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(expected_arity, expected_keywords, arbitrary_keywords, unlimited_arguments) ⇒ ArityCheck

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ArityCheck.



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/respond_to.rb', line 162

def initialize(expected_arity, expected_keywords, arbitrary_keywords, unlimited_arguments)
  expectation = Support::MethodSignatureExpectation.new

  if expected_arity.is_a?(Range)
    expectation.min_count = expected_arity.min
    expectation.max_count = expected_arity.max
  else
    expectation.min_count = expected_arity
  end

  expectation.keywords = expected_keywords
  expectation.expect_unlimited_arguments = unlimited_arguments
  expectation.expect_arbitrary_keywords  = arbitrary_keywords
  @expectation = expectation
end

Instance Method Details

#matches?(actual, name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


178
179
180
181
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/respond_to.rb', line 178

def matches?(actual, name)
  return true if @expectation.empty?
  verifier_for(actual, name).with_expectation(@expectation).valid?
end

#method_signature_for(actual, name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



187
188
189
190
191
192
193
194
195
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/respond_to.rb', line 187

def method_signature_for(actual, name)
  method_handle = Support.method_handle_for(actual, name)

  if name == :new && method_handle.owner === ::Class && ::Class === actual
    Support::MethodSignature.new(actual.instance_method(:initialize))
  else
    Support::MethodSignature.new(method_handle)
  end
end

#verifier_for(actual, name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



183
184
185
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/respond_to.rb', line 183

def verifier_for(actual, name)
  Support::StrictSignatureVerifier.new(method_signature_for(actual, name))
end