Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
make impl cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmohare committed Jan 17, 2024
1 parent 7f30ba3 commit 30dea7d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/rspec/support/method_signature_verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def invalid_kw_args_from(given_kw_args)
def has_kw_args_in?(args)
Hash === args.last &&
could_contain_kw_args?(args) &&
(args.last.empty? || args.last.keys.any? { |x| x.is_a?(Symbol) || RubyFeatures.kw_arg_separation? })
(RubyFeatures.kw_arg_separation? || args.last.empty? || args.last.keys.any? { |x| x.is_a?(Symbol) })
end

# Without considering what the last arg is, could it
Expand Down Expand Up @@ -363,15 +363,17 @@ def unlimited_args?
end

def split_args(*args)
kw_args = if @signature.has_kw_args_in?(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) || RubyFeatures.kw_arg_separation? }
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) || RubyFeatures.kw_arg_separation? }.keys
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
Expand Down

0 comments on commit 30dea7d

Please sign in to comment.