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

Commit ea46730

Browse files
committed
Add spec to track Ripper support for each Ruby implementation
1 parent 6042ee1 commit ea46730

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

spec/rspec/support/ruby_features_spec.rb

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,59 @@ module Support
8686
it 'does not load Ripper' do
8787
expect { RubyFeatures.ripper_supported? }.not_to change { defined?(::Ripper) }
8888
end
89+
90+
describe 'Ripper' do
91+
let(:line_number) do
92+
token = tokens.first
93+
location = token.first
94+
location.first
95+
end
96+
97+
let(:tokens) do
98+
require 'ripper'
99+
::Ripper.lex('foo')
100+
end
101+
102+
if Ruby.mri?
103+
context 'on MRI' do
104+
context '1.8.x', :if => RUBY_VERSION.start_with?('1.8.') do
105+
it 'is not supported' do
106+
expect { tokens }.to raise_error(LoadError)
107+
end
108+
end
109+
110+
context '1.9.x or later', :if => RUBY_VERSION >= '1.9' do
111+
it 'is supported' do
112+
expect(line_number).to eq(1)
113+
end
114+
end
115+
end
116+
end
117+
118+
if Ruby.jruby?
119+
context 'on JRuby' do
120+
context '1.7.x', :if => JRUBY_VERSION.start_with?('1.7.') do
121+
context 'in 1.8 mode', :if => RUBY_VERSION.start_with?('1.8.') do
122+
it 'is not supported' do
123+
expect { tokens }.to raise_error(NameError)
124+
end
125+
end
126+
127+
context 'in non 1.8 mode', :unless => RUBY_VERSION.start_with?('1.8.') do
128+
it 'is supported' do
129+
expect(line_number).to eq(1)
130+
end
131+
end
132+
end
133+
134+
context '9.x.x.x', :if => JRUBY_VERSION.start_with?('9.') do
135+
it 'reports wrong line number' do
136+
expect(line_number).to eq(2)
137+
end
138+
end
139+
end
140+
end
141+
end
89142
end
90143
end
91144
end

0 commit comments

Comments
 (0)