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
@@ -155,7 +155,7 @@ shared_examples "Ohai::DSL::Plugin" do
155
155
  end
156
156
 
157
157
  context "when getting attributes" do
158
- before(:each) do
158
+ before do
159
159
  plugin.set_attribute(:tea, "is soothing")
160
160
  end
161
161
 
@@ -170,7 +170,7 @@ shared_examples "Ohai::DSL::Plugin" do
170
170
  end
171
171
 
172
172
  describe "a top-level attribute" do
173
- before(:each) do
173
+ before do
174
174
  plugin.set_attribute(:tea, "is soothing")
175
175
  end
176
176
 
@@ -196,7 +196,7 @@ shared_examples "Ohai::DSL::Plugin" do
196
196
  end
197
197
 
198
198
  describe "a nested attribute" do
199
- before(:each) do
199
+ before do
200
200
  plugin.set_attribute(:the_monarch, { arch_rival: "dr_venture" })
201
201
  end
202
202
 
@@ -304,7 +304,7 @@ shared_examples "Ohai::DSL::Plugin" do
304
304
  end
305
305
 
306
306
  describe "a nested attribute" do
307
- before(:each) do
307
+ before do
308
308
  plugin.set_attribute(:the_monarch, { arch_rival: "dr_venture" })
309
309
  end
310
310
 
@@ -383,9 +383,10 @@ end
383
383
 
384
384
  describe Ohai::DSL::Plugin::VersionVII do
385
385
  let(:logger) { Ohai::Log }
386
+
386
387
  it "does not modify the plugin name when the plugin is named correctly" do
387
388
  plugin = Ohai.plugin(:FunkyVALIDpluginName) {}.new({}, logger)
388
- expect(plugin.name).to eql(:FunkyVALIDpluginName)
389
+ expect(plugin.name).to be(:FunkyVALIDpluginName)
389
390
  end
390
391
 
391
392
  describe "when the plugin is named incorrectly" do
@@ -411,7 +412,7 @@ describe Ohai::DSL::Plugin::VersionVII do
411
412
  describe "#version" do
412
413
  it "saves the plugin version as :version7" do
413
414
  plugin = Ohai.plugin(:Test) {}
414
- expect(plugin.version).to eql(:version7)
415
+ expect(plugin.version).to be(:version7)
415
416
  end
416
417
  end
417
418
 
@@ -575,7 +576,7 @@ describe Ohai::DSL::Plugin::VersionVII do
575
576
 
576
577
  it "does not auto-vivify an un-configured plugin" do
577
578
  plugin.configuration(:foo)
578
- expect(Ohai.config[:plugin]).to_not have_key(:test)
579
+ expect(Ohai.config[:plugin]).not_to have_key(:test)
579
580
  end
580
581
 
581
582
  it "returns nil when the option is not configured" do
@@ -30,14 +30,14 @@ describe Ohai::Mixin::Command, "shell_out" do
30
30
 
31
31
  let(:logger) { instance_double("Mixlib::Log::Child", trace: nil, debug: nil, warn: nil) }
32
32
 
33
- before(:each) do
33
+ before do
34
34
  allow(Ohai::Mixin::Command).to receive(:logger).and_return(logger)
35
35
  allow(Ohai::Mixin::Command).to receive(:name).and_return(plugin_name)
36
36
  @original_env = ENV.to_hash
37
37
  ENV.clear
38
38
  end
39
39
 
40
- after(:each) do
40
+ after do
41
41
  ENV.clear
42
42
  ENV.update(@original_env)
43
43
  end
@@ -23,6 +23,7 @@ describe Ohai::Mixin::DmiDecode, "guest_from_dmi_data" do
23
23
  let(:mixin) { Object.new.extend(Ohai::Mixin::DmiDecode) }
24
24
 
25
25
  # for the full DMI data used in these tests see https://github.com/chef/dmidecode_collection
26
+ # the fields here are manufacturer, product, and version as passed to #guest_from_dmi_data
26
27
  {
27
28
  xen: ["Xen", "HVM domU", "4.2.amazon"],
28
29
  vmware: ["VMware, Inc.", "VMware Virtual Platform", "None"],
@@ -31,7 +32,7 @@ describe Ohai::Mixin::DmiDecode, "guest_from_dmi_data" do
31
32
  veertu: ["Veertu", "Veertu", "Not Specified"],
32
33
  parallels: ["Parallels Software International Inc.", "Parallels Virtual Platform", "None"],
33
34
  vbox: ["Oracle Corporation", "VirtualBox", "1.2"],
34
- openstack: ["Red Hat Inc.", "OpenStack Nova", "2014.1.2-1.el6"],
35
+ openstack: ["OpenStack Foundation", "", "15.1.5"],
35
36
  kvm: ["Red Hat", "KVM", "RHEL 7.0.0 PC (i440FX + PIIX, 1996"],
36
37
  bhyve: ["", "BHYVE", "1.0"],
37
38
  }.each_pair do |hypervisor, values|
@@ -42,6 +43,12 @@ describe Ohai::Mixin::DmiDecode, "guest_from_dmi_data" do
42
43
  end
43
44
  end
44
45
 
46
+ describe "when passed Redhat's Openstack varient dmi data" do
47
+ it "returns 'openstack'" do
48
+ expect(mixin.guest_from_dmi_data("Red Hat Inc.", "OpenStack Nova", "2014.1.2-1.el6")).to eq("openstack")
49
+ end
50
+ end
51
+
45
52
  describe "When running on RHEV Hypervisor" do
46
53
  it "returns 'kvm'" do
47
54
  expect(mixin.guest_from_dmi_data("Red Hat", "RHEV Hypervisor", "6.7-20150911.0.el6ev")).to eq("kvm")
@@ -38,13 +38,13 @@ describe "a plug-in that aborts execution" do
38
38
 
39
39
  end
40
40
 
41
- before(:each) do
41
+ before do
42
42
  fail_file = File.open("#{tmp}/plugins/abort.rb", "w+")
43
43
  fail_file.write(abortstr)
44
44
  fail_file.close
45
45
  end
46
46
 
47
- after(:each) do
47
+ after do
48
48
  File.delete("#{tmp}/plugins/abort.rb")
49
49
  end
50
50
 
@@ -56,13 +56,13 @@ describe "a plug-in that aborts execution" do
56
56
 
57
57
  end
58
58
 
59
- before(:each) do
59
+ before do
60
60
  @ohai = Ohai::System.new
61
61
  @loader = Ohai::Loader.new(@ohai)
62
62
  @runner = Ohai::Runner.new(@ohai)
63
63
  end
64
64
 
65
- it "should raise SystemExit" do
65
+ it "raises SystemExit" do
66
66
  @plugin = @loader.load_plugin("#{tmp}/plugins/abort.rb")
67
67
  expect { @runner.run_plugin(@plugin) }.to raise_error(SystemExit)
68
68
  end
@@ -19,7 +19,7 @@
19
19
  require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "AIX cpu plugin" do
22
- before(:each) do
22
+ before do
23
23
  @lsdev_cc_processor = <<~LSDEV_CC_PROCESSOR
24
24
  proc0 Available 00-00 Processor
25
25
  proc4 Defined 00-04 Processor
@@ -19,7 +19,7 @@
19
19
  require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "AIX filesystem plugin" do
22
- before(:each) do
22
+ before do
23
23
  @df_pk_lpar = <<~DF_PK
24
24
  Filesystem 1024-blocks Used Available Capacity Mounted on
25
25
  /dev/hd4 2097152 219796 1877356 11% /
@@ -19,7 +19,7 @@
19
19
  require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "AIX hostname plugin" do
22
- before(:each) do
22
+ before do
23
23
  @plugin = get_plugin("hostname")
24
24
  allow(@plugin).to receive(:collect_os).and_return(:aix)
25
25
  allow(@plugin).to receive(:from_cmd).with("hostname -s").and_return("aix_admin")
@@ -27,7 +27,7 @@ describe Ohai::System, "AIX hostname plugin" do
27
27
  @plugin.run
28
28
  end
29
29
 
30
- it "should set the machinename" do
30
+ it "sets the machinename" do
31
31
  expect(@plugin[:machinename]).to eql("aix_admin")
32
32
  end
33
33
  end
@@ -19,7 +19,7 @@
19
19
  require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "AIX kernel plugin" do
22
- before(:each) do
22
+ before do
23
23
  @plugin = get_plugin("aix/kernel")
24
24
  allow(@plugin).to receive(:collect_os).and_return(:aix)
25
25
  allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "AIX", nil))
@@ -19,7 +19,7 @@
19
19
  require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "AIX memory plugin" do
22
- before(:each) do
22
+ before do
23
23
  @plugin = get_plugin("aix/memory")
24
24
  allow(@plugin).to receive(:collect_os).and_return(:aix)
25
25
  allow(@plugin).to receive(:shell_out).with("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").and_return(mock_shell_out(0, " 513280.00 340034.17 173245.83 62535.17 230400.05 276950.14 70176.00\n", nil))
@@ -27,22 +27,22 @@ describe Ohai::System, "AIX memory plugin" do
27
27
  allow(@plugin).to receive(:shell_out).with("swap -s").and_return(mock_shell_out(0, @swap_s, nil))
28
28
  end
29
29
 
30
- it "should get total memory" do
30
+ it "gets total memory" do
31
31
  @plugin.run
32
32
  expect(@plugin["memory"]["total"]).to eql("#{513280 * 1024}kB")
33
33
  end
34
34
 
35
- it "should get free memory" do
35
+ it "gets free memory" do
36
36
  @plugin.run
37
37
  expect(@plugin["memory"]["free"]).to eql("#{173245.83.to_i * 1024}kB")
38
38
  end
39
39
 
40
- it "should get total swap" do
40
+ it "gets total swap" do
41
41
  @plugin.run
42
42
  expect(@plugin["memory"]["swap"]["total"]).to eql( "#{23887872 * 4}kB")
43
43
  end
44
44
 
45
- it "should get free swap" do
45
+ it "gets free swap" do
46
46
  @plugin.run
47
47
  expect(@plugin["memory"]["swap"]["free"]).to eql( "#{23598960 * 4}kB")
48
48
  end
@@ -20,7 +20,7 @@ require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "AIX network plugin" do
22
22
 
23
- before(:each) do
23
+ before do
24
24
  @netstat_rn_grep_default = <<~NETSTAT_RN_GREP_DEFAULT
25
25
  default 172.31.8.1 UG 2 121789 en0 - -
26
26
  NETSTAT_RN_GREP_DEFAULT
@@ -232,6 +232,7 @@ describe Ohai::System, "AIX network plugin" do
232
232
  @plugin.run
233
233
  @inet_interface_addresses = @plugin["network"]["interfaces"]["en0"][:addresses]["BE:42:80:00:B0:05"]
234
234
  end
235
+
235
236
  it "detects the family" do
236
237
  expect(@inet_interface_addresses[:family]).to eq("lladdr")
237
238
  end
@@ -286,6 +287,7 @@ describe Ohai::System, "AIX network plugin" do
286
287
  before do
287
288
  @plugin.run
288
289
  end
290
+
289
291
  it "supresses the hostname entries" do
290
292
  expect(@plugin["network"]["arp"][0][:remote_host]).to eq("?")
291
293
  end
@@ -303,6 +305,7 @@ describe Ohai::System, "AIX network plugin" do
303
305
  before do
304
306
  @plugin.run
305
307
  end
308
+
306
309
  it "converts a netmask from hexadecimal form to decimal form" do
307
310
  expect(@plugin.hex_to_dec_netmask("0xffff0000")).to eq("255.255.0.0")
308
311
  end
@@ -19,7 +19,7 @@
19
19
  require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "Aix plugin platform" do
22
- before(:each) do
22
+ before do
23
23
  @plugin = get_plugin("aix/platform")
24
24
  allow(@plugin).to receive(:collect_os).and_return(:aix)
25
25
  kernel = Mash.new
@@ -30,15 +30,15 @@ describe Ohai::System, "Aix plugin platform" do
30
30
  @plugin.run
31
31
  end
32
32
 
33
- it "should set platform to aix" do
33
+ it "sets platform to aix" do
34
34
  expect(@plugin[:platform]).to eq("aix")
35
35
  end
36
36
 
37
- it "should set the platform_version" do
37
+ it "sets the platform_version" do
38
38
  expect(@plugin[:platform_version]).to eq("7.1")
39
39
  end
40
40
 
41
- it "should set platform_family" do
41
+ it "sets platform_family" do
42
42
  expect(@plugin[:platform_family]).to eq(@plugin[:platform])
43
43
  end
44
44
  end
@@ -20,20 +20,20 @@ require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "Aix plugin uptime" do
22
22
 
23
- before(:each) do
23
+ before do
24
24
  @plugin = get_plugin("aix/uptime")
25
25
  allow(@plugin).to receive(:collect_os).and_return(:aix)
26
26
  allow(@plugin).to receive(:shell_out).and_call_original
27
27
  end
28
28
 
29
- it "should set uptime_seconds and uptime standard case" do
29
+ it "sets uptime_seconds and uptime standard case" do
30
30
  allow(@plugin).to receive(:shell_out).with("LC_ALL=POSIX ps -o etime= -p 1").and_return(mock_shell_out(0, "1148-20:54:50", nil))
31
31
  @plugin.run
32
32
  expect(@plugin[:uptime_seconds]).to eq(99262490)
33
33
  expect(@plugin[:uptime]).to eq("1148 days 20 hours 54 minutes 50 seconds")
34
34
  end
35
35
 
36
- it "should set uptime_seconds and uptime in the whitespace case" do
36
+ it "sets uptime_seconds and uptime in the whitespace case" do
37
37
  allow(@plugin).to receive(:shell_out).with("LC_ALL=POSIX ps -o etime= -p 1").and_return(mock_shell_out(0, " 2-20:54:50", nil))
38
38
  @plugin.run
39
39
  expect(@plugin[:uptime_seconds]).to eq(248090)
@@ -31,7 +31,7 @@ describe Ohai::System, "AIX virtualization plugin" do
31
31
  p
32
32
  end
33
33
 
34
- before(:each) do
34
+ before do
35
35
  @lswpar_l = <<~LSWPAR_L
36
36
  =================================================================
37
37
  applejack-541ba3 - Active
@@ -74,7 +74,7 @@ describe Ohai::System, "plugin azure" do
74
74
  end
75
75
 
76
76
  describe "with azure hint file" do
77
- before(:each) do
77
+ before do
78
78
  allow(plugin).to receive(:hint?).with("azure").and_return(hint)
79
79
  end
80
80
 
@@ -90,7 +90,7 @@ describe Ohai::System, "plugin azure" do
90
90
  end
91
91
 
92
92
  describe "without azure hint file or agent or dhcp options" do
93
- before(:each) do
93
+ before do
94
94
  allow(plugin).to receive(:hint?).with("azure").and_return(false)
95
95
  allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false)
96
96
  allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false)
@@ -123,7 +123,7 @@ describe Ohai::System, "plugin azure" do
123
123
  end
124
124
 
125
125
  describe "with rackspace hint file, no agent, and no dhcp lease" do
126
- before(:each) do
126
+ before do
127
127
  allow(plugin).to receive(:hint?).with("rackspace").and_return(true)
128
128
  allow(plugin).to receive(:hint?).with("azure").and_return(false)
129
129
  allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false)
@@ -135,7 +135,7 @@ describe Ohai::System, "plugin azure" do
135
135
  end
136
136
 
137
137
  describe "without azure hint file but with agent on linux" do
138
- before(:each) do
138
+ before do
139
139
  allow(plugin).to receive(:hint?).with("azure").and_return(false)
140
140
  allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(true)
141
141
  allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false)
@@ -145,7 +145,7 @@ describe Ohai::System, "plugin azure" do
145
145
  end
146
146
 
147
147
  describe "without azure hint file but with agent on windows" do
148
- before(:each) do
148
+ before do
149
149
  allow(plugin).to receive(:hint?).with("azure").and_return(false)
150
150
  allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false)
151
151
  allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(true)
@@ -155,7 +155,7 @@ describe Ohai::System, "plugin azure" do
155
155
  end
156
156
 
157
157
  describe "without azure hint or agent but with dhcp option" do
158
- before(:each) do
158
+ before do
159
159
  allow(plugin).to receive(:hint?).with("azure").and_return(false)
160
160
  allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false)
161
161
  allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false)
@@ -188,7 +188,7 @@ describe Ohai::System, "plugin azure" do
188
188
  end
189
189
 
190
190
  describe "with non-responsive metadata endpoint" do
191
- before(:each) do
191
+ before do
192
192
  allow(plugin).to receive(:hint?).with("azure").and_return({})
193
193
  end
194
194
 
@@ -205,7 +205,7 @@ describe Ohai::System, "plugin azure" do
205
205
  end
206
206
 
207
207
  describe "with responsive metadata endpoint" do
208
- before(:each) do
208
+ before do
209
209
  allow(plugin).to receive(:hint?).with("azure").and_return({})
210
210
  allow(plugin).to receive(:can_socket_connect?)
211
211
  .with(Ohai::Mixin::AzureMetadata::AZURE_METADATA_ADDR, 80)
@@ -21,7 +21,8 @@ require "spec_helper"
21
21
 
22
22
  describe Ohai::System, "BSD filesystem plugin" do
23
23
  let(:plugin) { get_plugin("filesystem") }
24
- before(:each) do
24
+
25
+ before do
25
26
  allow(plugin).to receive(:collect_os).and_return(:freebsd)
26
27
 
27
28
  allow(plugin).to receive(:shell_out).with("df").and_return(mock_shell_out(0, "", ""))
@@ -30,7 +31,7 @@ describe Ohai::System, "BSD filesystem plugin" do
30
31
  end
31
32
 
32
33
  describe "when gathering filesystem usage data from df" do
33
- before(:each) do
34
+ before do
34
35
  @stdout = <<~DF
35
36
  Filesystem 1K-blocks Used Avail Capacity Mounted on
36
37
  /dev/ada0p2 9637788 3313504 5553264 37% /
@@ -46,55 +47,55 @@ describe Ohai::System, "BSD filesystem plugin" do
46
47
  allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
47
48
  end
48
49
 
49
- it "should run df and df -iP" do
50
+ it "runs df and df -iP" do
50
51
  expect(plugin).to receive(:shell_out).ordered.with("df").and_return(mock_shell_out(0, @stdout, ""))
51
52
  expect(plugin).to receive(:shell_out).ordered.with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
52
53
  plugin.run
53
54
  end
54
55
 
55
- it "should set kb_size to value from df" do
56
+ it "sets kb_size to value from df" do
56
57
  plugin.run
57
58
  expect(plugin[:filesystem]["/dev/ada0p2"][:kb_size]).to eq("9637788")
58
59
  expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:kb_size]).to eq("9637788")
59
60
  end
60
61
 
61
- it "should set kb_used to value from df" do
62
+ it "sets kb_used to value from df" do
62
63
  plugin.run
63
64
  expect(plugin[:filesystem]["/dev/ada0p2"][:kb_used]).to eq("3313504")
64
65
  expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:kb_used]).to eq("3313504")
65
66
  end
66
67
 
67
- it "should set kb_available to value from df" do
68
+ it "sets kb_available to value from df" do
68
69
  plugin.run
69
70
  expect(plugin[:filesystem]["/dev/ada0p2"][:kb_available]).to eq("5553264")
70
71
  expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:kb_available]).to eq("5553264")
71
72
  end
72
73
 
73
- it "should set percent_used to value from df" do
74
+ it "sets percent_used to value from df" do
74
75
  plugin.run
75
76
  expect(plugin[:filesystem]["/dev/ada0p2"][:percent_used]).to eq("37%")
76
77
  expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:percent_used]).to eq("37%")
77
78
  end
78
79
 
79
- it "should set mount to value from df" do
80
+ it "sets mount to value from df" do
80
81
  plugin.run
81
82
  expect(plugin[:filesystem]["/dev/ada0p2"][:mount]).to eq("/")
82
83
  expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:mount]).to eq("/")
83
84
  end
84
85
 
85
- it "should set total_inodes to value from df -iP" do
86
+ it "sets total_inodes to value from df -iP" do
86
87
  plugin.run
87
88
  expect(plugin[:filesystem]["/dev/ada0p2"][:total_inodes]).to eq("1043326")
88
89
  expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:total_inodes]).to eq("1043326")
89
90
  end
90
91
 
91
- it "should set inodes_used to value from df -iP" do
92
+ it "sets inodes_used to value from df -iP" do
92
93
  plugin.run
93
94
  expect(plugin[:filesystem]["/dev/ada0p2"][:inodes_used]).to eq("252576")
94
95
  expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:inodes_used]).to eq("252576")
95
96
  end
96
97
 
97
- it "should set inodes_available to value from df -iP" do
98
+ it "sets inodes_available to value from df -iP" do
98
99
  plugin.run
99
100
  expect(plugin[:filesystem]["/dev/ada0p2"][:inodes_available]).to eq("790750")
100
101
  expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:inodes_available]).to eq("790750")
@@ -102,7 +103,7 @@ describe Ohai::System, "BSD filesystem plugin" do
102
103
  end
103
104
 
104
105
  describe "when gathering mounted filesystem data from mount" do
105
- before(:each) do
106
+ before do
106
107
  @stdout = <<~MOUNT
107
108
  /dev/ada0p2 on / (ufs, local, journaled soft-updates)
108
109
  devfs on /dev (devfs, local, multilabel)
@@ -110,24 +111,24 @@ describe Ohai::System, "BSD filesystem plugin" do
110
111
  allow(plugin).to receive(:shell_out).with("mount -l").and_return(mock_shell_out(0, @stdout, ""))
111
112
  end
112
113
 
113
- it "should run mount" do
114
+ it "runs mount" do
114
115
  expect(plugin).to receive(:shell_out).with("mount -l").and_return(mock_shell_out(0, @stdout, ""))
115
116
  plugin.run
116
117
  end
117
118
 
118
- it "should set mount to value from mount" do
119
+ it "sets mount to value from mount" do
119
120
  plugin.run
120
121
  expect(plugin[:filesystem]["/dev/ada0p2"][:mount]).to eq("/")
121
122
  expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:mount]).to eq("/")
122
123
  end
123
124
 
124
- it "should set fs_type to value from mount" do
125
+ it "sets fs_type to value from mount" do
125
126
  plugin.run
126
127
  expect(plugin[:filesystem]["/dev/ada0p2"][:fs_type]).to eq("ufs")
127
128
  expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:fs_type]).to eq("ufs")
128
129
  end
129
130
 
130
- it "should set mount_options to an array of values from mount" do
131
+ it "sets mount_options to an array of values from mount" do
131
132
  plugin.run
132
133
  expect(plugin[:filesystem]["/dev/ada0p2"][:mount_options]).to eq(["local", "journaled soft-updates"])
133
134
  expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:mount_options]).to eq(["local", "journaled soft-updates"])