summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorNigel Kersten <nigelk@google.com>2009-07-23 08:34:47 -0700
committerPaul Nasrat <pnasrat@googlemail.com>2009-08-07 11:08:42 +0100
commitbe9e484c0daaf4befb0dfbcf85bda08ce6c1effd (patch)
tree08ab3dd6012df3d198364e66480d9b829a7fcb6d /spec
parentf3ad66f69979cd107025b6edd07bbe6c958d447b (diff)
downloadfacter-be9e484c0daaf4befb0dfbcf85bda08ce6c1effd.tar.gz
facter-be9e484c0daaf4befb0dfbcf85bda08ce6c1effd.tar.xz
facter-be9e484c0daaf4befb0dfbcf85bda08ce6c1effd.zip
Update OS X minor version fact to cope with '10.x' values and provide test coverage
switch %x{} call to Facter::Util::Resolution.exec for better testing
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/util/macosx.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/unit/util/macosx.rb b/spec/unit/util/macosx.rb
index a543013..283fe75 100755
--- a/spec/unit/util/macosx.rb
+++ b/spec/unit/util/macosx.rb
@@ -44,4 +44,38 @@ describe Facter::Util::Macosx do
Facter::Util::Macosx.expects(:profiler_data).with("SPSoftwareDataType").returns "eh"
Facter::Util::Macosx.os_overview.should == "eh"
end
+
+ describe "when working out software version" do
+
+ before do
+ Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productName").returns "Mac OS X"
+ Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -buildVersion").returns "9J62"
+ end
+
+ it "should have called sw_vers three times when determining software version" do
+ Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "10.5.7"
+ Facter::Util::Macosx.sw_vers
+ end
+
+ it "should return a hash with the correct keys when determining software version" do
+ Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "10.5.7"
+ Facter::Util::Macosx.sw_vers.keys.sort.should == ["macosx_productName",
+ "macosx_buildVersion",
+ "macosx_productversion_minor",
+ "macosx_productversion_major",
+ "macosx_productVersion"].sort
+ end
+
+ it "should split a product version of 'x.y.z' into separate hash entries correctly" do
+ Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "1.2.3"
+ sw_vers = Facter::Util::Macosx.sw_vers
+ sw_vers["macosx_productversion_major"].should == "1.2"
+ sw_vers["macosx_productversion_minor"].should == "3"
+ end
+
+ it "should treat a product version of 'x.y' as 'x.y.0" do
+ Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "2.3"
+ Facter::Util::Macosx.sw_vers["macosx_productversion_minor"].should == "0"
+ end
+ end
end