ohai 8.13.0 → 8.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/lib/ohai/common/dmi.rb +1 -1
  4. data/lib/ohai/config.rb +2 -2
  5. data/lib/ohai/dsl/plugin.rb +1 -1
  6. data/lib/ohai/loader.rb +1 -1
  7. data/lib/ohai/mixin/command.rb +18 -5
  8. data/lib/ohai/mixin/ec2_metadata.rb +1 -1
  9. data/lib/ohai/plugins/aix/os.rb +1 -1
  10. data/lib/ohai/plugins/c.rb +49 -67
  11. data/lib/ohai/plugins/darwin/memory.rb +1 -1
  12. data/lib/ohai/plugins/darwin/network.rb +3 -3
  13. data/lib/ohai/plugins/darwin/platform.rb +1 -1
  14. data/lib/ohai/plugins/darwin/system_profiler.rb +1 -1
  15. data/lib/ohai/plugins/digital_ocean.rb +1 -1
  16. data/lib/ohai/plugins/ec2.rb +42 -41
  17. data/lib/ohai/plugins/erlang.rb +1 -1
  18. data/lib/ohai/plugins/ip_scopes.rb +1 -1
  19. data/lib/ohai/plugins/kernel.rb +1 -1
  20. data/lib/ohai/plugins/linux/network.rb +2 -2
  21. data/lib/ohai/plugins/linux/platform.rb +6 -1
  22. data/lib/ohai/plugins/mono.rb +1 -1
  23. data/lib/ohai/plugins/network.rb +2 -2
  24. data/lib/ohai/plugins/packages.rb +59 -46
  25. data/lib/ohai/plugins/python.rb +2 -2
  26. data/lib/ohai/plugins/rackspace.rb +4 -4
  27. data/lib/ohai/plugins/sigar/network.rb +1 -1
  28. data/lib/ohai/plugins/sigar/network_route.rb +1 -1
  29. data/lib/ohai/plugins/solaris2/dmi.rb +1 -1
  30. data/lib/ohai/plugins/solaris2/network.rb +25 -8
  31. data/lib/ohai/plugins/ssh_host_key.rb +1 -1
  32. data/lib/ohai/plugins/windows/network.rb +5 -5
  33. data/lib/ohai/provides_map.rb +2 -2
  34. data/lib/ohai/system.rb +1 -1
  35. data/lib/ohai/version.rb +1 -1
  36. data/spec/functional/loader_spec.rb +1 -1
  37. data/spec/unit/mixin/command_spec.rb +118 -0
  38. data/spec/unit/plugins/aix/os_spec.rb +6 -5
  39. data/spec/unit/plugins/c_spec.rb +169 -118
  40. data/spec/unit/plugins/digital_ocean_spec.rb +7 -7
  41. data/spec/unit/plugins/dmi_spec.rb +4 -4
  42. data/spec/unit/plugins/ec2_spec.rb +64 -69
  43. data/spec/unit/plugins/linode_spec.rb +6 -6
  44. data/spec/unit/plugins/linux/platform_spec.rb +7 -0
  45. data/spec/unit/plugins/linux/sessions_spec.rb +2 -2
  46. data/spec/unit/plugins/network_spec.rb +16 -16
  47. data/spec/unit/plugins/openstack_spec.rb +1 -1
  48. data/spec/unit/plugins/packages_spec.rb +165 -191
  49. data/spec/unit/plugins/rackspace_spec.rb +203 -130
  50. data/spec/unit/plugins/solaris2/filesystem.rb +2 -2
  51. data/spec/unit/plugins/solaris2/network_spec.rb +36 -5
  52. metadata +3 -3
data/lib/ohai/version.rb CHANGED
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Ohai
20
20
  OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
21
- VERSION = "8.13.0"
21
+ VERSION = "8.14.0"
22
22
  end
@@ -23,7 +23,7 @@ RSpec.describe "Ohai::Loader" do
23
23
  describe "#load_all" do
24
24
  context "when the plugin path contains backslash characters", :windows_only do
25
25
  let(:plugin_directory) { Dir.mktmpdir("plugins") }
26
- let(:plugin_path) { plugin_directory.gsub("/", "\\") }
26
+ let(:plugin_path) { plugin_directory.tr("/", "\\") }
27
27
 
28
28
  before(:each) do
29
29
  Ohai.config[:plugin_path] = plugin_path
@@ -85,5 +85,123 @@ describe Ohai::Mixin::Command, "popen4" do
85
85
  end
86
86
  expect(reaped_procs).to eq(0)
87
87
  end
88
+ end
89
+
90
+ describe Ohai::Mixin::Command, "shell_out" do
91
+ let(:cmd) { "sparkle-dream --version" }
92
+
93
+ let(:shell_out) { double("Mixlib::ShellOut") }
94
+
95
+ let(:plugin_name) { :OSSparkleDream }
96
+
97
+ before(:each) do
98
+ allow(Ohai::Mixin::Command).to receive(:name).and_return(plugin_name)
99
+ end
100
+
101
+ describe "when the command runs" do
102
+ it "logs the command and exitstatus" do
103
+ expect(Mixlib::ShellOut).
104
+ to receive(:new).
105
+ with(cmd, { timeout: 30 }).
106
+ and_return(shell_out)
107
+
108
+ expect(shell_out).
109
+ to receive(:run_command)
110
+
111
+ expect(shell_out).
112
+ to receive(:exitstatus).
113
+ and_return(256)
114
+
115
+ expect(Ohai::Log).to receive(:debug).
116
+ with("Plugin OSSparkleDream ran 'sparkle-dream --version' and returned 256")
117
+
118
+ Ohai::Mixin::Command.shell_out(cmd)
119
+ end
120
+ end
121
+
122
+ describe "when the command does not exist" do
123
+ it "logs the command and error message" do
124
+ expect(Mixlib::ShellOut).
125
+ to receive(:new).
126
+ with(cmd, { timeout: 30 }).
127
+ and_return(shell_out)
128
+
129
+ expect(shell_out).
130
+ to receive(:run_command).
131
+ and_raise(Errno::ENOENT, "sparkle-dream")
132
+
133
+ expect(Ohai::Log).
134
+ to receive(:debug).
135
+ with("Plugin OSSparkleDream ran 'sparkle-dream --version' and failed " \
136
+ "#<Errno::ENOENT: No such file or directory - sparkle-dream>")
137
+
138
+ expect { Ohai::Mixin::Command.shell_out(cmd) }.
139
+ to raise_error(Ohai::Exceptions::Exec)
140
+ end
141
+ end
88
142
 
143
+ describe "when the command times out" do
144
+ it "logs the command an timeout error message" do
145
+ expect(Mixlib::ShellOut).
146
+ to receive(:new).
147
+ with(cmd, { timeout: 30 }).
148
+ and_return(shell_out)
149
+
150
+ expect(shell_out).
151
+ to receive(:run_command).
152
+ and_raise(Mixlib::ShellOut::CommandTimeout)
153
+
154
+ expect(Ohai::Log).
155
+ to receive(:debug).
156
+ with("Plugin OSSparkleDream ran 'sparkle-dream --version' and timed " \
157
+ "out after 30 seconds")
158
+
159
+ expect { Ohai::Mixin::Command.shell_out(cmd) }.
160
+ to raise_error(Ohai::Exceptions::Exec)
161
+ end
162
+ end
163
+
164
+ describe "when a timeout option is provided" do
165
+ let(:options) { { timeout: 10 } }
166
+
167
+ it "runs the command with the provided timeout" do
168
+ expect(Mixlib::ShellOut).
169
+ to receive(:new).
170
+ with(cmd, options).
171
+ and_return(shell_out)
172
+
173
+ expect(shell_out).
174
+ to receive(:run_command)
175
+
176
+ expect(shell_out).
177
+ to receive(:exitstatus).
178
+ and_return(256)
179
+
180
+ expect(Ohai::Log).to receive(:debug).
181
+ with("Plugin OSSparkleDream ran 'sparkle-dream --version' and returned 256")
182
+
183
+ Ohai::Mixin::Command.shell_out(cmd, options)
184
+ end
185
+
186
+ describe "when the command times out" do
187
+ it "logs the command an timeout error message" do
188
+ expect(Mixlib::ShellOut).
189
+ to receive(:new).
190
+ with(cmd, options).
191
+ and_return(shell_out)
192
+
193
+ expect(shell_out).
194
+ to receive(:run_command).
195
+ and_raise(Mixlib::ShellOut::CommandTimeout)
196
+
197
+ expect(Ohai::Log).
198
+ to receive(:debug).
199
+ with("Plugin OSSparkleDream ran 'sparkle-dream --version' and timed " \
200
+ "out after 10 seconds")
201
+
202
+ expect { Ohai::Mixin::Command.shell_out(cmd, options) }.
203
+ to raise_error(Ohai::Exceptions::Exec)
204
+ end
205
+ end
206
+ end
89
207
  end
@@ -20,15 +20,16 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
20
20
  describe Ohai::System, "AIX os plugin" do
21
21
  before(:each) do
22
22
  @plugin = get_plugin("aix/os")
23
- kernel = Mash.new
24
- kernel[:version] = "6"
25
- kernel[:release] = "1"
26
23
  allow(@plugin).to receive(:collect_os).and_return(:aix)
27
- allow(@plugin).to receive(:kernel).and_return(kernel)
24
+ allow(@plugin).to receive(:shell_out).with("oslevel -s").and_return(mock_shell_out(0, "7200-00-01-1543\n", nil))
28
25
  @plugin.run
29
26
  end
30
27
 
28
+ it "should set the top-level os attribute" do
29
+ expect(@plugin[:os]).to eql(:aix)
30
+ end
31
+
31
32
  it "should set the top-level os_level attribute" do
32
- expect(@plugin[:os_version]).to eql("6")
33
+ expect(@plugin[:os_version]).to eql("7200-00-01-1543")
33
34
  end
34
35
  end
@@ -102,207 +102,258 @@ EOF
102
102
 
103
103
  describe Ohai::System, "plugin c" do
104
104
 
105
+ let(:plugin) { get_plugin("c") }
106
+
105
107
  before(:each) do
106
- @plugin = get_plugin("c")
107
108
 
108
- @plugin[:languages] = Mash.new
109
+ plugin[:languages] = Mash.new
109
110
  #gcc
110
- allow(@plugin).to receive(:shell_out).with("gcc -v").and_return(mock_shell_out(0, "", C_GCC))
111
+ allow(plugin).to receive(:shell_out).with("gcc -v").and_return(mock_shell_out(0, "", C_GCC))
111
112
  #glibc
112
- allow(@plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_3_4, ""))
113
+ allow(plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_3_4, ""))
113
114
  #ms cl
114
- allow(@plugin).to receive(:shell_out).with("cl /\?").and_return(mock_shell_out(0, "", C_CL))
115
+ allow(plugin).to receive(:shell_out).with("cl /\?").and_return(mock_shell_out(0, "", C_CL))
115
116
  #ms vs
116
- allow(@plugin).to receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(0, C_VS, ""))
117
+ allow(plugin).to receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(0, C_VS, ""))
117
118
  #ibm xlc
118
- allow(@plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC, ""))
119
+ allow(plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC, ""))
119
120
  #sun pro
120
- allow(@plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", C_SUN))
121
+ allow(plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", C_SUN))
121
122
  #hpux cc
122
- allow(@plugin).to receive(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(0, C_HPUX, ""))
123
+ allow(plugin).to receive(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(0, C_HPUX, ""))
123
124
  end
124
125
 
125
126
  #gcc
126
- it "should get the gcc version from running gcc -v" do
127
- expect(@plugin).to receive(:shell_out).with("gcc -v").and_return(mock_shell_out(0, "", C_GCC))
128
- @plugin.run
127
+ it "gets the gcc version from running gcc -v" do
128
+ expect(plugin).to receive(:shell_out).with("gcc -v").and_return(mock_shell_out(0, "", C_GCC))
129
+ plugin.run
130
+ end
131
+
132
+ it "sets languages[:c][:gcc][:version]" do
133
+ plugin.run
134
+ expect(plugin.languages[:c][:gcc][:version]).to eql("3.4.6")
129
135
  end
130
136
 
131
- it "should set languages[:c][:gcc][:version]" do
132
- @plugin.run
133
- expect(@plugin.languages[:c][:gcc][:version]).to eql("3.4.6")
137
+ it "sets languages[:c][:gcc][:description]" do
138
+ plugin.run
139
+ expect(plugin.languages[:c][:gcc][:description]).to eql(C_GCC.split($/).last)
134
140
  end
135
141
 
136
- it "should set languages[:c][:gcc][:description]" do
137
- @plugin.run
138
- expect(@plugin.languages[:c][:gcc][:description]).to eql(C_GCC.split($/).last)
142
+ it "does not set the languages[:c][:gcc] tree up if gcc command exits nonzero" do
143
+ allow(plugin).to receive(:shell_out).with("gcc -v").and_return(mock_shell_out(1, "", ""))
144
+ plugin.run
145
+ expect(plugin[:languages][:c]).not_to have_key(:gcc)
139
146
  end
140
147
 
141
- it "should not set the languages[:c][:gcc] tree up if gcc command fails" do
142
- allow(@plugin).to receive(:shell_out).with("gcc -v").and_return(mock_shell_out(1, "", ""))
143
- @plugin.run
144
- expect(@plugin[:languages][:c]).not_to have_key(:gcc) if @plugin[:languages][:c]
148
+ it "does not set the languages[:c][:gcc] tree up if gcc command fails" do
149
+ allow(plugin).to receive(:shell_out).with("gcc -v").and_raise(Ohai::Exceptions::Exec)
150
+ plugin.run
151
+ expect(plugin[:languages][:c]).not_to have_key(:gcc)
152
+ expect(plugin[:languages][:c]).not_to be_empty # expect other attributes
145
153
  end
146
154
 
147
155
  #glibc
148
- it "should get the glibc x.x.x version from running /lib/libc.so.6" do
149
- expect(@plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_3_4, ""))
150
- @plugin.run
156
+ it "gets the glibc x.x.x version from running /lib/libc.so.6" do
157
+ expect(plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_3_4, ""))
158
+ plugin.run
159
+ end
160
+
161
+ it "sets languages[:c][:glibc][:version]" do
162
+ plugin.run
163
+ expect(plugin.languages[:c][:glibc][:version]).to eql("2.3.4")
151
164
  end
152
165
 
153
- it "should set languages[:c][:glibc][:version]" do
154
- @plugin.run
155
- expect(@plugin.languages[:c][:glibc][:version]).to eql("2.3.4")
166
+ it "sets languages[:c][:glibc][:description]" do
167
+ plugin.run
168
+ expect(plugin.languages[:c][:glibc][:description]).to eql(C_GLIBC_2_3_4.split($/).first)
156
169
  end
157
170
 
158
- it "should set languages[:c][:glibc][:description]" do
159
- @plugin.run
160
- expect(@plugin.languages[:c][:glibc][:description]).to eql(C_GLIBC_2_3_4.split($/).first)
171
+ it "does not set the languages[:c][:glibc] tree up if glibc exits nonzero" do
172
+ allow(plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(1, "", ""))
173
+ allow(plugin).to receive(:shell_out).with("/lib64/libc.so.6").and_return(mock_shell_out(1, "", ""))
174
+ plugin.run
175
+ expect(plugin[:languages][:c]).not_to have_key(:glibc)
161
176
  end
162
177
 
163
- it "should not set the languages[:c][:glibc] tree up if glibc command fails" do
164
- allow(@plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(1, "", ""))
165
- allow(@plugin).to receive(:shell_out).with("/lib64/libc.so.6").and_return(mock_shell_out(1, "", ""))
166
- @plugin.run
167
- expect(@plugin[:languages][:c]).not_to have_key(:glibc) if @plugin[:languages][:c]
178
+ it "does not set the languages[:c][:glibc] tree up if glibc fails" do
179
+ allow(plugin).to receive(:shell_out).with("/lib/libc.so.6").and_raise(Ohai::Exceptions::Exec)
180
+ allow(plugin).to receive(:shell_out).with("/lib64/libc.so.6").and_raise(Ohai::Exceptions::Exec)
181
+ plugin.run
182
+ expect(plugin[:languages][:c]).not_to have_key(:glibc)
183
+ expect(plugin[:languages][:c]).not_to be_empty # expect other attributes
168
184
  end
169
185
 
170
- it "should get the glibc x.x version from running /lib/libc.so.6" do
171
- allow(@plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_5, ""))
172
- expect(@plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_5, ""))
173
- @plugin.run
174
- expect(@plugin.languages[:c][:glibc][:version]).to eql("2.5")
186
+ it "gets the glibc x.x version from running /lib/libc.so.6" do
187
+ allow(plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_5, ""))
188
+ expect(plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_5, ""))
189
+ plugin.run
190
+ expect(plugin.languages[:c][:glibc][:version]).to eql("2.5")
175
191
  end
176
192
 
177
193
  #ms cl
178
- it "should get the cl version from running cl /?" do
179
- expect(@plugin).to receive(:shell_out).with("cl /\?").and_return(mock_shell_out(0, "", C_CL))
180
- @plugin.run
194
+ it "gets the cl version from running cl /?" do
195
+ expect(plugin).to receive(:shell_out).with("cl /\?").and_return(mock_shell_out(0, "", C_CL))
196
+ plugin.run
197
+ end
198
+
199
+ it "sets languages[:c][:cl][:version]" do
200
+ plugin.run
201
+ expect(plugin.languages[:c][:cl][:version]).to eql("14.00.50727.762")
181
202
  end
182
203
 
183
- it "should set languages[:c][:cl][:version]" do
184
- @plugin.run
185
- expect(@plugin.languages[:c][:cl][:version]).to eql("14.00.50727.762")
204
+ it "sets languages[:c][:cl][:description]" do
205
+ plugin.run
206
+ expect(plugin.languages[:c][:cl][:description]).to eql(C_CL.split($/).first)
186
207
  end
187
208
 
188
- it "should set languages[:c][:cl][:description]" do
189
- @plugin.run
190
- expect(@plugin.languages[:c][:cl][:description]).to eql(C_CL.split($/).first)
209
+ it "does not set the languages[:c][:cl] tree up if cl command exits nonzero" do
210
+ allow(plugin).to receive(:shell_out).with("cl /\?").and_return(mock_shell_out(1, "", ""))
211
+ plugin.run
212
+ expect(plugin[:languages][:c]).not_to have_key(:cl)
191
213
  end
192
214
 
193
- it "should not set the languages[:c][:cl] tree up if cl command fails" do
194
- allow(@plugin).to receive(:shell_out).with("cl /\?").and_return(mock_shell_out(1, "", ""))
195
- @plugin.run
196
- expect(@plugin[:languages][:c]).not_to have_key(:cl) if @plugin[:languages][:c]
215
+ it "does not set the languages[:c][:cl] tree up if cl command fails" do
216
+ allow(plugin).to receive(:shell_out).with("cl /\?").and_raise(Ohai::Exceptions::Exec)
217
+ plugin.run
218
+ expect(plugin[:languages][:c]).not_to have_key(:cl)
219
+ expect(plugin[:languages][:c]).not_to be_empty # expect other attributes
197
220
  end
198
221
 
199
222
  #ms vs
200
- it "should get the vs version from running devenv.com /?" do
201
- expect(@plugin).to receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(0, C_VS, ""))
202
- @plugin.run
223
+ it "gets the vs version from running devenv.com /?" do
224
+ expect(plugin).to receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(0, C_VS, ""))
225
+ plugin.run
203
226
  end
204
227
 
205
- it "should set languages[:c][:vs][:version]" do
206
- @plugin.run
207
- expect(@plugin.languages[:c][:vs][:version]).to eql("8.0.50727.762")
228
+ it "sets languages[:c][:vs][:version]" do
229
+ plugin.run
230
+ expect(plugin.languages[:c][:vs][:version]).to eql("8.0.50727.762")
208
231
  end
209
232
 
210
- it "should set languages[:c][:vs][:description]" do
211
- @plugin.run
212
- expect(@plugin.languages[:c][:vs][:description]).to eql(C_VS.split($/)[1])
233
+ it "sets languages[:c][:vs][:description]" do
234
+ plugin.run
235
+ expect(plugin.languages[:c][:vs][:description]).to eql(C_VS.split($/)[1])
213
236
  end
214
237
 
215
- it "should not set the languages[:c][:vs] tree up if devenv command fails" do
216
- allow(@plugin).to receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(1, "", ""))
217
- @plugin.run
218
- expect(@plugin[:languages][:c]).not_to have_key(:vs) if @plugin[:languages][:c]
238
+ it "does not set the languages[:c][:vs] tree up if devenv command exits nonzero" do
239
+ allow(plugin).to receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(1, "", ""))
240
+ plugin.run
241
+ expect(plugin[:languages][:c]).not_to have_key(:vs)
242
+ end
243
+
244
+ it "does not set the languages[:c][:vs] tree up if devenv command fails" do
245
+ allow(plugin).to receive(:shell_out).with("devenv.com /\?").and_raise(Ohai::Exceptions::Exec)
246
+ plugin.run
247
+ expect(plugin[:languages][:c]).not_to have_key(:vs)
248
+ expect(plugin[:languages][:c]).not_to be_empty # expect other attributes
219
249
  end
220
250
 
221
251
  #ibm xlc
222
- it "should get the xlc version from running xlc -qversion" do
223
- expect(@plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC, ""))
224
- @plugin.run
252
+ it "gets the xlc version from running xlc -qversion" do
253
+ expect(plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC, ""))
254
+ plugin.run
255
+ end
256
+
257
+ it "sets languages[:c][:xlc][:version]" do
258
+ plugin.run
259
+ expect(plugin.languages[:c][:xlc][:version]).to eql("9.0")
225
260
  end
226
261
 
227
- it "should set languages[:c][:xlc][:version]" do
228
- @plugin.run
229
- expect(@plugin.languages[:c][:xlc][:version]).to eql("9.0")
262
+ it "sets languages[:c][:xlc][:description]" do
263
+ plugin.run
264
+ expect(plugin.languages[:c][:xlc][:description]).to eql(C_XLC.split($/).first)
230
265
  end
231
266
 
232
- it "should set languages[:c][:xlc][:description]" do
233
- @plugin.run
234
- expect(@plugin.languages[:c][:xlc][:description]).to eql(C_XLC.split($/).first)
267
+ it "does not set the languages[:c][:xlc] tree up if xlc command exits nonzero" do
268
+ allow(plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(1, "", ""))
269
+ plugin.run
270
+ expect(plugin[:languages][:c]).not_to have_key(:xlc)
235
271
  end
236
272
 
237
- it "should not set the languages[:c][:xlc] tree up if xlc command fails" do
238
- allow(@plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(1, "", ""))
239
- @plugin.run
240
- expect(@plugin[:languages][:c]).not_to have_key(:xlc) if @plugin[:languages][:c]
273
+ it "does not set the languages[:c][:xlc] tree up if xlc command fails" do
274
+ allow(plugin).to receive(:shell_out).with("xlc -qversion").and_raise(Ohai::Exceptions::Exec)
275
+ plugin.run
276
+ expect(plugin[:languages][:c]).not_to have_key(:xlc)
277
+ expect(plugin[:languages][:c]).not_to be_empty # expect other attributes
241
278
  end
242
279
 
243
- it "should set the languages[:c][:xlc] tree up if xlc exit status is 249" do
244
- allow(@plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(63744, "", ""))
245
- @plugin.run
246
- expect(@plugin[:languages][:c]).not_to have_key(:xlc) if @plugin[:languages][:c]
280
+ it "sets the languages[:c][:xlc] tree up if xlc exit status is 249" do
281
+ allow(plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(63744, "", ""))
282
+ plugin.run
283
+ expect(plugin[:languages][:c]).not_to have_key(:xlc)
247
284
  end
248
285
 
249
286
  #sun pro
250
- it "should get the cc version from running cc -V -flags" do
251
- expect(@plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", C_SUN))
252
- @plugin.run
287
+ it "gets the cc version from running cc -V -flags" do
288
+ expect(plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", C_SUN))
289
+ plugin.run
253
290
  end
254
291
 
255
- it "should set languages[:c][:sunpro][:version]" do
256
- @plugin.run
257
- expect(@plugin.languages[:c][:sunpro][:version]).to eql("5.8")
292
+ it "sets languages[:c][:sunpro][:version]" do
293
+ plugin.run
294
+ expect(plugin.languages[:c][:sunpro][:version]).to eql("5.8")
258
295
  end
259
296
 
260
- it "should set languages[:c][:sunpro][:description]" do
261
- @plugin.run
262
- expect(@plugin.languages[:c][:sunpro][:description]).to eql(C_SUN.chomp)
297
+ it "sets languages[:c][:sunpro][:description]" do
298
+ plugin.run
299
+ expect(plugin.languages[:c][:sunpro][:description]).to eql(C_SUN.chomp)
263
300
  end
264
301
 
265
- it "should not set the languages[:c][:sunpro] tree up if cc command fails" do
266
- allow(@plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(1, "", ""))
267
- @plugin.run
268
- expect(@plugin[:languages][:c]).not_to have_key(:sunpro) if @plugin[:languages][:c]
302
+ it "does not set the languages[:c][:sunpro] tree up if cc command exits nonzero" do
303
+ allow(plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(1, "", ""))
304
+ plugin.run
305
+ expect(plugin[:languages][:c]).not_to have_key(:sunpro)
269
306
  end
270
307
 
271
- it "should not set the languages[:c][:sunpro] tree if the corresponding cc command fails on linux" do
308
+ it "does not set the languages[:c][:sunpro] tree up if cc command fails" do
309
+ allow(plugin).to receive(:shell_out).with("cc -V -flags").and_raise(Ohai::Exceptions::Exec)
310
+ plugin.run
311
+ expect(plugin[:languages][:c]).not_to have_key(:sunpro)
312
+ expect(plugin[:languages][:c]).not_to be_empty # expect other attributes
313
+ end
314
+
315
+ it "does not set the languages[:c][:sunpro] tree if the corresponding cc command fails on linux" do
272
316
  fedora_error_message = "cc: error trying to exec 'i686-redhat-linux-gcc--flags': execvp: No such file or directory"
273
317
 
274
- allow(@plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", fedora_error_message))
275
- @plugin.run
276
- expect(@plugin[:languages][:c]).not_to have_key(:sunpro) if @plugin[:languages][:c]
318
+ allow(plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", fedora_error_message))
319
+ plugin.run
320
+ expect(plugin[:languages][:c]).not_to have_key(:sunpro)
277
321
  end
278
322
 
279
- it "should not set the languages[:c][:sunpro] tree if the corresponding cc command fails on hpux" do
323
+ it "does not set the languages[:c][:sunpro] tree if the corresponding cc command fails on hpux" do
280
324
  hpux_error_message = "cc: warning 901: unknown option: `-flags': use +help for online documentation.\ncc: HP C/aC++ B3910B A.06.25 [Nov 30 2009]"
281
- allow(@plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", hpux_error_message))
282
- @plugin.run
283
- expect(@plugin[:languages][:c]).not_to have_key(:sunpro) if @plugin[:languages][:c]
325
+ allow(plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", hpux_error_message))
326
+ plugin.run
327
+ expect(plugin[:languages][:c]).not_to have_key(:sunpro)
284
328
  end
285
329
 
286
330
  #hpux cc
287
- it "should get the cc version from running what cc" do
288
- expect(@plugin).to receive(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(0, C_HPUX, ""))
289
- @plugin.run
331
+ it "gets the cc version from running what cc" do
332
+ expect(plugin).to receive(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(0, C_HPUX, ""))
333
+ plugin.run
334
+ end
335
+
336
+ it "sets languages[:c][:hpcc][:version]" do
337
+ plugin.run
338
+ expect(plugin.languages[:c][:hpcc][:version]).to eql("B.11.11.16")
290
339
  end
291
340
 
292
- it "should set languages[:c][:hpcc][:version]" do
293
- @plugin.run
294
- expect(@plugin.languages[:c][:hpcc][:version]).to eql("B.11.11.16")
341
+ it "sets languages[:c][:hpcc][:description]" do
342
+ plugin.run
343
+ expect(plugin.languages[:c][:hpcc][:description]).to eql(C_HPUX.split($/)[3].strip)
295
344
  end
296
345
 
297
- it "should set languages[:c][:hpcc][:description]" do
298
- @plugin.run
299
- expect(@plugin.languages[:c][:hpcc][:description]).to eql(C_HPUX.split($/)[3].strip)
346
+ it "does not set the languages[:c][:hpcc] tree up if cc command exits nonzero" do
347
+ allow(plugin).to receive(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(1, "", ""))
348
+ plugin.run
349
+ expect(plugin[:languages][:c]).not_to have_key(:hpcc)
300
350
  end
301
351
 
302
- it "should not set the languages[:c][:hpcc] tree up if cc command fails" do
303
- allow(@plugin).to receive(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(1, "", ""))
304
- @plugin.run
305
- expect(@plugin[:languages][:c]).not_to have_key(:hpcc) if @plugin[:languages][:c]
352
+ it "does not set the languages[:c][:hpcc] tree up if cc command fails" do
353
+ allow(plugin).to receive(:shell_out).with("what /opt/ansic/bin/cc").and_raise(Ohai::Exceptions::Exec)
354
+ plugin.run
355
+ expect(plugin[:languages][:c]).not_to have_key(:hpcc)
356
+ expect(plugin[:languages][:c]).not_to be_empty # expect other attributes
306
357
  end
307
358
 
308
359
  end