ohai 7.6.0.rc.1 → 8.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/ohai/version.rb +1 -1
- data/spec/functional/plugins/powershell_spec.rb +4 -4
- data/spec/functional/plugins/root_group_spec.rb +1 -1
- data/spec/ohai_spec.rb +1 -1
- data/spec/spec_helper.rb +12 -12
- data/spec/unit/dsl/plugin_spec.rb +40 -40
- data/spec/unit/hints_spec.rb +3 -3
- data/spec/unit/loader_spec.rb +16 -16
- data/spec/unit/mixin/cloudstack_metadata_spec.rb +1 -1
- data/spec/unit/mixin/command_spec.rb +6 -6
- data/spec/unit/mixin/ec2_metadata_spec.rb +8 -8
- data/spec/unit/plugins/aix/cpu_spec.rb +15 -15
- data/spec/unit/plugins/aix/filesystem_spec.rb +15 -15
- data/spec/unit/plugins/aix/hostname_spec.rb +3 -3
- data/spec/unit/plugins/aix/kernel_spec.rb +14 -14
- data/spec/unit/plugins/aix/network_spec.rb +43 -43
- data/spec/unit/plugins/aix/platform_spec.rb +5 -5
- data/spec/unit/plugins/aix/uptime_spec.rb +7 -7
- data/spec/unit/plugins/aix/virtualization_spec.rb +3 -3
- data/spec/unit/plugins/azure_spec.rb +18 -18
- data/spec/unit/plugins/c_spec.rb +52 -52
- data/spec/unit/plugins/chef_spec.rb +1 -1
- data/spec/unit/plugins/cloud_spec.rb +31 -31
- data/spec/unit/plugins/cloud_v2_spec.rb +33 -33
- data/spec/unit/plugins/cloudstack_spec.rb +6 -6
- data/spec/unit/plugins/darwin/cpu_spec.rb +19 -19
- data/spec/unit/plugins/darwin/hostname_spec.rb +6 -6
- data/spec/unit/plugins/darwin/kernel_spec.rb +14 -14
- data/spec/unit/plugins/darwin/memory_spec.rb +7 -7
- data/spec/unit/plugins/darwin/network_spec.rb +358 -358
- data/spec/unit/plugins/darwin/platform_spec.rb +10 -10
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +4 -4
- data/spec/unit/plugins/dmi_spec.rb +3 -3
- data/spec/unit/plugins/ec2_spec.rb +80 -80
- data/spec/unit/plugins/erlang_spec.rb +7 -7
- data/spec/unit/plugins/eucalyptus_spec.rb +28 -28
- data/spec/unit/plugins/fail_spec.rb +8 -8
- data/spec/unit/plugins/freebsd/cpu_spec.rb +10 -10
- data/spec/unit/plugins/freebsd/hostname_spec.rb +4 -4
- data/spec/unit/plugins/freebsd/kernel_spec.rb +6 -6
- data/spec/unit/plugins/freebsd/os_spec.rb +3 -3
- data/spec/unit/plugins/freebsd/platform_spec.rb +5 -5
- data/spec/unit/plugins/freebsd/virtualization_spec.rb +20 -20
- data/spec/unit/plugins/gce_spec.rb +18 -18
- data/spec/unit/plugins/go_spec.rb +5 -5
- data/spec/unit/plugins/groovy_spec.rb +5 -5
- data/spec/unit/plugins/hostname_spec.rb +24 -24
- data/spec/unit/plugins/init_package_spec.rb +5 -5
- data/spec/unit/plugins/ip_scopes_spec.rb +1 -1
- data/spec/unit/plugins/java_spec.rb +23 -23
- data/spec/unit/plugins/joyent_spec.rb +13 -13
- data/spec/unit/plugins/kernel_spec.rb +20 -20
- data/spec/unit/plugins/linode_spec.rb +18 -18
- data/spec/unit/plugins/linux/cpu_spec.rb +25 -25
- data/spec/unit/plugins/linux/filesystem_spec.rb +61 -60
- data/spec/unit/plugins/linux/hostname_spec.rb +7 -7
- data/spec/unit/plugins/linux/kernel_spec.rb +5 -5
- data/spec/unit/plugins/linux/lsb_spec.rb +23 -23
- data/spec/unit/plugins/linux/mdadm_spec.rb +11 -11
- data/spec/unit/plugins/linux/platform_spec.rb +167 -167
- data/spec/unit/plugins/linux/uptime_spec.rb +6 -6
- data/spec/unit/plugins/linux/virtualization_spec.rb +156 -156
- data/spec/unit/plugins/lua_spec.rb +5 -5
- data/spec/unit/plugins/mono_spec.rb +5 -5
- data/spec/unit/plugins/netbsd/hostname_spec.rb +6 -6
- data/spec/unit/plugins/netbsd/kernel_spec.rb +6 -6
- data/spec/unit/plugins/netbsd/platform_spec.rb +5 -5
- data/spec/unit/plugins/network_spec.rb +116 -116
- data/spec/unit/plugins/nodejs_spec.rb +5 -5
- data/spec/unit/plugins/ohai_spec.rb +1 -1
- data/spec/unit/plugins/ohai_time_spec.rb +5 -5
- data/spec/unit/plugins/openbsd/hostname_spec.rb +6 -6
- data/spec/unit/plugins/openbsd/kernel_spec.rb +6 -6
- data/spec/unit/plugins/openbsd/platform_spec.rb +4 -4
- data/spec/unit/plugins/openstack_spec.rb +8 -8
- data/spec/unit/plugins/os_spec.rb +5 -5
- data/spec/unit/plugins/passwd_spec.rb +13 -13
- data/spec/unit/plugins/perl_spec.rb +8 -8
- data/spec/unit/plugins/php_spec.rb +7 -7
- data/spec/unit/plugins/platform_spec.rb +9 -9
- data/spec/unit/plugins/powershell_spec.rb +10 -10
- data/spec/unit/plugins/rackspace_spec.rb +72 -70
- data/spec/unit/plugins/root_group_spec.rb +14 -14
- data/spec/unit/plugins/ruby_spec.rb +1 -1
- data/spec/unit/plugins/sigar/network_route_spec.rb +17 -17
- data/spec/unit/plugins/solaris2/cpu_spec.rb +18 -18
- data/spec/unit/plugins/solaris2/hostname_spec.rb +4 -4
- data/spec/unit/plugins/solaris2/kernel_spec.rb +8 -8
- data/spec/unit/plugins/solaris2/memory_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/network_spec.rb +13 -13
- data/spec/unit/plugins/solaris2/platform_spec.rb +14 -14
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +24 -24
- data/spec/unit/plugins/solaris2/zpools_spec.rb +6 -6
- data/spec/unit/plugins/ssh_host_keys_spec.rb +18 -18
- data/spec/unit/runner_spec.rb +26 -26
- data/spec/unit/system_spec.rb +54 -54
- data/spec/unit/util/file_helper_spec.rb +2 -2
- metadata +50 -95
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0d9d3f875c58cc677e9188ec2183e25de5911e3e
|
4
|
+
data.tar.gz: fb59c6094438728c98ff3a9f2c9d4420579096dc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eab2a721b93ce4e9ccce9d4fce5fec55c191def267ee2ed713f0a859050ea1d4a59b0d583182475669408a3636ca2df3aa2890b7cff49401813220eb476c9e4f
|
7
|
+
data.tar.gz: f076c97eb34c8c66361dfdecb4fd3e418ca367494fcfc025a2c033f046949b64e850304ccd63519699c3b3e20c07acb8b2c7a043a0e99d9454951f3d016adb1d
|
data/lib/ohai/version.rb
CHANGED
@@ -23,10 +23,10 @@ describe Ohai::System, 'languages plugin' do
|
|
23
23
|
describe 'powershell plugin', :windows_only do
|
24
24
|
RSpec.shared_examples "a version looking thing" do
|
25
25
|
it 'should be present' do
|
26
|
-
subject.
|
26
|
+
expect(subject).not_to be_nil
|
27
27
|
end
|
28
28
|
it 'should look like a version' do
|
29
|
-
subject.
|
29
|
+
expect(subject).to match(VERSION_MATCHING_REGEX)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
before(:all) do
|
@@ -38,7 +38,7 @@ describe Ohai::System, 'languages plugin' do
|
|
38
38
|
subject { @plugin[:languages][:powershell] }
|
39
39
|
|
40
40
|
it 'should have information about powershell' do
|
41
|
-
subject.
|
41
|
+
expect(subject).not_to be_nil
|
42
42
|
end
|
43
43
|
|
44
44
|
describe :version do
|
@@ -74,7 +74,7 @@ describe Ohai::System, 'languages plugin' do
|
|
74
74
|
describe :compatible_versions do
|
75
75
|
it 'has compatible_versions that look like versions' do
|
76
76
|
@plugin.languages[:powershell][described_class].each do |version|
|
77
|
-
version.
|
77
|
+
expect(version).to match(VERSION_MATCHING_REGEX)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -32,7 +32,7 @@ describe Ohai::System, 'root_group plugin' do
|
|
32
32
|
# groups in Active Directory -- not a typical test scenario, but
|
33
33
|
# something to watch if you run this test in such an environment.
|
34
34
|
groups = wmi.query("select * from Win32_Group where sid = 'S-1-5-32-544'")
|
35
|
-
groups.length.
|
35
|
+
expect(groups.length).to eq(1)
|
36
36
|
administrators_group = groups[0]['name'].downcase
|
37
37
|
plugin.run
|
38
38
|
expect(plugin[:root_group].downcase).to be == administrators_group
|
data/spec/ohai_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -35,34 +35,34 @@ end
|
|
35
35
|
def it_should_check_from(plugin, attribute, from, value)
|
36
36
|
it "should set the #{attribute} to the value from '#{from}'" do
|
37
37
|
@plugin.run
|
38
|
-
@plugin[attribute].
|
38
|
+
expect(@plugin[attribute]).to eq(value)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
def it_should_check_from_mash(plugin, attribute, from, value)
|
43
43
|
it "should get the #{plugin}[:#{attribute}] value from '#{from}'" do
|
44
|
-
@plugin.
|
44
|
+
expect(@plugin).to receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
|
45
45
|
@plugin.run
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should set the #{plugin}[:#{attribute}] to the value from '#{from}'" do
|
49
49
|
@plugin.run
|
50
|
-
@plugin[plugin][attribute].
|
50
|
+
expect(@plugin[plugin][attribute]).to eq(value[1].split($/)[0])
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
def mock_shell_out(exitstatus, stdout, stderr)
|
55
55
|
shell_out = double("mixlib_shell_out")
|
56
|
-
shell_out.
|
57
|
-
shell_out.
|
58
|
-
shell_out.
|
56
|
+
allow(shell_out).to receive(:exitstatus).and_return(exitstatus)
|
57
|
+
allow(shell_out).to receive(:stdout).and_return(stdout)
|
58
|
+
allow(shell_out).to receive(:stderr).and_return(stderr)
|
59
59
|
shell_out
|
60
60
|
end
|
61
61
|
|
62
62
|
# the mash variable may be an array listing multiple levels of Mash hierarchy
|
63
63
|
def it_should_check_from_deep_mash(plugin, mash, attribute, from, value)
|
64
64
|
it "should get the #{mash.inspect}[:#{attribute}] value from '#{from}'" do
|
65
|
-
@plugin.
|
65
|
+
expect(@plugin).to receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
|
66
66
|
@plugin.run
|
67
67
|
end
|
68
68
|
|
@@ -70,12 +70,12 @@ def it_should_check_from_deep_mash(plugin, mash, attribute, from, value)
|
|
70
70
|
@plugin.run
|
71
71
|
value = value[1].split($/)[0]
|
72
72
|
if mash.is_a?(String)
|
73
|
-
@plugin[mash][attribute].
|
73
|
+
expect(@plugin[mash][attribute]).to eq(value)
|
74
74
|
elsif mash.is_a?(Array)
|
75
75
|
if mash.length == 2
|
76
|
-
@plugin[mash[0]][mash[1]][attribute].
|
76
|
+
expect(@plugin[mash[0]][mash[1]][attribute]).to eq value
|
77
77
|
elsif mash.length == 3
|
78
|
-
@plugin[mash[0]][mash[1]][mash[2]][attribute].
|
78
|
+
expect(@plugin[mash[0]][mash[1]][mash[2]][attribute]).to eq value
|
79
79
|
else
|
80
80
|
return nil
|
81
81
|
end
|
@@ -92,10 +92,10 @@ RSpec.configure do |config|
|
|
92
92
|
# `expect` should be preferred for new tests or when refactoring old tests,
|
93
93
|
# but we're not going to do a "big bang" change at this time.
|
94
94
|
config.expect_with :rspec do |c|
|
95
|
-
c.syntax =
|
95
|
+
c.syntax = :expect
|
96
96
|
end
|
97
97
|
config.mock_with :rspec do |c|
|
98
|
-
c.syntax =
|
98
|
+
c.syntax = :expect
|
99
99
|
end
|
100
100
|
|
101
101
|
config.filter_run :focus => true
|
@@ -22,54 +22,54 @@ require File.expand_path("../../../spec_helper.rb", __FILE__)
|
|
22
22
|
shared_examples "Ohai::DSL::Plugin" do
|
23
23
|
context "#initialize" do
|
24
24
|
it "should set has_run? to false" do
|
25
|
-
plugin.has_run
|
25
|
+
expect(plugin.has_run?).to be false
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should set the correct plugin version" do
|
29
|
-
plugin.version.
|
29
|
+
expect(plugin.version).to eql(version)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
context "#run" do
|
34
34
|
before do
|
35
|
-
plugin.
|
36
|
-
plugin.
|
35
|
+
allow(plugin).to receive(:run_plugin).and_return(true)
|
36
|
+
allow(plugin).to receive(:name).and_return(:TestPlugin)
|
37
37
|
end
|
38
38
|
|
39
39
|
describe "when plugin is enabled" do
|
40
40
|
before do
|
41
|
-
Ohai::Config.
|
41
|
+
allow(Ohai::Config).to receive(:[]).with(:disabled_plugins).and_return([ ])
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should run the plugin" do
|
45
|
-
plugin.
|
45
|
+
expect(plugin).to receive(:run_plugin)
|
46
46
|
plugin.run
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should set has_run? to true" do
|
50
50
|
plugin.run
|
51
|
-
plugin.has_run
|
51
|
+
expect(plugin.has_run?).to be true
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
describe "if the plugin is disabled" do
|
56
56
|
before do
|
57
|
-
Ohai::Config.
|
57
|
+
allow(Ohai::Config).to receive(:[]).with(:disabled_plugins).and_return([ :TestPlugin ])
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should not run the plugin" do
|
61
|
-
plugin.
|
61
|
+
expect(plugin).not_to receive(:run_plugin)
|
62
62
|
plugin.run
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should log a message to debug" do
|
66
|
-
Ohai::Log.
|
66
|
+
expect(Ohai::Log).to receive(:debug).with(/Skipping disabled plugin TestPlugin/)
|
67
67
|
plugin.run
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should set has_run? to true" do
|
71
71
|
plugin.run
|
72
|
-
plugin.has_run
|
72
|
+
expect(plugin.has_run?).to be true
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -77,16 +77,16 @@ shared_examples "Ohai::DSL::Plugin" do
|
|
77
77
|
context "when accessing data via method_missing" do
|
78
78
|
it "should take a missing method and store the method name as a key, with its arguments as values" do
|
79
79
|
plugin.guns_n_roses("chinese democracy")
|
80
|
-
plugin.data["guns_n_roses"].
|
80
|
+
expect(plugin.data["guns_n_roses"]).to eql("chinese democracy")
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should return the current value of the method name" do
|
84
|
-
plugin.guns_n_roses("chinese democracy").
|
84
|
+
expect(plugin.guns_n_roses("chinese democracy")).to eql("chinese democracy")
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should allow you to get the value of a key by calling method_missing with no arguments" do
|
88
88
|
plugin.guns_n_roses("chinese democracy")
|
89
|
-
plugin.guns_n_roses.
|
89
|
+
expect(plugin.guns_n_roses).to eql("chinese democracy")
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -96,18 +96,18 @@ shared_examples "Ohai::DSL::Plugin" do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should return true if an attribute exists with the given name" do
|
99
|
-
plugin.attribute?("metallica").
|
99
|
+
expect(plugin.attribute?("metallica")).to eql(true)
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should return false if an attribute does not exist with the given name" do
|
103
|
-
plugin.attribute?("alice in chains").
|
103
|
+
expect(plugin.attribute?("alice in chains")).to eql(false)
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
107
|
context "when setting attributes" do
|
108
108
|
it "should let you set an attribute" do
|
109
109
|
plugin.set_attribute(:tea, "is soothing")
|
110
|
-
plugin.data["tea"].
|
110
|
+
expect(plugin.data["tea"]).to eql("is soothing")
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -117,7 +117,7 @@ shared_examples "Ohai::DSL::Plugin" do
|
|
117
117
|
end
|
118
118
|
|
119
119
|
it "should let you get an attribute" do
|
120
|
-
plugin.get_attribute("tea").
|
120
|
+
expect(plugin.get_attribute("tea")).to eql("is soothing")
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
@@ -125,7 +125,7 @@ end
|
|
125
125
|
describe Ohai::DSL::Plugin::VersionVII do
|
126
126
|
it "should not modify the plugin name when the plugin is named correctly" do
|
127
127
|
plugin = Ohai.plugin(:FunkyVALIDpluginName) { }.new({ })
|
128
|
-
plugin.name.
|
128
|
+
expect(plugin.name).to eql(:FunkyVALIDpluginName)
|
129
129
|
end
|
130
130
|
|
131
131
|
describe "when the plugin is named incorrectly" do
|
@@ -151,19 +151,19 @@ describe Ohai::DSL::Plugin::VersionVII do
|
|
151
151
|
describe "#version" do
|
152
152
|
it "should save the plugin version as :version7" do
|
153
153
|
plugin = Ohai.plugin(:Test) { }
|
154
|
-
plugin.version.
|
154
|
+
expect(plugin.version).to eql(:version7)
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
158
|
describe "#provides" do
|
159
159
|
it "should collect a single attribute" do
|
160
160
|
plugin = Ohai.plugin(:Test) { provides("one") }
|
161
|
-
plugin.provides_attrs.
|
161
|
+
expect(plugin.provides_attrs).to eql(["one"])
|
162
162
|
end
|
163
163
|
|
164
164
|
it "should collect a list of attributes" do
|
165
165
|
plugin = Ohai.plugin(:Test) { provides("one", "two", "three") }
|
166
|
-
plugin.provides_attrs.
|
166
|
+
expect(plugin.provides_attrs).to eql(["one", "two", "three"])
|
167
167
|
end
|
168
168
|
|
169
169
|
it "should collect from multiple provides statements" do
|
@@ -172,31 +172,31 @@ describe Ohai::DSL::Plugin::VersionVII do
|
|
172
172
|
provides("two", "three")
|
173
173
|
provides("four")
|
174
174
|
}
|
175
|
-
plugin.provides_attrs.
|
175
|
+
expect(plugin.provides_attrs).to eql(["one", "two", "three", "four"])
|
176
176
|
end
|
177
177
|
|
178
178
|
it "should collect attributes across multiple plugin files" do
|
179
179
|
plugin = Ohai.plugin(:Test) { provides("one") }
|
180
180
|
plugin = Ohai.plugin(:Test) { provides("two", "three") }
|
181
|
-
plugin.provides_attrs.
|
181
|
+
expect(plugin.provides_attrs).to eql(["one", "two", "three"])
|
182
182
|
end
|
183
183
|
|
184
184
|
it "should collect unique attributes" do
|
185
185
|
plugin = Ohai.plugin(:Test) { provides("one") }
|
186
186
|
plugin = Ohai.plugin(:Test) { provides("one", "two") }
|
187
|
-
plugin.provides_attrs.
|
187
|
+
expect(plugin.provides_attrs).to eql(["one", "two"])
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
191
|
describe "#depends" do
|
192
192
|
it "should collect a single dependency" do
|
193
193
|
plugin = Ohai.plugin(:Test) { depends("one") }
|
194
|
-
plugin.depends_attrs.
|
194
|
+
expect(plugin.depends_attrs).to eql(["one"])
|
195
195
|
end
|
196
196
|
|
197
197
|
it "should collect a list of dependencies" do
|
198
198
|
plugin = Ohai.plugin(:Test) { depends("one", "two", "three") }
|
199
|
-
plugin.depends_attrs.
|
199
|
+
expect(plugin.depends_attrs).to eql(["one", "two", "three"])
|
200
200
|
end
|
201
201
|
|
202
202
|
it "should collect from multiple depends statements" do
|
@@ -205,37 +205,37 @@ describe Ohai::DSL::Plugin::VersionVII do
|
|
205
205
|
depends("two", "three")
|
206
206
|
depends("four")
|
207
207
|
}
|
208
|
-
plugin.depends_attrs.
|
208
|
+
expect(plugin.depends_attrs).to eql(["one", "two", "three", "four"])
|
209
209
|
end
|
210
210
|
|
211
211
|
it "should collect dependencies across multiple plugin files" do
|
212
212
|
plugin = Ohai.plugin(:Test) { depends("one") }
|
213
213
|
plugin = Ohai.plugin(:Test) { depends("two", "three") }
|
214
|
-
plugin.depends_attrs.
|
214
|
+
expect(plugin.depends_attrs).to eql(["one", "two", "three"])
|
215
215
|
end
|
216
216
|
|
217
217
|
it "should collect unique attributes" do
|
218
218
|
plugin = Ohai.plugin(:Test) { depends("one") }
|
219
219
|
plugin = Ohai.plugin(:Test) { depends("one", "two") }
|
220
|
-
plugin.depends_attrs.
|
220
|
+
expect(plugin.depends_attrs).to eql(["one", "two"])
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
224
224
|
describe "#collect_data" do
|
225
225
|
it "should save as :default if no platform is given" do
|
226
226
|
plugin = Ohai.plugin(:Test) { collect_data { } }
|
227
|
-
plugin.data_collector.
|
227
|
+
expect(plugin.data_collector).to have_key(:default)
|
228
228
|
end
|
229
229
|
|
230
230
|
it "should save a single given platform" do
|
231
231
|
plugin = Ohai.plugin(:Test) { collect_data(:ubuntu) { } }
|
232
|
-
plugin.data_collector.
|
232
|
+
expect(plugin.data_collector).to have_key(:ubuntu)
|
233
233
|
end
|
234
234
|
|
235
235
|
it "should save a list of platforms" do
|
236
236
|
plugin = Ohai.plugin(:Test) { collect_data(:freebsd, :netbsd, :openbsd) { } }
|
237
237
|
[:freebsd, :netbsd, :openbsd].each do |platform|
|
238
|
-
plugin.data_collector.
|
238
|
+
expect(plugin.data_collector).to have_key(platform)
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
@@ -246,7 +246,7 @@ describe Ohai::DSL::Plugin::VersionVII do
|
|
246
246
|
collect_data(:darwin) { }
|
247
247
|
}
|
248
248
|
[:darwin, :default, :windows].each do |platform|
|
249
|
-
plugin.data_collector.
|
249
|
+
expect(plugin.data_collector).to have_key(platform)
|
250
250
|
end
|
251
251
|
end
|
252
252
|
|
@@ -254,7 +254,7 @@ describe Ohai::DSL::Plugin::VersionVII do
|
|
254
254
|
plugin = Ohai.plugin(:Test) { collect_data { } }
|
255
255
|
plugin = Ohai.plugin(:Test) { collect_data(:aix, :sigar) { } }
|
256
256
|
[:aix, :default, :sigar].each do |platform|
|
257
|
-
plugin.data_collector.
|
257
|
+
expect(plugin.data_collector).to have_key(platform)
|
258
258
|
end
|
259
259
|
end
|
260
260
|
|
@@ -280,7 +280,7 @@ describe Ohai::DSL::Plugin::VersionVII do
|
|
280
280
|
describe "#provides (deprecated)" do
|
281
281
|
it "should log a warning" do
|
282
282
|
plugin = Ohai::DSL::Plugin::VersionVII.new(Mash.new)
|
283
|
-
Ohai::Log.
|
283
|
+
expect(Ohai::Log).to receive(:warn).with(/\[UNSUPPORTED OPERATION\]/)
|
284
284
|
plugin.provides("attribute")
|
285
285
|
end
|
286
286
|
end
|
@@ -288,7 +288,7 @@ describe Ohai::DSL::Plugin::VersionVII do
|
|
288
288
|
describe "#require_plugin (deprecated)" do
|
289
289
|
it "should log a warning" do
|
290
290
|
plugin = Ohai::DSL::Plugin::VersionVII.new(Mash.new)
|
291
|
-
Ohai::Log.
|
291
|
+
expect(Ohai::Log).to receive(:warn).with(/\[UNSUPPORTED OPERATION\]/)
|
292
292
|
plugin.require_plugin("plugin")
|
293
293
|
end
|
294
294
|
end
|
@@ -304,7 +304,7 @@ describe Ohai::DSL::Plugin::VersionVI do
|
|
304
304
|
describe "#version" do
|
305
305
|
it "should save the plugin version as :version6" do
|
306
306
|
plugin = Class.new(Ohai::DSL::Plugin::VersionVI) { }
|
307
|
-
plugin.version.
|
307
|
+
expect(plugin.version).to eql(:version6)
|
308
308
|
end
|
309
309
|
end
|
310
310
|
|
@@ -314,7 +314,7 @@ describe Ohai::DSL::Plugin::VersionVI do
|
|
314
314
|
end
|
315
315
|
|
316
316
|
it "should log a debug message when provides is used" do
|
317
|
-
Ohai::Log.
|
317
|
+
expect(Ohai::Log).to receive(:debug).with(/Skipping provides/)
|
318
318
|
plugin = Ohai::DSL::Plugin::VersionVI.new(@ohai, "/some/plugin/path.rb", "/some/plugin")
|
319
319
|
plugin.provides("attribute")
|
320
320
|
end
|
@@ -322,7 +322,7 @@ describe Ohai::DSL::Plugin::VersionVI do
|
|
322
322
|
it "should not update the provides map for version 6 plugins." do
|
323
323
|
plugin = Ohai::DSL::Plugin::VersionVI.new(@ohai, "/some/plugin/path.rb", "/some/plugin")
|
324
324
|
plugin.provides("attribute")
|
325
|
-
@ohai.provides_map.map.
|
325
|
+
expect(@ohai.provides_map.map).to be_empty
|
326
326
|
end
|
327
327
|
|
328
328
|
end
|
data/spec/unit/hints_spec.rb
CHANGED
@@ -37,7 +37,7 @@ describe "Ohai::Hints" do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it "hint? should return nil" do
|
40
|
-
Ohai::Hints.hint?("cloud").
|
40
|
+
expect(Ohai::Hints.hint?("cloud")).to be_nil
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -54,11 +54,11 @@ EOF
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "hint? should return the data for full hints" do
|
57
|
-
Ohai::Hints.hint?("cloud").
|
57
|
+
expect(Ohai::Hints.hint?("cloud")).to eq({"name" => "circus"})
|
58
58
|
end
|
59
59
|
|
60
60
|
it "hint? should return empty hash for empty hints" do
|
61
|
-
Ohai::Hints.hint?("cloud_empty").
|
61
|
+
expect(Ohai::Hints.hint?("cloud_empty")).to eq({ })
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
data/spec/unit/loader_spec.rb
CHANGED
@@ -33,7 +33,7 @@ describe Ohai::Loader do
|
|
33
33
|
describe "#initialize" do
|
34
34
|
it "should return an Ohai::Loader object" do
|
35
35
|
loader = Ohai::Loader.new(@ohai)
|
36
|
-
loader.
|
36
|
+
expect(loader).to be_a_kind_of(Ohai::Loader)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -61,38 +61,38 @@ EOF
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should save the plugin according to its attribute" do
|
64
|
-
@provides_map.map.keys.
|
64
|
+
expect(@provides_map.map.keys).to include("seals")
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should save a single plugin source" do
|
68
|
-
@plugin.source.
|
68
|
+
expect(@plugin.source).to eql([path_to("zoo.rb")])
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should save all plugin sources" do
|
72
72
|
@loader.load_plugin(path_to("zoo_too.rb"))
|
73
|
-
@plugin.source.
|
73
|
+
expect(@plugin.source).to eql([path_to("zoo.rb"), path_to("zoo_too.rb")])
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
describe "when loading a v6 plugin" do
|
78
78
|
before(:each) do
|
79
|
-
Ohai::Log.
|
79
|
+
expect(Ohai::Log).to receive(:warn).with(/\[DEPRECATION\]/)
|
80
80
|
@plugin = @loader.load_plugin(path_to("lake.rb"), path_to("."))
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should not add this plugin's provided attributes to the provides map" do
|
84
|
-
@provides_map.map.
|
84
|
+
expect(@provides_map.map).to be_empty
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should save the plugin's source" do
|
88
|
-
@plugin.source.
|
88
|
+
expect(@plugin.source).to eql(path_to("lake.rb"))
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should log a warning if a plugin doesn't exist" do
|
93
|
-
Ohai::Log.
|
93
|
+
expect(Ohai::Log).to receive(:warn).with(/Unable to open or read plugin/)
|
94
94
|
@loader.load_plugin(path_to("rainier.rb"), path_to("."))
|
95
|
-
@provides_map.map.
|
95
|
+
expect(@provides_map.map).to be_empty
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
@@ -147,7 +147,7 @@ EOF
|
|
147
147
|
describe "load_plugin() method" do
|
148
148
|
describe "when the plugin uses Ohai.plugin instead of Ohai.plugins" do
|
149
149
|
it "should log an unsupported operation warning" do
|
150
|
-
Ohai::Log.
|
150
|
+
expect(Ohai::Log).to receive(:warn).with(/Plugin Method Error: <#{path_to("extra_s.rb")}>:/)
|
151
151
|
@loader.load_plugin(path_to("extra_s.rb"))
|
152
152
|
end
|
153
153
|
|
@@ -158,7 +158,7 @@ EOF
|
|
158
158
|
|
159
159
|
describe "when the plugin tries to call an unexisting method" do
|
160
160
|
it "shoud log an unsupported operation warning" do
|
161
|
-
Ohai::Log.
|
161
|
+
expect(Ohai::Log).to receive(:warn).with(/Plugin Method Error: <#{path_to("no_method.rb")}>:/)
|
162
162
|
@loader.load_plugin(path_to("no_method.rb"))
|
163
163
|
end
|
164
164
|
|
@@ -169,7 +169,7 @@ EOF
|
|
169
169
|
|
170
170
|
describe "when the plugin defines collect_data on the same platform more than once" do
|
171
171
|
it "shoud log an illegal plugin definition warning" do
|
172
|
-
Ohai::Log.
|
172
|
+
expect(Ohai::Log).to receive(:warn).with(/Plugin Definition Error: <#{path_to("illegal_def.rb")}>:/)
|
173
173
|
@loader.load_plugin(path_to("illegal_def.rb"))
|
174
174
|
end
|
175
175
|
|
@@ -180,7 +180,7 @@ EOF
|
|
180
180
|
|
181
181
|
describe "when an unexpected error is encountered" do
|
182
182
|
it "should log a warning" do
|
183
|
-
Ohai::Log.
|
183
|
+
expect(Ohai::Log).to receive(:warn).with(/Plugin Error: <#{path_to("unexpected_error.rb")}>:/)
|
184
184
|
@loader.load_plugin(path_to("unexpected_error.rb"))
|
185
185
|
end
|
186
186
|
|
@@ -191,7 +191,7 @@ EOF
|
|
191
191
|
|
192
192
|
describe "when the plugin name symbol has bad syntax" do
|
193
193
|
it "should log a syntax error warning" do
|
194
|
-
Ohai::Log.
|
194
|
+
expect(Ohai::Log).to receive(:warn).with(/Plugin Syntax Error: <#{path_to("bad_symbol.rb")}>:/)
|
195
195
|
@loader.load_plugin(path_to("bad_symbol.rb"))
|
196
196
|
end
|
197
197
|
|
@@ -202,7 +202,7 @@ EOF
|
|
202
202
|
|
203
203
|
describe "when the plugin forgets an 'end'" do
|
204
204
|
it "should log a syntax error warning" do
|
205
|
-
Ohai::Log.
|
205
|
+
expect(Ohai::Log).to receive(:warn).with(/Plugin Syntax Error: <#{path_to("no_end.rb")}>:/)
|
206
206
|
@loader.load_plugin(path_to("no_end.rb"))
|
207
207
|
end
|
208
208
|
|
@@ -213,7 +213,7 @@ EOF
|
|
213
213
|
|
214
214
|
describe "when the plugin has an invalid name" do
|
215
215
|
it "should log an invalid plugin name warning" do
|
216
|
-
Ohai::Log.
|
216
|
+
expect(Ohai::Log).to receive(:warn).with(/Plugin Name Error: <#{path_to("bad_name.rb")}>:/)
|
217
217
|
@loader.load_plugin(path_to("bad_name.rb"))
|
218
218
|
end
|
219
219
|
|