Using the last argument as keyword parameters is deprecated for arbitrary handling with a block
Created by: linkyndy
Subject of the issue
I am performing a complex expectation as described in the arbitrary handling section of the docs. Here is the expectation:
expect(double).to receive(:method) do |item:, &block|
expect(item).to eq(item)
expect(another_double).to receive(:another_method)
# ...other expectations...
block.call(another_double)
end
I get the following warning from Ruby 2.7:
/Users/foo/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/message_expectation.rb:694: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/Users/foo/project/spec/bar_spec.rb:33: warning: The called method `call' is defined here
where the line mentioned is the first line in the Ruby snippet above.
Your environment
- Ruby version: 2.7.0
- rspec-mocks version: 3.9.1
I am not sure how I can fix this; tried expect(double).to receive(:method) do |item:, **kwargs, &block|
but it yielded the same error.