ohai 15.2.5 → 15.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ohai/application.rb +2 -2
  3. data/lib/ohai/mixin/dmi_decode.rb +4 -1
  4. data/lib/ohai/plugins/linux/sysctl.rb +38 -0
  5. data/lib/ohai/plugins/linux/virtualization.rb +11 -10
  6. data/lib/ohai/plugins/openstack.rb +8 -3
  7. data/lib/ohai/plugins/passwd.rb +4 -0
  8. data/lib/ohai/version.rb +1 -1
  9. data/spec/functional/application_spec.rb +5 -5
  10. data/spec/functional/loader_spec.rb +2 -2
  11. data/spec/functional/plugins/powershell_spec.rb +11 -5
  12. data/spec/functional/plugins/root_group_spec.rb +1 -1
  13. data/spec/functional/plugins/windows/uptime_spec.rb +3 -3
  14. data/spec/ohai_spec.rb +1 -1
  15. data/spec/spec_helper.rb +8 -8
  16. data/spec/support/integration_helper.rb +3 -3
  17. data/spec/unit/application_spec.rb +5 -5
  18. data/spec/unit/dsl/plugin_spec.rb +8 -7
  19. data/spec/unit/mixin/command_spec.rb +2 -2
  20. data/spec/unit/mixin/dmi_decode.rb +8 -1
  21. data/spec/unit/plugins/abort_spec.rb +4 -4
  22. data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
  23. data/spec/unit/plugins/aix/filesystem_spec.rb +1 -1
  24. data/spec/unit/plugins/aix/hostname_spec.rb +2 -2
  25. data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
  26. data/spec/unit/plugins/aix/memory_spec.rb +5 -5
  27. data/spec/unit/plugins/aix/network_spec.rb +4 -1
  28. data/spec/unit/plugins/aix/platform_spec.rb +4 -4
  29. data/spec/unit/plugins/aix/uptime_spec.rb +3 -3
  30. data/spec/unit/plugins/aix/virtualization_spec.rb +1 -1
  31. data/spec/unit/plugins/azure_spec.rb +8 -8
  32. data/spec/unit/plugins/bsd/filesystem_spec.rb +17 -16
  33. data/spec/unit/plugins/bsd/virtualization_spec.rb +1 -1
  34. data/spec/unit/plugins/c_spec.rb +6 -5
  35. data/spec/unit/plugins/chef_spec.rb +2 -2
  36. data/spec/unit/plugins/cloud_spec.rb +4 -4
  37. data/spec/unit/plugins/darwin/cpu_spec.rb +11 -11
  38. data/spec/unit/plugins/darwin/filesystem_spec.rb +14 -13
  39. data/spec/unit/plugins/darwin/hardware_spec.rb +2 -1
  40. data/spec/unit/plugins/darwin/hostname_spec.rb +3 -3
  41. data/spec/unit/plugins/darwin/kernel_spec.rb +5 -5
  42. data/spec/unit/plugins/darwin/memory_spec.rb +5 -5
  43. data/spec/unit/plugins/darwin/network_spec.rb +3 -3
  44. data/spec/unit/plugins/darwin/platform_spec.rb +9 -9
  45. data/spec/unit/plugins/darwin/virtualization_spec.rb +10 -10
  46. data/spec/unit/plugins/digital_ocean_spec.rb +14 -12
  47. data/spec/unit/plugins/dmi_spec.rb +1 -1
  48. data/spec/unit/plugins/docker_spec.rb +2 -2
  49. data/spec/unit/plugins/ec2_spec.rb +41 -30
  50. data/spec/unit/plugins/elixir_spec.rb +2 -2
  51. data/spec/unit/plugins/erlang_spec.rb +1 -1
  52. data/spec/unit/plugins/eucalyptus_spec.rb +17 -13
  53. data/spec/unit/plugins/fail_spec.rb +15 -15
  54. data/spec/unit/plugins/freebsd/cpu_spec.rb +2 -2
  55. data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
  56. data/spec/unit/plugins/freebsd/kernel_spec.rb +2 -2
  57. data/spec/unit/plugins/freebsd/platform_spec.rb +3 -3
  58. data/spec/unit/plugins/gce_spec.rb +9 -7
  59. data/spec/unit/plugins/go_spec.rb +2 -2
  60. data/spec/unit/plugins/groovy_spec.rb +1 -1
  61. data/spec/unit/plugins/haskell_spec.rb +10 -10
  62. data/spec/unit/plugins/hostname_spec.rb +15 -14
  63. data/spec/unit/plugins/init_package_spec.rb +4 -4
  64. data/spec/unit/plugins/java_spec.rb +7 -3
  65. data/spec/unit/plugins/joyent_spec.rb +4 -4
  66. data/spec/unit/plugins/kernel_spec.rb +1 -1
  67. data/spec/unit/plugins/linux/block_device_spec.rb +2 -2
  68. data/spec/unit/plugins/linux/cpu_spec.rb +9 -8
  69. data/spec/unit/plugins/linux/filesystem_spec.rb +36 -35
  70. data/spec/unit/plugins/linux/fips_spec.rb +7 -5
  71. data/spec/unit/plugins/linux/hostname_spec.rb +4 -4
  72. data/spec/unit/plugins/linux/hostnamectl_spec.rb +3 -3
  73. data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
  74. data/spec/unit/plugins/linux/lsb_spec.rb +18 -18
  75. data/spec/unit/plugins/linux/lspci_spec.rb +2 -1
  76. data/spec/unit/plugins/linux/machineid_spec.rb +3 -3
  77. data/spec/unit/plugins/linux/mdadm_spec.rb +13 -13
  78. data/spec/unit/plugins/linux/memory_spec.rb +39 -39
  79. data/spec/unit/plugins/linux/network_spec.rb +20 -19
  80. data/spec/unit/plugins/linux/platform_spec.rb +60 -57
  81. data/spec/unit/plugins/linux/sessions_spec.rb +3 -3
  82. data/spec/unit/plugins/linux/sysctl_spec.rb +53 -0
  83. data/spec/unit/plugins/linux/systemd_paths_spec.rb +3 -3
  84. data/spec/unit/plugins/linux/uptime_spec.rb +5 -5
  85. data/spec/unit/plugins/linux/virtualization_spec.rb +4 -4
  86. data/spec/unit/plugins/lua_spec.rb +1 -1
  87. data/spec/unit/plugins/mono_spec.rb +1 -1
  88. data/spec/unit/plugins/netbsd/hostname_spec.rb +3 -3
  89. data/spec/unit/plugins/netbsd/kernel_spec.rb +2 -2
  90. data/spec/unit/plugins/netbsd/platform_spec.rb +3 -3
  91. data/spec/unit/plugins/network_spec.rb +3 -3
  92. data/spec/unit/plugins/nodejs_spec.rb +1 -1
  93. data/spec/unit/plugins/ohai_spec.rb +2 -2
  94. data/spec/unit/plugins/ohai_time_spec.rb +4 -4
  95. data/spec/unit/plugins/openbsd/hostname_spec.rb +3 -3
  96. data/spec/unit/plugins/openbsd/kernel_spec.rb +2 -2
  97. data/spec/unit/plugins/openbsd/platform_spec.rb +2 -2
  98. data/spec/unit/plugins/openstack_spec.rb +13 -8
  99. data/spec/unit/plugins/os_spec.rb +12 -12
  100. data/spec/unit/plugins/packages_spec.rb +10 -7
  101. data/spec/unit/plugins/passwd_spec.rb +18 -19
  102. data/spec/unit/plugins/perl_spec.rb +1 -1
  103. data/spec/unit/plugins/php_spec.rb +1 -1
  104. data/spec/unit/plugins/platform_spec.rb +7 -7
  105. data/spec/unit/plugins/powershell_spec.rb +1 -1
  106. data/spec/unit/plugins/rackspace_spec.rb +25 -20
  107. data/spec/unit/plugins/root_group_spec.rb +14 -10
  108. data/spec/unit/plugins/ruby_spec.rb +2 -2
  109. data/spec/unit/plugins/rust_spec.rb +3 -3
  110. data/spec/unit/plugins/scala_spec.rb +2 -2
  111. data/spec/unit/plugins/scaleway_spec.rb +14 -12
  112. data/spec/unit/plugins/scsi_spec.rb +2 -1
  113. data/spec/unit/plugins/shard_spec.rb +18 -16
  114. data/spec/unit/plugins/solaris2/cpu_spec.rb +29 -29
  115. data/spec/unit/plugins/solaris2/dmi_spec.rb +4 -4
  116. data/spec/unit/plugins/solaris2/filesystem.rb +3 -3
  117. data/spec/unit/plugins/solaris2/hostname_spec.rb +2 -2
  118. data/spec/unit/plugins/solaris2/kernel_spec.rb +4 -4
  119. data/spec/unit/plugins/solaris2/memory_spec.rb +4 -4
  120. data/spec/unit/plugins/solaris2/platform_spec.rb +9 -9
  121. data/spec/unit/plugins/solaris2/virtualization_spec.rb +6 -6
  122. data/spec/unit/plugins/ssh_host_keys_spec.rb +4 -1
  123. data/spec/unit/plugins/sysconf_spec.rb +2 -2
  124. data/spec/unit/plugins/timezone_spec.rb +2 -2
  125. data/spec/unit/plugins/virtualbox_spec.rb +10 -10
  126. data/spec/unit/plugins/vmware_spec.rb +4 -4
  127. data/spec/unit/plugins/windows/cpu_spec.rb +13 -13
  128. data/spec/unit/plugins/windows/filesystem_spec.rb +1 -1
  129. data/spec/unit/plugins/windows/fips_spec.rb +7 -5
  130. data/spec/unit/plugins/windows/kernel_spec.rb +1 -1
  131. data/spec/unit/plugins/windows/memory_spec.rb +4 -4
  132. data/spec/unit/plugins/windows/network_spec.rb +1 -1
  133. data/spec/unit/plugins/windows/system_enclosure_spec.rb +2 -2
  134. data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
  135. data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
  136. data/spec/unit/plugins/zpools_spec.rb +2 -0
  137. data/spec/unit/provides_map_spec.rb +18 -18
  138. data/spec/unit/runner_spec.rb +29 -29
  139. data/spec/unit/system_spec.rb +13 -13
  140. data/spec/unit/util/file_helper_spec.rb +1 -1
  141. data/spec/unit/util/ip_helper_spec.rb +6 -6
  142. metadata +4 -2
@@ -33,7 +33,7 @@ describe Ohai::System, "plugin packages" do
33
33
  File.read(File.join(SPEC_PLUGIN_PATH, "dpkg-query.output"))
34
34
  end
35
35
 
36
- before(:each) do
36
+ before do
37
37
  allow(plugin).to receive(:collect_os).and_return(:linux)
38
38
  allow(plugin).to receive(:shell_out)
39
39
  .with("dpkg-query -W -f='#{format}'")
@@ -72,7 +72,7 @@ describe Ohai::System, "plugin packages" do
72
72
  File.read(File.join(SPEC_PLUGIN_PATH, "rpmquery.output"))
73
73
  end
74
74
 
75
- before(:each) do
75
+ before do
76
76
  allow(plugin).to receive(:collect_os).and_return(:linux)
77
77
  allow(plugin).to receive(:shell_out).with("rpm -qa --qf '#{format}'").and_return(mock_shell_out(0, stdout, ""))
78
78
  plugin.run
@@ -133,7 +133,7 @@ describe Ohai::System, "plugin packages" do
133
133
  File.read(File.join(SPEC_PLUGIN_PATH, "pacman.output"))
134
134
  end
135
135
 
136
- before(:each) do
136
+ before do
137
137
  allow(plugin).to receive(:collect_os).and_return(:linux)
138
138
  allow(plugin).to receive(:shell_out).with("LANG=C pacman -Qi").and_return(mock_shell_out(0, stdout, ""))
139
139
  plugin.run
@@ -209,7 +209,7 @@ describe Ohai::System, "plugin packages" do
209
209
  end
210
210
  end
211
211
 
212
- before(:each) do
212
+ before do
213
213
  allow(plugin).to receive(:collect_os).and_return(:windows)
214
214
  allow(win_reg_double).to receive(:open).with(win_reg_keys[0]).and_return(win_reg_output[0])
215
215
  allow(win_reg_double).to receive(:open).with(win_reg_keys[1]).and_return(win_reg_output[1])
@@ -222,6 +222,7 @@ describe Ohai::System, "plugin packages" do
222
222
  allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with('Software\Microsoft\Windows\CurrentVersion\Uninstall', i386_reg_type).and_yield(win_reg_double)
223
223
  allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with('Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall', i386_reg_type).and_yield(win_reg_double)
224
224
  end
225
+
225
226
  it_behaves_like "windows_package_plugin"
226
227
  end
227
228
 
@@ -231,6 +232,7 @@ describe Ohai::System, "plugin packages" do
231
232
  allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with('Software\Microsoft\Windows\CurrentVersion\Uninstall', x86_64_reg_type).and_yield(win_reg_double)
232
233
  allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with('Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall', x86_64_reg_type).and_yield(win_reg_double)
233
234
  end
235
+
234
236
  it_behaves_like "windows_package_plugin"
235
237
  end
236
238
 
@@ -240,6 +242,7 @@ describe Ohai::System, "plugin packages" do
240
242
  allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with('Software\Microsoft\Windows\CurrentVersion\Uninstall', Win32::Registry::KEY_READ).and_yield(win_reg_double)
241
243
  allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with('Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall', Win32::Registry::KEY_READ).and_yield(win_reg_double)
242
244
  end
245
+
243
246
  it_behaves_like "windows_package_plugin"
244
247
  end
245
248
  end
@@ -251,7 +254,7 @@ describe Ohai::System, "plugin packages" do
251
254
  File.read(File.join(SPEC_PLUGIN_PATH, "lslpp.output"))
252
255
  end
253
256
 
254
- before(:each) do
257
+ before do
255
258
  allow(plugin).to receive(:collect_os).and_return(:aix)
256
259
  allow(plugin).to receive(:shell_out).with("lslpp -L -q -c").and_return(mock_shell_out(0, stdout, ""))
257
260
  plugin.run
@@ -280,7 +283,7 @@ describe Ohai::System, "plugin packages" do
280
283
  File.read(File.join(SPEC_PLUGIN_PATH, "pkg-query.output"))
281
284
  end
282
285
 
283
- before(:each) do
286
+ before do
284
287
  allow(plugin).to receive(:collect_os).and_return(:freebsd)
285
288
  allow(plugin).to receive(:shell_out).with('pkg query -a "%n %v"').and_return(mock_shell_out(0, stdout, ""))
286
289
  plugin.run
@@ -309,7 +312,7 @@ describe Ohai::System, "plugin packages" do
309
312
  File.read(File.join(SPEC_PLUGIN_PATH, "pkginfo.output"))
310
313
  end
311
314
 
312
- before(:each) do
315
+ before do
313
316
  allow(plugin).to receive(:collect_os).and_return(:solaris2)
314
317
  allow(plugin).to receive(:shell_out).with("pkg list -H").and_return(mock_shell_out(0, pkglist_output, ""))
315
318
  allow(plugin).to receive(:shell_out).with("pkginfo -l").and_return(mock_shell_out(0, pkginfo_output, ""))
@@ -1,5 +1,6 @@
1
1
  #
2
2
  # License:: Apache License, Version 2.0
3
+ # Copyright:: 2019 Chef Software, Inc.
3
4
  #
4
5
  # Licensed under the Apache License, Version 2.0 (the "License");
5
6
  # you may not use this file except in compliance with the License.
@@ -17,40 +18,38 @@
17
18
  require "spec_helper"
18
19
 
19
20
  describe Ohai::System, "plugin etc", :unix_only do
20
- before(:each) do
21
- @plugin = get_plugin("passwd")
22
- end
21
+ let(:plugin) { get_plugin("passwd") }
23
22
 
24
23
  PasswdEntry = Struct.new(:name, :uid, :gid, :dir, :shell, :gecos)
25
24
  GroupEntry = Struct.new(:name, :gid, :mem)
26
25
 
27
- it "should include a list of all users" do
26
+ it "includes a list of all users" do
28
27
  expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, "/root", "/bin/zsh", "BOFH"))
29
28
  .and_yield(PasswdEntry.new("www", 800, 800, "/var/www", "/bin/false", "Serving the web since 1970"))
30
- @plugin.run
31
- expect(@plugin[:etc][:passwd]["root"]).to eq(Mash.new(shell: "/bin/zsh", gecos: "BOFH", gid: 1, uid: 1, dir: "/root"))
32
- expect(@plugin[:etc][:passwd]["www"]).to eq(Mash.new(shell: "/bin/false", gecos: "Serving the web since 1970", gid: 800, uid: 800, dir: "/var/www"))
29
+ plugin.run
30
+ expect(plugin[:etc][:passwd]["root"]).to eq(Mash.new(shell: "/bin/zsh", gecos: "BOFH", gid: 1, uid: 1, dir: "/root"))
31
+ expect(plugin[:etc][:passwd]["www"]).to eq(Mash.new(shell: "/bin/false", gecos: "Serving the web since 1970", gid: 800, uid: 800, dir: "/var/www"))
33
32
  end
34
33
 
35
- it "should ignore duplicate users" do
34
+ it "ignores duplicate users" do
36
35
  expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, "/root", "/bin/zsh", "BOFH"))
37
36
  .and_yield(PasswdEntry.new("root", 1, 1, "/", "/bin/false", "I do not belong"))
38
- @plugin.run
39
- expect(@plugin[:etc][:passwd]["root"]).to eq(Mash.new(shell: "/bin/zsh", gecos: "BOFH", gid: 1, uid: 1, dir: "/root"))
37
+ plugin.run
38
+ expect(plugin[:etc][:passwd]["root"]).to eq(Mash.new(shell: "/bin/zsh", gecos: "BOFH", gid: 1, uid: 1, dir: "/root"))
40
39
  end
41
40
 
42
- it "should set the current user" do
41
+ it "sets the current user" do
43
42
  expect(Process).to receive(:euid).and_return("31337")
44
43
  expect(Etc).to receive(:getpwuid).and_return(PasswdEntry.new("chef", 31337, 31337, "/home/chef", "/bin/ksh", "Julia Child"))
45
- @plugin.run
46
- expect(@plugin[:current_user]).to eq("chef")
44
+ plugin.run
45
+ expect(plugin[:current_user]).to eq("chef")
47
46
  end
48
47
 
49
- it "should set the available groups" do
48
+ it "sets the available groups" do
50
49
  expect(Etc).to receive(:group).and_yield(GroupEntry.new("admin", 100, %w{root chef})).and_yield(GroupEntry.new("www", 800, %w{www deploy}))
51
- @plugin.run
52
- expect(@plugin[:etc][:group]["admin"]).to eq(Mash.new(gid: 100, members: %w{root chef}))
53
- expect(@plugin[:etc][:group]["www"]).to eq(Mash.new(gid: 800, members: %w{www deploy}))
50
+ plugin.run
51
+ expect(plugin[:etc][:group]["admin"]).to eq(Mash.new(gid: 100, members: %w{root chef}))
52
+ expect(plugin[:etc][:group]["www"]).to eq(Mash.new(gid: 800, members: %w{www deploy}))
54
53
  end
55
54
 
56
55
  if "".respond_to?(:force_encoding)
@@ -58,8 +57,8 @@ describe Ohai::System, "plugin etc", :unix_only do
58
57
  fields = ["root", 1, 1, "/root", "/bin/zsh", "BOFH"]
59
58
  fields.each { |f| f.force_encoding(Encoding::ASCII_8BIT) if f.respond_to?(:force_encoding) }
60
59
  allow(Etc).to receive(:passwd).and_yield(PasswdEntry.new(*fields))
61
- @plugin.run
62
- root = @plugin[:etc][:passwd]["root"]
60
+ plugin.run
61
+ root = plugin[:etc][:passwd]["root"]
63
62
  expect(root["gecos"].encoding).to eq(Encoding.default_external)
64
63
  end
65
64
  end
@@ -22,7 +22,7 @@ require "spec_helper"
22
22
  describe Ohai::System, "plugin perl" do
23
23
  let(:plugin) { get_plugin("perl") }
24
24
 
25
- before(:each) do
25
+ before do
26
26
  plugin[:languages] = Mash.new
27
27
  @stdout = "version='5.8.8';#{$/}archname='darwin-thread-multi-2level';"
28
28
  allow(plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
@@ -23,7 +23,7 @@ require "spec_helper"
23
23
  describe Ohai::System, "plugin php" do
24
24
  let(:plugin) { get_plugin("php") }
25
25
 
26
- before(:each) do
26
+ before do
27
27
  plugin[:languages] = Mash.new
28
28
  @stdout = <<~OUT
29
29
  PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)
@@ -19,45 +19,45 @@
19
19
  require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "plugin platform" do
22
- before(:each) do
22
+ before do
23
23
  @plugin = get_plugin("platform")
24
24
  allow(@plugin).to receive(:collect_os).and_return(:default)
25
25
  @plugin[:os] = "monkey"
26
26
  @plugin[:os_version] = "poop"
27
27
  end
28
28
 
29
- it "should set the platform and platform family to the os if it was not set earlier" do
29
+ it "sets the platform and platform family to the os if it was not set earlier" do
30
30
  @plugin.run
31
31
  expect(@plugin[:platform]).to eql("monkey")
32
32
  expect(@plugin[:platform_family]).to eql("monkey")
33
33
  end
34
34
 
35
- it "should not set the platform to the os if it was set earlier" do
35
+ it "does not set the platform to the os if it was set earlier" do
36
36
  @plugin[:platform] = "lars"
37
37
  @plugin.run
38
38
  expect(@plugin[:platform]).to eql("lars")
39
39
  end
40
40
 
41
- it "should set the platform_family to the platform if platform was set earlier but not platform_family" do
41
+ it "sets the platform_family to the platform if platform was set earlier but not platform_family" do
42
42
  @plugin[:platform] = "lars"
43
43
  @plugin[:platform_family] = "jack"
44
44
  @plugin.run
45
45
  expect(@plugin[:platform_family]).to eql("jack")
46
46
  end
47
47
 
48
- it "should not set the platform_family if the platform_family was set earlier." do
48
+ it "does not set the platform_family if the platform_family was set earlier." do
49
49
  @plugin[:platform] = "lars"
50
50
  @plugin.run
51
51
  expect(@plugin[:platform]).to eql("lars")
52
52
  expect(@plugin[:platform_family]).to eql("lars")
53
53
  end
54
54
 
55
- it "should set the platform_version to the os_version if it was not set earlier" do
55
+ it "sets the platform_version to the os_version if it was not set earlier" do
56
56
  @plugin.run
57
57
  expect(@plugin[:os_version]).to eql("poop")
58
58
  end
59
59
 
60
- it "should not set the platform to the os if it was set earlier" do
60
+ it "does not set the platform to the os if it was set earlier" do
61
61
  @plugin[:platform_version] = "ulrich"
62
62
  @plugin.run
63
63
  expect(@plugin[:platform_version]).to eql("ulrich")
@@ -24,7 +24,7 @@ describe Ohai::System, "plugin powershell" do
24
24
  stub_const("::RbConfig::CONFIG", { "host_os" => "windows" })
25
25
  end
26
26
 
27
- before(:each) do
27
+ before do
28
28
  plugin[:languages] = Mash.new
29
29
  end
30
30
 
@@ -21,7 +21,7 @@ require "spec_helper"
21
21
  describe Ohai::System, "plugin rackspace" do
22
22
  let(:plugin) { get_plugin("rackspace") }
23
23
 
24
- before(:each) do
24
+ before do
25
25
  allow(Resolv).to receive(:getname).and_return("1.2.3.4")
26
26
 
27
27
  plugin[:hostname] = "katie"
@@ -184,15 +184,15 @@ describe Ohai::System, "plugin rackspace" do
184
184
  end
185
185
 
186
186
  describe "with rackspace hint file" do
187
- it_behaves_like "rackspace"
188
-
189
- before(:each) do
187
+ before do
190
188
  allow(Resolv).to receive(:getname).and_raise(Resolv::ResolvError)
191
189
  allow(File).to receive(:exist?).with("/etc/resolv.conf").and_return(true)
192
190
  allow(File).to receive(:read).with("/etc/resolv.conf").and_return("")
193
191
  allow(plugin).to receive(:hint?).with("rackspace").and_return(true)
194
192
  end
195
193
 
194
+ it_behaves_like "rackspace"
195
+
196
196
  describe "with no public interfaces (empty eth0)" do
197
197
  before do
198
198
  # unset public (eth0) addresses
@@ -216,55 +216,60 @@ describe Ohai::System, "plugin rackspace" do
216
216
  end
217
217
 
218
218
  describe "without hint file" do
219
- it_behaves_like "!rackspace"
220
-
221
- before(:each) do
219
+ before do
222
220
  allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
223
221
  end
222
+
223
+ it_behaves_like "!rackspace"
224
+
224
225
  end
225
226
 
226
227
  describe "with Rackspace windows manufacturer data" do
228
+ before do
229
+ allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
230
+ allow(plugin).to receive(:has_rackspace_manufacturer?).and_return(true)
231
+ end
232
+
227
233
  it "has rackspace attribute" do
228
234
  plugin.run
229
235
  expect(plugin[:rackspace]).not_to be_nil
230
236
  end
231
237
 
232
- before(:each) do
233
- allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
234
- allow(plugin).to receive(:has_rackspace_manufacturer?).and_return(true)
235
- end
236
238
  end
237
239
 
238
240
  describe "xenstore provider returns rackspace" do
239
- it_behaves_like "rackspace"
240
-
241
- before(:each) do
241
+ before do
242
242
  stdout = "Rackspace\n"
243
243
  allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
244
244
  allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
245
245
  end
246
+
247
+ it_behaves_like "rackspace"
248
+
246
249
  end
247
250
 
248
251
  describe "xenstore provider does not return rackspace" do
249
- it_behaves_like "!rackspace"
250
-
251
- before(:each) do
252
+ before do
252
253
  allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
253
254
  stdout = "cumulonimbus\n"
254
255
  allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
255
256
  end
256
- end
257
257
 
258
- describe "xenstore provider does not exist" do
259
258
  it_behaves_like "!rackspace"
260
259
 
261
- before(:each) do
260
+ end
261
+
262
+ describe "xenstore provider does not exist" do
263
+ before do
262
264
  allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
263
265
  allow(plugin)
264
266
  .to receive(:shell_out)
265
267
  .with("xenstore-read vm-data/provider_data/provider")
266
268
  .and_raise(Ohai::Exceptions::Exec)
267
269
  end
270
+
271
+ it_behaves_like "!rackspace"
272
+
268
273
  end
269
274
 
270
275
  describe "when private networks shell out fails" do
@@ -19,12 +19,12 @@
19
19
  require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "root_group" do
22
- before(:each) do
22
+ before do
23
23
  @plugin = get_plugin("root_group")
24
24
  end
25
25
 
26
26
  describe "unix platform", :unix_only do
27
- before(:each) do
27
+ before do
28
28
  # this is deeply intertwingled. unfortunately, the law of demeter
29
29
  # apparently didn't apply to this api. we're just trying to fake
30
30
  # Etc.getgrgid(Etc.getpwnam('root').gid).name
@@ -36,30 +36,33 @@ describe Ohai::System, "root_group" do
36
36
  end
37
37
 
38
38
  describe "with wheel group" do
39
- before(:each) do
39
+ before do
40
40
  allow(@grgid).to receive(:name).and_return("wheel")
41
41
  end
42
- it "should have a root_group of wheel" do
42
+
43
+ it "has a root_group of wheel" do
43
44
  @plugin.run
44
45
  expect(@plugin[:root_group]).to eq("wheel")
45
46
  end
46
47
  end
47
48
 
48
49
  describe "with root group" do
49
- before(:each) do
50
+ before do
50
51
  allow(@grgid).to receive(:name).and_return("root")
51
52
  end
52
- it "should have a root_group of root" do
53
+
54
+ it "has a root_group of root" do
53
55
  @plugin.run
54
56
  expect(@plugin[:root_group]).to eq("root")
55
57
  end
56
58
  end
57
59
 
58
60
  describe "platform aix with system group" do
59
- before(:each) do
61
+ before do
60
62
  allow(@grgid).to receive(:name).and_return("system")
61
63
  end
62
- it "should have a root_group of system" do
64
+
65
+ it "has a root_group of system" do
63
66
  @plugin.run
64
67
  expect(@plugin[:root_group]).to eq("system")
65
68
  end
@@ -70,11 +73,12 @@ describe Ohai::System, "root_group" do
70
73
 
71
74
  let(:wmi) { double("wmi", { query: "" }) }
72
75
 
73
- before(:each) do
76
+ before do
74
77
  allow(WmiLite::Wmi).to receive(:new).and_return(wmi)
75
78
  allow(@plugin).to receive(:collect_os).and_return(:windows)
76
79
  end
77
- it "should return the group Administrators" do
80
+
81
+ it "returns the group Administrators" do
78
82
  expect(wmi)
79
83
  .to receive(:query)
80
84
  .with("select * from Win32_Group where sid like 'S-1-5-32-544' and LocalAccount=True")
@@ -30,7 +30,7 @@ describe Ohai::System, "plugin ruby" do
30
30
  @ruby_ohai_data_pristine = @plugin[:languages][:ruby]
31
31
  end
32
32
 
33
- before(:each) do
33
+ before do
34
34
  @ruby_ohai_data = @ruby_ohai_data_pristine.dup
35
35
  end
36
36
 
@@ -52,7 +52,7 @@ describe Ohai::System, "plugin ruby" do
52
52
  end.find { |bin| ::File.exist? bin },
53
53
  ruby_bin: ruby_bin,
54
54
  }.each do |attribute, value|
55
- it "should have #{attribute} set to #{value.inspect}" do
55
+ it "has #{attribute} set to #{value.inspect}" do
56
56
  expect(@ruby_ohai_data[attribute]).to eql(value)
57
57
  end
58
58
  end
@@ -25,17 +25,17 @@ describe Ohai::System, "plugin rust" do
25
25
  plugin
26
26
  end
27
27
 
28
- it "should get the rust version" do
28
+ it "gets the rust version" do
29
29
  expect(plugin).to receive(:shell_out).with("rustc --version").and_return(mock_shell_out(0, stdout, ""))
30
30
  plugin.run
31
31
  end
32
32
 
33
- it "should set languages[:rust][:version]" do
33
+ it "sets languages[:rust][:version]" do
34
34
  plugin.run
35
35
  expect(plugin.languages[:rust][:version]).to eql("1.0.0-nightly")
36
36
  end
37
37
 
38
- it "should not set the languages[:rust] if rust command fails" do
38
+ it "does not set the languages[:rust] if rust command fails" do
39
39
  allow(plugin).to receive(:shell_out).with("rustc --version").and_return(mock_shell_out(1, stdout, ""))
40
40
  plugin.run
41
41
  expect(plugin.languages).not_to have_key(:rust)