Skip to content

Commit

Permalink
adds spec for an empty keyword splat to a method that does not accept…
Browse files Browse the repository at this point in the history
… keywords
  • Loading branch information
moofkit committed Oct 14, 2020
1 parent 77041a3 commit b98c728
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions language/method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,22 @@ def m(a, b = nil, c = nil, d, e: nil, **f)
end
end

ruby_version_is '2.7'...'3.0' do
context 'when passing an empty keyword splat to a method that does not accept keywords' do
evaluate <<-ruby do
def m(a); a; end
ruby
h = {}

-> do
suppress_warning do
m(**h).should == {}
end
end.should_not raise_error
end
end
end

ruby_version_is ''...'3.0' do
context "assigns keyword arguments from a passed Hash without modifying it" do
evaluate <<-ruby do
Expand All @@ -1706,6 +1722,18 @@ def m(a: nil); a; end
end

ruby_version_is '3.0' do
context 'when passing an empty keyword splat to a method that does not accept keywords' do
evaluate <<-ruby do
def m(a); a; end
ruby
h = {}

-> do
m(**h).should == {}
end.should raise_error(ArgumentError)
end
end

context "raises ArgumentError if passing hash as keyword arguments" do
evaluate <<-ruby do
def m(a: nil); a; end
Expand Down

0 comments on commit b98c728

Please sign in to comment.