Skip to content

Commit 9f9b71c

Browse files
committed
Fix method name typo
Fix NoMethodError when using a union (||) of comparator sets. Add test to cover that case and update comments. Note SemanticPuppet incorrectly merges comparators sets with prerelease versions. So it should consider 1.0.0 to be included in the range, but it is not currently.
1 parent 66f73a5 commit 9f9b71c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

lib/semantic_puppet/version_range.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ def upper_bound?
398398

399399
# Merge two ranges so that the result matches the intersection of all matching versions.
400400
#
401-
# @param range [AbastractRange] the range to intersect with
402-
# @return [AbastractRange,nil] the intersection between the ranges
401+
# @param range [AbstractRange] the range to intersect with
402+
# @return [AbstractRange,nil] the intersection between the ranges
403403
#
404404
# @api private
405405
def intersection(range)
@@ -474,7 +474,7 @@ def merge(other)
474474
excl_end = other.exclude_end?
475475
else
476476
max = self.end
477-
excl_end = exclude_end && other.exclude_end?
477+
excl_end = exclude_end? && other.exclude_end?
478478
end
479479

480480
MinMaxRange.create(excl_begin ? GtRange.new(min) : GtEqRange.new(min), excl_end ? LtRange.new(max) : LtEqRange.new(max))
@@ -499,7 +499,7 @@ def merge(other)
499499
# Checks if this matcher accepts a prerelease with the same major, minor, patch triple as the given version. Only matchers
500500
# where this has been explicitly stated will respond `true` to this method
501501
#
502-
# @return [Boolean] `true` if this matcher accepts a prerelase with the tuple from the given version
502+
# @return [Boolean] `true` if this matcher accepts a prerelease with the tuple from the given version
503503
def test_prerelease?(_)
504504
false
505505
end

spec/unit/semantic_puppet/version_range_spec.rb

+10
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,16 @@ def self.test_range(range_list, str, includes, excludes)
270270
expect(range.exclude_end?).to be_nil
271271
end
272272
end
273+
274+
context 'prerelease' do
275+
test_expressions(
276+
[ '>=5.0.1-rc0' || '>=0.5.0' ] => {
277+
:to_str => '>=5.0.1-rc0',
278+
:includes => ['5.0.1-rc0', '5.0.1'], # should include 1.0.0
279+
:excludes => ['1.0.0', '5.0.0-rc0', '5.0.2-rc0']
280+
}
281+
)
282+
end
273283
end
274284

275285
context 'invalid expressions' do

0 commit comments

Comments
 (0)