Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit ee98c6d

Browse files
committed
Add spec to track Ripper support for each Ruby implementation
1 parent 4ba2e05 commit ee98c6d

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

spec/rspec/support/ruby_features_spec.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,51 @@ module Support
131131
end
132132
end
133133
end
134+
135+
describe 'Ripper' do
136+
let(:line_number) do
137+
token = tokens.first
138+
location = token.first
139+
location.first
140+
end
141+
142+
let(:tokens) do
143+
require 'ripper'
144+
Ripper.lex('foo')
145+
end
146+
147+
if Ruby.mri?
148+
context 'on MRI' do
149+
context '1.8.x', :if => RUBY_VERSION.start_with?('1.8.') do
150+
it 'is not supported' do
151+
expect { tokens }.to raise_error(LoadError)
152+
end
153+
end
154+
155+
context '1.9.x or later', :if => RUBY_VERSION >= '1.9' do
156+
it 'is supported' do
157+
expect(line_number).to eq(1)
158+
end
159+
end
160+
end
161+
end
162+
163+
if Ruby.jruby? && RUBY_VERSION >= '1.9.0'
164+
context 'on JRuby' do
165+
context '1.7.x', :if => JRUBY_VERSION.start_with?('1.7.') do
166+
it 'is supported' do
167+
expect(line_number).to eq(1)
168+
end
169+
end
170+
171+
context '9.x.x.x', :if => JRUBY_VERSION.start_with?('9.') do
172+
it 'reports wrong line number' do
173+
expect(line_number).to eq(2)
174+
end
175+
end
176+
end
177+
end
178+
end
134179
end
135180
end
136181
end

0 commit comments

Comments
 (0)