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
@@ -19,273 +19,273 @@ end
19
19
 
20
20
 
21
21
  describe Facter::Util::Loader do
22
- before :each do
23
- Facter::Util::Loader.any_instance.unstub(:load_all)
24
- end
22
+ before :each do
23
+ Facter::Util::Loader.any_instance.unstub(:load_all)
24
+ end
25
25
 
26
- def with_env(values)
27
- old = {}
28
- values.each do |var, value|
29
- if old_val = ENV[var]
30
- old[var] = old_val
31
- end
32
- ENV[var] = value
33
- end
34
- yield
35
- values.each do |var, value|
36
- if old.include?(var)
37
- ENV[var] = old[var]
38
- else
39
- ENV.delete(var)
40
- end
41
- end
26
+ def with_env(values)
27
+ old = {}
28
+ values.each do |var, value|
29
+ if old_val = ENV[var]
30
+ old[var] = old_val
31
+ end
32
+ ENV[var] = value
42
33
  end
43
-
44
- it "should have a method for loading individual facts by name" do
45
- Facter::Util::Loader.new.should respond_to(:load)
34
+ yield
35
+ values.each do |var, value|
36
+ if old.include?(var)
37
+ ENV[var] = old[var]
38
+ else
39
+ ENV.delete(var)
40
+ end
46
41
  end
42
+ end
47
43
 
48
- it "should have a method for loading all facts" do
49
- Facter::Util::Loader.new.should respond_to(:load_all)
50
- end
44
+ it "should have a method for loading individual facts by name" do
45
+ Facter::Util::Loader.new.should respond_to(:load)
46
+ end
51
47
 
52
- it "should have a method for returning directories containing facts" do
53
- Facter::Util::Loader.new.should respond_to(:search_path)
54
- end
48
+ it "should have a method for loading all facts" do
49
+ Facter::Util::Loader.new.should respond_to(:load_all)
50
+ end
55
51
 
56
- describe "when determining the search path" do
57
- before do
58
- @loader = Facter::Util::Loader.new
59
- @settings = mock 'settings'
60
- @settings.stubs(:value).returns "/eh"
61
- end
52
+ it "should have a method for returning directories containing facts" do
53
+ Facter::Util::Loader.new.should respond_to(:search_path)
54
+ end
62
55
 
63
- it "should include the facter subdirectory of all paths in ruby LOAD_PATH" do
64
- dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") }
65
- paths = @loader.search_path
56
+ describe "when determining the search path" do
57
+ before do
58
+ @loader = Facter::Util::Loader.new
59
+ @settings = mock 'settings'
60
+ @settings.stubs(:value).returns "/eh"
61
+ end
66
62
 
67
- dirs.each do |dir|
68
- paths.should be_include(dir)
69
- end
70
- end
63
+ it "should include the facter subdirectory of all paths in ruby LOAD_PATH" do
64
+ dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") }
65
+ paths = @loader.search_path
71
66
 
72
- it "should include all search paths registered with Facter" do
73
- Facter.expects(:search_path).returns %w{/one /two}
74
- paths = @loader.search_path
75
- paths.should be_include("/one")
76
- paths.should be_include("/two")
77
- end
67
+ dirs.each do |dir|
68
+ paths.should be_include(dir)
69
+ end
70
+ end
78
71
 
79
- describe "and the FACTERLIB environment variable is set" do
80
- it "should include all paths in FACTERLIB" do
81
- with_env "FACTERLIB" => "/one/path:/two/path" do
82
- paths = @loader.search_path
83
- %w{/one/path /two/path}.each do |dir|
84
- paths.should be_include(dir)
85
- end
86
- end
87
- end
88
- end
72
+ it "should include all search paths registered with Facter" do
73
+ Facter.expects(:search_path).returns %w{/one /two}
74
+ paths = @loader.search_path
75
+ paths.should be_include("/one")
76
+ paths.should be_include("/two")
89
77
  end
90
78
 
91
- describe "when loading facts" do
92
- before do
93
- @loader = Facter::Util::Loader.new
94
- @loader.stubs(:search_path).returns []
79
+ describe "and the FACTERLIB environment variable is set" do
80
+ it "should include all paths in FACTERLIB" do
81
+ with_env "FACTERLIB" => "/one/path:/two/path" do
82
+ paths = @loader.search_path
83
+ %w{/one/path /two/path}.each do |dir|
84
+ paths.should be_include(dir)
85
+ end
95
86
  end
87
+ end
88
+ end
89
+ end
96
90
 
97
- it "should load values from the matching environment variable if one is present" do
98
- Facter.expects(:add).with("testing")
91
+ describe "when loading facts" do
92
+ before do
93
+ @loader = Facter::Util::Loader.new
94
+ @loader.stubs(:search_path).returns []
95
+ end
99
96
 
100
- with_env "facter_testing" => "yayness" do
101
- @loader.load(:testing)
102
- end
103
- end
97
+ it "should load values from the matching environment variable if one is present" do
98
+ Facter.expects(:add).with("testing")
104
99
 
105
- it "should load any files in the search path with names matching the fact name" do
106
- @loader.expects(:search_path).returns %w{/one/dir /two/dir}
107
- FileTest.stubs(:exist?).returns false
108
- FileTest.expects(:exist?).with("/one/dir/testing.rb").returns true
109
- FileTest.expects(:exist?).with("/two/dir/testing.rb").returns true
100
+ with_env "facter_testing" => "yayness" do
101
+ @loader.load(:testing)
102
+ end
103
+ end
110
104
 
111
- Kernel.expects(:load).with("/one/dir/testing.rb")
112
- Kernel.expects(:load).with("/two/dir/testing.rb")
105
+ it "should load any files in the search path with names matching the fact name" do
106
+ @loader.expects(:search_path).returns %w{/one/dir /two/dir}
107
+ FileTest.stubs(:exist?).returns false
108
+ FileTest.expects(:exist?).with("/one/dir/testing.rb").returns true
109
+ FileTest.expects(:exist?).with("/two/dir/testing.rb").returns true
113
110
 
114
- @loader.load(:testing)
115
- end
111
+ Kernel.expects(:load).with("/one/dir/testing.rb")
112
+ Kernel.expects(:load).with("/two/dir/testing.rb")
116
113
 
117
- it 'should load any ruby files in directories matching the fact name in the search path in sorted order regardless of the order returned by Dir.entries' do
118
- @loader = TestLoader.new
114
+ @loader.load(:testing)
115
+ end
119
116
 
120
- @loader.stubs(:search_path).returns %w{/one/dir}
121
- FileTest.stubs(:exist?).returns false
122
- FileTest.stubs(:directory?).with("/one/dir/testing").returns true
123
- @loader.stubs(:search_path).returns %w{/one/dir}
117
+ it 'should load any ruby files in directories matching the fact name in the search path in sorted order regardless of the order returned by Dir.entries' do
118
+ @loader = TestLoader.new
124
119
 
125
- Dir.stubs(:entries).with("/one/dir/testing").returns %w{foo.rb bar.rb}
126
- %w{/one/dir/testing/foo.rb /one/dir/testing/bar.rb}.each do |f|
127
- File.stubs(:directory?).with(f).returns false
128
- Kernel.stubs(:load).with(f)
129
- end
120
+ @loader.stubs(:search_path).returns %w{/one/dir}
121
+ FileTest.stubs(:exist?).returns false
122
+ FileTest.stubs(:directory?).with("/one/dir/testing").returns true
123
+ @loader.stubs(:search_path).returns %w{/one/dir}
130
124
 
131
- @loader.load(:testing)
132
- @loader.loaded_files.should == %w{/one/dir/testing/bar.rb /one/dir/testing/foo.rb}
133
- end
125
+ Dir.stubs(:entries).with("/one/dir/testing").returns %w{foo.rb bar.rb}
126
+ %w{/one/dir/testing/foo.rb /one/dir/testing/bar.rb}.each do |f|
127
+ File.stubs(:directory?).with(f).returns false
128
+ Kernel.stubs(:load).with(f)
129
+ end
134
130
 
135
- it "should load any ruby files in directories matching the fact name in the search path" do
136
- @loader.expects(:search_path).returns %w{/one/dir}
137
- FileTest.stubs(:exist?).returns false
138
- FileTest.expects(:directory?).with("/one/dir/testing").returns true
131
+ @loader.load(:testing)
132
+ @loader.loaded_files.should == %w{/one/dir/testing/bar.rb /one/dir/testing/foo.rb}
133
+ end
139
134
 
140
- Dir.expects(:entries).with("/one/dir/testing").returns %w{two.rb}
135
+ it "should load any ruby files in directories matching the fact name in the search path" do
136
+ @loader.expects(:search_path).returns %w{/one/dir}
137
+ FileTest.stubs(:exist?).returns false
138
+ FileTest.expects(:directory?).with("/one/dir/testing").returns true
141
139
 
142
- Kernel.expects(:load).with("/one/dir/testing/two.rb")
140
+ Dir.expects(:entries).with("/one/dir/testing").returns %w{two.rb}
143
141
 
144
- @loader.load(:testing)
145
- end
142
+ Kernel.expects(:load).with("/one/dir/testing/two.rb")
146
143
 
147
- it "should not load files that don't end in '.rb'" do
148
- @loader.expects(:search_path).returns %w{/one/dir}
149
- FileTest.stubs(:exist?).returns false
150
- FileTest.expects(:directory?).with("/one/dir/testing").returns true
144
+ @loader.load(:testing)
145
+ end
151
146
 
152
- Dir.expects(:entries).with("/one/dir/testing").returns %w{one}
147
+ it "should not load files that don't end in '.rb'" do
148
+ @loader.expects(:search_path).returns %w{/one/dir}
149
+ FileTest.stubs(:exist?).returns false
150
+ FileTest.expects(:directory?).with("/one/dir/testing").returns true
153
151
 
154
- Kernel.expects(:load).never
152
+ Dir.expects(:entries).with("/one/dir/testing").returns %w{one}
155
153
 
156
- @loader.load(:testing)
157
- end
154
+ Kernel.expects(:load).never
155
+
156
+ @loader.load(:testing)
158
157
  end
158
+ end
159
159
 
160
- describe "when loading all facts" do
161
- before do
162
- @loader = Facter::Util::Loader.new
163
- @loader.stubs(:search_path).returns []
160
+ describe "when loading all facts" do
161
+ before do
162
+ @loader = Facter::Util::Loader.new
163
+ @loader.stubs(:search_path).returns []
164
164
 
165
- FileTest.stubs(:directory?).returns true
166
- end
165
+ FileTest.stubs(:directory?).returns true
166
+ end
167
167
 
168
- it "should skip directories that do not exist" do
169
- @loader.expects(:search_path).returns %w{/one/dir}
168
+ it "should skip directories that do not exist" do
169
+ @loader.expects(:search_path).returns %w{/one/dir}
170
170
 
171
- FileTest.expects(:directory?).with("/one/dir").returns false
171
+ FileTest.expects(:directory?).with("/one/dir").returns false
172
172
 
173
- Dir.expects(:entries).with("/one/dir").never
173
+ Dir.expects(:entries).with("/one/dir").never
174
174
 
175
- @loader.load_all
176
- end
175
+ @loader.load_all
176
+ end
177
177
 
178
- it "should load all files in all search paths" do
179
- @loader.expects(:search_path).returns %w{/one/dir /two/dir}
178
+ it "should load all files in all search paths" do
179
+ @loader.expects(:search_path).returns %w{/one/dir /two/dir}
180
180
 
181
- Dir.expects(:entries).with("/one/dir").returns %w{a.rb b.rb}
182
- Dir.expects(:entries).with("/two/dir").returns %w{c.rb d.rb}
181
+ Dir.expects(:entries).with("/one/dir").returns %w{a.rb b.rb}
182
+ Dir.expects(:entries).with("/two/dir").returns %w{c.rb d.rb}
183
183
 
184
- %w{/one/dir/a.rb /one/dir/b.rb /two/dir/c.rb /two/dir/d.rb}.each { |f| Kernel.expects(:load).with(f) }
184
+ %w{/one/dir/a.rb /one/dir/b.rb /two/dir/c.rb /two/dir/d.rb}.each { |f| Kernel.expects(:load).with(f) }
185
185
 
186
- @loader.load_all
187
- end
186
+ @loader.load_all
187
+ end
188
188
 
189
- it "should load all files in all subdirectories in all search paths" do
190
- @loader.expects(:search_path).returns %w{/one/dir /two/dir}
189
+ it "should load all files in all subdirectories in all search paths" do
190
+ @loader.expects(:search_path).returns %w{/one/dir /two/dir}
191
191
 
192
- Dir.expects(:entries).with("/one/dir").returns %w{a}
193
- Dir.expects(:entries).with("/two/dir").returns %w{b}
192
+ Dir.expects(:entries).with("/one/dir").returns %w{a}
193
+ Dir.expects(:entries).with("/two/dir").returns %w{b}
194
194
 
195
- %w{/one/dir/a /two/dir/b}.each { |f| File.expects(:directory?).with(f).returns true }
195
+ %w{/one/dir/a /two/dir/b}.each { |f| File.expects(:directory?).with(f).returns true }
196
196
 
197
- Dir.expects(:entries).with("/one/dir/a").returns %w{c.rb}
198
- Dir.expects(:entries).with("/two/dir/b").returns %w{d.rb}
197
+ Dir.expects(:entries).with("/one/dir/a").returns %w{c.rb}
198
+ Dir.expects(:entries).with("/two/dir/b").returns %w{d.rb}
199
199
 
200
- %w{/one/dir/a/c.rb /two/dir/b/d.rb}.each { |f| Kernel.expects(:load).with(f) }
200
+ %w{/one/dir/a/c.rb /two/dir/b/d.rb}.each { |f| Kernel.expects(:load).with(f) }
201
201
 
202
- @loader.load_all
203
- end
202
+ @loader.load_all
203
+ end
204
204
 
205
- it 'should load all files in sorted order for any given directory regardless of the order returned by Dir.entries' do
206
- @loader = TestLoader.new
205
+ it 'should load all files in sorted order for any given directory regardless of the order returned by Dir.entries' do
206
+ @loader = TestLoader.new
207
207
 
208
- @loader.stubs(:search_path).returns %w{/one/dir}
209
- Dir.stubs(:entries).with("/one/dir").returns %w{foo.rb bar.rb}
208
+ @loader.stubs(:search_path).returns %w{/one/dir}
209
+ Dir.stubs(:entries).with("/one/dir").returns %w{foo.rb bar.rb}
210
210
 
211
- %w{/one/dir}.each { |f| File.stubs(:directory?).with(f).returns true }
211
+ %w{/one/dir}.each { |f| File.stubs(:directory?).with(f).returns true }
212
212
 
213
- %w{/one/dir/foo.rb /one/dir/bar.rb}.each do |f|
214
- File.stubs(:directory?).with(f).returns false
215
- Kernel.expects(:load).with(f)
216
- end
213
+ %w{/one/dir/foo.rb /one/dir/bar.rb}.each do |f|
214
+ File.stubs(:directory?).with(f).returns false
215
+ Kernel.expects(:load).with(f)
216
+ end
217
217
 
218
- @loader.load_all
218
+ @loader.load_all
219
219
 
220
- @loader.loaded_files.should == %w{/one/dir/bar.rb /one/dir/foo.rb}
221
- end
220
+ @loader.loaded_files.should == %w{/one/dir/bar.rb /one/dir/foo.rb}
221
+ end
222
222
 
223
- it "should not load files in the util subdirectory" do
224
- @loader.expects(:search_path).returns %w{/one/dir}
223
+ it "should not load files in the util subdirectory" do
224
+ @loader.expects(:search_path).returns %w{/one/dir}
225
225
 
226
- Dir.expects(:entries).with("/one/dir").returns %w{util}
226
+ Dir.expects(:entries).with("/one/dir").returns %w{util}
227
227
 
228
- File.expects(:directory?).with("/one/dir/util").returns true
228
+ File.expects(:directory?).with("/one/dir/util").returns true
229
229
 
230
- Dir.expects(:entries).with("/one/dir/util").never
230
+ Dir.expects(:entries).with("/one/dir/util").never
231
231
 
232
- @loader.load_all
233
- end
232
+ @loader.load_all
233
+ end
234
234
 
235
- it "should not load files in a lib subdirectory" do
236
- @loader.expects(:search_path).returns %w{/one/dir}
235
+ it "should not load files in a lib subdirectory" do
236
+ @loader.expects(:search_path).returns %w{/one/dir}
237
237
 
238
- Dir.expects(:entries).with("/one/dir").returns %w{lib}
238
+ Dir.expects(:entries).with("/one/dir").returns %w{lib}
239
239
 
240
- File.expects(:directory?).with("/one/dir/lib").returns true
240
+ File.expects(:directory?).with("/one/dir/lib").returns true
241
241
 
242
- Dir.expects(:entries).with("/one/dir/lib").never
242
+ Dir.expects(:entries).with("/one/dir/lib").never
243
243
 
244
- @loader.load_all
245
- end
244
+ @loader.load_all
245
+ end
246
246
 
247
- it "should not load files in '.' or '..'" do
248
- @loader.expects(:search_path).returns %w{/one/dir}
247
+ it "should not load files in '.' or '..'" do
248
+ @loader.expects(:search_path).returns %w{/one/dir}
249
249
 
250
- Dir.expects(:entries).with("/one/dir").returns %w{. ..}
250
+ Dir.expects(:entries).with("/one/dir").returns %w{. ..}
251
251
 
252
- File.expects(:entries).with("/one/dir/.").never
253
- File.expects(:entries).with("/one/dir/..").never
252
+ File.expects(:entries).with("/one/dir/.").never
253
+ File.expects(:entries).with("/one/dir/..").never
254
254
 
255
- @loader.load_all
256
- end
255
+ @loader.load_all
256
+ end
257
257
 
258
- it "should not raise an exception when a file is unloadable" do
259
- @loader.expects(:search_path).returns %w{/one/dir}
260
- Dir.expects(:entries).with("/one/dir").returns %w{a.rb}
258
+ it "should not raise an exception when a file is unloadable" do
259
+ @loader.expects(:search_path).returns %w{/one/dir}
260
+ Dir.expects(:entries).with("/one/dir").returns %w{a.rb}
261
261
 
262
- Kernel.expects(:load).with("/one/dir/a.rb").raises(LoadError)
263
- @loader.expects(:warn)
262
+ Kernel.expects(:load).with("/one/dir/a.rb").raises(LoadError)
263
+ @loader.expects(:warn)
264
264
 
265
- lambda { @loader.load_all }.should_not raise_error
266
- end
265
+ lambda { @loader.load_all }.should_not raise_error
266
+ end
267
267
 
268
- it "should load all facts from the environment" do
269
- Facter.expects(:add).with('one')
270
- Facter.expects(:add).with('two')
268
+ it "should load all facts from the environment" do
269
+ Facter.expects(:add).with('one')
270
+ Facter.expects(:add).with('two')
271
271
 
272
- with_env "facter_one" => "yayness", "facter_two" => "boo" do
273
- @loader.load_all
274
- end
275
- end
272
+ with_env "facter_one" => "yayness", "facter_two" => "boo" do
273
+ @loader.load_all
274
+ end
275
+ end
276
276
 
277
- it "should only load all facts one time" do
278
- @loader.expects(:load_env).once
279
- @loader.load_all
280
- @loader.load_all
281
- end
277
+ it "should only load all facts one time" do
278
+ @loader.expects(:load_env).once
279
+ @loader.load_all
280
+ @loader.load_all
282
281
  end
282
+ end
283
283
 
284
- it "should load facts on the facter search path only once" do
285
- facterlibdir = File.expand_path(File.dirname(__FILE__) + '../../../fixtures/unit/util/loader')
286
- with_env 'FACTERLIB' => facterlibdir do
287
- Facter::Util::Loader.new.load_all
288
- Facter.value(:nosuchfact).should be_nil
289
- end
284
+ it "should load facts on the facter search path only once" do
285
+ facterlibdir = File.expand_path(File.dirname(__FILE__) + '../../../fixtures/unit/util/loader')
286
+ with_env 'FACTERLIB' => facterlibdir do
287
+ Facter::Util::Loader.new.load_all
288
+ Facter.value(:nosuchfact).should be_nil
290
289
  end
290
+ end
291
291
  end