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

Commit 7c2aef3

Browse files
committed
Merge pull request #375 from twalpole/allow_all_kwargs
Empty last hash matches allow any kwargs
1 parent 8c29ca3 commit 7c2aef3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/rspec/support/method_signature_verifier.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ def invalid_kw_args_from(given_kw_args)
7878
end
7979

8080
def has_kw_args_in?(args)
81-
Hash === args.last && could_contain_kw_args?(args)
81+
Hash === args.last &&
82+
could_contain_kw_args?(args) &&
83+
(args.last.empty? || args.last.keys.any? { |x| x.is_a?(Symbol) })
8284
end
8385

8486
# 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
@@ -636,6 +636,7 @@ def arity_kw_arg_splat(x, **rest); end
636636
expect(valid?(nil, :x => 1)).to eq(true)
637637
expect(valid?(nil, :x => 1, :y => 2)).to eq(true)
638638
expect(valid?(:x => 1)).to eq(true)
639+
expect(valid?(nil, {})).to eq(true)
639640

640641
expect(valid?).to eq(false)
641642
expect(valid?(nil, nil)).to eq(false)

0 commit comments

Comments
 (0)