Skip to content

Commit 4a3bb93

Browse files
committed
Add spec for a method taking multiple optional arguments and keywords
* See #2302 (cherry picked from commit 9ab4cb5)
1 parent b568baa commit 4a3bb93

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spec/ruby/language/method_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,6 +1758,17 @@ def m(a: nil); a; end
17581758
end
17591759
end
17601760
end
1761+
1762+
it "assigns the last Hash to the last optional argument if the Hash contains non-Symbol keys and is not passed as keywords" do
1763+
def m(a = nil, b = {}, v: false)
1764+
[a, b, v]
1765+
end
1766+
1767+
h = { "key" => "value" }
1768+
m(:a, h).should == [:a, h, false]
1769+
m(:a, h, v: true).should == [:a, h, true]
1770+
m(v: true).should == [nil, {}, true]
1771+
end
17611772
end
17621773

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

0 commit comments

Comments
 (0)