Make `with` support Ruby 3 keywords
Created by: mame
As you know, keyword arguments have been separated from positional ones in Ruby 3.
How about making with
to match the semantics?
It would be good to allow rspec to check if positional or keyword arguments are passed appropriately.
For example, if a mock object has `with(a: 'a', b: 'b'), it should accept keywords, not a positional Hash.
class Foo
end
foo = Foo.new
allow(foo).to receive(:bar).with(a: 'a', b: 'b')
args = { a: 'a', b: 'b' }
foo.bar(args) # fail
foo.bar(**args) # pass
Also, if a mock object has `with({ a: 'a', b: 'b' }), it should accept a positional Hash, not keywords.
foo = Foo.new
allow(foo).to receive(:bar).with({ a: 'a', b: 'b' })
args = { a: 'a', b: 'b' }
foo.bar(args) # pass
foo.bar(**args) # fail
This PR is just a proof of concept and the change partially includes #1385. What do you think?