Skip to content

Commit f2440bb

Browse files
committed
Fix tests on older Rubies
Endless/beginless ranges are not valid syntax pre 2.6
1 parent 8252dd1 commit f2440bb

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

.rspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
--format documentation
33
--color
44
<% if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7') %>
5-
--exclude-pattern spec/pattern_matching_spec.rb
5+
--exclude-pattern spec/pattern_matching_spec.rb,spec/range_of_endless_spec.rb
66
<% end %>

spec/pattern_matching_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Only works in Ruby 2.7+
12
RSpec.describe ValueSemantics, 'pattern matching integration' do
23
shared_examples 'pattern matching' do
34
it 'deconstructs to a hash' do

spec/range_of_endless_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Only works in Ruby 2.6+
2+
RSpec.describe ValueSemantics::RangeOf do
3+
subject { described_class.new(Integer) }
4+
5+
it 'matches beginless ranges' do
6+
is_expected.to be === (1..)
7+
end
8+
9+
it 'matches endless ranges' do
10+
is_expected.to be === (..10)
11+
end
12+
end

spec/range_of_spec.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
is_expected.to be === (1..10)
66
end
77

8-
it 'matches beginless ranges' do
9-
is_expected.to be === (1..)
10-
end
11-
12-
it 'matches endless ranges' do
13-
is_expected.to be === (..10)
14-
end
15-
168
it 'does not match ranges whose `begin` does not match the subvalidator' do
179
expect(subject === (1.0..10)).to be(false)
1810
end

0 commit comments

Comments
 (0)