summaryrefslogtreecommitdiffstats
path: root/spec/unit/util
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2008-12-19 17:35:08 +0100
committerJames Turnbull <james@lovedthanlost.net>2008-12-27 12:44:51 +1100
commitd69abfeaade452845924a0d4446dc1ea85637fc7 (patch)
tree8ddd1f2a2c71ed4460e06cb54f27744c206d2c63 /spec/unit/util
parent4c648bb1e7428806550f57160f72892709b0a30f (diff)
downloadpuppet-d69abfeaade452845924a0d4446dc1ea85637fc7.tar.gz
puppet-d69abfeaade452845924a0d4446dc1ea85637fc7.tar.xz
puppet-d69abfeaade452845924a0d4446dc1ea85637fc7.zip
Fix #1807 - make Puppet::Util::Package.versioncmp a module function
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/util')
-rw-r--r--spec/unit/util/package.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/unit/util/package.rb b/spec/unit/util/package.rb
new file mode 100644
index 000000000..7d956efb5
--- /dev/null
+++ b/spec/unit/util/package.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+require 'puppet/util/package'
+
+describe Puppet::Util::Package, " versioncmp" do
+
+ it "should be able to be used as a module function" do
+ Puppet::Util::Package.should respond_to(:versioncmp)
+ end
+
+ it "should be able to sort a long set of various unordered versions" do
+ ary = %w{ 1.1.6 2.3 1.1a 3.0 1.5 1 2.4 1.1-4 2.3.1 1.2 2.3.0 1.1-3 2.4b 2.4 2.40.2 2.3a.1 3.1 0002 1.1-5 1.1.a 1.06}
+
+ newary = ary.sort { |a, b| Puppet::Util::Package.versioncmp(a,b) }
+
+ newary.should == ["0002", "1", "1.06", "1.1-3", "1.1-4", "1.1-5", "1.1.6", "1.1.a", "1.1a", "1.2", "1.5", "2.3", "2.3.0", "2.3.1", "2.3a.1", "2.4", "2.4", "2.4b", "2.40.2", "3.0", "3.1"]
+ end
+
+end