mixlib-versioning 1.2.2 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/mixlib/versioning.rb +1 -2
- data/lib/mixlib/versioning/exceptions.rb +1 -1
- data/lib/mixlib/versioning/format.rb +2 -3
- data/lib/mixlib/versioning/format/git_describe.rb +1 -1
- data/lib/mixlib/versioning/format/opscode_semver.rb +1 -1
- data/lib/mixlib/versioning/format/partial_semver.rb +1 -1
- data/lib/mixlib/versioning/format/rubygems.rb +1 -1
- data/lib/mixlib/versioning/format/semver.rb +1 -1
- data/lib/mixlib/versioning/version.rb +2 -2
- metadata +6 -53
- data/.expeditor/config.yml +0 -14
- data/.expeditor/update_version.sh +0 -9
- data/.github/CODEOWNERS +0 -3
- data/.gitignore +0 -21
- data/.travis.yml +0 -28
- data/CHANGELOG.md +0 -30
- data/Gemfile +0 -26
- data/README.md +0 -377
- data/Rakefile +0 -24
- data/VERSION +0 -1
- data/mixlib-versioning.gemspec +0 -20
- data/spec/mixlib/versioning/format/git_describe_spec.rb +0 -190
- data/spec/mixlib/versioning/format/opscode_semver_spec.rb +0 -138
- data/spec/mixlib/versioning/format/partial_semver_spec.rb +0 -121
- data/spec/mixlib/versioning/format/rubygems_spec.rb +0 -157
- data/spec/mixlib/versioning/format/semver_spec.rb +0 -128
- data/spec/mixlib/versioning/format_spec.rb +0 -88
- data/spec/mixlib/versioning/versioning_spec.rb +0 -281
- data/spec/spec_helper.rb +0 -42
- data/spec/support/shared_examples/basic_semver.rb +0 -40
- data/spec/support/shared_examples/behaviors/comparable.rb +0 -80
- data/spec/support/shared_examples/behaviors/comparable_types.rb +0 -56
- data/spec/support/shared_examples/behaviors/filterable.rb +0 -54
- data/spec/support/shared_examples/behaviors/parses_valid_version_strings.rb +0 -29
- data/spec/support/shared_examples/behaviors/rejects_invalid_version_strings.rb +0 -29
- data/spec/support/shared_examples/behaviors/serializable.rb +0 -49
- data/spec/support/shared_examples/behaviors/sortable.rb +0 -43
- data/spec/support/shared_examples/semver.rb +0 -117
data/spec/spec_helper.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "mixlib/versioning"
|
20
|
-
require "rspec/its"
|
21
|
-
|
22
|
-
# load all shared examples and shared contexts
|
23
|
-
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each do |file|
|
24
|
-
require(file)
|
25
|
-
end
|
26
|
-
|
27
|
-
RSpec.configure do |config|
|
28
|
-
# a little syntactic sugar
|
29
|
-
config.alias_it_should_behave_like_to :it_has_behavior, "has behavior:"
|
30
|
-
|
31
|
-
# Use color in STDOUT
|
32
|
-
config.color = true
|
33
|
-
|
34
|
-
# Use color not only in STDOUT but also in pagers and files
|
35
|
-
config.tty = true
|
36
|
-
|
37
|
-
# run the examples in random order
|
38
|
-
config.order = :rand
|
39
|
-
|
40
|
-
config.filter_run focus: true
|
41
|
-
config.run_all_when_everything_filtered = true
|
42
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
shared_examples "Basic SemVer" do
|
20
|
-
it_has_behavior "parses valid version strings", {
|
21
|
-
"1.2.3" => {
|
22
|
-
major: 1,
|
23
|
-
minor: 2,
|
24
|
-
patch: 3,
|
25
|
-
prerelease: nil,
|
26
|
-
build: nil,
|
27
|
-
release?: true,
|
28
|
-
prerelease?: false,
|
29
|
-
build?: false,
|
30
|
-
release_build?: false,
|
31
|
-
prerelease_build?: false,
|
32
|
-
},
|
33
|
-
}
|
34
|
-
|
35
|
-
it_has_behavior "rejects invalid version strings", {
|
36
|
-
"a.1.1" => "non-numeric MAJOR",
|
37
|
-
"1.a.1" => "non-numeric MINOR",
|
38
|
-
"1.1.a" => "non-numeric PATCH",
|
39
|
-
}
|
40
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Krzysztof Wilczynski (<kwilczynski@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
shared_examples "comparable" do |version_matrix|
|
20
|
-
describe "#<" do
|
21
|
-
version_matrix.each_slice(2) do |a, b|
|
22
|
-
it "confirms that #{a} is less-than #{b}" do
|
23
|
-
expect(described_class.new(a) < b).to be true
|
24
|
-
expect(b < described_class.new(a)).to be false
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "#<=" do
|
30
|
-
version_matrix.each_slice(2) do |a, b|
|
31
|
-
it "confirms that #{a} less-than or equal to #{b}" do
|
32
|
-
expect(described_class.new(a) <= b).to be true
|
33
|
-
expect(described_class.new(a) <= a).to be true
|
34
|
-
expect(b <= described_class.new(a)).to be false
|
35
|
-
expect(b < described_class.new(a)).to be false
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "#==" do
|
41
|
-
version_matrix.each do |v|
|
42
|
-
it "confirms that #{v} is equal to #{v}" do
|
43
|
-
expect(described_class.new(v) == v).to be true
|
44
|
-
expect(described_class.new(v) < v).to be false
|
45
|
-
expect(described_class.new(v) > v).to be false
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#>" do
|
51
|
-
version_matrix.reverse.each_slice(2) do |a, b|
|
52
|
-
it "confirms that #{a} is greather-than #{b}" do
|
53
|
-
expect(described_class.new(a) > b).to be true
|
54
|
-
expect(b > described_class.new(a)).to be false
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#>=" do
|
60
|
-
version_matrix.reverse.each_slice(2) do |a, b|
|
61
|
-
it "confirms that #{a} greater-than or equal to #{b}" do
|
62
|
-
expect(described_class.new(a) >= b).to be true
|
63
|
-
expect(described_class.new(a) >= a).to be true
|
64
|
-
expect(b >= described_class.new(a)).to be false
|
65
|
-
expect(b > described_class.new(a)).to be false
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "#between?" do
|
71
|
-
let(:versions) { version_matrix.map { |v| described_class.new(v) }.sort }
|
72
|
-
|
73
|
-
it "comfirms that a version is between the oldest and latest release" do
|
74
|
-
min, max = versions.minmax.map(&:to_s)
|
75
|
-
middle = versions[versions.size / 2].to_s
|
76
|
-
expect(described_class.new(middle).between?(min, max)).to be true
|
77
|
-
expect(described_class.new(middle).between?(max, min)).to be false
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Krzysztof Wilczynski (<kwilczynski@chef.io>)
|
3
|
-
# Author:: Ryan Hass (<rhass@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2014, 2017 Chef Software Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
shared_examples "comparable_types" do |version_matrix|
|
21
|
-
describe "#<" do
|
22
|
-
version_matrix.each_slice(2) do |a, b|
|
23
|
-
it "confirms that #{a} is less-than #{b}" do
|
24
|
-
expect(described_class.new(a) < b[:class].new(b[:value])).to be true
|
25
|
-
expect(b[:class].new(b[:value]) < described_class.new(a)).to be false
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#<=" do
|
31
|
-
version_matrix.each_slice(2) do |a, b|
|
32
|
-
it "confirms that #{a} less-than or equal to #{b}" do
|
33
|
-
expect(described_class.new(a) <= b[:class].new(b[:value])).to be true
|
34
|
-
expect(b[:class].new("#{b[:value]}") <= described_class.new(a)).to be false
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "#>" do
|
40
|
-
version_matrix.each_slice(2) do |a, b|
|
41
|
-
it "confirms that #{a} is greater-than #{b}" do
|
42
|
-
expect(b[:class].new(b[:value]) > described_class.new(a)).to be true
|
43
|
-
expect(described_class.new(a) > b[:class].new(b[:value])).to be false
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "#>=" do
|
49
|
-
version_matrix.each_slice(2) do |a, b|
|
50
|
-
it "confirms that #{a} greater-than or equal to #{b}" do
|
51
|
-
expect(b[:class].new(b[:value]) >= described_class.new(a)).to be true
|
52
|
-
expect(described_class.new(a) >= b[:class].new(b[:value])).to be false
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
shared_examples "filterable" do
|
20
|
-
let(:unsorted_versions) do
|
21
|
-
unsorted_version_strings.map { |v| described_class.new(v) }
|
22
|
-
end
|
23
|
-
|
24
|
-
# this should/will be overriden by calling spec
|
25
|
-
let(:release_versions) { [] }
|
26
|
-
let(:prerelease_versions) { [] }
|
27
|
-
let(:build_versions) { [] }
|
28
|
-
let(:release_build_versions) { [] }
|
29
|
-
let(:prerelease_build_versions) { [] }
|
30
|
-
|
31
|
-
it "filters by release versions only" do
|
32
|
-
expect(unsorted_versions.select(&:release?)).to eq(release_versions.map { |v| described_class.new(v) })
|
33
|
-
end # it
|
34
|
-
|
35
|
-
it "filters by pre-release versions only" do
|
36
|
-
filtered = unsorted_versions.select(&:prerelease?)
|
37
|
-
expect(filtered).to eq(prerelease_versions.map { |v| described_class.new(v) })
|
38
|
-
end # it
|
39
|
-
|
40
|
-
it "filters by build versions only" do
|
41
|
-
filtered = unsorted_versions.select(&:build?)
|
42
|
-
expect(filtered).to eq(build_versions.map { |v| described_class.new(v) })
|
43
|
-
end # it
|
44
|
-
|
45
|
-
it "filters by release build versions only" do
|
46
|
-
filtered = unsorted_versions.select(&:release_build?)
|
47
|
-
expect(filtered).to eq(release_build_versions.map { |v| described_class.new(v) })
|
48
|
-
end # it
|
49
|
-
|
50
|
-
it "filters by pre-release build versions only" do
|
51
|
-
filtered = unsorted_versions.select(&:prerelease_build?)
|
52
|
-
expect(filtered).to eq(prerelease_build_versions.map { |v| described_class.new(v) })
|
53
|
-
end # it
|
54
|
-
end # shared_examples
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
shared_examples "parses valid version strings" do |valid_examples|
|
20
|
-
valid_examples.each do |version, options|
|
21
|
-
context version do
|
22
|
-
let(:version_string) { version }
|
23
|
-
|
24
|
-
options.each_pair do |name, value|
|
25
|
-
its(name) { should eq value }
|
26
|
-
end
|
27
|
-
end # context
|
28
|
-
end # valid_examples
|
29
|
-
end # shared_examples
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
shared_examples "rejects invalid version strings" do |invalid_examples|
|
20
|
-
invalid_examples.each_pair do |version, reason|
|
21
|
-
context version do
|
22
|
-
let(:version_string) { version }
|
23
|
-
|
24
|
-
it "fails because: #{reason}" do
|
25
|
-
expect { subject }.to raise_error(Mixlib::Versioning::ParseError)
|
26
|
-
end
|
27
|
-
end # context
|
28
|
-
end # invalid_examples
|
29
|
-
end # shared_examples
|
@@ -1,49 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
shared_examples "serializable" do |version_strings|
|
20
|
-
describe "#to_s" do
|
21
|
-
version_strings.each do |v|
|
22
|
-
it "reconstructs the initial input for #{v}" do
|
23
|
-
expect(described_class.new(v).to_s).to eq(v)
|
24
|
-
end # it
|
25
|
-
end # version_strings
|
26
|
-
end # describe
|
27
|
-
|
28
|
-
describe "#to_semver_string" do
|
29
|
-
version_strings.each do |v|
|
30
|
-
it "generates a semver version string for #{v}" do
|
31
|
-
subject = described_class.new(v)
|
32
|
-
string = subject.to_semver_string
|
33
|
-
semver = Mixlib::Versioning::Format::SemVer.new(string)
|
34
|
-
expect(string).to eq semver.to_s
|
35
|
-
end # it
|
36
|
-
end # version_strings
|
37
|
-
end # describe
|
38
|
-
|
39
|
-
describe "#to_rubygems_string" do
|
40
|
-
version_strings.each do |v|
|
41
|
-
it "generates a rubygems version string for #{v}" do
|
42
|
-
subject = described_class.new(v)
|
43
|
-
string = subject.to_rubygems_string
|
44
|
-
rubygems = Mixlib::Versioning::Format::Rubygems.new(string)
|
45
|
-
expect(string).to eq rubygems.to_s
|
46
|
-
end # it
|
47
|
-
end # version_strings
|
48
|
-
end # describe
|
49
|
-
end # shared_examples
|
@@ -1,43 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
shared_examples "sortable" do
|
20
|
-
let(:unsorted_versions) do
|
21
|
-
unsorted_version_strings.map { |v| described_class.new(v) }
|
22
|
-
end
|
23
|
-
|
24
|
-
let(:sorted_versions) do
|
25
|
-
sorted_version_strings.map { |v| described_class.new(v) }
|
26
|
-
end
|
27
|
-
|
28
|
-
it "responds to <=>" do
|
29
|
-
expect(described_class).to respond_to(:<=>)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "sorts all properly" do
|
33
|
-
expect(unsorted_versions.sort).to eq sorted_versions
|
34
|
-
end
|
35
|
-
|
36
|
-
it "finds the min" do
|
37
|
-
expect(unsorted_versions.min).to eq described_class.new(min)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "finds the max" do
|
41
|
-
expect(unsorted_versions.max).to eq described_class.new(max)
|
42
|
-
end
|
43
|
-
end # shared_examples
|
@@ -1,117 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "mixlib/versioning"
|
20
|
-
|
21
|
-
shared_examples Mixlib::Versioning::Format::SemVer do
|
22
|
-
it_should_behave_like "Basic SemVer"
|
23
|
-
|
24
|
-
it_has_behavior "parses valid version strings", {
|
25
|
-
"1.0.0-alpha.1" => {
|
26
|
-
major: 1,
|
27
|
-
minor: 0,
|
28
|
-
patch: 0,
|
29
|
-
prerelease: "alpha.1",
|
30
|
-
build: nil,
|
31
|
-
release?: false,
|
32
|
-
prerelease?: true,
|
33
|
-
build?: false,
|
34
|
-
release_build?: false,
|
35
|
-
prerelease_build?: false,
|
36
|
-
},
|
37
|
-
"1.0.0+20130308110833" => {
|
38
|
-
major: 1,
|
39
|
-
minor: 0,
|
40
|
-
patch: 0,
|
41
|
-
prerelease: nil,
|
42
|
-
build: "20130308110833",
|
43
|
-
release?: false,
|
44
|
-
prerelease?: false,
|
45
|
-
build?: true,
|
46
|
-
release_build?: true,
|
47
|
-
prerelease_build?: false,
|
48
|
-
},
|
49
|
-
"1.0.0-beta.3+20130308110833" => {
|
50
|
-
major: 1,
|
51
|
-
minor: 0,
|
52
|
-
patch: 0,
|
53
|
-
prerelease: "beta.3",
|
54
|
-
build: "20130308110833",
|
55
|
-
release?: false,
|
56
|
-
prerelease?: false,
|
57
|
-
build?: true,
|
58
|
-
release_build?: false,
|
59
|
-
prerelease_build?: true,
|
60
|
-
},
|
61
|
-
}
|
62
|
-
|
63
|
-
it_has_behavior "rejects invalid version strings", {
|
64
|
-
"8.8.8.8" => "too many segments: MAJOR.MINOR.PATCH.EXTRA",
|
65
|
-
"01.1.1" => "leading zero invalid",
|
66
|
-
"1.01.1" => "leading zero invalid",
|
67
|
-
"1.1.01" => "leading zero invalid",
|
68
|
-
"1.0.0-" => "empty prerelease identifier",
|
69
|
-
"1.0.0-alpha.." => "empty prerelease identifier",
|
70
|
-
"1.0.0-01.02.03" => "leading zero invalid",
|
71
|
-
"1.0.0-alpha.01" => "leading zero invalid",
|
72
|
-
"6.3.1+" => "empty build identifier",
|
73
|
-
"6.4.8-alpha.1.2.3+build." => "empty build identifier",
|
74
|
-
"4.0.000000000002-alpha.1" => "leading zero invalid",
|
75
|
-
"007.2.3-rc.1+build.16" => "leading zero invalid",
|
76
|
-
"12.0005.1-alpha.12" => "leading zero invalid",
|
77
|
-
"12.2.10-beta.00000017" => "leading zero invalid",
|
78
|
-
}
|
79
|
-
|
80
|
-
describe "build qualification" do
|
81
|
-
context "release version" do
|
82
|
-
let(:version_string) { "1.0.0" }
|
83
|
-
its(:release?) { should be_truthy }
|
84
|
-
its(:prerelease?) { should be_falsey }
|
85
|
-
its(:build?) { should be_falsey }
|
86
|
-
its(:release_build?) { should be_falsey }
|
87
|
-
its(:prerelease_build?) { should be_falsey }
|
88
|
-
end
|
89
|
-
|
90
|
-
context "pre-release version" do
|
91
|
-
let(:version_string) { "1.0.0-alpha.1" }
|
92
|
-
its(:release?) { should be_falsey }
|
93
|
-
its(:prerelease?) { should be_truthy }
|
94
|
-
its(:build?) { should be_falsey }
|
95
|
-
its(:release_build?) { should be_falsey }
|
96
|
-
its(:prerelease_build?) { should be_falsey }
|
97
|
-
end
|
98
|
-
|
99
|
-
context "pre-release build version" do
|
100
|
-
let(:version_string) { "1.0.0-alpha.1+20130308110833" }
|
101
|
-
its(:release?) { should be_falsey }
|
102
|
-
its(:prerelease?) { should be_falsey }
|
103
|
-
its(:build?) { should be_truthy }
|
104
|
-
its(:release_build?) { should be_falsey }
|
105
|
-
its(:prerelease_build?) { should be_truthy }
|
106
|
-
end
|
107
|
-
|
108
|
-
context "release build version" do
|
109
|
-
let(:version_string) { "1.0.0+20130308110833" }
|
110
|
-
its(:release?) { should be_falsey }
|
111
|
-
its(:prerelease?) { should be_falsey }
|
112
|
-
its(:build?) { should be_truthy }
|
113
|
-
its(:release_build?) { should be_truthy }
|
114
|
-
its(:prerelease_build?) { should be_falsey }
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|