Skip to content

Commit b780621

Browse files
Fix range check for string versions
Fixes #267
1 parent e030a6b commit b780621

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

jruby-gradle-base-plugin/src/main/groovy/com/github/jrubygradle/internal/GemVersion.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ class GemVersion {
169169
return 1
170170
}
171171

172-
int aaObject
173-
int bbObject
172+
def aaObject
173+
def bbObject
174174

175175
if (aDigits[index].isInteger() && bDigits[index].isInteger()) {
176176
// compare them as number

jruby-gradle-base-plugin/src/test/groovy/com/github/jrubygradle/internal/GemVersionSpec.groovy

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,28 @@ class GemVersionSpec extends Specification {
178178
expect:
179179
subject.intersect('[1.2.4, 1.2.4]').conflict() == true
180180
}
181+
182+
def "passes non-integer version ranges with no conflicts"() {
183+
given:
184+
GemVersion subject = new GemVersion('[1.2.bar, 1.2.foo]')
185+
186+
expect:
187+
!subject.conflict()
188+
}
189+
190+
def "fails non-integer version ranges with conflicts"() {
191+
given:
192+
GemVersion subject = new GemVersion('[1.2.foo, 1.2.bar]')
193+
194+
expect:
195+
subject.conflict()
196+
}
197+
198+
def "it does not throw an exception for a '+' version"() {
199+
when:
200+
new GemVersion('+').conflict()
201+
202+
then:
203+
notThrown(Exception)
204+
}
181205
}

0 commit comments

Comments
 (0)