version: allow versions to be compared against NULL_TOKEN
This commit is contained in:
parent
f904cc2aea
commit
fb96ccf4c8
@ -184,9 +184,14 @@ describe Version do
|
||||
end
|
||||
|
||||
it "can be compared against tokens" do
|
||||
expect(described_class.create("2.1.0-p194")).to be > Version::Token.create("2")
|
||||
expect(described_class.create("1")).to be == Version::Token.create("1")
|
||||
end
|
||||
|
||||
it "can be compared against Version::NULL_TOKEN" do
|
||||
expect(described_class.create("2.1.0-p194")).to be > Version::NULL_TOKEN
|
||||
end
|
||||
|
||||
specify "comparison returns nil for non-version" do
|
||||
v = described_class.create("1.0")
|
||||
expect(v <=> Object.new).to be nil
|
||||
|
||||
@ -445,9 +445,9 @@ class Version
|
||||
# Used by the *_build_version comparisons, which formerly returned Fixnum
|
||||
other = Version.new(other.to_s) if other.is_a? Integer
|
||||
return 1 if other.nil?
|
||||
return 1 if other.respond_to?(:null?) && other.null?
|
||||
|
||||
other = Version.new(other.to_s) if other.is_a? Token
|
||||
return 1 if other.respond_to?(:null?) && other.null?
|
||||
return unless other.is_a?(Version)
|
||||
return 0 if version == other.version
|
||||
return 1 if head? && !other.head?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user