semantic_puppet 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,644 @@
1
+ require 'spec_helper'
2
+ require 'semantic_puppet/version'
3
+
4
+ describe SemanticPuppet::Version do
5
+
6
+ def subject(str)
7
+ SemanticPuppet::Version.parse(str)
8
+ end
9
+
10
+ describe '.parse' do
11
+
12
+ context 'Spec v2.0.0' do
13
+ context 'Section 2' do
14
+ # A normal version number MUST take the form X.Y.Z where X, Y, and Z are
15
+ # non-negative integers, and MUST NOT contain leading zeroes. X is the
16
+ # major version, Y is the minor version, and Z is the patch version.
17
+ # Each element MUST increase numerically.
18
+ # For instance: 1.9.0 -> 1.10.0 -> 1.11.0.
19
+
20
+ let(:parse_failure) do
21
+ /Unable to parse .* as a semantic version identifier/
22
+ end
23
+
24
+ it 'rejects versions that contain too few parts' do
25
+ expect { subject('1.2') }.to raise_error(parse_failure)
26
+ end
27
+
28
+ it 'rejects versions that contain too many parts' do
29
+ expect { subject('1.2.3.4') }.to raise_error(parse_failure)
30
+ end
31
+
32
+ it 'rejects versions that contain non-integers' do
33
+ expect { subject('x.2.3') }.to raise_error(parse_failure)
34
+ expect { subject('1.y.3') }.to raise_error(parse_failure)
35
+ expect { subject('1.2.z') }.to raise_error(parse_failure)
36
+ end
37
+
38
+ it 'rejects versions that contain negative integers' do
39
+ expect { subject('-1.2.3') }.to raise_error(parse_failure)
40
+ expect { subject('1.-2.3') }.to raise_error(parse_failure)
41
+ expect { subject('1.2.-3') }.to raise_error(parse_failure)
42
+ end
43
+
44
+ it 'rejects version numbers containing leading zeroes' do
45
+ expect { subject('01.2.3') }.to raise_error(parse_failure)
46
+ expect { subject('1.02.3') }.to raise_error(parse_failure)
47
+ expect { subject('1.2.03') }.to raise_error(parse_failure)
48
+ end
49
+
50
+ it 'permits zeroes in version number parts' do
51
+ expect { subject('0.2.3') }.to_not raise_error
52
+ expect { subject('1.0.3') }.to_not raise_error
53
+ expect { subject('1.2.0') }.to_not raise_error
54
+ end
55
+
56
+ context 'examples' do
57
+ example '1.9.0' do
58
+ version = subject('1.9.0')
59
+ expect(version.major).to eql 1
60
+ expect(version.minor).to eql 9
61
+ expect(version.patch).to eql 0
62
+ end
63
+
64
+ example '1.10.0' do
65
+ version = subject('1.10.0')
66
+ expect(version.major).to eql 1
67
+ expect(version.minor).to eql 10
68
+ expect(version.patch).to eql 0
69
+ end
70
+
71
+ example '1.11.0' do
72
+ version = subject('1.11.0')
73
+ expect(version.major).to eql 1
74
+ expect(version.minor).to eql 11
75
+ expect(version.patch).to eql 0
76
+ end
77
+ end
78
+ end
79
+
80
+ context 'Section 9' do
81
+ # A pre-release version MAY be denoted by appending a hyphen and a
82
+ # series of dot separated identifiers immediately following the patch
83
+ # version. Identifiers MUST comprise only ASCII alphanumerics and
84
+ # hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric
85
+ # identifiers MUST NOT include leading zeroes. Pre-release versions
86
+ # have a lower precedence than the associated normal version. A
87
+ # pre-release version indicates that the version is unstable and
88
+ # might not satisfy the intended compatibility requirements as denoted
89
+ # by its associated normal version.
90
+ # Examples: 1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7, 1.0.0-x.7.z.92.
91
+
92
+ let(:restricted_charset) do
93
+ 'Prerelease identifiers MUST use only ASCII alphanumerics and hyphens'
94
+ end
95
+
96
+ let(:must_not_be_empty) do
97
+ 'Prerelease identifiers MUST NOT be empty'
98
+ end
99
+
100
+ let(:no_leading_zeroes) do
101
+ 'Prerelease identifiers MUST NOT contain leading zeroes'
102
+ end
103
+
104
+ it 'rejects prerelease identifiers with non-alphanumerics' do
105
+ expect { subject('1.2.3-$100') }.to raise_error(restricted_charset)
106
+ expect { subject('1.2.3-rc.1@me') }.to raise_error(restricted_charset)
107
+ end
108
+
109
+ it 'rejects empty prerelease versions' do
110
+ expect { subject('1.2.3-') }.to raise_error(must_not_be_empty)
111
+ end
112
+
113
+ it 'rejects empty prerelease version identifiers' do
114
+ expect { subject('1.2.3-.rc1') }.to raise_error(must_not_be_empty)
115
+ expect { subject('1.2.3-rc1.') }.to raise_error(must_not_be_empty)
116
+ expect { subject('1.2.3-rc..1') }.to raise_error(must_not_be_empty)
117
+ end
118
+
119
+ it 'rejects numeric prerelease identifiers with leading zeroes' do
120
+ expect { subject('1.2.3-01') }.to raise_error(no_leading_zeroes)
121
+ expect { subject('1.2.3-rc.01') }.to raise_error(no_leading_zeroes)
122
+ end
123
+
124
+ it 'permits numeric prerelease identifiers of zero' do
125
+ expect { subject('1.2.3-0') }.to_not raise_error
126
+ expect { subject('1.2.3-rc.0') }.to_not raise_error
127
+ end
128
+
129
+ it 'permits non-numeric prerelease identifiers with leading zeroes' do
130
+ expect { subject('1.2.3-0xDEADBEEF') }.to_not raise_error
131
+ expect { subject('1.2.3-rc.0x10c') }.to_not raise_error
132
+ end
133
+
134
+ context 'examples' do
135
+ example '1.0.0-alpha' do
136
+ version = subject('1.0.0-alpha')
137
+ expect(version.major).to eql 1
138
+ expect(version.minor).to eql 0
139
+ expect(version.patch).to eql 0
140
+ expect(version.prerelease).to eql 'alpha'
141
+ end
142
+
143
+ example '1.0.0-alpha.1' do
144
+ version = subject('1.0.0-alpha.1')
145
+ expect(version.major).to eql 1
146
+ expect(version.minor).to eql 0
147
+ expect(version.patch).to eql 0
148
+ expect(version.prerelease).to eql 'alpha.1'
149
+ end
150
+
151
+ example '1.0.0-0.3.7' do
152
+ version = subject('1.0.0-0.3.7')
153
+ expect(version.major).to eql 1
154
+ expect(version.minor).to eql 0
155
+ expect(version.patch).to eql 0
156
+ expect(version.prerelease).to eql '0.3.7'
157
+ end
158
+
159
+ example '1.0.0-x.7.z.92' do
160
+ version = subject('1.0.0-x.7.z.92')
161
+ expect(version.major).to eql 1
162
+ expect(version.minor).to eql 0
163
+ expect(version.patch).to eql 0
164
+ expect(version.prerelease).to eql 'x.7.z.92'
165
+ end
166
+ end
167
+ end
168
+
169
+ context 'Section 10' do
170
+ # Build metadata is not yet in scope so
171
+ it 'rejects build identifiers' do
172
+ ver = '1.2.3+anything'
173
+ expect { subject(ver) }.to raise_error("'#{ver}' MUST NOT include build identifiers")
174
+ end
175
+ end
176
+
177
+ context 'Section 10', :pending => "build metadata is not yet in scope" do
178
+ # Build metadata MAY be denoted by appending a plus sign and a series
179
+ # of dot separated identifiers immediately following the patch or
180
+ # pre-release version. Identifiers MUST comprise only ASCII
181
+ # alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty.
182
+ # Build metadata SHOULD be ignored when determining version precedence.
183
+ # Thus two versions that differ only in the build metadata, have the
184
+ # same precedence.
185
+ # Examples: 1.0.0-alpha+001, 1.0.0+20130313144700,
186
+ # 1.0.0-beta+exp.sha.5114f85.
187
+
188
+
189
+ let(:restricted_charset) do
190
+ 'Build identifiers MUST use only ASCII alphanumerics and hyphens'
191
+ end
192
+
193
+ let(:must_not_be_empty) do
194
+ 'Build identifiers MUST NOT be empty'
195
+ end
196
+
197
+ it 'rejects build identifiers with non-alphanumerics' do
198
+ expect { subject('1.2.3+$100') }.to raise_error(restricted_charset)
199
+ expect { subject('1.2.3+rc.1@me') }.to raise_error(restricted_charset)
200
+ end
201
+
202
+ it 'rejects empty build metadata' do
203
+ expect { subject('1.2.3+') }.to raise_error(must_not_be_empty)
204
+ end
205
+
206
+ it 'rejects empty build identifiers' do
207
+ expect { subject('1.2.3+.rc1') }.to raise_error(must_not_be_empty)
208
+ expect { subject('1.2.3+rc1.') }.to raise_error(must_not_be_empty)
209
+ expect { subject('1.2.3+rc..1') }.to raise_error(must_not_be_empty)
210
+ end
211
+
212
+ it 'permits numeric build identifiers with leading zeroes' do
213
+ expect { subject('1.2.3+01') }.to_not raise_error
214
+ expect { subject('1.2.3+rc.01') }.to_not raise_error
215
+ end
216
+
217
+ it 'permits numeric build identifiers of zero' do
218
+ expect { subject('1.2.3+0') }.to_not raise_error
219
+ expect { subject('1.2.3+rc.0') }.to_not raise_error
220
+ end
221
+
222
+ it 'permits non-numeric build identifiers with leading zeroes' do
223
+ expect { subject('1.2.3+0xDEADBEEF') }.to_not raise_error
224
+ expect { subject('1.2.3+rc.0x10c') }.to_not raise_error
225
+ end
226
+
227
+ context 'examples' do
228
+ example '1.0.0-alpha+001' do
229
+ version = subject('1.0.0-alpha+001')
230
+ expect(version.major).to eql 1
231
+ expect(version.minor).to eql 0
232
+ expect(version.patch).to eql 0
233
+ expect(version.prerelease).to eql 'alpha'
234
+ expect(version.build).to eql '001'
235
+ end
236
+
237
+ example '1.0.0+20130313144700' do
238
+ version = subject('1.0.0+20130313144700')
239
+ expect(version.major).to eql 1
240
+ expect(version.minor).to eql 0
241
+ expect(version.patch).to eql 0
242
+ expect(version.prerelease).to eql nil
243
+ expect(version.build).to eql '20130313144700'
244
+ end
245
+
246
+ example '1.0.0-beta+exp.sha.5114f85' do
247
+ version = subject('1.0.0-beta+exp.sha.5114f85')
248
+ expect(version.major).to eql 1
249
+ expect(version.minor).to eql 0
250
+ expect(version.patch).to eql 0
251
+ expect(version.prerelease).to eql 'beta'
252
+ expect(version.build).to eql 'exp.sha.5114f85'
253
+ end
254
+ end
255
+ end
256
+ end
257
+
258
+ context 'Spec v1.0.0' do
259
+ context 'Section 2' do
260
+ # A normal version number MUST take the form X.Y.Z where X, Y, and Z
261
+ # are integers. X is the major version, Y is the minor version, and Z
262
+ # is the patch version. Each element MUST increase numerically by
263
+ # increments of one.
264
+ # For instance: 1.9.0 -> 1.10.0 -> 1.11.0
265
+
266
+ let(:parse_failure) do
267
+ /Unable to parse .* as a semantic version identifier/
268
+ end
269
+
270
+ it 'rejects versions that contain too few parts' do
271
+ expect { subject('1.2') }.to raise_error(parse_failure)
272
+ end
273
+
274
+ it 'rejects versions that contain too many parts' do
275
+ expect { subject('1.2.3.4') }.to raise_error(parse_failure)
276
+ end
277
+
278
+ it 'rejects versions that contain non-integers' do
279
+ expect { subject('x.2.3') }.to raise_error(parse_failure)
280
+ expect { subject('1.y.3') }.to raise_error(parse_failure)
281
+ expect { subject('1.2.z') }.to raise_error(parse_failure)
282
+ end
283
+
284
+ it 'permits zeroes in version number parts' do
285
+ expect { subject('0.2.3') }.to_not raise_error
286
+ expect { subject('1.0.3') }.to_not raise_error
287
+ expect { subject('1.2.0') }.to_not raise_error
288
+ end
289
+
290
+ context 'examples' do
291
+ example '1.9.0' do
292
+ version = subject('1.9.0')
293
+ expect(version.major).to eql 1
294
+ expect(version.minor).to eql 9
295
+ expect(version.patch).to eql 0
296
+ end
297
+
298
+ example '1.10.0' do
299
+ version = subject('1.10.0')
300
+ expect(version.major).to eql 1
301
+ expect(version.minor).to eql 10
302
+ expect(version.patch).to eql 0
303
+ end
304
+
305
+ example '1.11.0' do
306
+ version = subject('1.11.0')
307
+ expect(version.major).to eql 1
308
+ expect(version.minor).to eql 11
309
+ expect(version.patch).to eql 0
310
+ end
311
+ end
312
+ end
313
+
314
+ context 'Section 4' do
315
+ # A pre-release version number MAY be denoted by appending an arbitrary
316
+ # string immediately following the patch version and a dash. The string
317
+ # MUST be comprised of only alphanumerics plus dash [0-9A-Za-z-].
318
+ # Pre-release versions satisfy but have a lower precedence than the
319
+ # associated normal version. Precedence SHOULD be determined by
320
+ # lexicographic ASCII sort order.
321
+ # For instance: 1.0.0-alpha1 < 1.0.0-beta1 < 1.0.0-beta2 < 1.0.0-rc1
322
+
323
+ let(:restricted_charset) do
324
+ 'Prerelease identifiers MUST use only ASCII alphanumerics and hyphens'
325
+ end
326
+
327
+ let(:must_not_be_empty) do
328
+ 'Prerelease identifiers MUST NOT be empty'
329
+ end
330
+
331
+ let(:no_leading_zeroes) do
332
+ 'Prerelease identifiers MUST NOT contain leading zeroes'
333
+ end
334
+
335
+ it 'rejects prerelease identifiers with non-alphanumerics' do
336
+ expect { subject('1.2.3-$100') }.to raise_error(restricted_charset)
337
+ expect { subject('1.2.3-rc.1@me') }.to raise_error(restricted_charset)
338
+ end
339
+
340
+ it 'rejects empty prerelease versions' do
341
+ expect { subject('1.2.3-') }.to raise_error(must_not_be_empty)
342
+ end
343
+
344
+ it 'rejects numeric prerelease identifiers with leading zeroes' do
345
+ expect { subject('1.2.3-01') }.to raise_error(no_leading_zeroes)
346
+ end
347
+
348
+ it 'permits numeric prerelease identifiers of zero' do
349
+ expect { subject('1.2.3-0') }.to_not raise_error
350
+ end
351
+
352
+ it 'permits non-numeric prerelease identifiers with leading zeroes' do
353
+ expect { subject('1.2.3-0xDEADBEEF') }.to_not raise_error
354
+ end
355
+
356
+ context 'examples' do
357
+ example '1.0.0-alpha1' do
358
+ version = subject('1.0.0-alpha1')
359
+ expect(version.major).to eql 1
360
+ expect(version.minor).to eql 0
361
+ expect(version.patch).to eql 0
362
+ expect(version.prerelease).to eql 'alpha1'
363
+ end
364
+
365
+ example '1.0.0-beta1' do
366
+ version = subject('1.0.0-beta1')
367
+ expect(version.major).to eql 1
368
+ expect(version.minor).to eql 0
369
+ expect(version.patch).to eql 0
370
+ expect(version.prerelease).to eql 'beta1'
371
+ end
372
+
373
+ example '1.0.0-beta2' do
374
+ version = subject('1.0.0-beta2')
375
+ expect(version.major).to eql 1
376
+ expect(version.minor).to eql 0
377
+ expect(version.patch).to eql 0
378
+ expect(version.prerelease).to eql 'beta2'
379
+ end
380
+
381
+ example '1.0.0-rc1' do
382
+ version = subject('1.0.0-rc1')
383
+ expect(version.major).to eql 1
384
+ expect(version.minor).to eql 0
385
+ expect(version.patch).to eql 0
386
+ expect(version.prerelease).to eql 'rc1'
387
+ end
388
+ end
389
+ end
390
+ end
391
+
392
+ end
393
+
394
+ describe '.valid?' do
395
+ # All the specific variations are tested in the .parse tests, so these are just basic
396
+ # smoke tests.
397
+
398
+ def subject(str)
399
+ SemanticPuppet::Version.valid?(str)
400
+ end
401
+
402
+ it 'recognizes valid versions' do
403
+ expect(subject('1.0.1')).to be true
404
+ expect(subject('1.0.3-p324')).to be true
405
+ end
406
+
407
+ it 'does not recognize invalid versions' do
408
+ expect(subject('1.0')).to be false # too few segments
409
+ expect(subject('1.0.3.6')).to be false # too many segments
410
+ expect(subject('1.03.14')).to be false # leading zero in segment
411
+ end
412
+ end
413
+
414
+ describe '#<=>' do
415
+ def parse(vstring)
416
+ SemanticPuppet::Version.parse(vstring)
417
+ end
418
+
419
+ context 'Spec v2.0.0' do
420
+ context 'Section 11' do
421
+ # Precedence refers to how versions are compared to each other when
422
+ # ordered. Precedence MUST be calculated by separating the version into
423
+ # major, minor, patch and pre-release identifiers in that order (Build
424
+ # metadata does not figure into precedence). Precedence is determined
425
+ # by the first difference when comparing each of these identifiers from
426
+ # left to right as follows: Major, minor, and patch versions are always
427
+ # compared numerically.
428
+ # Example: 1.0.0 < 2.0.0 < 2.1.0 < 2.1.1.
429
+ # When major, minor, and patch are equal, a pre-release version has
430
+ # lower precedence than a normal version.
431
+ # Example: 1.0.0-alpha < 1.0.0.
432
+ # Precedence for two pre-release versions with the same major, minor,
433
+ # and patch version MUST be determined by comparing each dot separated
434
+ # identifier from left to right until a difference is found as follows:
435
+ # identifiers consisting of only digits are compared numerically and
436
+ # identifiers with letters or hyphens are compared lexically in ASCII
437
+ # sort order. Numeric identifiers always have lower precedence than
438
+ # non-numeric identifiers. A larger set of pre-release fields has a
439
+ # higher precedence than a smaller set, if all of the preceding
440
+ # identifiers are equal.
441
+ # Example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta
442
+ # < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0.
443
+
444
+ context 'comparisons without prereleases' do
445
+ subject do
446
+ %w[ 1.0.0 2.0.0 2.1.0 2.1.1 ].map { |v| parse(v) }.shuffle
447
+ end
448
+
449
+ example 'sorted order' do
450
+ sorted = subject.sort.map { |v| v.to_s }
451
+ expect(sorted).to eql(%w[ 1.0.0 2.0.0 2.1.0 2.1.1 ])
452
+ end
453
+ end
454
+
455
+ context 'comparisons against prereleases' do
456
+ let(:stable) { parse('1.0.0') }
457
+ let(:prerelease) { parse('1.0.0-alpha') }
458
+
459
+ example 'prereleases have lower precedence' do
460
+ expect(stable).to be > prerelease
461
+ expect(prerelease).to be < stable
462
+ end
463
+ end
464
+
465
+ context 'comparisions between prereleases' do
466
+ example 'identical prereleases are equal' do
467
+ expect(parse('1.0.0-rc1')).to eql parse('1.0.0-rc1')
468
+ end
469
+
470
+ example 'non-numeric identifiers sort ASCIIbetically' do
471
+ alpha, beta = parse('1.0.0-alpha'), parse('1.0.0-beta')
472
+ expect(alpha).to be < beta
473
+ expect(beta).to be > alpha
474
+ end
475
+
476
+ example 'numeric identifiers sort numerically' do
477
+ two, eleven = parse('1.0.0-2'), parse('1.0.0-11')
478
+ expect(two).to be < eleven
479
+ expect(eleven).to be > two
480
+ end
481
+
482
+ example 'non-numeric identifiers have a higher precendence' do
483
+ number, word = parse('1.0.0-1'), parse('1.0.0-one')
484
+ expect(number).to be < word
485
+ expect(word).to be > number
486
+ end
487
+
488
+ example 'identifiers are parsed left-to-right' do
489
+ a = parse('1.0.0-these.parts.are.the-same.but.not.waffles.123')
490
+ b = parse('1.0.0-these.parts.are.the-same.but.not.123.waffles')
491
+ expect(b).to be < a
492
+ expect(a).to be > b
493
+ end
494
+
495
+ example 'larger identifier sets have precendence' do
496
+ a = parse('1.0.0-alpha')
497
+ b = parse('1.0.0-alpha.1')
498
+ expect(a).to be < b
499
+ expect(b).to be > a
500
+ end
501
+
502
+ example 'build metadata does not figure into precendence' do
503
+ pending 'build metadata is not yet in scope'
504
+ a = parse('1.0.0-alpha+SHA1')
505
+ b = parse('1.0.0-alpha+MD5')
506
+ expect(a).to eql b
507
+ expect(a.to_s).to_not eql b.to_s
508
+ end
509
+
510
+ example 'sorted order' do
511
+ list = %w[
512
+ 1.0.0-alpha
513
+ 1.0.0-alpha.1
514
+ 1.0.0-alpha.beta
515
+ 1.0.0-beta
516
+ 1.0.0-beta.2
517
+ 1.0.0-beta.11
518
+ 1.0.0-rc.1
519
+ 1.0.0
520
+ ].map { |v| parse(v) }.shuffle
521
+
522
+ sorted = list.sort.map { |v| v.to_s }
523
+ expect(sorted).to eql %w[
524
+ 1.0.0-alpha
525
+ 1.0.0-alpha.1
526
+ 1.0.0-alpha.beta
527
+ 1.0.0-beta
528
+ 1.0.0-beta.2
529
+ 1.0.0-beta.11
530
+ 1.0.0-rc.1
531
+ 1.0.0
532
+ ]
533
+ end
534
+ end
535
+ end
536
+ end
537
+
538
+ context 'Spec v1.0.0' do
539
+ context 'Section 4' do
540
+ # A pre-release version number MAY be denoted by appending an arbitrary
541
+ # string immediately following the patch version and a dash. The string
542
+ # MUST be comprised of only alphanumerics plus dash [0-9A-Za-z-].
543
+ # Pre-release versions satisfy but have a lower precedence than the
544
+ # associated normal version. Precedence SHOULD be determined by
545
+ # lexicographic ASCII sort order.
546
+ # For instance: 1.0.0-alpha1 < 1.0.0-beta1 < 1.0.0-beta2 < 1.0.0-rc1 <
547
+ # 1.0.0
548
+
549
+ example 'sorted order' do
550
+ list = %w[
551
+ 1.0.0-alpha1
552
+ 1.0.0-beta1
553
+ 1.0.0-beta2
554
+ 1.0.0-rc1
555
+ 1.0.0
556
+ ].map { |v| parse(v) }.shuffle
557
+
558
+ sorted = list.sort.map { |v| v.to_s }
559
+ expect(sorted).to eql %w[
560
+ 1.0.0-alpha1
561
+ 1.0.0-beta1
562
+ 1.0.0-beta2
563
+ 1.0.0-rc1
564
+ 1.0.0
565
+ ]
566
+ end
567
+ end
568
+ end
569
+
570
+ end
571
+
572
+ describe '#next' do
573
+ context 'with :major' do
574
+ it 'returns the next major version' do
575
+ expect(subject('1.0.0').next(:major)).to eql(subject('2.0.0'))
576
+ end
577
+
578
+ it 'does not modify the original version' do
579
+ v1 = subject('1.0.0')
580
+ v2 = v1.next(:major)
581
+ expect(v1).to_not eql(v2)
582
+ end
583
+
584
+ it 'resets the minor and patch versions to 0' do
585
+ expect(subject('1.1.1').next(:major)).to eql(subject('2.0.0'))
586
+ end
587
+
588
+ it 'removes any prerelease information' do
589
+ expect(subject('1.0.0-alpha').next(:major)).to eql(subject('2.0.0'))
590
+ end
591
+
592
+ it 'removes any build information' do
593
+ pending 'build metadata is not yet in scope'
594
+ expect(subject('1.0.0+abc').next(:major)).to eql(subject('2.0.0'))
595
+ end
596
+ end
597
+
598
+ context 'with :minor' do
599
+ it 'returns the next minor version' do
600
+ expect(subject('1.0.0').next(:minor)).to eql(subject('1.1.0'))
601
+ end
602
+
603
+ it 'does not modify the original version' do
604
+ v1 = subject('1.0.0')
605
+ v2 = v1.next(:minor)
606
+ expect(v1).to_not eql(v2)
607
+ end
608
+
609
+ it 'resets the patch version to 0' do
610
+ expect(subject('1.1.1').next(:minor)).to eql(subject('1.2.0'))
611
+ end
612
+
613
+ it 'removes any prerelease information' do
614
+ expect(subject('1.1.0-alpha').next(:minor)).to eql(subject('1.2.0'))
615
+ end
616
+
617
+ it 'removes any build information' do
618
+ pending 'build metadata is not yet in scope'
619
+ expect(subject('1.1.0+abc').next(:minor)).to eql(subject('1.2.0'))
620
+ end
621
+ end
622
+
623
+ context 'with :patch' do
624
+ it 'returns the next patch version' do
625
+ expect(subject('1.1.1').next(:patch)).to eql(subject('1.1.2'))
626
+ end
627
+
628
+ it 'does not modify the original version' do
629
+ v1 = subject('1.0.0')
630
+ v2 = v1.next(:patch)
631
+ expect(v1).to_not eql(v2)
632
+ end
633
+
634
+ it 'removes any prerelease information' do
635
+ expect(subject('1.0.0-alpha').next(:patch)).to eql(subject('1.0.1'))
636
+ end
637
+
638
+ it 'removes any build information' do
639
+ pending 'build metadata is not yet in scope'
640
+ expect(subject('1.0.0+abc').next(:patch)).to eql(subject('1.0.1'))
641
+ end
642
+ end
643
+ end
644
+ end