class RSpec::Matchers::BuiltIn::RespondTo::ArityCheck
@private
def initialize(expected_arity, expected_keywords, arbitrary_keywords, unlimited_arguments)
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
def matches?(actual, name)
def matches?(actual, name) return true if @expectation.empty? verifier_for(actual, name).with_expectation(@expectation).valid? end
def method_signature_for(actual, name)
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
def verifier_for(actual, name)
def verifier_for(actual, name) Support::StrictSignatureVerifier.new(method_signature_for(actual, name)) end