class RSpec::Support::MethodSignature

def has_kw_args_in?(args)

def has_kw_args_in?(args)
  # If the last arg is a hash, depending on the signature it could be kw_args or a positional parameter.
  return false unless Hash === args.last && could_contain_kw_args?(args)
  # If the position of the hash is beyond the count of required and optional positional
  # args then it is the kwargs hash
  return true if args.count > @max_non_kw_args
  # This is the proper way to disambiguate between positional args and keywords hash
  # but relies on beginning of the call chain annotating the method with
  # ruby2_keywords, so only use it for positive feedback as without the annotation
  # this is always false
  return true if Hash.ruby2_keywords_hash?(args[-1])
  # Otherwise, the hash could be defined kw_args or an optional positional parameter
  # inspect the keys against known kwargs to determine what it is
  # Note: the problem with this is that if a user passes only invalid keyword args,
  #       rspec no longer detects is and will assign this to a positional argument
  return arbitrary_kw_args? || args.last.keys.all? { |x| @allowed_kw_args.include?(x) }
end