summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-01-31 13:21:22 -0800
committerDaniel Pittman <daniel@rimspace.net>2011-01-31 13:21:22 -0800
commitfa06a388cd3fd91b62d4e65bbe4ff74bcfe46ad0 (patch)
tree04369523bed9f9ce292ada8503e4183f0da84d31 /spec/unit
parente717fed872f68c52fc0193bab2095a12f03433ac (diff)
parentd9b8f2ad68626b8655d98a8d9037283f671f86bb (diff)
downloadfacter-fa06a388cd3fd91b62d4e65bbe4ff74bcfe46ad0.tar.gz
facter-fa06a388cd3fd91b62d4e65bbe4ff74bcfe46ad0.tar.xz
facter-fa06a388cd3fd91b62d4e65bbe4ff74bcfe46ad0.zip
Merge commit 'd9b8f2a'
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/facter_spec.rb (renamed from spec/unit/facter.rb)2
-rwxr-xr-x[-rw-r--r--]spec/unit/interfaces_spec.rb (renamed from spec/unit/interfaces.rb)2
-rwxr-xr-x[-rw-r--r--]spec/unit/operatingsystem_spec.rb (renamed from spec/unit/operatingsystem.rb)2
-rwxr-xr-x[-rw-r--r--]spec/unit/operatingsystemrelease_spec.rb (renamed from spec/unit/operatingsystemrelease.rb)4
-rwxr-xr-x[-rw-r--r--]spec/unit/selinux_spec.rb (renamed from spec/unit/selinux.rb)2
-rwxr-xr-x[-rw-r--r--]spec/unit/uptime_spec.rb (renamed from spec/unit/uptime.rb)8
-rwxr-xr-xspec/unit/util/collection_spec.rb (renamed from spec/unit/util/collection.rb)2
-rwxr-xr-xspec/unit/util/confine_spec.rb (renamed from spec/unit/util/confine.rb)2
-rwxr-xr-xspec/unit/util/fact_spec.rb (renamed from spec/unit/util/fact.rb)2
-rwxr-xr-xspec/unit/util/ip_spec.rb (renamed from spec/unit/util/ip.rb)2
-rwxr-xr-xspec/unit/util/loader_spec.rb (renamed from spec/unit/util/loader.rb)2
-rwxr-xr-x[-rw-r--r--]spec/unit/util/macaddress_spec.rb (renamed from spec/unit/util/macaddress.rb)12
-rwxr-xr-xspec/unit/util/macosx_spec.rb (renamed from spec/unit/util/macosx.rb)2
-rw-r--r--spec/unit/util/manufacturer_spec.rb (renamed from spec/unit/util/manufacturer.rb)2
-rwxr-xr-xspec/unit/util/resolution_spec.rb (renamed from spec/unit/util/resolution.rb)2
-rw-r--r--spec/unit/util/uptime.rb53
-rwxr-xr-xspec/unit/util/uptime_spec.rb73
-rw-r--r--spec/unit/util/virtual_spec.rb (renamed from spec/unit/util/virtual.rb)4
-rwxr-xr-x[-rw-r--r--]spec/unit/util/vlans_spec.rb (renamed from spec/unit/util/vlans.rb)2
-rwxr-xr-x[-rw-r--r--]spec/unit/util/xendomains_spec.rb (renamed from spec/unit/util/xendomains.rb)4
-rw-r--r--spec/unit/virtual_spec.rb (renamed from spec/unit/virtual.rb)2
21 files changed, 103 insertions, 83 deletions
diff --git a/spec/unit/facter.rb b/spec/unit/facter_spec.rb
index 20f9ed1..e63bc76 100755
--- a/spec/unit/facter.rb
+++ b/spec/unit/facter_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Facter do
diff --git a/spec/unit/interfaces.rb b/spec/unit/interfaces_spec.rb
index 49d5d1f..8b295d6 100644..100755
--- a/spec/unit/interfaces.rb
+++ b/spec/unit/interfaces_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'facter'
diff --git a/spec/unit/operatingsystem.rb b/spec/unit/operatingsystem_spec.rb
index de86230..be83916 100644..100755
--- a/spec/unit/operatingsystem.rb
+++ b/spec/unit/operatingsystem_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'facter'
diff --git a/spec/unit/operatingsystemrelease.rb b/spec/unit/operatingsystemrelease_spec.rb
index 31d4ae8..1cfb4ac 100644..100755
--- a/spec/unit/operatingsystemrelease.rb
+++ b/spec/unit/operatingsystemrelease_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'facter'
@@ -26,7 +26,7 @@ describe "Operating System Release fact" do
}
test_cases.each do |system, file|
- context "with operatingsystem reported as #{system.inspect}" do
+ describe "with operatingsystem reported as #{system.inspect}" do
it "should read the #{file.inspect} file" do
Facter.fact(:operatingsystem).stubs(:value).returns(system)
diff --git a/spec/unit/selinux.rb b/spec/unit/selinux_spec.rb
index 8afa463..43fd5bf 100644..100755
--- a/spec/unit/selinux.rb
+++ b/spec/unit/selinux_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'facter'
diff --git a/spec/unit/uptime.rb b/spec/unit/uptime_spec.rb
index 19a55fe..bd695fa 100644..100755
--- a/spec/unit/uptime.rb
+++ b/spec/unit/uptime_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'facter'
require 'facter/util/uptime'
@@ -9,7 +9,7 @@ describe "uptime facts:" do
before { Facter.clear }
after { Facter.clear }
- context "when uptime information is available" do
+ describe "when uptime information is available" do
describe "uptime" do
test_cases = [
[60 * 60 * 24 * 3, '3 days'],
@@ -34,7 +34,7 @@ describe "uptime facts:" do
end
- context "when uptime information is available" do
+ describe "when uptime information is available" do
before do
Facter::Util::Uptime.stubs(:get_uptime_seconds_unix).returns(60 * 60 * 24 + 23)
Facter::Util::Uptime.stubs(:get_uptime_seconds_win).returns(60 * 60 * 24 + 23)
@@ -59,7 +59,7 @@ describe "uptime facts:" do
end
end
- context "when uptime information is not available" do
+ describe "when uptime information is not available" do
before do
Facter::Util::Uptime.stubs(:get_uptime_seconds_unix).returns(nil)
Facter::Util::Uptime.stubs(:get_uptime_seconds_win).returns(nil)
diff --git a/spec/unit/util/collection.rb b/spec/unit/util/collection_spec.rb
index 7baef96..86b602f 100755
--- a/spec/unit/util/collection.rb
+++ b/spec/unit/util/collection_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'facter/util/collection'
diff --git a/spec/unit/util/confine.rb b/spec/unit/util/confine_spec.rb
index 757ca26..147c70d 100755
--- a/spec/unit/util/confine.rb
+++ b/spec/unit/util/confine_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'facter/util/confine'
require 'facter/util/values'
diff --git a/spec/unit/util/fact.rb b/spec/unit/util/fact_spec.rb
index 1652032..db08670 100755
--- a/spec/unit/util/fact.rb
+++ b/spec/unit/util/fact_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'facter/util/fact'
diff --git a/spec/unit/util/ip.rb b/spec/unit/util/ip_spec.rb
index a9aae76..d87b4b9 100755
--- a/spec/unit/util/ip.rb
+++ b/spec/unit/util/ip_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'facter/util/ip'
diff --git a/spec/unit/util/loader.rb b/spec/unit/util/loader_spec.rb
index 0a28020..0bb823e 100755
--- a/spec/unit/util/loader.rb
+++ b/spec/unit/util/loader_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'facter/util/loader'
diff --git a/spec/unit/util/macaddress.rb b/spec/unit/util/macaddress_spec.rb
index 1ccca18..98215c4 100644..100755
--- a/spec/unit/util/macaddress.rb
+++ b/spec/unit/util/macaddress_spec.rb
@@ -1,10 +1,10 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'facter/util/macaddress'
-context "Darwin" do
+describe "Darwin" do
test_cases = [
# version, iface, real macaddress, fallback macaddress
["9.8.0", 'en0', "00:17:f2:06:e4:2e", "00:17:f2:06:e4:2e"],
@@ -17,12 +17,12 @@ context "Darwin" do
ifconfig_file_no_iface = File.join(SPECDIR, "fixtures", "ifconfig", "darwin_#{version.tr('.', '_')}")
ifconfig_file = "#{ifconfig_file_no_iface}_#{default_iface}"
- context "version #{version}" do
+ describe "version #{version}" do
describe Facter::Util::Macaddress::Darwin do
describe ".default_interface" do
- context "when netstat has a default interface" do
+ describe "when netstat has a default interface" do
before do
Facter::Util::Macaddress::Darwin.stubs(:netstat_command).returns("cat \"#{netstat_file}\"")
@@ -36,7 +36,7 @@ context "Darwin" do
end
describe ".macaddress" do
- context "when netstat has a default interface" do
+ describe "when netstat has a default interface" do
before do
Facter.stubs(:warn)
Facter::Util::Macaddress::Darwin.stubs(:default_interface).returns('')
@@ -49,7 +49,7 @@ context "Darwin" do
end
- context "when netstat does not have a default interface" do
+ describe "when netstat does not have a default interface" do
before do
Facter::Util::Macaddress::Darwin.stubs(:default_interface).returns("")
Facter::Util::Macaddress::Darwin.stubs(:ifconfig_command).returns("cat \"#{ifconfig_file_no_iface}\"")
diff --git a/spec/unit/util/macosx.rb b/spec/unit/util/macosx_spec.rb
index 283fe75..44ba460 100755
--- a/spec/unit/util/macosx.rb
+++ b/spec/unit/util/macosx_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'facter/util/macosx'
diff --git a/spec/unit/util/manufacturer.rb b/spec/unit/util/manufacturer_spec.rb
index 291a6ff..07473db 100644
--- a/spec/unit/util/manufacturer.rb
+++ b/spec/unit/util/manufacturer_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'facter/util/manufacturer'
diff --git a/spec/unit/util/resolution.rb b/spec/unit/util/resolution_spec.rb
index 396f800..581d0e1 100755
--- a/spec/unit/util/resolution.rb
+++ b/spec/unit/util/resolution_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'facter/util/resolution'
diff --git a/spec/unit/util/uptime.rb b/spec/unit/util/uptime.rb
deleted file mode 100644
index 72c97ed..0000000
--- a/spec/unit/util/uptime.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../spec_helper'
-
-require 'facter/util/uptime'
-
-describe Facter::Util::Uptime do
-
- describe ".get_uptime_seconds_unix" do
- context "when /proc/uptime is available" do
- before do
- uptime_file = File.join(SPECDIR, "fixtures", "uptime", "ubuntu_proc_uptime")
- Facter::Util::Uptime.stubs(:uptime_file).returns("\"#{uptime_file}\"")
- end
-
- it "should return the uptime in seconds as an integer" do
- Facter::Util::Uptime.get_uptime_seconds_unix.should == 5097686
- end
-
- end
-
- it "should use sysctl kern.boottime when /proc/uptime not available" do
- nonexistent_file = '/non/existent/file'
- File.exists?(nonexistent_file).should == false
- Facter::Util::Uptime.stubs(:uptime_file).returns(nonexistent_file)
- sysctl_output_file = File.join(SPECDIR, 'fixtures', 'uptime', 'sysctl_kern_boottime') # Aug 01 14:13:47 -0700 2010
- Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat \"#{sysctl_output_file}\"")
- Time.stubs(:now).returns Time.parse("Aug 01 15:13:47 -0700 2010") # one hour later
- Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
- end
-
- it "should use who -b when neither /proc/uptime nor sysctl kern.boottime is available" do
- nonexistent_file = '/non/existent/file'
- File.exists?(nonexistent_file).should == false
- Facter::Util::Uptime.stubs(:uptime_file).returns(nonexistent_file)
- Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat #{nonexistent_file}")
- who_b_output_file = File.join(SPECDIR, 'fixtures', 'uptime', 'who_b_boottime') # Aug 1 14:13
- Facter::Util::Uptime.stubs(:uptime_who_cmd).returns("cat \"#{who_b_output_file}\"")
- Time.stubs(:now).returns Time.parse("Aug 01 15:13") # one hour later
- Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
- end
-
- it "should return nil when none of /proc/uptime, sysctl kern.boottime, or who -b is available" do
- nonexistent_file = '/non/existent/file'
- File.exists?(nonexistent_file).should == false
- Facter::Util::Uptime.stubs(:uptime_file).returns(nonexistent_file)
- Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat #{nonexistent_file}")
- Facter::Util::Uptime.stubs(:uptime_who_cmd).returns("cat #{nonexistent_file}")
- Facter::Util::Uptime.get_uptime_seconds_unix.should == nil
- end
- end
-
-end
diff --git a/spec/unit/util/uptime_spec.rb b/spec/unit/util/uptime_spec.rb
new file mode 100755
index 0000000..8d3980c
--- /dev/null
+++ b/spec/unit/util/uptime_spec.rb
@@ -0,0 +1,73 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+
+require 'facter/util/uptime'
+
+describe Facter::Util::Uptime do
+
+ describe ".get_uptime_seconds_unix" do
+ describe "when /proc/uptime is available" do
+ before do
+ uptime_file = File.join(SPECDIR, "fixtures", "uptime", "ubuntu_proc_uptime")
+ Facter::Util::Uptime.stubs(:uptime_file).returns("\"#{uptime_file}\"")
+ end
+
+ it "should return the uptime in seconds as an integer" do
+ Facter::Util::Uptime.get_uptime_seconds_unix.should == 5097686
+ end
+
+ end
+
+ describe "when /proc/uptime is not available" do
+ before :each do
+ @nonexistent_file = '/non/existent/file'
+ File.exists?(@nonexistent_file).should == false
+ Facter::Util::Uptime.stubs(:uptime_file).returns(@nonexistent_file)
+ end
+
+ it "should use 'sysctl kern.boottime'" do
+ sysctl_output_file = File.join(SPECDIR, 'fixtures', 'uptime', 'sysctl_kern_boottime') # Aug 01 14:13:47 -0700 2010
+ Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat \"#{sysctl_output_file}\"")
+ Time.stubs(:now).returns Time.parse("Aug 01 15:13:47 -0700 2010") # one hour later
+ Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
+ end
+
+ describe "nor is 'sysctl kern.boottime'" do
+ before :each do
+ Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat \"#{@nonexistent_file}\"")
+ end
+
+ it "should use 'kstat -p unix:::boot_time'" do
+ kstat_output_file = File.join(SPECDIR, 'fixtures', 'uptime', 'kstat_boot_time') # unix:0:system_misc:boot_time 1236919980
+ Facter::Util::Uptime.stubs(:uptime_kstat_cmd).returns("cat \"#{kstat_output_file}\"")
+ Time.stubs(:now).returns Time.at(1236923580) #one hour later
+ Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
+ end
+
+ describe "nor is 'kstat -p unix:::boot_time'" do
+ before :each do
+ Facter::Util::Uptime.stubs(:uptime_kstat_cmd).returns("cat \"#{@nonexistent_file}\"")
+ end
+
+ it "should use 'who -b'" do
+ who_b_output_file = File.join(SPECDIR, 'fixtures', 'uptime', 'who_b_boottime') # Aug 1 14:13
+ Facter::Util::Uptime.stubs(:uptime_who_cmd).returns("cat \"#{who_b_output_file}\"")
+ Time.stubs(:now).returns Time.parse("Aug 01 15:13") # one hour later
+ Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
+ end
+
+ describe "nor is 'who -b'" do
+ before :each do
+ Facter::Util::Uptime.stubs(:uptime_who_cmd).returns("cat \"#{@nonexistent_file}\"")
+ end
+
+ it "should return nil" do
+ Facter::Util::Uptime.get_uptime_seconds_unix.should == nil
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spec/unit/util/virtual.rb b/spec/unit/util/virtual_spec.rb
index 72186f7..12ba0ac 100644
--- a/spec/unit/util/virtual.rb
+++ b/spec/unit/util/virtual_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'facter/util/virtual'
@@ -67,7 +67,7 @@ describe Facter::Util::Virtual do
]
test_cases.each do |status_file, expected, description|
- context "with /proc/self/status from #{description}" do
+ describe "with /proc/self/status from #{description}" do
it "should detect vserver as #{expected.inspect}" do
status = File.read(status_file)
FileTest.stubs(:exists?).with("/proc/self/status").returns(true)
diff --git a/spec/unit/util/vlans.rb b/spec/unit/util/vlans_spec.rb
index e06a2af..0331234 100644..100755
--- a/spec/unit/util/vlans.rb
+++ b/spec/unit/util/vlans_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'facter/util/vlans'
diff --git a/spec/unit/util/xendomains.rb b/spec/unit/util/xendomains_spec.rb
index a0fa345..dc7e178 100644..100755
--- a/spec/unit/util/xendomains.rb
+++ b/spec/unit/util/xendomains_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'facter/util/xendomains'
@@ -13,7 +13,7 @@ describe Facter::Util::Xendomains do
Facter::Util::Xendomains.get_domains.should == %{web01,mailserver}
end
- context "when xm list isn't executable" do
+ describe "when xm list isn't executable" do
it "should be nil" do
Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/xm list').returns(nil)
Facter::Util::Xendomains.get_domains.should == nil
diff --git a/spec/unit/virtual.rb b/spec/unit/virtual_spec.rb
index 9e8e358..a152b40 100644
--- a/spec/unit/virtual.rb
+++ b/spec/unit/virtual_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'facter'
require 'facter/util/virtual'