semverse 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: acd0de1d4331bcafe552f3a60d11caedf7a2ca3c
4
- data.tar.gz: c7e9348008c15c128bf803c903b737464f44bba1
2
+ SHA256:
3
+ metadata.gz: a37f02dda073771ca1a404b4bf2742bb9aefa8b076bd5eef500032f30aa61a65
4
+ data.tar.gz: a69871553baf90560aa8ca47c785e5f3f9c5269a925ec6f135e0789f9d47ebbb
5
5
  SHA512:
6
- metadata.gz: 949b52f5f44bbd50e23a4a900566dc68d6be71fd6dd635e6cd1f7efcb18376aa0d137934b11e78e116f9bf528f71803ee0604e7018902b390f4d5789dcb7ed40
7
- data.tar.gz: 73bc85a5eac21780da8b3225b2aa05f3f989027a8a4f1ac7d745704a832e9dfa3f558a51df72d49e2782873cb1e180a656bc5416e57e44aa62aa032b0236be6f
6
+ metadata.gz: 7d9c900303c6a18dc6d7e20b01d183ef1d7bff9c8f92b9e6ad5f009f93ec72b8ef6fcfa75e10f849dc91c72e0d195f31b5814a7d24b42ec713fda212f5a7b62b
7
+ data.tar.gz: ab3c2512b621de9a29c25cd553f12c7409aa625a83a79a13e1a6120d7f4ffbc016e1d0ba16220406ae53b773aeb10f3d35d22763e2e701846d47959d4356f4dd
@@ -1,3 +1,3 @@
1
1
  module Semverse
2
- VERSION = "2.0.0"
2
+ VERSION = "3.0.0"
3
3
  end
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semverse
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-03 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.5'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.5'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
11
+ date: 2018-12-10 00:00:00.000000000 Z
12
+ dependencies: []
41
13
  description: An elegant library for representing and comparing SemVer versions and
42
14
  constraints
43
15
  email:
@@ -46,26 +18,15 @@ executables: []
46
18
  extensions: []
47
19
  extra_rdoc_files: []
48
20
  files:
49
- - ".gitignore"
50
- - ".travis.yml"
51
- - Gemfile
52
- - Guardfile
53
21
  - LICENSE
54
- - README.md
55
- - Rakefile
56
22
  - lib/semverse.rb
57
23
  - lib/semverse/constraint.rb
58
24
  - lib/semverse/errors.rb
59
25
  - lib/semverse/gem_version.rb
60
26
  - lib/semverse/version.rb
61
- - semverse.gemspec
62
- - spec/spec_helper.rb
63
- - spec/unit/semverse/constraint_spec.rb
64
- - spec/unit/semverse/version_spec.rb
65
- - spec/unit/semverse_spec.rb
66
- homepage: https://github.com/berkshelf/semverse
27
+ homepage: https://github.com/berkshelf/semverse/
67
28
  licenses:
68
- - Apache 2.0
29
+ - Apache-2.0
69
30
  metadata: {}
70
31
  post_install_message:
71
32
  rdoc_options: []
@@ -75,7 +36,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
36
  requirements:
76
37
  - - ">="
77
38
  - !ruby/object:Gem::Version
78
- version: 2.1.0
39
+ version: 2.2.0
79
40
  required_rubygems_version: !ruby/object:Gem::Requirement
80
41
  requirements:
81
42
  - - ">="
@@ -83,12 +44,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
44
  version: '0'
84
45
  requirements: []
85
46
  rubyforge_project:
86
- rubygems_version: 2.6.6
47
+ rubygems_version: 2.7.7
87
48
  signing_key:
88
49
  specification_version: 4
89
50
  summary: An elegant library for representing and comparing SemVer versions and constraints
90
- test_files:
91
- - spec/spec_helper.rb
92
- - spec/unit/semverse/constraint_spec.rb
93
- - spec/unit/semverse/version_spec.rb
94
- - spec/unit/semverse_spec.rb
51
+ test_files: []
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
@@ -1,13 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
- bundler_args: --without development
5
- matrix:
6
- include:
7
- - rvm: 2.1.9
8
- - rvm: 2.2.5
9
- - rvm: 2.3.1
10
- allow_failures:
11
- - rvm: 2.3.1
12
-
13
- script: bundle exec rake spec
data/Gemfile DELETED
@@ -1,29 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- group :development do
6
- gem "fuubar"
7
- gem "yard"
8
- gem "guard-rspec"
9
- gem "guard-spork"
10
- gem "coolline"
11
-
12
- require "rbconfig"
13
-
14
- if RbConfig::CONFIG["target_os"] =~ /darwin/i
15
- gem "ruby_gntp", require: false
16
-
17
- elsif RbConfig::CONFIG["target_os"] =~ /linux/i
18
- gem "libnotify", require: false
19
-
20
- elsif RbConfig::CONFIG["target_os"] =~ /mswin|mingw/i
21
- gem "win32console", require: false
22
- end
23
- end
24
-
25
- group :test do
26
- gem "spork"
27
- gem "rake"
28
- gem "rspec", "~> 3.0"
29
- end
data/Guardfile DELETED
@@ -1,11 +0,0 @@
1
- guard 'spork', rspec_port: 8991 do
2
- watch('Gemfile')
3
- watch('spec/spec_helper.rb') { :rspec }
4
- end
5
-
6
- guard 'rspec', cli: "--color --drb --drb-port 8991 --format Fuubar", all_on_start: false, all_after_pass: false, notification: false do
7
- watch(%r{^spec/acceptance/.+_spec\.rb$})
8
- watch(%r{^spec/unit/.+_spec\.rb$})
9
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
10
- watch('spec/spec_helper.rb') { "spec" }
11
- end
data/README.md DELETED
@@ -1,40 +0,0 @@
1
- # Semverse
2
-
3
- [![Gem Version](http://img.shields.io/gem/v/semverse.svg)][gem] [![Build Status](http://img.shields.io/travis/berkshelf/semverse.svg)][travis]
4
-
5
- An elegant library for representing and comparing SemVer versions and constraints
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```
12
- gem 'semverse'
13
- ```
14
-
15
- And then execute:
16
-
17
- ```
18
- $ bundle
19
- ```
20
-
21
- Or install it yourself as:
22
-
23
- ```
24
- $ gem install semverse
25
- ```
26
-
27
- ## Usage
28
-
29
- TODO: Write usage instructions here
30
-
31
- ## Contributing
32
-
33
- 1. Fork it ( <http://github.com/berkshelf/semverse/fork> )
34
- 2. Create your feature branch (`git checkout -b my-new-feature`)
35
- 3. Commit your changes (`git commit -am 'Add some feature'`)
36
- 4. Push to the branch (`git push origin my-new-feature`)
37
- 5. Create new Pull Request
38
-
39
- [gem]: https://rubygems.org/gems/semverse
40
- [travis]: http://travis-ci.org/berkshelf/semverse
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -1,24 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'semverse/gem_version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "semverse"
8
- spec.version = Semverse::VERSION
9
- spec.authors = ["Jamie Winsor"]
10
- spec.email = ["jamie@vialstudios.com"]
11
- spec.summary = %q{An elegant library for representing and comparing SemVer versions and constraints}
12
- spec.description = spec.summary
13
- spec.homepage = "https://github.com/berkshelf/semverse"
14
- spec.license = "Apache 2.0"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
- spec.required_ruby_version = ">= 2.1.0"
21
-
22
- spec.add_development_dependency "bundler", "~> 1.5"
23
- spec.add_development_dependency "rake"
24
- end
@@ -1,24 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- require 'spork'
4
-
5
- Spork.prefork do
6
- require 'rspec'
7
-
8
- APP_ROOT = File.expand_path('../../', __FILE__)
9
-
10
- Dir[File.join(APP_ROOT, "spec/support/**/*.rb")].each {|f| require f}
11
-
12
- RSpec.configure do |config|
13
- config.mock_with :rspec
14
- config.filter_run focus: true
15
- config.run_all_when_everything_filtered = true
16
-
17
- # Run specs in a random order
18
- config.order = :random
19
- end
20
- end
21
-
22
- Spork.each_run do
23
- require 'semverse'
24
- end
@@ -1,711 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec::Matchers.define :satisfies do |*args|
4
- match do |constraint|
5
- expect(constraint.satisfies?(*args)).to be true
6
- end
7
- end
8
-
9
- describe Semverse::Constraint do
10
- let(:valid_string) { ">= 0.0.0" }
11
- let(:invalid_string) { "x23u7089213.*" }
12
-
13
- describe "ClassMethods" do
14
- subject { Semverse::Constraint }
15
-
16
- describe "::new" do
17
- it "returns a new instance of Constraint" do
18
- expect(subject.new(valid_string)).to be_a(Semverse::Constraint)
19
- end
20
-
21
- it "assigns the parsed operator to the operator attribute" do
22
- expect(subject.new(valid_string).operator).to eq(">=")
23
- end
24
-
25
- it "assigns the parsed operator to the operator attribute with no separation between operator and version" do
26
- expect(subject.new(">=0.0.0").operator).to eq(">=")
27
- end
28
-
29
- it "assigns the parsed version string as an instance of Version to the version attribute" do
30
- result = subject.new(valid_string)
31
-
32
- expect(result.version).to be_a(Semverse::Version)
33
- expect(result.version.to_s).to eq("0.0.0")
34
- end
35
-
36
- it "falls back to a default constraint if nil is provided" do
37
- result = subject.new(nil)
38
-
39
- expect(result.version.to_s).to eq("0.0.0")
40
- expect(result.operator).to eq(">=")
41
- end
42
-
43
- it "fall sback to a default constraint if a blank string is provided" do
44
- result = subject.new("")
45
-
46
- expect(result.version.to_s).to eq("0.0.0")
47
- expect(result.operator).to eq(">=")
48
- end
49
-
50
- context "given a string that does not match the Constraint REGEXP" do
51
- it "raises an InvalidConstraintFormat error" do
52
- expect {
53
- subject.new(invalid_string)
54
- }.to raise_error(Semverse::InvalidConstraintFormat)
55
- end
56
- end
57
-
58
- context "given a constraint that does not include a minor version (~>)" do
59
- it "has a nil value for minor" do
60
- expect(subject.new("~> 1").minor).to be_nil
61
- end
62
-
63
- it "has a nil value for patch" do
64
- expect(subject.new("~> 1").patch).to be_nil
65
- end
66
- end
67
-
68
- context "given a constraint that does not include a minor version (=)" do
69
- it "has a 0 for minor" do
70
- expect(subject.new("= 1").minor).to eq(0)
71
- end
72
- end
73
-
74
- context "given a constraint that does not include a patch version (~>)" do
75
- it "has a nil value for patch" do
76
- expect(subject.new("~> 1.2").patch).to be_nil
77
- end
78
- end
79
-
80
- context "given a constraint that does not include a patch version (=)" do
81
- it "has a 0 for patch" do
82
- expect(subject.new("= 1.2").patch).to eq(0)
83
- end
84
- end
85
-
86
- context "given a constraint that does not include a build version" do
87
- it "has a nil value for build" do
88
- expect(subject.new(">= 1.2.3-alpha").build).to be_nil
89
- end
90
- end
91
-
92
- context "given a constraint that does not include a pre release version" do
93
- it "has a nil value for pre release" do
94
- expect(subject.new(">= 1.2.3+build").pre_release).to be_nil
95
- end
96
- end
97
- end
98
-
99
- describe "::split" do
100
- let(:constraint_string) { nil }
101
-
102
- subject { described_class.split(constraint_string) }
103
-
104
- context "given a constraint containing the elements (operator, major, minor, patch, pre_release, build)" do
105
- let(:constraint_string) { ">= 1.2.3-alpha+build" }
106
-
107
- it "returns an array with the constraint operator at index 0" do
108
- expect(subject[0]).to eq(">=")
109
- end
110
-
111
- it "returns an array with the major version in index 1" do
112
- expect(subject[1]).to eq(1)
113
- end
114
-
115
- it "returns an array with the minor version at index 2" do
116
- expect(subject[2]).to eq(2)
117
- end
118
-
119
- it "returns an array with the patch version at index 3" do
120
- expect(subject[3]).to eq(3)
121
- end
122
-
123
- it "returns an array with the pre release version at index 4" do
124
- expect(subject[4]).to eq("alpha")
125
- end
126
-
127
- it "returns an array with the build version at index 5" do
128
- expect(subject[5]).to eq("build")
129
- end
130
- end
131
-
132
- context "given a constraint containing the elements (operator, major, minor, patch, pre_release)" do
133
- let(:constraint_string) { ">= 1.2.3-alpha" }
134
-
135
- it "returns an array with the constraint operator at index 0" do
136
- expect(subject[0]).to eq(">=")
137
- end
138
-
139
- it "returns an array with the major version in index 1" do
140
- expect(subject[1]).to eq(1)
141
- end
142
-
143
- it "returns an array with the minor version at index 2" do
144
- expect(subject[2]).to eq(2)
145
- end
146
-
147
- it "returns an array with the patch version at index 3" do
148
- expect(subject[3]).to eq(3)
149
- end
150
-
151
- it "returns an array with the pre release version at index 4" do
152
- expect(subject[4]).to eq("alpha")
153
- end
154
-
155
- it "returns an array with a nil value at index 5" do
156
- expect(subject[5]).to be_nil
157
- end
158
- end
159
-
160
- context "given a constraint containing the elements (operator, major, minor, patch)" do
161
- let(:constraint_string) { ">= 1.2.3" }
162
-
163
- it "returns an array with the constraint operator at index 0" do
164
- expect(subject[0]).to eq(">=")
165
- end
166
-
167
- it "returns an array with the major version in index 1" do
168
- expect(subject[1]).to eq(1)
169
- end
170
-
171
- it "returns an array with the minor version at index 2" do
172
- expect(subject[2]).to eq(2)
173
- end
174
-
175
- it "returns an array with the patch version at index 3" do
176
- expect(subject[3]).to eq(3)
177
- end
178
-
179
- it "returns an array with a nil value at index 4" do
180
- expect(subject[4]).to be_nil
181
- end
182
-
183
- it "returns an array with a nil value at index 5" do
184
- expect(subject[5]).to be_nil
185
- end
186
- end
187
-
188
- context "given a constraint containing the elements (operator, major, minor)" do
189
- let(:constraint_string) { ">= 1.2" }
190
-
191
- it "returns an array with the constraint operator at index 0" do
192
- expect(subject[0]).to eq(">=")
193
- end
194
-
195
- it "returns an array with the major version in index 1" do
196
- expect(subject[1]).to eq(1)
197
- end
198
-
199
- it "returns an array with the minor version at index 2" do
200
- expect(subject[2]).to eq(2)
201
- end
202
-
203
- it "returns an array with a nil value at index 3" do
204
- expect(subject[3]).to be_nil
205
- end
206
-
207
- it "returns an array with a nil value at index 4" do
208
- expect(subject[4]).to be_nil
209
- end
210
-
211
- it "returns an array with a nil value at index 5" do
212
- expect(subject[5]).to be_nil
213
- end
214
- end
215
-
216
- context "given a constraint containing the elements (operator, major)" do
217
- let(:constraint_string) { ">= 1" }
218
-
219
- it "returns an array with the constraint operator at index 0" do
220
- expect(subject[0]).to eq(">=")
221
- end
222
-
223
- it "returns an array with the major version in index 1" do
224
- expect(subject[1]).to eq(1)
225
- end
226
-
227
- it "returns an array with a nil value at index 2" do
228
- expect(subject[2]).to be_nil
229
- end
230
-
231
- it "returns an array with a nil value at index 3" do
232
- expect(subject[3]).to be_nil
233
- end
234
-
235
- it "returns an array with a nil value at index 4" do
236
- expect(subject[4]).to be_nil
237
- end
238
-
239
- it "returns an array with a nil value at index 5" do
240
- expect(subject[5]).to be_nil
241
- end
242
- end
243
-
244
- context "given a constraint which is missing an operator" do
245
- let(:constraint_string) { "1.2.3" }
246
-
247
- it "returns an equality operator at index 0" do
248
- expect(subject[0]).to eq("=")
249
- end
250
- end
251
-
252
- context "given a string that does not match the Constraint REGEXP" do
253
- let(:constraint_string) { "x23u7089213.*" }
254
-
255
- it "raises an InvalidConstraintFormat error" do
256
- expect {
257
- subject.split(invalid_string)
258
- }.to raise_error(Semverse::InvalidConstraintFormat)
259
- end
260
- end
261
-
262
- context "given a string that does not contain an operator" do
263
- let(:constraint_string) { "1.2.3" }
264
-
265
- it "returns a constraint constraint with a default operator (=)" do
266
- expect(subject[0]).to eq("=")
267
- end
268
- end
269
- end
270
- end
271
-
272
- describe "#satisfies?" do
273
- subject { Semverse::Constraint.new("= 1.0.0") }
274
-
275
- it { should satisfies("1.0.0") }
276
- it { should satisfies(Semverse::Version.new("1.0.0")) }
277
-
278
- context "strictly greater than (>) pre-release constraint" do
279
- subject { Semverse::Constraint.new("> 1.0.0-alpha") }
280
-
281
- it { should_not satisfies("0.9.9+build") }
282
- it { should_not satisfies("1.0.0-alpha") }
283
- it { should satisfies("1.0.0-alpha.2") }
284
- it { should satisfies("1.0.0") }
285
- it { should satisfies("1.0.0+build") }
286
- it { should satisfies("1.0.1-beta") }
287
- it { should satisfies("1.0.1") }
288
- it { should satisfies("1.0.1+build.2") }
289
- it { should satisfies("2.0.0") }
290
- end
291
-
292
- context "strictly greater than (>)" do
293
- subject { Semverse::Constraint.new("> 1.0.0") }
294
-
295
- it { should_not satisfies("0.9.9+build") }
296
- it { should_not satisfies("1.0.0-alpha") }
297
- it { should_not satisfies("1.0.0-alpha.2") }
298
- it { should_not satisfies("1.0.0") }
299
- it { should satisfies("1.0.0+build") }
300
- it { should_not satisfies("1.0.1-beta") }
301
- it { should satisfies("1.0.1") }
302
- it { should satisfies("1.0.1+build.2") }
303
- it { should satisfies("2.0.0") }
304
- end
305
-
306
- context "strictly greater than (>) build constraint" do
307
- subject { Semverse::Constraint.new("> 1.0.0+build") }
308
-
309
- it { should_not satisfies("0.9.9+build") }
310
- it { should_not satisfies("1.0.0-alpha") }
311
- it { should_not satisfies("1.0.0-alpha.2") }
312
- it { should_not satisfies("1.0.0") }
313
- it { should_not satisfies("1.0.0+build") }
314
- it { should_not satisfies("1.0.1-beta") }
315
- it { should satisfies("1.0.1") }
316
- it { should satisfies("1.0.1+build.2") }
317
- it { should satisfies("2.0.0") }
318
- end
319
-
320
- context "greater than or equal to (>) zero pre-release constraint" do
321
- subject { Semverse::Constraint.new("> 0.0.0-alpha") }
322
-
323
- it { should satisfies("0.9.9+build") }
324
- it { should satisfies("1.0.0-alpha") }
325
- it { should satisfies("1.0.0-alpha.2") }
326
- it { should satisfies("1.0.0") }
327
- it { should satisfies("1.0.0+build") }
328
- it { should satisfies("1.0.1-beta") }
329
- it { should satisfies("1.0.1") }
330
- it { should satisfies("1.0.1+build.2") }
331
- it { should satisfies("2.0.0") }
332
- end
333
-
334
- context "greater than or equal to (>) zero constraint" do
335
- subject { Semverse::Constraint.new("> 0.0.0") }
336
-
337
- it { should satisfies("0.9.9+build") }
338
- it { should satisfies("1.0.0-alpha") }
339
- it { should satisfies("1.0.0-alpha.2") }
340
- it { should satisfies("1.0.0") }
341
- it { should satisfies("1.0.0+build") }
342
- it { should satisfies("1.0.1-beta") }
343
- it { should satisfies("1.0.1") }
344
- it { should satisfies("1.0.1+build.2") }
345
- it { should satisfies("2.0.0") }
346
- end
347
-
348
- context "greater than or equal to (>) zero build constraint" do
349
- subject { Semverse::Constraint.new("> 0.0.0+build") }
350
-
351
- it { should satisfies("0.9.9+build") }
352
- it { should satisfies("1.0.0-alpha") }
353
- it { should satisfies("1.0.0-alpha.2") }
354
- it { should satisfies("1.0.0") }
355
- it { should satisfies("1.0.0+build") }
356
- it { should satisfies("1.0.1-beta") }
357
- it { should satisfies("1.0.1") }
358
- it { should satisfies("1.0.1+build.2") }
359
- it { should satisfies("2.0.0") }
360
- end
361
-
362
- context "strictly less than (<) pre-release constraint" do
363
- subject { Semverse::Constraint.new("< 1.0.0-alpha.3") }
364
-
365
- it { should satisfies("0.9.9+build") }
366
- it { should satisfies("1.0.0-alpha") }
367
- it { should satisfies("1.0.0-alpha.2") }
368
- it { should_not satisfies("1.0.0") }
369
- it { should_not satisfies("1.0.0+build") }
370
- it { should_not satisfies("1.0.1-beta") }
371
- it { should_not satisfies("1.0.1") }
372
- it { should_not satisfies("1.0.1+build.2") }
373
- it { should_not satisfies("2.0.0") }
374
- end
375
-
376
- context "strictly less than (<)" do
377
- subject { Semverse::Constraint.new("< 1.0.0") }
378
-
379
- it { should satisfies("0.9.9+build") }
380
- it { should satisfies("1.0.0-alpha") }
381
- it { should satisfies("1.0.0-alpha.2") }
382
- it { should_not satisfies("1.0.0") }
383
- it { should_not satisfies("1.0.0+build") }
384
- it { should_not satisfies("1.0.1-beta") }
385
- it { should_not satisfies("1.0.1") }
386
- it { should_not satisfies("1.0.1+build.2") }
387
- it { should_not satisfies("2.0.0") }
388
- end
389
-
390
- context "strictly less than (<) build constraint" do
391
- subject { Semverse::Constraint.new("< 1.0.0+build.20") }
392
-
393
- it { should satisfies("0.9.9+build") }
394
- it { should satisfies("1.0.0-alpha") }
395
- it { should satisfies("1.0.0-alpha.2") }
396
- it { should satisfies("1.0.0") }
397
- it { should satisfies("1.0.0+build") }
398
- it { should_not satisfies("1.0.1-beta") }
399
- it { should_not satisfies("1.0.1") }
400
- it { should_not satisfies("1.0.1+build.2") }
401
- it { should_not satisfies("2.0.0") }
402
- end
403
-
404
- context "strictly equal to (=)" do
405
- subject { Semverse::Constraint.new("= 1.0.0") }
406
-
407
- it { should_not satisfies("0.9.9+build") }
408
- it { should satisfies("1.0.0") }
409
- it { should_not satisfies("1.0.1") }
410
- it { should_not satisfies("1.0.0-alpha") }
411
- end
412
-
413
- context "greater than or equal to (>=) pre-release constraint" do
414
- subject { Semverse::Constraint.new(">= 1.0.0-alpha") }
415
-
416
- it { should_not satisfies("0.9.9+build") }
417
- it { should satisfies("1.0.0-alpha") }
418
- it { should satisfies("1.0.0-alpha.2") }
419
- it { should satisfies("1.0.0") }
420
- it { should satisfies("1.0.0+build") }
421
- it { should satisfies("1.0.1-beta") }
422
- it { should satisfies("1.0.1") }
423
- it { should satisfies("1.0.1+build.2") }
424
- it { should satisfies("2.0.0") }
425
- end
426
-
427
- context "greater than or equal to (>=)" do
428
- subject { Semverse::Constraint.new(">= 1.0.0") }
429
-
430
- it { should_not satisfies("0.9.9+build") }
431
- it { should_not satisfies("1.0.0-alpha") }
432
- it { should_not satisfies("1.0.0-alpha.2") }
433
- it { should satisfies("1.0.0") }
434
- it { should satisfies("1.0.0+build") }
435
- it { should_not satisfies("1.0.1-beta") }
436
- it { should satisfies("1.0.1") }
437
- it { should satisfies("1.0.1+build.2") }
438
- it { should satisfies("2.0.0") }
439
- end
440
-
441
- context "greater than or equal to (>=) build constraint" do
442
- subject { Semverse::Constraint.new(">= 1.0.0+build") }
443
-
444
- it { should_not satisfies("0.9.9+build") }
445
- it { should_not satisfies("1.0.0-alpha") }
446
- it { should_not satisfies("1.0.0-alpha.2") }
447
- it { should_not satisfies("1.0.0") }
448
- it { should satisfies("1.0.0+build") }
449
- it { should_not satisfies("1.0.1-beta") }
450
- it { should satisfies("1.0.1") }
451
- it { should satisfies("1.0.1+build.2") }
452
- it { should satisfies("2.0.0") }
453
- end
454
-
455
- context "greater than or equal to (>=) zero pre-release constraint" do
456
- subject { Semverse::Constraint.new(">= 0.0.0-alpha") }
457
-
458
- it { should satisfies("0.9.9+build") }
459
- it { should satisfies("1.0.0-alpha") }
460
- it { should satisfies("1.0.0-alpha.2") }
461
- it { should satisfies("1.0.0") }
462
- it { should satisfies("1.0.0+build") }
463
- it { should satisfies("1.0.1-beta") }
464
- it { should satisfies("1.0.1") }
465
- it { should satisfies("1.0.1+build.2") }
466
- it { should satisfies("2.0.0") }
467
- end
468
-
469
- context "greater than or equal to (>=) zero constraint" do
470
- subject { Semverse::Constraint.new(">= 0.0.0") }
471
-
472
- it { should satisfies("0.9.9+build") }
473
- it { should satisfies("1.0.0-alpha") }
474
- it { should satisfies("1.0.0-alpha.2") }
475
- it { should satisfies("1.0.0") }
476
- it { should satisfies("1.0.0+build") }
477
- it { should satisfies("1.0.1-beta") }
478
- it { should satisfies("1.0.1") }
479
- it { should satisfies("1.0.1+build.2") }
480
- it { should satisfies("2.0.0") }
481
- end
482
-
483
- context "greater than or equal to (>=) zero build constraint" do
484
- subject { Semverse::Constraint.new(">= 0.0.0+build") }
485
-
486
- it { should satisfies("0.9.9+build") }
487
- it { should satisfies("1.0.0-alpha") }
488
- it { should satisfies("1.0.0-alpha.2") }
489
- it { should satisfies("1.0.0") }
490
- it { should satisfies("1.0.0+build") }
491
- it { should satisfies("1.0.1-beta") }
492
- it { should satisfies("1.0.1") }
493
- it { should satisfies("1.0.1+build.2") }
494
- it { should satisfies("2.0.0") }
495
- end
496
-
497
- context "lower than or equal to (<=) pre-release constraint" do
498
- subject { Semverse::Constraint.new("<= 1.0.0") }
499
-
500
- it { should satisfies("0.9.9+build") }
501
- it { should satisfies("1.0.0-alpha") }
502
- it { should satisfies("1.0.0-alpha.2") }
503
- it { should satisfies("1.0.0") }
504
- it { should_not satisfies("1.0.0+build") }
505
- it { should_not satisfies("1.0.1-beta") }
506
- it { should_not satisfies("1.0.1") }
507
- it { should_not satisfies("1.0.1+build.2") }
508
- it { should_not satisfies("2.0.0") }
509
- end
510
-
511
- context "lower than or equal to (<=)" do
512
- subject { Semverse::Constraint.new("<= 1.0.0-alpha") }
513
-
514
- it { should satisfies("0.9.9+build") }
515
- it { should satisfies("1.0.0-alpha") }
516
- it { should_not satisfies("1.0.0-alpha.2") }
517
- it { should_not satisfies("1.0.0") }
518
- it { should_not satisfies("1.0.0+build") }
519
- it { should_not satisfies("1.0.1-beta") }
520
- it { should_not satisfies("1.0.1") }
521
- it { should_not satisfies("1.0.1+build.2") }
522
- it { should_not satisfies("2.0.0") }
523
- end
524
-
525
- context "lower than or equal to (<=) build constraint" do
526
- subject { Semverse::Constraint.new("<= 1.0.0+build") }
527
-
528
- it { should satisfies("0.9.9+build") }
529
- it { should satisfies("1.0.0-alpha") }
530
- it { should satisfies("1.0.0-alpha.2") }
531
- it { should satisfies("1.0.0") }
532
- it { should satisfies("1.0.0+build") }
533
- it { should_not satisfies("1.0.1-beta") }
534
- it { should_not satisfies("1.0.1") }
535
- it { should_not satisfies("1.0.1+build.2") }
536
- it { should_not satisfies("2.0.0") }
537
- end
538
-
539
- %w[~> ~].each do |operator|
540
- describe "aproximately (#{operator})" do
541
- context "when the last value in the constraint is for minor" do
542
- subject { Semverse::Constraint.new("#{operator} 1.2") }
543
-
544
- it { should_not satisfies("1.1.0") }
545
- it { should_not satisfies("1.2.0-alpha") }
546
- it { should satisfies("1.2.0") }
547
- it { should satisfies("1.2.3") }
548
- it { should satisfies("1.2.3+build") }
549
- it { should satisfies("1.3") }
550
- it { should satisfies("1.3.0") }
551
- it { should_not satisfies("2.0.0-0") }
552
- it { should_not satisfies("2.0.0") }
553
- end
554
-
555
- context "when the last value in the constraint is for patch" do
556
- subject { Semverse::Constraint.new("#{operator} 1.2.0") }
557
-
558
- it { should_not satisfies("1.1.0") }
559
- it { should_not satisfies("1.2.3-alpha") }
560
- it { should satisfies("1.2.2") }
561
- it { should satisfies("1.2.3") }
562
- it { should satisfies("1.2.5+build") }
563
- it { should_not satisfies("1.3.0-0") }
564
- it { should_not satisfies("1.3.0") }
565
- end
566
-
567
- context "when the last value in the constraint is for pre_release with a last numeric identifier" do
568
- subject { Semverse::Constraint.new("#{operator} 1.2.3-4") }
569
-
570
- it { should_not satisfies("1.2.3") }
571
- it { should satisfies("1.2.3-4") }
572
- it { should satisfies("1.2.3-10") }
573
- it { should satisfies("1.2.3-10.5+build.33") }
574
- it { should_not satisfies("1.2.3--") }
575
- it { should_not satisfies("1.2.3-alpha") }
576
- it { should_not satisfies("1.2.3") }
577
- it { should_not satisfies("1.2.4") }
578
- it { should_not satisfies("1.3.0") }
579
- end
580
-
581
- context "when the last value in the constraint is for pre_release with a last non-numeric identifier" do
582
- subject { Semverse::Constraint.new("#{operator} 1.2.3-alpha") }
583
-
584
- it { should_not satisfies("1.2.3-4") }
585
- it { should_not satisfies("1.2.3--") }
586
- it { should satisfies("1.2.3-alpha") }
587
- it { should satisfies("1.2.3-alpha.0") }
588
- it { should satisfies("1.2.3-beta") }
589
- it { should satisfies("1.2.3-omega") }
590
- it { should satisfies("1.2.3-omega.4") }
591
- it { should_not satisfies("1.2.3") }
592
- it { should_not satisfies("1.3.0") }
593
- end
594
-
595
- context "when the last value in the constraint is for build with a last numeric identifier and a pre-release" do
596
- subject { Semverse::Constraint.new("#{operator} 1.2.3-alpha+5") }
597
-
598
- it { should_not satisfies("1.2.3-alpha") }
599
- it { should_not satisfies("1.2.3-alpha.4") }
600
- it { should_not satisfies("1.2.3-alpha.4+4") }
601
- it { should satisfies("1.2.3-alpha+5") }
602
- it { should satisfies("1.2.3-alpha+5.5") }
603
- it { should satisfies("1.2.3-alpha+10") }
604
- it { should_not satisfies("1.2.3-alpha+-") }
605
- it { should_not satisfies("1.2.3-alpha+build") }
606
- it { should_not satisfies("1.2.3-beta") }
607
- it { should_not satisfies("1.2.3") }
608
- it { should_not satisfies("1.3.0") }
609
- end
610
-
611
- context "when the last value in the constraint is for build with a last non-numeric identifier and a pre-release" do
612
- subject { Semverse::Constraint.new("#{operator} 1.2.3-alpha+build") }
613
-
614
- it { should_not satisfies("1.2.3-alpha") }
615
- it { should_not satisfies("1.2.3-alpha.4") }
616
- it { should_not satisfies("1.2.3-alpha.4+4") }
617
- it { should satisfies("1.2.3-alpha+build") }
618
- it { should satisfies("1.2.3-alpha+build.5") }
619
- it { should satisfies("1.2.3-alpha+preview") }
620
- it { should satisfies("1.2.3-alpha+zzz") }
621
- it { should_not satisfies("1.2.3-alphb") }
622
- it { should_not satisfies("1.2.3-beta") }
623
- it { should_not satisfies("1.2.3") }
624
- it { should_not satisfies("1.3.0") }
625
- end
626
-
627
- context "when the last value in the constraint is for build with a last numeric identifier" do
628
- subject { Semverse::Constraint.new("#{operator} 1.2.3+5") }
629
-
630
- it { should_not satisfies("1.2.3") }
631
- it { should_not satisfies("1.2.3-alpha") }
632
- it { should_not satisfies("1.2.3+4") }
633
- it { should satisfies("1.2.3+5") }
634
- it { should satisfies("1.2.3+99") }
635
- it { should_not satisfies("1.2.3+5.build") }
636
- it { should_not satisfies("1.2.3+-") }
637
- it { should_not satisfies("1.2.3+build") }
638
- it { should_not satisfies("1.2.4") }
639
- it { should_not satisfies("1.3.0") }
640
- end
641
-
642
- context "when the last value in the constraint is for build with a last non-numeric identifier" do
643
- subject { Semverse::Constraint.new("#{operator} 1.2.3+build") }
644
-
645
- it { should_not satisfies("1.2.3-alpha") }
646
- it { should_not satisfies("1.2.3") }
647
- it { should_not satisfies("1.2.3+5") }
648
- it { should satisfies("1.2.3+build") }
649
- it { should satisfies("1.2.3+build.5") }
650
- it { should satisfies("1.2.3+preview") }
651
- it { should satisfies("1.2.3+zzz") }
652
- it { should_not satisfies("1.2.4-0") }
653
- it { should_not satisfies("1.2.4") }
654
- it { should_not satisfies("1.2.5") }
655
- it { should_not satisfies("1.3.0") }
656
- end
657
- end
658
- end
659
- end
660
-
661
- describe "#==" do
662
- subject { Semverse::Constraint.new("= 1.0.0") }
663
-
664
- it "returns true if the other object is a Semverse::Constraint with the same operator and version" do
665
- other = Semverse::Constraint.new("= 1.0.0")
666
- expect(subject).to eq(other)
667
- end
668
-
669
- it "returns false if the other object is a Semverse::Constraint with the same operator and different version" do
670
- other = Semverse::Constraint.new("= 9.9.9")
671
- expect(subject).to_not eq(other)
672
- end
673
-
674
- it "returns false if the other object is a Semverse::Constraint with the same version and different operator" do
675
- other = Semverse::Constraint.new("> 1.0.0")
676
- expect(subject).to_not eq(other)
677
- end
678
-
679
- it "returns false if the other object is not a Semverse::Constraint" do
680
- other = "chicken"
681
- expect(subject).to_not eq(other)
682
- end
683
- end
684
-
685
- describe "#to_s" do
686
- let(:constraint_string) { ">= 1.2.3-alpha+123" }
687
- subject { described_class.new(constraint_string).to_s }
688
-
689
- it { should eq(constraint_string) }
690
-
691
- context "when the constraint does not contain a minor or patch value" do
692
- let(:constraint_string) { "~> 1" }
693
- it { should eq(constraint_string) }
694
- end
695
-
696
- context "when the constraint does not contain a patch value" do
697
- let(:constraint_string) { "~> 1.2" }
698
- it { should eq(constraint_string) }
699
- end
700
-
701
- context "when the constraint does not contain a build value" do
702
- let(:constraint_string) { ">= 1.2.0-alpha"}
703
- it { should eq(constraint_string) }
704
- end
705
-
706
- context "when the constraint contains a pre_release value" do
707
- let(:constraint_string) { ">= 1.2.0+123"}
708
- it { should eq(constraint_string) }
709
- end
710
- end
711
- end