3.11.1 breaks argument matching in Ruby 2.7
Created by: drcapulet
Subject of the issue
When delegating using **kwargs
, the spec fails when passed no keyword arguments in 2.7 (no issues with 3.0).
Your environment
- Ruby version: 2.7
- rspec-mocks version: 3.11.1
Steps to reproduce
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rspec", "3.11.0"
gem "rspec-mocks", "3.11.1"
end
puts "Ruby version is: #{RUBY_VERSION}"
require 'rspec/autorun'
def call(client, name, *args, **kwargs)
client.public_send(name, *args, **kwargs)
end
RSpec.describe 'args broken' do
let(:client) { double('@client') }
it 'works' do
expect(client).to receive(:foo).with('a', 1)
call(client, :foo, 'a', 1)
end
it 'works with keyword args' do
expect(client).to receive(:foo).with('a', 1, baz: 5)
call(client, :foo, 'a', 1, baz: 5)
end
end
Expected behavior
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using bundler 2.3.4
Using rspec-support 3.11.0
Using diff-lcs 1.5.0
Using rspec-core 3.11.0
Using rspec-expectations 3.11.0
Using rspec-mocks 3.11.0
Using rspec 3.11.0
Ruby version is: 2.7.5
..
Finished in 0.00934 seconds (files took 0.06848 seconds to load)
2 examples, 0 failures
Actual behavior
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using bundler 2.3.4
Using diff-lcs 1.5.0
Using rspec-support 3.11.0
Using rspec-expectations 3.11.0
Using rspec-core 3.11.0
Using rspec-mocks 3.11.1
Using rspec 3.11.0
Ruby version is: 2.7.5
F.
Failures:
1) args broken works
Failure/Error: client.public_send(name, *args, **kwargs)
#<Double "@client"> received unexpected message :foo with ("a", 1)
# new.rb:21:in `public_send'
# new.rb:21:in `call'
# new.rb:30:in `block (2 levels) in <main>'
Finished in 0.00692 seconds (files took 0.07046 seconds to load)
2 examples, 1 failure
Failed examples:
rspec new.rb:27 # args broken works