Skip to content

Commit

Permalink
Fix a failed test in hook_spec.rb use ruby-head
Browse files Browse the repository at this point in the history
  • Loading branch information
ydah committed Oct 14, 2024
1 parent e06caeb commit c52269b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions spec/rubocop/rspec/hook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,32 @@ def metadata(source)
hook(source).metadata.to_s
end

if RUBY_VERSION >= '3.4'
let(:expected_special) { 's(:sym, :special) => true' }
let(:expected_symbol) { 's(:sym, :symbol) => true' }
else
let(:expected_special) { 's(:sym, :special)=>true' }
let(:expected_symbol) { 's(:sym, :symbol)=>true' }
end

it 'extracts symbol metadata' do
expect(metadata('before(:example, :special) { foo }'))
.to eq('{s(:sym, :special)=>true}')
.to eq("{#{expected_special}}")
end

it 'extracts hash metadata' do
expect(metadata('before(:example, special: true) { foo }'))
.to eq('{s(:sym, :special)=>true}')
.to eq("{#{expected_special}}")
end

it 'combines symbol and hash metadata' do
expect(metadata('before(:example, :symbol, special: true) { foo }'))
.to eq('{s(:sym, :symbol)=>true, s(:sym, :special)=>true}')
.to eq("{#{expected_symbol}, #{expected_special}}")
end

it 'extracts hash metadata with no scope given' do
expect(metadata('before(special: true) { foo }'))
.to eq('{s(:sym, :special)=>true}')
.to eq("{#{expected_special}}")
end

it 'withstands no arguments' do
Expand Down

0 comments on commit c52269b

Please sign in to comment.