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

Commit 027a2e1

Browse files
authored
Merge pull request #375 from twalpole/allow_all_kwargs
Empty last hash matches allow any kwargs
2 parents e972ee6 + 2b6a502 commit 027a2e1

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/rspec/support/method_signature_verifier.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def invalid_kw_args_from(given_kw_args)
8282
def has_kw_args_in?(args)
8383
Hash === args.last &&
8484
could_contain_kw_args?(args) &&
85-
args.last.keys.any? { |x| x.is_a?(Symbol) }
85+
(args.last.empty? || args.last.keys.any? { |x| x.is_a?(Symbol) })
8686
end
8787

8888
# Without considering what the last arg is, could it

spec/rspec/support/method_signature_verifier_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ def arity_kw_arg_splat(x, **rest); end
732732
expect(valid?(nil, :x => 1)).to eq(true)
733733
expect(valid?(nil, :x => 1, :y => 2)).to eq(true)
734734
expect(valid?(:x => 1)).to eq(true)
735+
expect(valid?(nil, {})).to eq(true)
735736

736737
expect(valid?).to eq(false)
737738
expect(valid?(nil, nil)).to eq(false)

0 commit comments

Comments
 (0)