Skip to content

Commit fe9678b

Browse files
committed
Run beginn/endless range tests only for respective Ruby versions
>= 2.6: endless range >= 2.7: beginnless range
1 parent 0411bbc commit fe9678b

1 file changed

Lines changed: 26 additions & 22 deletions

File tree

spec/code_breaker/parser/ranges_spec.rb

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,39 @@
1818
end
1919
end
2020

21-
context 'for a beginless inclusive range' do
22-
it 'returns a Hash with key :irange and the upper bounding type' do
23-
input = '..1.2'
24-
output = { irange: [NilClass, Float]}
25-
expect(input).to be_parsed_as output
21+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
22+
context 'for a beginless inclusive range' do
23+
it 'returns a Hash with key :irange and the upper bounding type' do
24+
input = '..1.2'
25+
output = { irange: [NilClass, Float]}
26+
expect(input).to be_parsed_as output
27+
end
2628
end
27-
end
2829

29-
context 'for a beginless exclusive range' do
30-
it 'returns a Hash with key :erange and the upper bounding type' do
31-
input = '...1.2'
32-
output = { erange: [NilClass, Float]}
33-
expect(input).to be_parsed_as output
30+
context 'for a beginless exclusive range' do
31+
it 'returns a Hash with key :erange and the upper bounding type' do
32+
input = '...1.2'
33+
output = { erange: [NilClass, Float]}
34+
expect(input).to be_parsed_as output
35+
end
3436
end
3537
end
3638

37-
context 'for a endless inclusive range' do
38-
it 'returns a Hash with key :irange and the lower bounding type' do
39-
input = '1.2..'
40-
output = { irange: [Float, NilClass]}
41-
expect(input).to be_parsed_as output
39+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0')
40+
context 'for a endless inclusive range' do
41+
it 'returns a Hash with key :irange and the lower bounding type' do
42+
input = '1.2..'
43+
output = { irange: [Float, NilClass]}
44+
expect(input).to be_parsed_as output
45+
end
4246
end
43-
end
4447

45-
context 'for a endless exclusive range' do
46-
it 'returns a Hash with key :erange and the lower bounding type' do
47-
input = '1.2...'
48-
output = { erange: [Float, NilClass]}
49-
expect(input).to be_parsed_as output
48+
context 'for a endless exclusive range' do
49+
it 'returns a Hash with key :erange and the lower bounding type' do
50+
input = '1.2...'
51+
output = { erange: [Float, NilClass]}
52+
expect(input).to be_parsed_as output
53+
end
5054
end
5155
end
5256
end

0 commit comments

Comments
 (0)