class RSpec::Support::MethodSignatureVerifier

@api private
Abstract base class for signature verifiers.

def arbitrary_kw_args?

def arbitrary_kw_args?
  !@arbitrary_kw_args || @signature.arbitrary_kw_args?
end

def error_message

def error_message
  if missing_kw_args.any?
    "Missing required keyword arguments: %s" % [
      missing_kw_args.join(", ")
    ]
  elsif invalid_kw_args.any?
    "Invalid keyword arguments provided: %s" % [
      invalid_kw_args.join(", ")
    ]
  elsif !valid_non_kw_args?
    "Wrong number of arguments. Expected %s, got %s." % [
      @signature.non_kw_args_arity_description,
      non_kw_args
    ]
  end
end

def initialize(signature, args=[])

def initialize(signature, args=[])
  @signature = signature
  @non_kw_args, @kw_args = split_args(*args)
  @min_non_kw_args = @max_non_kw_args = @non_kw_args
  @arbitrary_kw_args = @unlimited_args = false
end

def invalid_kw_args

def invalid_kw_args
  @signature.invalid_kw_args_from(kw_args)
end

def missing_kw_args

def missing_kw_args
  @signature.missing_kw_args_from(kw_args)
end

def split_args(*args)

def split_args(*args)
  kw_args = if @signature.has_kw_args_in?(args) && !RubyFeatures.kw_arg_separation?
              last = args.pop
              non_kw_args = last.reject { |k, _| k.is_a?(Symbol) }
              if non_kw_args.empty?
                last.keys
              else
                args << non_kw_args
                last.select { |k, _| k.is_a?(Symbol) }.keys
              end
            elsif @signature.has_kw_args_in?(args) && RubyFeatures.kw_arg_separation?
              args.pop.keys
            else
              []
            end
  [args.length, kw_args]
end

def unlimited_args?

def unlimited_args?
  !@unlimited_args || @signature.unlimited_args?
end

def valid?

def valid?
  missing_kw_args.empty? &&
    invalid_kw_args.empty? &&
    valid_non_kw_args? &&
    arbitrary_kw_args? &&
    unlimited_args?
end

def valid_non_kw_args?

def valid_non_kw_args?
  @signature.valid_non_kw_args?(min_non_kw_args, max_non_kw_args)
end

def with_expectation(expectation) # rubocop:disable Metrics/MethodLength

rubocop:disable Metrics/MethodLength
def with_expectation(expectation) # rubocop:disable Metrics/MethodLength
  return self unless MethodSignatureExpectation === expectation
  if expectation.empty?
    @min_non_kw_args = @max_non_kw_args = @non_kw_args = nil
    @kw_args     = []
  else
    @min_non_kw_args = @non_kw_args = expectation.min_count || 0
    @max_non_kw_args                = expectation.max_count || @min_non_kw_args
    if RubyFeatures.optional_and_splat_args_supported?
      @unlimited_args = expectation.expect_unlimited_arguments
    else
      @unlimited_args = false
    end
    if RubyFeatures.kw_args_supported?
      @kw_args           = expectation.keywords
      @arbitrary_kw_args = expectation.expect_arbitrary_keywords
    else
      @kw_args           = []
      @arbitrary_kw_args = false
    end
  end
  self
end