facter 1.6.2 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of facter might be problematic. Click here for more details.

Files changed (57) hide show
  1. data/CHANGELOG +11 -0
  2. data/LICENSE +1 -1
  3. data/conf/osx/createpackage.sh +1 -1
  4. data/conf/redhat/facter.spec +9 -6
  5. data/conf/solaris/pkginfo +1 -1
  6. data/install.rb +1 -1
  7. data/lib/facter.rb +2 -2
  8. data/lib/facter/architecture.rb +1 -2
  9. data/lib/facter/augeasversion.rb +1 -2
  10. data/lib/facter/domain.rb +3 -3
  11. data/lib/facter/hardwareisa.rb +1 -1
  12. data/lib/facter/ipaddress.rb +2 -2
  13. data/lib/facter/lsbmajdistrelease.rb +1 -1
  14. data/lib/facter/macaddress.rb +2 -2
  15. data/lib/facter/manufacturer.rb +1 -1
  16. data/lib/facter/netmask.rb +0 -3
  17. data/lib/facter/network.rb +2 -3
  18. data/lib/facter/operatingsystem.rb +5 -2
  19. data/lib/facter/operatingsystemrelease.rb +3 -3
  20. data/lib/facter/osfamily.rb +1 -1
  21. data/lib/facter/processor.rb +2 -2
  22. data/lib/facter/selinux.rb +3 -3
  23. data/lib/facter/uniqueid.rb +1 -1
  24. data/lib/facter/uptime_days.rb +0 -1
  25. data/lib/facter/uptime_hours.rb +0 -1
  26. data/lib/facter/util/manufacturer.rb +2 -3
  27. data/lib/facter/util/processor.rb +3 -3
  28. data/lib/facter/util/resolution.rb +3 -3
  29. data/lib/facter/util/values.rb +1 -1
  30. data/lib/facter/virtual.rb +2 -2
  31. data/lib/facter/vlans.rb +1 -2
  32. data/lib/facter/xendomains.rb +0 -1
  33. data/spec/fixtures/unit/util/manufacturer/solaris_sunfire_v120_prtdiag +33 -0
  34. data/spec/fixtures/unit/util/manufacturer/solaris_t5220_prtdiag +136 -0
  35. data/spec/spec_helper.rb +5 -0
  36. data/spec/unit/architecture_spec.rb +40 -40
  37. data/spec/unit/facter_spec.rb +220 -220
  38. data/spec/unit/id_spec.rb +16 -16
  39. data/spec/unit/interfaces_spec.rb +6 -6
  40. data/spec/unit/memory_spec.rb +105 -105
  41. data/spec/unit/operatingsystem_spec.rb +72 -63
  42. data/spec/unit/operatingsystemrelease_spec.rb +44 -43
  43. data/spec/unit/processor_spec.rb +2 -2
  44. data/spec/unit/selinux_spec.rb +53 -53
  45. data/spec/unit/util/collection_spec.rb +183 -183
  46. data/spec/unit/util/confine_spec.rb +92 -92
  47. data/spec/unit/util/fact_spec.rb +96 -96
  48. data/spec/unit/util/ip_spec.rb +218 -218
  49. data/spec/unit/util/loader_spec.rb +193 -193
  50. data/spec/unit/util/macosx_spec.rb +63 -63
  51. data/spec/unit/util/manufacturer_spec.rb +124 -107
  52. data/spec/unit/util/resolution_spec.rb +235 -235
  53. data/spec/unit/util/virtual_spec.rb +167 -167
  54. data/spec/unit/util/vlans_spec.rb +6 -6
  55. data/spec/unit/virtual_spec.rb +246 -246
  56. data/spec/watchr.rb +1 -1
  57. metadata +6 -4
@@ -133,7 +133,7 @@ Facter.add("virtual") do
133
133
  end
134
134
  end
135
135
  end
136
-
136
+
137
137
  if output = Facter::Util::Resolution.exec("vmware -v")
138
138
  result = output.sub(/(\S+)\s+(\S+).*/) { | text | "#{$1}_#{$2}"}.downcase
139
139
  end
@@ -148,7 +148,7 @@ end
148
148
  # Purpose: returning true or false for if a machine is virtualised or not.
149
149
  #
150
150
  # Resolution: Hypervisors and the like may be detected as a virtual type, but
151
- # are not actual virtual machines, or should not be treated as such. This
151
+ # are not actual virtual machines, or should not be treated as such. This
152
152
  # determines if the host is actually virtualized.
153
153
  #
154
154
  # Caveats:
@@ -7,9 +7,8 @@
7
7
  #
8
8
  # Caveats:
9
9
  #
10
-
11
10
  require 'facter/util/vlans'
12
-
11
+
13
12
  Facter.add("vlans") do
14
13
  confine :kernel => :linux
15
14
  setcode do
@@ -8,7 +8,6 @@
8
8
  #
9
9
  # Caveats:
10
10
  #
11
-
12
11
  require 'facter/util/xendomains'
13
12
 
14
13
  Facter.add("xendomains") do
@@ -0,0 +1,33 @@
1
+ System Configuration: Sun Microsystems sun4u Sun Fire V120 (UltraSPARC-IIe 648MHz)
2
+ System clock frequency: 100 MHz
3
+ Memory size: 2048 Megabytes
4
+
5
+ ========================= CPUs =========================
6
+
7
+ Run Ecache CPU CPU
8
+ Brd CPU Module MHz MB Impl. Mask
9
+ --- --- ------- ----- ------ ------ ----
10
+ 0 0 0 648 0.5 13 3.3
11
+
12
+
13
+ ========================= IO Cards =========================
14
+
15
+ Bus# Freq
16
+ Brd Type MHz Slot Name Model
17
+ --- ---- ---- ---- -------------------------------- ----------------------
18
+ 0 PCI-1 33 12 ebus
19
+ 0 PCI-1 33 3 pmu-pci10b9,7101
20
+ 0 PCI-1 33 3 lomp
21
+ 0 PCI-1 33 7 isa
22
+ 0 PCI-1 33 12 network-pci108e,1101 SUNW,pci-eri
23
+ 0 PCI-1 33 12 usb-pci108e,1103.1
24
+ 0 PCI-1 33 13 ide-pci10b9,5229
25
+ 0 PCI-1 33 5 network-pci108e,1101 SUNW,pci-eri
26
+ 0 PCI-1 33 5 usb-pci108e,1103.1
27
+ 0 PCI-2 33 8 scsi-glm Symbios,53C896
28
+ 0 PCI-2 33 8 scsi-glm Symbios,53C896
29
+ 0 PCI-2 33 5 network-pci108e,2bad SUNW,pci-gem
30
+
31
+
32
+ No failures found in System
33
+ ===========================
@@ -0,0 +1,136 @@
1
+ System Configuration: Sun Microsystems sun4v SPARC Enterprise T5220
2
+ Memory size: 32640 Megabytes
3
+
4
+ ================================ Virtual CPUs ================================
5
+
6
+
7
+ CPU ID Frequency Implementation Status
8
+ ------ --------- ---------------------- -------
9
+ 0 1165 MHz SUNW,UltraSPARC-T2 on-line
10
+ 1 1165 MHz SUNW,UltraSPARC-T2 on-line
11
+ 2 1165 MHz SUNW,UltraSPARC-T2 on-line
12
+ 3 1165 MHz SUNW,UltraSPARC-T2 on-line
13
+ 4 1165 MHz SUNW,UltraSPARC-T2 on-line
14
+ 5 1165 MHz SUNW,UltraSPARC-T2 on-line
15
+ 6 1165 MHz SUNW,UltraSPARC-T2 on-line
16
+ 7 1165 MHz SUNW,UltraSPARC-T2 on-line
17
+ 8 1165 MHz SUNW,UltraSPARC-T2 on-line
18
+ 9 1165 MHz SUNW,UltraSPARC-T2 on-line
19
+ 10 1165 MHz SUNW,UltraSPARC-T2 on-line
20
+ 11 1165 MHz SUNW,UltraSPARC-T2 on-line
21
+ 12 1165 MHz SUNW,UltraSPARC-T2 on-line
22
+ 13 1165 MHz SUNW,UltraSPARC-T2 on-line
23
+ 14 1165 MHz SUNW,UltraSPARC-T2 on-line
24
+ 15 1165 MHz SUNW,UltraSPARC-T2 on-line
25
+ 16 1165 MHz SUNW,UltraSPARC-T2 on-line
26
+ 17 1165 MHz SUNW,UltraSPARC-T2 on-line
27
+ 18 1165 MHz SUNW,UltraSPARC-T2 on-line
28
+ 19 1165 MHz SUNW,UltraSPARC-T2 on-line
29
+ 20 1165 MHz SUNW,UltraSPARC-T2 on-line
30
+ 21 1165 MHz SUNW,UltraSPARC-T2 on-line
31
+ 22 1165 MHz SUNW,UltraSPARC-T2 on-line
32
+ 23 1165 MHz SUNW,UltraSPARC-T2 on-line
33
+ 24 1165 MHz SUNW,UltraSPARC-T2 on-line
34
+ 25 1165 MHz SUNW,UltraSPARC-T2 on-line
35
+ 26 1165 MHz SUNW,UltraSPARC-T2 on-line
36
+ 27 1165 MHz SUNW,UltraSPARC-T2 on-line
37
+ 28 1165 MHz SUNW,UltraSPARC-T2 on-line
38
+ 29 1165 MHz SUNW,UltraSPARC-T2 on-line
39
+ 30 1165 MHz SUNW,UltraSPARC-T2 on-line
40
+ 31 1165 MHz SUNW,UltraSPARC-T2 on-line
41
+ 32 1165 MHz SUNW,UltraSPARC-T2 on-line
42
+ 33 1165 MHz SUNW,UltraSPARC-T2 on-line
43
+ 34 1165 MHz SUNW,UltraSPARC-T2 on-line
44
+ 35 1165 MHz SUNW,UltraSPARC-T2 on-line
45
+ 36 1165 MHz SUNW,UltraSPARC-T2 on-line
46
+ 37 1165 MHz SUNW,UltraSPARC-T2 on-line
47
+ 38 1165 MHz SUNW,UltraSPARC-T2 on-line
48
+ 39 1165 MHz SUNW,UltraSPARC-T2 on-line
49
+ 40 1165 MHz SUNW,UltraSPARC-T2 on-line
50
+ 41 1165 MHz SUNW,UltraSPARC-T2 on-line
51
+ 42 1165 MHz SUNW,UltraSPARC-T2 on-line
52
+ 43 1165 MHz SUNW,UltraSPARC-T2 on-line
53
+ 44 1165 MHz SUNW,UltraSPARC-T2 on-line
54
+ 45 1165 MHz SUNW,UltraSPARC-T2 on-line
55
+ 46 1165 MHz SUNW,UltraSPARC-T2 on-line
56
+ 47 1165 MHz SUNW,UltraSPARC-T2 on-line
57
+ 48 1165 MHz SUNW,UltraSPARC-T2 on-line
58
+ 49 1165 MHz SUNW,UltraSPARC-T2 on-line
59
+ 50 1165 MHz SUNW,UltraSPARC-T2 on-line
60
+ 51 1165 MHz SUNW,UltraSPARC-T2 on-line
61
+ 52 1165 MHz SUNW,UltraSPARC-T2 on-line
62
+ 53 1165 MHz SUNW,UltraSPARC-T2 on-line
63
+ 54 1165 MHz SUNW,UltraSPARC-T2 on-line
64
+ 55 1165 MHz SUNW,UltraSPARC-T2 on-line
65
+ 56 1165 MHz SUNW,UltraSPARC-T2 on-line
66
+ 57 1165 MHz SUNW,UltraSPARC-T2 on-line
67
+ 58 1165 MHz SUNW,UltraSPARC-T2 on-line
68
+ 59 1165 MHz SUNW,UltraSPARC-T2 on-line
69
+ 60 1165 MHz SUNW,UltraSPARC-T2 on-line
70
+ 61 1165 MHz SUNW,UltraSPARC-T2 on-line
71
+ 62 1165 MHz SUNW,UltraSPARC-T2 on-line
72
+ 63 1165 MHz SUNW,UltraSPARC-T2 on-line
73
+
74
+ ======================= Physical Memory Configuration ========================
75
+ Segment Table:
76
+ --------------------------------------------------------------
77
+ Base Segment Interleave Bank Contains
78
+ Address Size Factor Size Modules
79
+ --------------------------------------------------------------
80
+ 0x0 32 GB 8 4 GB MB/CMP0/BR0/CH0/D0
81
+ MB/CMP0/BR0/CH1/D0
82
+ 4 GB MB/CMP0/BR0/CH0/D1
83
+ MB/CMP0/BR0/CH1/D1
84
+ 4 GB MB/CMP0/BR1/CH0/D0
85
+ MB/CMP0/BR1/CH1/D0
86
+ 4 GB MB/CMP0/BR1/CH0/D1
87
+ MB/CMP0/BR1/CH1/D1
88
+ 4 GB MB/CMP0/BR2/CH0/D0
89
+ MB/CMP0/BR2/CH1/D0
90
+ 4 GB MB/CMP0/BR2/CH0/D1
91
+ MB/CMP0/BR2/CH1/D1
92
+ 4 GB MB/CMP0/BR3/CH0/D0
93
+ MB/CMP0/BR3/CH1/D0
94
+ 4 GB MB/CMP0/BR3/CH0/D1
95
+ MB/CMP0/BR3/CH1/D1
96
+
97
+
98
+ ================================ IO Devices ================================
99
+ Slot + Bus Name + Model
100
+ Status Type Path
101
+ ----------------------------------------------------------------------------
102
+ MB/NET0 PCIE network-pciex8086,105e
103
+ /pci@0/pci@0/pci@1/pci@0/pci@2/network@0
104
+ MB/NET1 PCIE network-pciex8086,105e
105
+ /pci@0/pci@0/pci@1/pci@0/pci@2/network@0,1
106
+ MB/NET2 PCIE network-pciex8086,105e
107
+ /pci@0/pci@0/pci@1/pci@0/pci@3/network@0
108
+ MB/NET3 PCIE network-pciex8086,105e
109
+ /pci@0/pci@0/pci@1/pci@0/pci@3/network@0,1
110
+ MB/SASHBA PCIE scsi-pciex1000,58 LSI,1068E
111
+ /pci@0/pci@0/pci@2/scsi@0
112
+ MB PCIX usb-pciclass,0c0310
113
+ /pci@0/pci@0/pci@1/pci@0/pci@1/pci@0/usb@0
114
+ MB PCIX usb-pciclass,0c0310
115
+ /pci@0/pci@0/pci@1/pci@0/pci@1/pci@0/usb@0,1
116
+ MB PCIX usb-pciclass,0c0320
117
+ /pci@0/pci@0/pci@1/pci@0/pci@1/pci@0/usb@0,2
118
+
119
+ ============================ Environmental Status ============================
120
+ Fan sensors:
121
+ All fan sensors are OK.
122
+
123
+ Temperature sensors:
124
+ All temperature sensors are OK.
125
+
126
+ Current sensors:
127
+ All current sensors are OK.
128
+
129
+ Voltage sensors:
130
+ All voltage sensors are OK.
131
+
132
+ Voltage indicators:
133
+ All voltage indicators are OK.
134
+
135
+ ============================ FRU Status ============================
136
+ All FRUs are enabled.
@@ -2,6 +2,11 @@ dir = File.expand_path(File.dirname(__FILE__))
2
2
 
3
3
  SPECDIR = dir
4
4
 
5
+ def fixture_data(file)
6
+ File.read(File.join(SPECDIR, "fixtures", file))
7
+ end
8
+
9
+
5
10
  $LOAD_PATH.unshift("#{dir}/")
6
11
  $LOAD_PATH.unshift("#{dir}/../lib")
7
12
 
@@ -6,49 +6,49 @@ require 'facter'
6
6
 
7
7
  describe "Architecture fact" do
8
8
 
9
- it "should default to the hardware model" do
10
- Facter.fact(:hardwaremodel).stubs(:value).returns("NonSpecialCasedHW")
11
-
12
- Facter.fact(:architecture).value.should == "NonSpecialCasedHW"
13
- end
14
-
15
- os_archs = Hash.new
16
- os_archs = {
17
- ["Debian","x86_64"] => "amd64",
18
- ["Gentoo","x86_64"] => "amd64",
19
- ["GNU/kFreeBSD","x86_64"] => "amd64",
20
- ["Ubuntu","x86_64"] => "amd64",
21
- ["Gentoo","i386"] => "x86",
22
- ["Gentoo","i486"] => "x86",
23
- ["Gentoo","i586"] => "x86",
24
- ["Gentoo","i686"] => "x86",
25
- ["Gentoo","pentium"] => "x86",
26
- }
27
- generic_archs = Hash.new
28
- generic_archs = {
29
- "i386" => "i386",
30
- "i486" => "i386",
31
- "i586" => "i386",
32
- "i686" => "i386",
33
- "pentium" => "i386",
34
- }
35
-
36
- os_archs.each do |pair, result|
37
- it "should be #{result} if os is #{pair[0]} and hardwaremodel is #{pair[1]}" do
38
- Facter.fact(:operatingsystem).stubs(:value).returns(pair[0])
39
- Facter.fact(:hardwaremodel).stubs(:value).returns(pair[1])
40
-
41
- Facter.fact(:architecture).value.should == result
42
- end
9
+ it "should default to the hardware model" do
10
+ Facter.fact(:hardwaremodel).stubs(:value).returns("NonSpecialCasedHW")
11
+
12
+ Facter.fact(:architecture).value.should == "NonSpecialCasedHW"
13
+ end
14
+
15
+ os_archs = Hash.new
16
+ os_archs = {
17
+ ["Debian","x86_64"] => "amd64",
18
+ ["Gentoo","x86_64"] => "amd64",
19
+ ["GNU/kFreeBSD","x86_64"] => "amd64",
20
+ ["Ubuntu","x86_64"] => "amd64",
21
+ ["Gentoo","i386"] => "x86",
22
+ ["Gentoo","i486"] => "x86",
23
+ ["Gentoo","i586"] => "x86",
24
+ ["Gentoo","i686"] => "x86",
25
+ ["Gentoo","pentium"] => "x86",
26
+ }
27
+ generic_archs = Hash.new
28
+ generic_archs = {
29
+ "i386" => "i386",
30
+ "i486" => "i386",
31
+ "i586" => "i386",
32
+ "i686" => "i386",
33
+ "pentium" => "i386",
34
+ }
35
+
36
+ os_archs.each do |pair, result|
37
+ it "should be #{result} if os is #{pair[0]} and hardwaremodel is #{pair[1]}" do
38
+ Facter.fact(:operatingsystem).stubs(:value).returns(pair[0])
39
+ Facter.fact(:hardwaremodel).stubs(:value).returns(pair[1])
40
+
41
+ Facter.fact(:architecture).value.should == result
43
42
  end
43
+ end
44
44
 
45
- generic_archs.each do |hw, result|
46
- it "should be #{result} if hardwaremodel is #{hw}" do
47
- Facter.fact(:hardwaremodel).stubs(:value).returns(hw)
48
- Facter.fact(:operatingsystem).stubs(:value).returns("NonSpecialCasedOS")
45
+ generic_archs.each do |hw, result|
46
+ it "should be #{result} if hardwaremodel is #{hw}" do
47
+ Facter.fact(:hardwaremodel).stubs(:value).returns(hw)
48
+ Facter.fact(:operatingsystem).stubs(:value).returns("NonSpecialCasedOS")
49
49
 
50
- Facter.fact(:architecture).value.should == result
51
- end
50
+ Facter.fact(:architecture).value.should == result
52
51
  end
52
+ end
53
53
 
54
54
  end
@@ -4,268 +4,268 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
4
 
5
5
  describe Facter do
6
6
 
7
- it "should have a version" do
8
- Facter.version.should =~ /^[0-9]+(\.[0-9]+)*$/
7
+ it "should have a version" do
8
+ Facter.version.should =~ /^[0-9]+(\.[0-9]+)*$/
9
+ end
10
+
11
+ it "should have a method for returning its collection" do
12
+ Facter.should respond_to(:collection)
13
+ end
14
+
15
+ it "should cache the collection" do
16
+ Facter.collection.should equal(Facter.collection)
17
+ end
18
+
19
+ it "should delegate the :flush method to the collection" do
20
+ Facter.collection.expects(:flush)
21
+ Facter.flush
22
+ end
23
+
24
+ it "should delegate the :fact method to the collection" do
25
+ Facter.collection.expects(:fact)
26
+ Facter.fact
27
+ end
28
+
29
+ it "should delegate the :list method to the collection" do
30
+ Facter.collection.expects(:list)
31
+ Facter.list
32
+ end
33
+
34
+ it "should load all facts when listing" do
35
+ Facter.collection.expects(:load_all)
36
+ Facter.collection.stubs(:list)
37
+ Facter.list
38
+ end
39
+
40
+ it "should delegate the :to_hash method to the collection" do
41
+ Facter.collection.expects(:to_hash)
42
+ Facter.to_hash
43
+ end
44
+
45
+ it "should load all facts when calling :to_hash" do
46
+ Facter.collection.expects(:load_all)
47
+ Facter.collection.stubs(:to_hash)
48
+ Facter.to_hash
49
+ end
50
+
51
+ it "should delegate the :value method to the collection" do
52
+ Facter.collection.expects(:value)
53
+ Facter.value
54
+ end
55
+
56
+ it "should delegate the :each method to the collection" do
57
+ Facter.collection.expects(:each)
58
+ Facter.each
59
+ end
60
+
61
+ it "should load all facts when calling :each" do
62
+ Facter.collection.expects(:load_all)
63
+ Facter.collection.stubs(:each)
64
+ Facter.each
65
+ end
66
+
67
+ it "should yield to the block when using :each" do
68
+ Facter.collection.stubs(:load_all)
69
+ Facter.collection.stubs(:each).yields "foo"
70
+ result = []
71
+ Facter.each { |f| result << f }
72
+ result.should == %w{foo}
73
+ end
74
+
75
+ describe "when provided code as a string" do
76
+ it "should execute the code in the shell" do
77
+ Facter.add("shell_testing") do
78
+ setcode "echo yup"
79
+ end
80
+
81
+ Facter["shell_testing"].value.should == "yup"
9
82
  end
10
-
11
- it "should have a method for returning its collection" do
12
- Facter.should respond_to(:collection)
83
+ end
84
+
85
+ describe "when asked for a fact as an undefined Facter class method" do
86
+ describe "and the collection is already initialized" do
87
+ it "should return the fact's value" do
88
+ Facter.collection
89
+ Facter.ipaddress.should == Facter['ipaddress'].value
90
+ end
13
91
  end
14
92
 
15
- it "should cache the collection" do
16
- Facter.collection.should equal(Facter.collection)
93
+ describe "and the collection has been just reset" do
94
+ it "should return the fact's value" do
95
+ Facter.reset
96
+ Facter.ipaddress.should == Facter['ipaddress'].value
97
+ end
17
98
  end
99
+ end
18
100
 
19
- it "should delegate the :flush method to the collection" do
20
- Facter.collection.expects(:flush)
21
- Facter.flush
22
- end
101
+ describe "when passed code as a block" do
102
+ it "should execute the provided block" do
103
+ Facter.add("block_testing") { setcode { "foo" } }
23
104
 
24
- it "should delegate the :fact method to the collection" do
25
- Facter.collection.expects(:fact)
26
- Facter.fact
105
+ Facter["block_testing"].value.should == "foo"
27
106
  end
107
+ end
28
108
 
29
- it "should delegate the :list method to the collection" do
30
- Facter.collection.expects(:list)
31
- Facter.list
109
+ describe Facter[:hostname] do
110
+ it "should have its ldapname set to 'cn'" do
111
+ Facter[:hostname].ldapname.should == "cn"
32
112
  end
113
+ end
33
114
 
34
- it "should load all facts when listing" do
35
- Facter.collection.expects(:load_all)
36
- Facter.collection.stubs(:list)
37
- Facter.list
115
+ describe Facter[:ipaddress] do
116
+ it "should have its ldapname set to 'iphostnumber'" do
117
+ Facter[:ipaddress].ldapname.should == "iphostnumber"
38
118
  end
39
-
40
- it "should delegate the :to_hash method to the collection" do
41
- Facter.collection.expects(:to_hash)
42
- Facter.to_hash
43
- end
44
-
45
- it "should load all facts when calling :to_hash" do
46
- Facter.collection.expects(:load_all)
47
- Facter.collection.stubs(:to_hash)
48
- Facter.to_hash
119
+ end
120
+
121
+ # #33 Make sure we only get one mac address
122
+ it "should only return one mac address" do
123
+ Facter.value(:macaddress).should_not be_include(" ")
124
+ end
125
+
126
+ it "should have a method for registering directories to search" do
127
+ Facter.should respond_to(:search)
128
+ end
129
+
130
+ it "should have a method for returning the registered search directories" do
131
+ Facter.should respond_to(:search_path)
132
+ end
133
+
134
+ it "should have a method to query debugging mode" do
135
+ Facter.should respond_to(:debugging?)
136
+ end
137
+
138
+ it "should have a method to query timing mode" do
139
+ Facter.should respond_to(:timing?)
140
+ end
141
+
142
+ it "should have a method to show timing information" do
143
+ Facter.should respond_to(:show_time)
144
+ end
145
+
146
+ it "should have a method to warn" do
147
+ Facter.should respond_to(:warn)
148
+ end
149
+
150
+ describe "when warning" do
151
+ it "should warn if debugging is enabled" do
152
+ Facter.debugging(true)
153
+ Kernel.stubs(:warn)
154
+ Kernel.expects(:warn).with('foo')
155
+ Facter.warn('foo')
49
156
  end
50
157
 
51
- it "should delegate the :value method to the collection" do
52
- Facter.collection.expects(:value)
53
- Facter.value
158
+ it "should not warn if debugging is enabled but nil is passed" do
159
+ Facter.debugging(true)
160
+ Kernel.stubs(:warn)
161
+ Kernel.expects(:warn).never
162
+ Facter.warn(nil)
54
163
  end
55
164
 
56
- it "should delegate the :each method to the collection" do
57
- Facter.collection.expects(:each)
58
- Facter.each
165
+ it "should not warn if debugging is enabled but an empyt string is passed" do
166
+ Facter.debugging(true)
167
+ Kernel.stubs(:warn)
168
+ Kernel.expects(:warn).never
169
+ Facter.warn('')
59
170
  end
60
171
 
61
- it "should load all facts when calling :each" do
62
- Facter.collection.expects(:load_all)
63
- Facter.collection.stubs(:each)
64
- Facter.each
172
+ it "should not warn if debugging is disabled" do
173
+ Facter.debugging(false)
174
+ Kernel.stubs(:warn)
175
+ Kernel.expects(:warn).never
176
+ Facter.warn('foo')
65
177
  end
66
178
 
67
- it "should yield to the block when using :each" do
68
- Facter.collection.stubs(:load_all)
69
- Facter.collection.stubs(:each).yields "foo"
70
- result = []
71
- Facter.each { |f| result << f }
72
- result.should == %w{foo}
179
+ it "should warn for any given element for an array if debugging is enabled" do
180
+ Facter.debugging(true)
181
+ Kernel.stubs(:warn)
182
+ Kernel.expects(:warn).with('foo')
183
+ Kernel.expects(:warn).with('bar')
184
+ Facter.warn( ['foo','bar'])
73
185
  end
74
-
75
- describe "when provided code as a string" do
76
- it "should execute the code in the shell" do
77
- Facter.add("shell_testing") do
78
- setcode "echo yup"
79
- end
80
-
81
- Facter["shell_testing"].value.should == "yup"
82
- end
186
+ end
187
+
188
+ describe "when warning once" do
189
+ it "should only warn once" do
190
+ Kernel.stubs(:warnonce)
191
+ Kernel.expects(:warn).with('foo').once
192
+ Facter.warnonce('foo')
193
+ Facter.warnonce('foo')
83
194
  end
84
195
 
85
- describe "when asked for a fact as an undefined Facter class method" do
86
- describe "and the collection is already initialized" do
87
- it "should return the fact's value" do
88
- Facter.collection
89
- Facter.ipaddress.should == Facter['ipaddress'].value
90
- end
91
- end
92
-
93
- describe "and the collection has been just reset" do
94
- it "should return the fact's value" do
95
- Facter.reset
96
- Facter.ipaddress.should == Facter['ipaddress'].value
97
- end
98
- end
196
+ it "should not warnonce if nil is passed" do
197
+ Kernel.stubs(:warn)
198
+ Kernel.expects(:warnonce).never
199
+ Facter.warnonce(nil)
99
200
  end
100
201
 
101
- describe "when passed code as a block" do
102
- it "should execute the provided block" do
103
- Facter.add("block_testing") { setcode { "foo" } }
104
-
105
- Facter["block_testing"].value.should == "foo"
106
- end
202
+ it "should not warnonce if an empty string is passed" do
203
+ Kernel.stubs(:warn)
204
+ Kernel.expects(:warnonce).never
205
+ Facter.warnonce('')
107
206
  end
207
+ end
108
208
 
109
- describe Facter[:hostname] do
110
- it "should have its ldapname set to 'cn'" do
111
- Facter[:hostname].ldapname.should == "cn"
112
- end
209
+ describe "when setting debugging mode" do
210
+ it "should have debugging enabled using 1" do
211
+ Facter.debugging(1)
212
+ Facter.should be_debugging
113
213
  end
114
-
115
- describe Facter[:ipaddress] do
116
- it "should have its ldapname set to 'iphostnumber'" do
117
- Facter[:ipaddress].ldapname.should == "iphostnumber"
118
- end
214
+ it "should have debugging enabled using true" do
215
+ Facter.debugging(true)
216
+ Facter.should be_debugging
119
217
  end
120
-
121
- # #33 Make sure we only get one mac address
122
- it "should only return one mac address" do
123
- Facter.value(:macaddress).should_not be_include(" ")
218
+ it "should have debugging enabled using any string except off" do
219
+ Facter.debugging('aaaaa')
220
+ Facter.should be_debugging
124
221
  end
125
-
126
- it "should have a method for registering directories to search" do
127
- Facter.should respond_to(:search)
222
+ it "should have debugging disabled using 0" do
223
+ Facter.debugging(0)
224
+ Facter.should_not be_debugging
128
225
  end
129
-
130
- it "should have a method for returning the registered search directories" do
131
- Facter.should respond_to(:search_path)
226
+ it "should have debugging disabled using false" do
227
+ Facter.debugging(false)
228
+ Facter.should_not be_debugging
132
229
  end
133
-
134
- it "should have a method to query debugging mode" do
135
- Facter.should respond_to(:debugging?)
230
+ it "should have debugging disabled using the string 'off'" do
231
+ Facter.debugging('off')
232
+ Facter.should_not be_debugging
136
233
  end
234
+ end
137
235
 
138
- it "should have a method to query timing mode" do
139
- Facter.should respond_to(:timing?)
236
+ describe "when setting timing mode" do
237
+ it "should have timing enabled using 1" do
238
+ Facter.timing(1)
239
+ Facter.should be_timing
140
240
  end
141
-
142
- it "should have a method to show timing information" do
143
- Facter.should respond_to(:show_time)
241
+ it "should have timing enabled using true" do
242
+ Facter.timing(true)
243
+ Facter.should be_timing
144
244
  end
145
-
146
- it "should have a method to warn" do
147
- Facter.should respond_to(:warn)
245
+ it "should have timing disabled using 0" do
246
+ Facter.timing(0)
247
+ Facter.should_not be_timing
148
248
  end
149
-
150
- describe "when warning" do
151
- it "should warn if debugging is enabled" do
152
- Facter.debugging(true)
153
- Kernel.stubs(:warn)
154
- Kernel.expects(:warn).with('foo')
155
- Facter.warn('foo')
156
- end
157
-
158
- it "should not warn if debugging is enabled but nil is passed" do
159
- Facter.debugging(true)
160
- Kernel.stubs(:warn)
161
- Kernel.expects(:warn).never
162
- Facter.warn(nil)
163
- end
164
-
165
- it "should not warn if debugging is enabled but an empyt string is passed" do
166
- Facter.debugging(true)
167
- Kernel.stubs(:warn)
168
- Kernel.expects(:warn).never
169
- Facter.warn('')
170
- end
171
-
172
- it "should not warn if debugging is disabled" do
173
- Facter.debugging(false)
174
- Kernel.stubs(:warn)
175
- Kernel.expects(:warn).never
176
- Facter.warn('foo')
177
- end
178
-
179
- it "should warn for any given element for an array if debugging is enabled" do
180
- Facter.debugging(true)
181
- Kernel.stubs(:warn)
182
- Kernel.expects(:warn).with('foo')
183
- Kernel.expects(:warn).with('bar')
184
- Facter.warn( ['foo','bar'])
185
- end
249
+ it "should have timing disabled using false" do
250
+ Facter.timing(false)
251
+ Facter.should_not be_timing
186
252
  end
253
+ end
187
254
 
188
- describe "when warning once" do
189
- it "should only warn once" do
190
- Kernel.stubs(:warnonce)
191
- Kernel.expects(:warn).with('foo').once
192
- Facter.warnonce('foo')
193
- Facter.warnonce('foo')
194
- end
195
-
196
- it "should not warnonce if nil is passed" do
197
- Kernel.stubs(:warn)
198
- Kernel.expects(:warnonce).never
199
- Facter.warnonce(nil)
200
- end
201
-
202
- it "should not warnonce if an empty string is passed" do
203
- Kernel.stubs(:warn)
204
- Kernel.expects(:warnonce).never
205
- Facter.warnonce('')
206
- end
207
- end
255
+ describe "when registering directories to search" do
256
+ after { Facter.instance_variable_set("@search_path", []) }
208
257
 
209
- describe "when setting debugging mode" do
210
- it "should have debugging enabled using 1" do
211
- Facter.debugging(1)
212
- Facter.should be_debugging
213
- end
214
- it "should have debugging enabled using true" do
215
- Facter.debugging(true)
216
- Facter.should be_debugging
217
- end
218
- it "should have debugging enabled using any string except off" do
219
- Facter.debugging('aaaaa')
220
- Facter.should be_debugging
221
- end
222
- it "should have debugging disabled using 0" do
223
- Facter.debugging(0)
224
- Facter.should_not be_debugging
225
- end
226
- it "should have debugging disabled using false" do
227
- Facter.debugging(false)
228
- Facter.should_not be_debugging
229
- end
230
- it "should have debugging disabled using the string 'off'" do
231
- Facter.debugging('off')
232
- Facter.should_not be_debugging
233
- end
258
+ it "should allow registration of a directory" do
259
+ Facter.search "/my/dir"
234
260
  end
235
261
 
236
- describe "when setting timing mode" do
237
- it "should have timing enabled using 1" do
238
- Facter.timing(1)
239
- Facter.should be_timing
240
- end
241
- it "should have timing enabled using true" do
242
- Facter.timing(true)
243
- Facter.should be_timing
244
- end
245
- it "should have timing disabled using 0" do
246
- Facter.timing(0)
247
- Facter.should_not be_timing
248
- end
249
- it "should have timing disabled using false" do
250
- Facter.timing(false)
251
- Facter.should_not be_timing
252
- end
262
+ it "should allow registration of multiple directories" do
263
+ Facter.search "/my/dir", "/other/dir"
253
264
  end
254
265
 
255
- describe "when registering directories to search" do
256
- after { Facter.instance_variable_set("@search_path", []) }
257
-
258
- it "should allow registration of a directory" do
259
- Facter.search "/my/dir"
260
- end
261
-
262
- it "should allow registration of multiple directories" do
263
- Facter.search "/my/dir", "/other/dir"
264
- end
265
-
266
- it "should return all registered directories when asked" do
267
- Facter.search "/my/dir", "/other/dir"
268
- Facter.search_path.should == %w{/my/dir /other/dir}
269
- end
266
+ it "should return all registered directories when asked" do
267
+ Facter.search "/my/dir", "/other/dir"
268
+ Facter.search_path.should == %w{/my/dir /other/dir}
270
269
  end
270
+ end
271
271
  end