-
-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
Make `with` support Ruby 3 keywords
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -381,16 +381,26 @@ def ==(other) | |
a_double.random_call(:a => "a", :b => "b") | ||
end | ||
|
||
it "matches against a hash submitted by reference and received by value" do | ||
it "matches against a hash submitted as keyword arguments a and received as a positional argument (in both Ruby 2 and Ruby 3)" do | ||
opts = {:a => "a", :b => "b"} | ||
expect(a_double).to receive(:random_call).with(opts) | ||
a_double.random_call(:a => "a", :b => "b") | ||
end | ||
|
||
it "matches against a hash submitted by value and received by reference" do | ||
opts = {:a => "a", :b => "b"} | ||
expect(a_double).to receive(:random_call).with(:a => "a", :b => "b") | ||
a_double.random_call(opts) | ||
if RUBY_VERSION >= "3" | ||
it "fails to matches against a hash submitted as a positional argument and received as keyword arguments in Ruby 3.0 or later", :reset => true do | ||
opts = {:a => "a", :b => "b"} | ||
expect(a_double).to receive(:random_call).with(:a => "a", :b => "b") | ||
expect do | ||
a_double.random_call(opts) | ||
end.to fail_with(/expected: \(\{(:a=>\"a\", :b=>\"b\"|:b=>\"b\", :a=>\"a\")\}\)/) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
simi
|
||
end | ||
else | ||
it "matches against a hash submitted as a positional argument and received as keyword arguments in Ruby 2.7 or before" do | ||
opts = {:a => "a", :b => "b"} | ||
expect(a_double).to receive(:random_call).with(:a => "a", :b => "b") | ||
a_double.random_call(opts) | ||
end | ||
end | ||
|
||
it "fails for a hash w/ wrong values", :reset => true do | ||
|
Error message reported here is slightly confusing.
We found out this in bundler spec suite rubygems/rubygems#5322 (comment).
@JonRowe @mame Would it be possible to fail with more explanatory message mentioning different kind of argument was expected? It is impossible to find out with current message and it seems like rspec bug instead. I can try to contribute as well, but I'm not sure how to report this kind of difference.