Skip to content

Commit

Permalink
[support] Merge pull request rspec/rspec-support#375 from twalpole/al…
Browse files Browse the repository at this point in the history
…low_all_kwargs

Empty last hash matches allow any kwargs

---
This commit was imported from rspec/rspec-support@7c2aef3.
  • Loading branch information
JonRowe committed Jun 10, 2019
1 parent a2fda6e commit 4a5dac3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rspec-support/lib/rspec/support/method_signature_verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def invalid_kw_args_from(given_kw_args)
end

def has_kw_args_in?(args)
Hash === args.last && could_contain_kw_args?(args)
Hash === args.last &&
could_contain_kw_args?(args) &&
(args.last.empty? || args.last.keys.any? { |x| x.is_a?(Symbol) })
end

# Without considering what the last arg is, could it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ def arity_kw_arg_splat(x, **rest); end
expect(valid?(nil, :x => 1)).to eq(true)
expect(valid?(nil, :x => 1, :y => 2)).to eq(true)
expect(valid?(:x => 1)).to eq(true)
expect(valid?(nil, {})).to eq(true)

expect(valid?).to eq(false)
expect(valid?(nil, nil)).to eq(false)
Expand Down

0 comments on commit 4a5dac3

Please sign in to comment.