Skip to content

Commit

Permalink
Add spec to ensure incoming Hash is not mutated by keyword args.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius authored and eregon committed Nov 27, 2018
1 parent 1643d71 commit 7ec1685
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions language/method_spec.rb
Expand Up @@ -1281,6 +1281,19 @@ def m(a, b = nil, c = nil, d, e: nil, **f)
result.should == [1, nil, nil, {foo: :bar}, nil, {}]
end
end

context "assigns keyword arguments from a passed Hash without modifying it" do
evaluate <<-ruby do
def m(a: nil); a; end
ruby

options = {a: 1}.freeze
lambda do
m(options).should == 1
end.should_not raise_error
options.should == {a: 1}
end
end
end

describe "A method call with a space between method name and parentheses" do
Expand Down

0 comments on commit 7ec1685

Please sign in to comment.