opscode-ohai 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/LICENSE +201 -0
  2. data/README.rdoc +56 -0
  3. data/Rakefile +58 -0
  4. data/bin/ohai +58 -0
  5. data/lib/ohai.rb +27 -0
  6. data/lib/ohai/config.rb +118 -0
  7. data/lib/ohai/exception.rb +23 -0
  8. data/lib/ohai/log.rb +89 -0
  9. data/lib/ohai/log/formatter.rb +57 -0
  10. data/lib/ohai/mixin/command.rb +198 -0
  11. data/lib/ohai/mixin/from_file.rb +36 -0
  12. data/lib/ohai/plugins/command.rb +19 -0
  13. data/lib/ohai/plugins/darwin/hostname.rb +20 -0
  14. data/lib/ohai/plugins/darwin/kernel.rb +31 -0
  15. data/lib/ohai/plugins/darwin/network.rb +154 -0
  16. data/lib/ohai/plugins/darwin/platform.rb +34 -0
  17. data/lib/ohai/plugins/darwin/ps.rb +21 -0
  18. data/lib/ohai/plugins/darwin/ssh_host_key.rb +24 -0
  19. data/lib/ohai/plugins/ec2.rb +41 -0
  20. data/lib/ohai/plugins/hostname.rb +23 -0
  21. data/lib/ohai/plugins/kernel.rb +24 -0
  22. data/lib/ohai/plugins/keys.rb +20 -0
  23. data/lib/ohai/plugins/languages.rb +19 -0
  24. data/lib/ohai/plugins/linux/block_device.rb +36 -0
  25. data/lib/ohai/plugins/linux/cpu.rb +58 -0
  26. data/lib/ohai/plugins/linux/filesystem.rb +55 -0
  27. data/lib/ohai/plugins/linux/hostname.rb +20 -0
  28. data/lib/ohai/plugins/linux/kernel.rb +31 -0
  29. data/lib/ohai/plugins/linux/lsb.rb +36 -0
  30. data/lib/ohai/plugins/linux/memory.rb +81 -0
  31. data/lib/ohai/plugins/linux/network.rb +103 -0
  32. data/lib/ohai/plugins/linux/platform.rb +41 -0
  33. data/lib/ohai/plugins/linux/ps.rb +21 -0
  34. data/lib/ohai/plugins/linux/ssh_host_key.rb +24 -0
  35. data/lib/ohai/plugins/linux/uptime.rb +26 -0
  36. data/lib/ohai/plugins/network.rb +48 -0
  37. data/lib/ohai/plugins/ohai_time.rb +19 -0
  38. data/lib/ohai/plugins/os.rb +34 -0
  39. data/lib/ohai/plugins/platform.rb +23 -0
  40. data/lib/ohai/plugins/ruby.rb +33 -0
  41. data/lib/ohai/plugins/uptime.rb +42 -0
  42. data/lib/ohai/system.rb +163 -0
  43. data/spec/ohai/log/log_formatter_spec.rb +50 -0
  44. data/spec/ohai/log_spec.rb +63 -0
  45. data/spec/ohai/mixin/from_file_spec.rb +53 -0
  46. data/spec/ohai/plugins/darwin/hostname_spec.rb +34 -0
  47. data/spec/ohai/plugins/darwin/kernel_spec.rb +35 -0
  48. data/spec/ohai/plugins/darwin/platform_spec.rb +67 -0
  49. data/spec/ohai/plugins/hostname_spec.rb +33 -0
  50. data/spec/ohai/plugins/kernel_spec.rb +41 -0
  51. data/spec/ohai/plugins/linux/cpu_spec.rb +128 -0
  52. data/spec/ohai/plugins/linux/hostname_spec.rb +34 -0
  53. data/spec/ohai/plugins/linux/kernel_spec.rb +31 -0
  54. data/spec/ohai/plugins/linux/lsb_spec.rb +59 -0
  55. data/spec/ohai/plugins/linux/platform_spec.rb +51 -0
  56. data/spec/ohai/plugins/linux/uptime_spec.rb +61 -0
  57. data/spec/ohai/plugins/ohai_time_spec.rb +46 -0
  58. data/spec/ohai/plugins/os_spec.rb +58 -0
  59. data/spec/ohai/plugins/platform_spec.rb +56 -0
  60. data/spec/ohai/plugins/ruby_spec.rb +49 -0
  61. data/spec/ohai/system_spec.rb +130 -0
  62. data/spec/ohai_spec.rb +27 -0
  63. data/spec/rcov.opts +2 -0
  64. data/spec/spec.opts +2 -0
  65. data/spec/spec_helper.rb +47 -0
  66. metadata +138 -0
@@ -0,0 +1,59 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+
20
+ require File.join(File.dirname(__FILE__), '..', '..', '..', '/spec_helper.rb')
21
+
22
+ describe Ohai::System, "Linux lsb plugin" do
23
+ before(:each) do
24
+ @ohai = Ohai::System.new
25
+ @ohai[:os] = "linux"
26
+ @ohai.stub!(:require_plugin).and_return(true)
27
+ @mock_file = mock("/etc/lsb-release")
28
+ @mock_file.stub!(:each).
29
+ and_yield("DISTRIB_ID=Ubuntu").
30
+ and_yield("DISTRIB_RELEASE=8.04").
31
+ and_yield("DISTRIB_CODENAME=hardy").
32
+ and_yield('DISTRIB_DESCRIPTION="Ubuntu 8.04"')
33
+ end
34
+
35
+ it "should set lsb[:id]" do
36
+ @ohai._require_plugin("linux::lsb")
37
+ @ohai[:lsb][:id] == "Ubuntu"
38
+ end
39
+
40
+ it "should set lsb[:release]" do
41
+ @ohai._require_plugin("linux::lsb")
42
+ @ohai[:lsb][:release] == "8.04"
43
+ end
44
+
45
+ it "should set lsb[:codename]" do
46
+ @ohai._require_plugin("linux::lsb")
47
+ @ohai[:lsb][:codename] == "hardy"
48
+ end
49
+
50
+ it "should set lsb[:description]" do
51
+ @ohai._require_plugin("linux::lsb")
52
+ @ohai[:lsb][:description] == "Ubuntu 8.04"
53
+ end
54
+
55
+ it "should not set any lsb values if /etc/lsb-release cannot be read" do
56
+ File.stub!(:open).with("/etc/lsb-release").and_raise(IOError)
57
+ @ohai.attribute?(:lsb).should be(false)
58
+ end
59
+ end
@@ -0,0 +1,51 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+
20
+ require File.join(File.dirname(__FILE__), '..', '..', '..', '/spec_helper.rb')
21
+
22
+ describe Ohai::System, "Linux plugin platform" do
23
+ before(:each) do
24
+ @ohai = Ohai::System.new
25
+ @ohai.stub!(:require_plugin).and_return(true)
26
+ @ohai[:os] = "linux"
27
+ @ohai[:lsb] = Mash.new
28
+ end
29
+
30
+ it "should require the lsb plugin" do
31
+ @ohai.should_receive(:require_plugin).with("linux::lsb").and_return(true)
32
+ @ohai._require_plugin("linux::platform")
33
+ end
34
+
35
+ describe "on lsb compliant distributions" do
36
+ before(:each) do
37
+ @ohai[:lsb][:id] = "Ubuntu"
38
+ @ohai[:lsb][:release] = "8.04"
39
+ end
40
+
41
+ it "should set platform to lowercased lsb[:id]" do
42
+ @ohai._require_plugin("linux::platform")
43
+ @ohai[:platform].should == "ubuntu"
44
+ end
45
+
46
+ it "should set platform_version to lsb[:release]" do
47
+ @ohai._require_plugin("linux::platform")
48
+ @ohai[:platform_version].should == "8.04"
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,61 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+
20
+ require File.join(File.dirname(__FILE__), '..', '..', '..', '/spec_helper.rb')
21
+
22
+ describe Ohai::System, "Linux plugin uptime" do
23
+ before(:each) do
24
+ @ohai = Ohai::System.new
25
+ @ohai.stub!(:require_plugin).and_return(true)
26
+ @ohai[:os] = "linux"
27
+ @ohai._require_plugin("uptime")
28
+ @mock_file = mock("/proc/uptime", { :gets => "18423 989" })
29
+ File.stub!(:open).with("/proc/uptime").and_return(@mock_file)
30
+ end
31
+
32
+ it "should check /proc/uptime for the uptime and idletime" do
33
+ File.should_receive(:open).with("/proc/uptime").and_return(@mock_file)
34
+ @ohai._require_plugin("linux::uptime")
35
+ end
36
+
37
+ it "should split the value of /proc uptime" do
38
+ @mock_file.gets.should_receive(:split).with(" ").and_return(["18423", "989"])
39
+ @ohai._require_plugin("linux::uptime")
40
+ end
41
+
42
+ it "should set uptime_seconds to uptime" do
43
+ @ohai._require_plugin("linux::uptime")
44
+ @ohai[:uptime_seconds].should == 18423
45
+ end
46
+
47
+ it "should set uptime to a human readable date" do
48
+ @ohai._require_plugin("linux::uptime")
49
+ @ohai[:uptime].should == "5 hours 07 minutes 03 seconds"
50
+ end
51
+
52
+ it "should set idletime_seconds to uptime" do
53
+ @ohai._require_plugin("linux::uptime")
54
+ @ohai[:idletime_seconds].should == 989
55
+ end
56
+
57
+ it "should set idletime to a human readable date" do
58
+ @ohai._require_plugin("linux::uptime")
59
+ @ohai[:idletime].should == "16 minutes 29 seconds"
60
+ end
61
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+
20
+ require File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')
21
+
22
+ describe Ohai::System, "plugin ohai_time" do
23
+ before(:each) do
24
+ @ohai = Ohai::System.new
25
+ @ohai.stub!(:require_plugin).and_return(true)
26
+ end
27
+
28
+ it "should get the current time" do
29
+ Time.should_receive(:now)
30
+ @ohai._require_plugin("ohai_time")
31
+ end
32
+
33
+ it "should turn the time into a floating point number" do
34
+ time = Time.now
35
+ time.should_receive(:to_f)
36
+ Time.stub!(:now).and_return(time)
37
+ @ohai._require_plugin("ohai_time")
38
+ end
39
+
40
+ it "should set ohai_time to the current time" do
41
+ time = Time.now
42
+ Time.stub!(:now).and_return(time)
43
+ @ohai._require_plugin("ohai_time")
44
+ @ohai[:ohai_time].should == time.to_f
45
+ end
46
+ end
@@ -0,0 +1,58 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+
20
+ require File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')
21
+
22
+ describe Ohai::System, "plugin os" do
23
+ before(:each) do
24
+ @ohai = Ohai::System.new
25
+ @ohai.stub!(:require_plugin).and_return(true)
26
+ @ohai[:languages] = Mash.new
27
+ @ohai[:languages][:ruby] = Mash.new
28
+ @ohai[:kernel] = Mash.new
29
+ @ohai[:kernel][:release] = "kings of leon"
30
+ end
31
+
32
+ it "should set os_version to kernel_release" do
33
+ @ohai._require_plugin("os")
34
+ @ohai[:os_version].should == @ohai[:kernel][:release]
35
+ end
36
+
37
+ describe "on linux" do
38
+ before(:each) do
39
+ @ohai[:languages][:ruby][:host_os] = "linux"
40
+ end
41
+
42
+ it "should set the os to linux" do
43
+ @ohai._require_plugin("os")
44
+ @ohai[:os].should == "linux"
45
+ end
46
+ end
47
+
48
+ describe "on darwin" do
49
+ before(:each) do
50
+ @ohai[:languages][:ruby][:host_os] = "darwin"
51
+ end
52
+
53
+ it "should set the os to darwin" do
54
+ @ohai._require_plugin("os")
55
+ @ohai[:os].should == "darwin"
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,56 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+
20
+ require File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')
21
+
22
+ describe Ohai::System, "plugin platform" do
23
+ before(:each) do
24
+ @ohai = Ohai::System.new
25
+ @ohai.stub!(:require_plugin).and_return(true)
26
+ @ohai[:os] = 'monkey'
27
+ @ohai[:os_version] = 'poop'
28
+ end
29
+
30
+ it "should require the os platform plugin" do
31
+ @ohai.should_receive(:require_plugin).with("monkey::platform")
32
+ @ohai._require_plugin("platform")
33
+ end
34
+
35
+ it "should set the platform to the os if it was not set earlier" do
36
+ @ohai._require_plugin("platform")
37
+ @ohai[:platform].should eql("monkey")
38
+ end
39
+
40
+ it "should not set the platform to the os if it was set earlier" do
41
+ @ohai[:platform] = 'lars'
42
+ @ohai._require_plugin("platform")
43
+ @ohai[:platform].should eql("lars")
44
+ end
45
+
46
+ it "should set the platform_version to the os_version if it was not set earlier" do
47
+ @ohai._require_plugin("platform")
48
+ @ohai[:os_version].should eql("poop")
49
+ end
50
+
51
+ it "should not set the platform to the os if it was set earlier" do
52
+ @ohai[:platform_version] = 'ulrich'
53
+ @ohai._require_plugin("platform")
54
+ @ohai[:platform_version].should eql("ulrich")
55
+ end
56
+ end
@@ -0,0 +1,49 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+
20
+ require File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')
21
+
22
+ describe Ohai::System, "plugin ruby" do
23
+
24
+ before(:each) do
25
+ @ohai = Ohai::System.new
26
+ @ohai[:languages] = Mash.new
27
+ @ohai.stub!(:require_plugin).and_return(true)
28
+ end
29
+
30
+ {
31
+ :platform => RUBY_PLATFORM,
32
+ :version => RUBY_VERSION,
33
+ :release_date => RUBY_RELEASE_DATE,
34
+ :target => ::Config::CONFIG['target'],
35
+ :target_cpu => ::Config::CONFIG['target_cpu'],
36
+ :target_vendor => ::Config::CONFIG['target_vendor'],
37
+ :target_os => ::Config::CONFIG['target_os'],
38
+ :host => ::Config::CONFIG['host'],
39
+ :host_cpu => ::Config::CONFIG['host_cpu'],
40
+ :host_os => ::Config::CONFIG['host_os'],
41
+ :host_vendor => ::Config::CONFIG['host_vendor']
42
+ }.each do |attribute, value|
43
+ it "should have #{attribute} set" do
44
+ @ohai._require_plugin("ruby")
45
+ @ohai[:languages][:ruby][attribute].should eql(value)
46
+ end
47
+ end
48
+
49
+ end
@@ -0,0 +1,130 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require File.join(File.dirname(__FILE__), '..', '/spec_helper.rb')
20
+
21
+ describe Ohai::System, "initialize" do
22
+ it "should return an Ohai::System object" do
23
+ Ohai::System.new.should be_a_kind_of(Ohai::System)
24
+ end
25
+
26
+ it "should set @data to a Mash" do
27
+ Ohai::System.new.data.should be_a_kind_of(Mash)
28
+ end
29
+
30
+ it "should set @seen_plugins to a Hash" do
31
+ Ohai::System.new.seen_plugins.should be_a_kind_of(Hash)
32
+ end
33
+ end
34
+
35
+ describe Ohai::System, "method_missing" do
36
+ before(:each) do
37
+ @ohai = Ohai::System.new
38
+ end
39
+
40
+ it "should take a missing method and store the method name as a key, with it's arguments as values" do
41
+ @ohai.guns_n_roses("chinese democracy")
42
+ @ohai.data["guns_n_roses"].should eql("chinese democracy")
43
+ end
44
+
45
+ it "should return the current value of the method name" do
46
+ @ohai.guns_n_roses("chinese democracy").should eql("chinese democracy")
47
+ end
48
+
49
+ it "should allow you to get the value of a key by calling method_missing with no arguments" do
50
+ @ohai.guns_n_roses("chinese democracy")
51
+ @ohai.guns_n_roses.should eql("chinese democracy")
52
+ end
53
+ end
54
+
55
+ describe Ohai::System, "attribute?" do
56
+ before(:each) do
57
+ @ohai = Ohai::System.new
58
+ @ohai.metallica("death magnetic")
59
+ end
60
+
61
+ it "should return true if an attribute exists with the given name" do
62
+ @ohai.attribute?("metallica").should eql(true)
63
+ end
64
+
65
+ it "should return false if an attribute does not exist with the given name" do
66
+ @ohai.attribute?("alice in chains").should eql(false)
67
+ end
68
+ end
69
+
70
+ describe Ohai::System, "set_attribute" do
71
+ before(:each) do
72
+ @ohai = Ohai::System.new
73
+ end
74
+
75
+ it "should let you set an attribute" do
76
+ @ohai.set_attribute(:tea, "is soothing")
77
+ @ohai.data["tea"].should eql("is soothing")
78
+ end
79
+ end
80
+
81
+ describe Ohai::System, "get_attribute" do
82
+ before(:each) do
83
+ @ohai = Ohai::System.new
84
+ @ohai.set_attribute(:tea, "is soothing")
85
+ end
86
+
87
+ it "should let you get an attribute" do
88
+ @ohai.get_attribute("tea").should eql("is soothing")
89
+ end
90
+ end
91
+
92
+ describe Ohai::System, "require_plugin" do
93
+ before(:each) do
94
+ @plugin_path = Ohai::Config[:plugin_path]
95
+ Ohai::Config[:plugin_path] = ["/tmp/plugins"]
96
+ File.stub!(:exists?).and_return(true)
97
+ @ohai = Ohai::System.new
98
+ @ohai.stub!(:from_file).and_return(true)
99
+ end
100
+
101
+ after(:each) do
102
+ Ohai::Config[:plugin_path] = @plugin_path
103
+ end
104
+
105
+ it "should convert the name of the plugin to a file path" do
106
+ plugin_name = "foo::bar"
107
+ plugin_name.should_receive(:gsub).with("::", File::SEPARATOR)
108
+ @ohai.require_plugin(plugin_name)
109
+ end
110
+
111
+ it "should check each part of the Ohai::Config[:plugin_path] for the plugin_filename.rb" do
112
+ @ohai.should_receive(:from_file).with("/tmp/plugins/foo.rb").and_return(true)
113
+ @ohai.require_plugin("foo")
114
+ end
115
+
116
+ it "should add a found plugin to the list of seen plugins" do
117
+ @ohai.require_plugin("foo")
118
+ @ohai.seen_plugins["foo"].should eql(true)
119
+ end
120
+
121
+ it "should return true if the plugin has been seen" do
122
+ @ohai.seen_plugins["foo"] = true
123
+ @ohai.require_plugin("foo")
124
+ end
125
+
126
+ it "should return true if the plugin has been loaded" do
127
+ @ohai.require_plugin("foo").should eql(true)
128
+ end
129
+ end
130
+