ohai 15.2.5 → 15.3.1

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 (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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98f79af3f1e5744de5e63178fcc9acf038c0d8cc7f684064dac8aabc2d34cbad
4
- data.tar.gz: e3a2b907da4cb97b5218b3d9013688c14cce257ef594f3bc47f43ecc84dc1526
3
+ metadata.gz: 070acba85ad3bc1dd6ea7dddb1ceee6a6d0cb87303c645cd718b5edc9e14005d
4
+ data.tar.gz: 52dcc619042c133354ac464ab982f4a0ba7080fbc2c5bf8d05940bb2f1e48309
5
5
  SHA512:
6
- metadata.gz: 9cdc8ca66bdd032d58ddce52f9a99c2a29189b7cdc95aa727ea84cd0b525cb84d8121cd161ab1681a9b0a46309679c46f07a396bfa055847a570cc63edf455ae
7
- data.tar.gz: 9fa787535d3ae2229647cb4e589f8a3bded19e25d2457b7858290555ff777258de6d8559bcdd1b8ce31767fd77c8d3f2fdac6c78249ea308350c5ff63dda7fe9
6
+ metadata.gz: 5cfd43b461e597cd9a9eb4b62e874d7d7618ded26f93604cc8eefa2f537e7ca9c360668b490ce0a6cdef7c450e1c975b6b4600ded5b60bc766ac07eed211fd23
7
+ data.tar.gz: 792591a83cd68ed3dd92d96a329392f95fcd82ef23e3e9843d47018ccb7f8ede208cad19d18588352cc60cb15d958c0cd2db8bbd2a5038b9facd7323a3b74816
@@ -77,11 +77,11 @@ class Ohai::Application
77
77
  #
78
78
  # @return void
79
79
  def run
80
- elapsed = Benchmark.measure do
80
+ elapsed = Benchmark.realtime do
81
81
  configure_ohai
82
82
  run_application
83
83
  end
84
- Ohai::Log.debug("Ohai took #{elapsed.total} total seconds to run.")
84
+ Ohai::Log.debug("Ohai took #{elapsed} total seconds to run.")
85
85
  end
86
86
 
87
87
  # parses the CLI options, loads the config file if present, and initializes logging
@@ -19,6 +19,8 @@
19
19
  module ::Ohai::Mixin::DmiDecode
20
20
  def guest_from_dmi_data(manufacturer, product, version)
21
21
  case manufacturer
22
+ when /OpenStack/
23
+ return "openstack"
22
24
  when /Xen/
23
25
  return "xen"
24
26
  when /VMware/
@@ -38,13 +40,14 @@ module ::Ohai::Mixin::DmiDecode
38
40
  case product
39
41
  when /VirtualBox/
40
42
  return "vbox"
41
- when /OpenStack/
43
+ when /OpenStack/ # yes this is here twice. Product catches Redhat's version
42
44
  return "openstack"
43
45
  when /(KVM|RHEV)/
44
46
  return "kvm"
45
47
  when /BHYVE/
46
48
  return "bhyve"
47
49
  end
50
+
48
51
  nil # doesn't look like a virt
49
52
  end
50
53
  end
@@ -0,0 +1,38 @@
1
+ #
2
+ # Author:: Joshua Miller <joshmiller@fb.com>
3
+ # Copyright:: Copyright (c) 2019 Facebook
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ Ohai.plugin(:Sysctl) do
20
+ provides "sysctl"
21
+ optional true
22
+
23
+ collect_data(:linux) do
24
+ sysctl_path = which("sysctl")
25
+ if sysctl_path
26
+ sysctl_cmd = shell_out("#{sysctl_path} -a")
27
+
28
+ if sysctl_cmd.exitstatus == 0
29
+ sysctl Mash.new unless sysctl
30
+
31
+ sysctl_cmd.stdout.lines.each do |line|
32
+ k, v = line.split("=").map(&:strip)
33
+ sysctl[k] = v
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -116,6 +116,17 @@ Ohai.plugin(:Virtualization) do
116
116
  end
117
117
  end
118
118
 
119
+ # parse dmi to discover various virtualization guests
120
+ # we do this *after* the kvm detection so that OpenStack isn't detected as KVM
121
+ logger.trace("Looking up DMI data manufacturer: '#{get_attribute(:dmi, :system, :manufacturer)}' product: '#{get_attribute(:dmi, :system, :product)}' version: '#{get_attribute(:dmi, :system, :version)}'")
122
+ guest = guest_from_dmi_data(get_attribute(:dmi, :system, :manufacturer), get_attribute(:dmi, :system, :product), get_attribute(:dmi, :system, :version))
123
+ if guest
124
+ logger.trace("Plugin Virtualization: DMI data indicates #{guest} guest")
125
+ virtualization[:system] = guest
126
+ virtualization[:role] = "guest"
127
+ virtualization[:systems][guest.to_sym] = "guest"
128
+ end
129
+
119
130
  # Detect OpenVZ / Virtuozzo.
120
131
  # http://wiki.openvz.org/BC_proc_entries
121
132
  if File.exist?("/proc/bc/0")
@@ -130,16 +141,6 @@ Ohai.plugin(:Virtualization) do
130
141
  virtualization[:systems][:openvz] = "guest"
131
142
  end
132
143
 
133
- # parse dmi to discover various virtualization guests
134
- logger.trace("Looking up #{get_attribute(:dmi, :system, :manufacturer)}, #{get_attribute(:dmi, :system, :product)} #{get_attribute(:dmi, :system, :version)}")
135
- guest = guest_from_dmi_data(get_attribute(:dmi, :system, :manufacturer), get_attribute(:dmi, :system, :product), get_attribute(:dmi, :system, :version))
136
- if guest
137
- logger.trace("Plugin Virtualization: DMI data indicates #{guest} guest")
138
- virtualization[:system] = guest
139
- virtualization[:role] = "guest"
140
- virtualization[:systems][guest.to_sym] = "guest"
141
- end
142
-
143
144
  # Detect Hyper-V guest and the hostname of the host
144
145
  if File.exist?("/var/lib/hyperv/.kvp_pool_3")
145
146
  logger.trace("Plugin Virtualization: /var/lib/hyperv/.kvp_pool_3 contains string indicating Hyper-V guest")
@@ -19,16 +19,16 @@
19
19
  Ohai.plugin(:Openstack) do
20
20
  require_relative "../mixin/ec2_metadata"
21
21
  require_relative "../mixin/http_helper"
22
+ require "etc" unless defined?(Etc)
22
23
  include Ohai::Mixin::Ec2Metadata
23
24
  include Ohai::Mixin::HttpHelper
24
25
 
25
26
  provides "openstack"
26
- depends "etc"
27
27
  depends "virtualization"
28
28
 
29
29
  # use virtualization data
30
30
  def openstack_virtualization?
31
- if get_attribute(:virtualization, :system, :guest) == "openstack"
31
+ if get_attribute(:virtualization, :systems, :openstack)
32
32
  logger.trace("Plugin Openstack: has_openstack_virtualization? == true")
33
33
  true
34
34
  end
@@ -47,8 +47,13 @@ Ohai.plugin(:Openstack) do
47
47
 
48
48
  # dreamhost systems have the dhc-user on them
49
49
  def openstack_provider
50
- return "dreamhost" if get_attribute("etc", "passwd", "dhc-user")
50
+ # dream host doesn't support windows so bail early if we're on windows
51
+ return "openstack" if RUBY_PLATFORM =~ /mswin|mingw32|windows/
51
52
 
53
+ if Etc.getpwnam("dhc-user")
54
+ "dreamhost"
55
+ end
56
+ rescue ArgumentError # getpwnam raises ArgumentError if the user is not found
52
57
  "openstack"
53
58
  end
54
59
 
@@ -4,6 +4,10 @@ Ohai.plugin(:Passwd) do
4
4
  provides "etc", "current_user"
5
5
  optional true
6
6
 
7
+ # @param [String] str
8
+ #
9
+ # @return [String]
10
+ #
7
11
  def fix_encoding(str)
8
12
  str.force_encoding(Encoding.default_external) if str.respond_to?(:force_encoding)
9
13
  str
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Ohai
20
20
  OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
21
- VERSION = "15.2.5".freeze
21
+ VERSION = "15.3.1".freeze
22
22
  end
@@ -25,12 +25,12 @@ RSpec.describe "Ohai::Application" do
25
25
  let(:argv) { [] }
26
26
  let(:stderr) { StringIO.new }
27
27
 
28
- before(:each) do
28
+ before do
29
29
  @original_argv = ARGV.dup
30
30
  ARGV.replace(argv)
31
31
  end
32
32
 
33
- after(:each) do
33
+ after do
34
34
  ARGV.replace(@original_argv)
35
35
  end
36
36
 
@@ -40,13 +40,13 @@ RSpec.describe "Ohai::Application" do
40
40
  let(:config_dir) { Dir.mktmpdir(".chef") }
41
41
  let(:config_location) { File.join(config_dir, "config.rb") }
42
42
 
43
- before(:each) do
43
+ before do
44
44
  File.open(config_location, "w+") do |f|
45
45
  f.write(config_content)
46
46
  end
47
47
  end
48
48
 
49
- after(:each) do
49
+ after do
50
50
  FileUtils.rm_rf(config_dir)
51
51
  end
52
52
 
@@ -74,7 +74,7 @@ RSpec.describe "Ohai::Application" do
74
74
  # https://github.com/chef/chef/blob/master/chef-config/lib/chef-config/workstation_config_loader.rb#L102
75
75
  let(:env) { { "KNIFE_HOME" => config_dir } }
76
76
 
77
- before(:each) do
77
+ before do
78
78
  allow_any_instance_of(ChefConfig::WorkstationConfigLoader)
79
79
  .to receive(:env).and_return(env)
80
80
  end
@@ -25,7 +25,7 @@ RSpec.describe "Ohai::Loader" do
25
25
  let(:plugin_directory) { Dir.mktmpdir("plugins") }
26
26
  let(:plugin_path) { plugin_directory.tr("/", "\\") }
27
27
 
28
- before(:each) do
28
+ before do
29
29
  Ohai.config[:plugin_path] = plugin_path
30
30
 
31
31
  plugin_content = <<~EOF
@@ -38,7 +38,7 @@ RSpec.describe "Ohai::Loader" do
38
38
  end
39
39
  end
40
40
 
41
- after(:each) do
41
+ after do
42
42
  FileUtils.rm_rf(plugin_directory)
43
43
  end
44
44
 
@@ -22,52 +22,58 @@ describe Ohai::System, "languages plugin" do
22
22
  VERSION_MATCHING_REGEX = /^(?:[\d]+\.)+[\d]+$/.freeze
23
23
  describe "powershell plugin", :windows_only do
24
24
  RSpec.shared_examples "a version looking thing" do
25
- it "should be present" do
25
+ it "is present" do
26
26
  expect(subject).not_to be_nil
27
27
  end
28
- it "should look like a version" do
28
+ it "looks like a version" do
29
29
  expect(subject).to match(VERSION_MATCHING_REGEX)
30
30
  end
31
31
  end
32
+ subject { @plugin[:languages][:powershell] }
33
+
32
34
  before(:all) do
33
35
  @plugin = get_plugin("powershell")
34
36
  @plugin[:languages] = Mash.new
35
37
  @plugin.run
36
38
  end
37
39
 
38
- subject { @plugin[:languages][:powershell] }
39
-
40
- it "should have information about powershell" do
40
+ it "has information about powershell" do
41
41
  expect(subject).not_to be_nil
42
42
  end
43
43
 
44
44
  describe :version do
45
45
  subject { @plugin.languages[:powershell][described_class] }
46
+
46
47
  it_behaves_like "a version looking thing"
47
48
  end
48
49
 
49
50
  describe :ws_man_stack_version do
50
51
  subject { @plugin.languages[:powershell][described_class] }
52
+
51
53
  it_behaves_like "a version looking thing"
52
54
  end
53
55
 
54
56
  describe :serialization_version do
55
57
  subject { @plugin.languages[:powershell][described_class] }
58
+
56
59
  it_behaves_like "a version looking thing"
57
60
  end
58
61
 
59
62
  describe :clr_version do
60
63
  subject { @plugin.languages[:powershell][described_class] }
64
+
61
65
  it_behaves_like "a version looking thing"
62
66
  end
63
67
 
64
68
  describe :build_version do
65
69
  subject { @plugin.languages[:powershell][described_class] }
70
+
66
71
  it_behaves_like "a version looking thing"
67
72
  end
68
73
 
69
74
  describe :remoting_protocol_version do
70
75
  subject { @plugin.languages[:powershell][described_class] }
76
+
71
77
  it_behaves_like "a version looking thing"
72
78
  end
73
79
 
@@ -26,7 +26,7 @@ describe Ohai::System, "root_group plugin" do
26
26
  describe "windows platform", :windows_only do
27
27
  let(:wmi) { WmiLite::Wmi.new }
28
28
 
29
- it "should return the system's administrators (root) group" do
29
+ it "returns the system's administrators (root) group" do
30
30
  # Notethat the Win32_Group WMI provider can be slow if your
31
31
  # system is domain-joined and has hundreds of thousands of
32
32
  # groups in Active Directory -- not a typical test scenario, but
@@ -32,18 +32,18 @@ describe Ohai::System, "Windows plugin uptime" do
32
32
  })
33
33
  end
34
34
 
35
- before(:each) do
35
+ before do
36
36
  allow(uptime_plugin).to receive(:collect_os).and_return(:windows)
37
37
  allow(WmiLite::Wmi).to receive(:new).and_return(wmi)
38
38
  allow(Time).to receive_message_chain(:new, :to_i).and_return(1473756619)
39
39
  end
40
40
 
41
- it "should set uptime_seconds to uptime" do
41
+ it "sets uptime_seconds to uptime" do
42
42
  uptime_plugin.run
43
43
  expect(uptime_plugin[:uptime_seconds]).to be == 80331
44
44
  end
45
45
 
46
- it "should set uptime to a human readable value" do
46
+ it "sets uptime to a human readable value" do
47
47
  uptime_plugin.run
48
48
  expect(uptime_plugin[:uptime]).to eq("22 hours 18 minutes 51 seconds")
49
49
  end
@@ -20,7 +20,7 @@ require "spec_helper"
20
20
 
21
21
  describe Ohai do
22
22
 
23
- it "should have a version constant defined" do
23
+ it "has a version constant defined" do
24
24
  expect(Ohai::VERSION).to be_a_kind_of(String)
25
25
  end
26
26
 
@@ -16,8 +16,8 @@ PLUGIN_PATH = File.expand_path("../../lib/ohai/plugins", __FILE__)
16
16
  SPEC_PLUGIN_PATH = File.expand_path("../data/plugins", __FILE__)
17
17
 
18
18
  RSpec.configure do |config|
19
- config.before(:each) { @object_pristine = Object.clone }
20
- config.after(:each) { remove_constants }
19
+ config.before { @object_pristine = Object.clone }
20
+ config.after { remove_constants }
21
21
  end
22
22
 
23
23
  include Ohai::Mixin::ConstantHelper
@@ -36,19 +36,19 @@ def convert_windows_output(stdout)
36
36
  end
37
37
 
38
38
  def it_should_check_from(plugin, attribute, from, value)
39
- it "should set the #{attribute} to the value from '#{from}'" do
39
+ it "sets the #{attribute} to the value from '#{from}'" do
40
40
  @plugin.run
41
41
  expect(@plugin[attribute]).to eq(value)
42
42
  end
43
43
  end
44
44
 
45
45
  def it_should_check_from_mash(plugin, attribute, from, value)
46
- it "should get the #{plugin}[:#{attribute}] value from '#{from}'" do
46
+ it "gets the #{plugin}[:#{attribute}] value from '#{from}'" do
47
47
  expect(@plugin).to receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
48
48
  @plugin.run
49
49
  end
50
50
 
51
- it "should set the #{plugin}[:#{attribute}] to the value from '#{from}'" do
51
+ it "sets the #{plugin}[:#{attribute}] to the value from '#{from}'" do
52
52
  @plugin.run
53
53
  expect(@plugin[plugin][attribute]).to eq(value[1].split($/)[0])
54
54
  end
@@ -64,12 +64,12 @@ end
64
64
 
65
65
  # the mash variable may be an array listing multiple levels of Mash hierarchy
66
66
  def it_should_check_from_deep_mash(plugin, mash, attribute, from, value)
67
- it "should get the #{mash.inspect}[:#{attribute}] value from '#{from}'" do
67
+ it "gets the #{mash.inspect}[:#{attribute}] value from '#{from}'" do
68
68
  expect(@plugin).to receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
69
69
  @plugin.run
70
70
  end
71
71
 
72
- it "should set the #{mash.inspect}[:#{attribute}] to the value from '#{from}'" do
72
+ it "sets the #{mash.inspect}[:#{attribute}] to the value from '#{from}'" do
73
73
  @plugin.run
74
74
  value = value[1].split($/)[0]
75
75
  if mash.is_a?(String)
@@ -114,7 +114,7 @@ RSpec.configure do |config|
114
114
 
115
115
  config.run_all_when_everything_filtered = true
116
116
 
117
- config.before :each do
117
+ config.before do
118
118
  # TODO: Change to Ohai.config once Ohai::Config is deprecated fully. Needs
119
119
  # to stay Ohai::Config for now so that top-level attributes will get cleared
120
120
  # out between tests (config_spec should be the only place where top-level
@@ -21,11 +21,11 @@ module IntegrationSupport
21
21
  def when_plugins_directory(description, &block)
22
22
  context "When the plugins directory #{description}" do
23
23
 
24
- before(:each) do
24
+ before do
25
25
  @plugins_directory = Dir.mktmpdir("ohai-plugins")
26
26
  end
27
27
 
28
- after(:each) do
28
+ after do
29
29
  if @plugins_directory
30
30
  begin
31
31
  FileUtils.remove_entry_secure(@plugins_directory)
@@ -49,7 +49,7 @@ module IntegrationSupport
49
49
  end
50
50
 
51
51
  def self.with_plugin(plugin_path, contents) # rubocop:disable Lint/NestedMethodDefinition
52
- before :each do
52
+ before do
53
53
  with_plugin(plugin_path, contents)
54
54
  end
55
55
  end
@@ -24,12 +24,12 @@ RSpec.describe "Ohai::Application" do
24
24
  let(:argv) { [] }
25
25
  let(:app) { Ohai::Application.new }
26
26
 
27
- before(:each) do
27
+ before do
28
28
  @original_argv = ARGV
29
29
  ARGV.replace(argv)
30
30
  end
31
31
 
32
- after(:each) do
32
+ after do
33
33
  ARGV.replace(@original_argv)
34
34
  end
35
35
 
@@ -41,7 +41,7 @@ RSpec.describe "Ohai::Application" do
41
41
  context "when specified on the command line" do
42
42
  let(:argv) { [ "-c", config_file ] }
43
43
 
44
- before(:each) do
44
+ before do
45
45
  if windows?
46
46
  expect(ChefConfig::WorkstationConfigLoader).to receive(:new)
47
47
  .with("C:#{config_file}", Ohai::Log)
@@ -68,7 +68,7 @@ RSpec.describe "Ohai::Application" do
68
68
  end
69
69
 
70
70
  context "when a local workstation config exists" do
71
- before(:each) do
71
+ before do
72
72
  expect(ChefConfig::WorkstationConfigLoader).to receive(:new)
73
73
  .with(nil, Ohai::Log)
74
74
  .and_return(config_loader)
@@ -86,7 +86,7 @@ RSpec.describe "Ohai::Application" do
86
86
  let(:directory) { "/some/fantastic/plugins" }
87
87
 
88
88
  it "does not generate deprecated config warnings for cli options" do
89
- expect(Ohai::Log).to_not receive(:warn)
89
+ expect(Ohai::Log).not_to receive(:warn)
90
90
  .with(/Ohai::Config\[:directory\] is deprecated/)
91
91
  app.configure_ohai
92
92
  end