Compatibility of shared_examples with Ruby 3
Created by: WojciechKo
Subject of the issue
Compatibility of shared_examples
with a "Real" keyword argument from upcoming Ruby 3
Your environment
- Ruby version: 2.7.0preview3
- rspec-core version: 3.9.0
Steps to reproduce
RSpec.describe 'ruby 2.7.0.preview3 warning' do
shared_examples 'expects hash' do |hash|
it { expect(hash[:input].reverse).to eq(hash[:output]) }
end
shared_examples 'expects keywords' do |input:, output:|
it { expect(input.reverse).to eq(output) }
end
include_examples 'expects hash', input: 'afla', output: 'alfa'
include_examples 'expects hash', { input: 'ovarb', output: 'bravo' }
include_examples 'expects keywords', input: 'eilrahc', output: 'charlie' # Warning
include_examples 'expects keywords', { input: 'atled', output: 'delta' } # Warning
end
Expected behavior
-
charlie
example should not produce any warning -
alfa
should not be supported to follow Ruby 3 changes (?)
Actual behavior
Following warning is being printed for charlie
and delta
case
/home/wojciechko/.rbenv/versions/2.7.0-preview3/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/shared_example_group.rb:36: warning: The last argument is used as the keyword parameter
/home/wojciechko/dev/sample_spec.rb:6: warning: for method defined here