-
Notifications
You must be signed in to change notification settings - Fork 6
/
ruby_version_spec.rb
92 lines (80 loc) · 2.72 KB
/
ruby_version_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
require 'ruby_dep/travis'
RSpec.describe RubyDep::Travis::RubyVersion do
subject { described_class.new(travis_version_string) }
describe '#initialize' do
context 'with an unknown version string' do
let(:travis_version_string) { 'ruby-head' }
it 'returns the version segments' do
expect { subject }.to raise_error(
described_class::Error::Unrecognized,
/Unrecognized Ruby version: "ruby-head"/
)
end
end
context 'with an unhandled JRuby version string' do
let(:travis_version_string) { 'jruby-9.9.9.9' }
it 'returns the version segments' do
expect { subject }.to raise_error(
described_class::Error::Unrecognized::JRubyVersion,
/Unrecognized JRuby version: "9.9.9.9"/
)
end
end
end
describe '#segments' do
context 'with a bare version string' do
let(:travis_version_string) { '2.2.4' }
it 'returns the version segments' do
expect(subject.segments).to eq([2, 2, 4])
end
end
context 'with a ruby version string' do
let(:travis_version_string) { 'ruby-2.2.4' }
it 'returns the version segments' do
expect(subject.segments).to eq([2, 2, 4])
end
end
context 'with a ruby version string' do
let(:travis_version_string) { 'ruby-2.2.4' }
it 'returns the version segments' do
expect(subject.segments).to eq([2, 2, 4])
end
end
context 'with JRuby 9.0.4.0' do
let(:travis_version_string) { 'jruby-9.0.4.0' }
it 'returns the Ruby implementation version segments' do
expect(subject.segments).to eq([2, 2, 2])
end
end
context 'with JRuby 9.0.5.0' do
let(:travis_version_string) { 'jruby-9.0.5.0' }
it 'returns the Ruby implementation version segments' do
expect(subject.segments).to eq([2, 2, 3])
end
end
context 'with a patch-level ruby string' do
let(:travis_version_string) { 'ruby-2.0.0-p648' }
it 'returns the version segments' do
expect(subject.segments).to eq([2, 0, 0])
end
end
context 'with a clang ruby string' do
let(:travis_version_string) { 'ruby-2.1.10-clang' }
it 'returns the version segments' do
expect(subject.segments).to eq([2, 1, 10])
end
end
context 'with a patch-level clang ruby string' do
let(:travis_version_string) { 'ruby-2.1.9-p123-clang' }
it 'returns the version segments' do
expect(subject.segments).to eq([2, 1, 9])
end
end
context 'with JRuby 9.1.2.0' do
let(:travis_version_string) { 'jruby-9.1.2.0' }
it 'returns the Ruby implementation version segments' do
expect(subject.segments).to eq([2, 3, 0])
end
end
end
end