From 30dea7db8130232dc40c9e544e6890f1aaac8d89 Mon Sep 17 00:00:00 2001 From: Malcolm O'Hare Date: Wed, 17 Jan 2024 12:58:10 -0500 Subject: [PATCH] make impl cleaner --- lib/rspec/support/method_signature_verifier.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/rspec/support/method_signature_verifier.rb b/lib/rspec/support/method_signature_verifier.rb index 21d0bb2d..0d590307 100644 --- a/lib/rspec/support/method_signature_verifier.rb +++ b/lib/rspec/support/method_signature_verifier.rb @@ -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 @@ -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