ohai 15.3.1 → 15.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -6
  3. data/lib/ohai/mixin/{network_constants.rb → network_helper.rb} +8 -1
  4. data/lib/ohai/plugins/aix/network.rb +3 -8
  5. data/lib/ohai/plugins/darwin/network.rb +6 -4
  6. data/lib/ohai/plugins/filesystem.rb +166 -0
  7. data/lib/ohai/plugins/network.rb +5 -5
  8. data/lib/ohai/plugins/openstack.rb +2 -1
  9. data/lib/ohai/plugins/solaris2/network.rb +6 -4
  10. data/lib/ohai/version.rb +1 -1
  11. data/ohai.gemspec +1 -1
  12. metadata +3 -162
  13. data/Rakefile +0 -42
  14. data/lib/ohai/plugins/windows/filesystem.rb +0 -147
  15. data/spec/data/plugins/dpkg-query.output +0 -4
  16. data/spec/data/plugins/lslpp.output +0 -50
  17. data/spec/data/plugins/pacman.output +0 -51
  18. data/spec/data/plugins/pkg-query.output +0 -58
  19. data/spec/data/plugins/pkginfo.output +0 -50
  20. data/spec/data/plugins/pkglist.output +0 -24
  21. data/spec/data/plugins/rpmquery.output +0 -7
  22. data/spec/functional/application_spec.rb +0 -107
  23. data/spec/functional/loader_spec.rb +0 -53
  24. data/spec/functional/plugins/powershell_spec.rb +0 -88
  25. data/spec/functional/plugins/root_group_spec.rb +0 -41
  26. data/spec/functional/plugins/windows/uptime_spec.rb +0 -51
  27. data/spec/ohai_spec.rb +0 -27
  28. data/spec/rcov.opts +0 -2
  29. data/spec/spec.opts +0 -2
  30. data/spec/spec_helper.rb +0 -124
  31. data/spec/support/integration_helper.rb +0 -61
  32. data/spec/support/platform_helpers.rb +0 -38
  33. data/spec/unit/application_spec.rb +0 -96
  34. data/spec/unit/config_spec.rb +0 -57
  35. data/spec/unit/dsl/plugin_spec.rb +0 -634
  36. data/spec/unit/hints_spec.rb +0 -65
  37. data/spec/unit/loader_spec.rb +0 -195
  38. data/spec/unit/mixin/azure_metadata_spec.rb +0 -72
  39. data/spec/unit/mixin/command_spec.rb +0 -151
  40. data/spec/unit/mixin/dmi_decode.rb +0 -75
  41. data/spec/unit/mixin/ec2_metadata_spec.rb +0 -88
  42. data/spec/unit/mixin/softlayer_metadata_spec.rb +0 -72
  43. data/spec/unit/plugin_config_spec.rb +0 -117
  44. data/spec/unit/plugins/abort_spec.rb +0 -69
  45. data/spec/unit/plugins/aix/cpu_spec.rb +0 -127
  46. data/spec/unit/plugins/aix/filesystem_spec.rb +0 -238
  47. data/spec/unit/plugins/aix/hostname_spec.rb +0 -33
  48. data/spec/unit/plugins/aix/kernel_spec.rb +0 -61
  49. data/spec/unit/plugins/aix/memory_spec.rb +0 -49
  50. data/spec/unit/plugins/aix/network_spec.rb +0 -313
  51. data/spec/unit/plugins/aix/platform_spec.rb +0 -44
  52. data/spec/unit/plugins/aix/uptime_spec.rb +0 -42
  53. data/spec/unit/plugins/aix/virtualization_spec.rb +0 -319
  54. data/spec/unit/plugins/azure_spec.rb +0 -243
  55. data/spec/unit/plugins/bsd/filesystem_spec.rb +0 -138
  56. data/spec/unit/plugins/bsd/virtualization_spec.rb +0 -145
  57. data/spec/unit/plugins/c_spec.rb +0 -341
  58. data/spec/unit/plugins/chef_spec.rb +0 -44
  59. data/spec/unit/plugins/cloud_spec.rb +0 -484
  60. data/spec/unit/plugins/darwin/cpu_spec.rb +0 -124
  61. data/spec/unit/plugins/darwin/filesystem_spec.rb +0 -140
  62. data/spec/unit/plugins/darwin/hardware_spec.rb +0 -105
  63. data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +0 -1110
  64. data/spec/unit/plugins/darwin/hostname_spec.rb +0 -43
  65. data/spec/unit/plugins/darwin/kernel_spec.rb +0 -65
  66. data/spec/unit/plugins/darwin/memory_spec.rb +0 -64
  67. data/spec/unit/plugins/darwin/network_spec.rb +0 -849
  68. data/spec/unit/plugins/darwin/platform_spec.rb +0 -71
  69. data/spec/unit/plugins/darwin/virtualization_spec.rb +0 -156
  70. data/spec/unit/plugins/digital_ocean_spec.rb +0 -106
  71. data/spec/unit/plugins/dmi_spec.rb +0 -156
  72. data/spec/unit/plugins/docker_spec.rb +0 -100
  73. data/spec/unit/plugins/ec2_spec.rb +0 -452
  74. data/spec/unit/plugins/elixir_spec.rb +0 -55
  75. data/spec/unit/plugins/erlang_spec.rb +0 -71
  76. data/spec/unit/plugins/eucalyptus_spec.rb +0 -109
  77. data/spec/unit/plugins/fail_spec.rb +0 -260
  78. data/spec/unit/plugins/freebsd/cpu_spec.rb +0 -129
  79. data/spec/unit/plugins/freebsd/hostname_spec.rb +0 -35
  80. data/spec/unit/plugins/freebsd/kernel_spec.rb +0 -36
  81. data/spec/unit/plugins/freebsd/platform_spec.rb +0 -38
  82. data/spec/unit/plugins/gce_spec.rb +0 -81
  83. data/spec/unit/plugins/go_spec.rb +0 -48
  84. data/spec/unit/plugins/groovy_spec.rb +0 -66
  85. data/spec/unit/plugins/haskell_spec.rb +0 -231
  86. data/spec/unit/plugins/hostname_spec.rb +0 -162
  87. data/spec/unit/plugins/init_package_spec.rb +0 -60
  88. data/spec/unit/plugins/java_spec.rb +0 -230
  89. data/spec/unit/plugins/joyent_spec.rb +0 -100
  90. data/spec/unit/plugins/kernel_spec.rb +0 -38
  91. data/spec/unit/plugins/linode_spec.rb +0 -135
  92. data/spec/unit/plugins/linux/block_device_spec.rb +0 -75
  93. data/spec/unit/plugins/linux/cpu_spec.rb +0 -441
  94. data/spec/unit/plugins/linux/filesystem_spec.rb +0 -550
  95. data/spec/unit/plugins/linux/fips_spec.rb +0 -60
  96. data/spec/unit/plugins/linux/hostname_spec.rb +0 -52
  97. data/spec/unit/plugins/linux/hostnamectl_spec.rb +0 -59
  98. data/spec/unit/plugins/linux/kernel_spec.rb +0 -71
  99. data/spec/unit/plugins/linux/lsb_spec.rb +0 -147
  100. data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
  101. data/spec/unit/plugins/linux/machineid_spec.rb +0 -46
  102. data/spec/unit/plugins/linux/mdadm_spec.rb +0 -170
  103. data/spec/unit/plugins/linux/memory_spec.rb +0 -256
  104. data/spec/unit/plugins/linux/network_spec.rb +0 -1392
  105. data/spec/unit/plugins/linux/platform_spec.rb +0 -812
  106. data/spec/unit/plugins/linux/sessions_spec.rb +0 -98
  107. data/spec/unit/plugins/linux/sysctl_spec.rb +0 -53
  108. data/spec/unit/plugins/linux/systemd_paths_spec.rb +0 -122
  109. data/spec/unit/plugins/linux/uptime_spec.rb +0 -48
  110. data/spec/unit/plugins/linux/virtualization_spec.rb +0 -650
  111. data/spec/unit/plugins/lua_spec.rb +0 -60
  112. data/spec/unit/plugins/mono_spec.rb +0 -67
  113. data/spec/unit/plugins/netbsd/hostname_spec.rb +0 -43
  114. data/spec/unit/plugins/netbsd/kernel_spec.rb +0 -35
  115. data/spec/unit/plugins/netbsd/platform_spec.rb +0 -38
  116. data/spec/unit/plugins/network_spec.rb +0 -1078
  117. data/spec/unit/plugins/nodejs_spec.rb +0 -55
  118. data/spec/unit/plugins/ohai_spec.rb +0 -32
  119. data/spec/unit/plugins/ohai_time_spec.rb +0 -44
  120. data/spec/unit/plugins/openbsd/hostname_spec.rb +0 -43
  121. data/spec/unit/plugins/openbsd/kernel_spec.rb +0 -36
  122. data/spec/unit/plugins/openbsd/platform_spec.rb +0 -33
  123. data/spec/unit/plugins/openstack_spec.rb +0 -311
  124. data/spec/unit/plugins/os_spec.rb +0 -115
  125. data/spec/unit/plugins/packages_spec.rb +0 -353
  126. data/spec/unit/plugins/passwd_spec.rb +0 -65
  127. data/spec/unit/plugins/perl_spec.rb +0 -62
  128. data/spec/unit/plugins/php_spec.rb +0 -97
  129. data/spec/unit/plugins/platform_spec.rb +0 -65
  130. data/spec/unit/plugins/powershell_spec.rb +0 -71
  131. data/spec/unit/plugins/python_spec.rb +0 -51
  132. data/spec/unit/plugins/rackspace_spec.rb +0 -350
  133. data/spec/unit/plugins/root_group_spec.rb +0 -90
  134. data/spec/unit/plugins/ruby_spec.rb +0 -60
  135. data/spec/unit/plugins/rust_spec.rb +0 -43
  136. data/spec/unit/plugins/scala_spec.rb +0 -58
  137. data/spec/unit/plugins/scaleway_spec.rb +0 -93
  138. data/spec/unit/plugins/scsi_spec.rb +0 -69
  139. data/spec/unit/plugins/shard_spec.rb +0 -121
  140. data/spec/unit/plugins/shells_spec.rb +0 -56
  141. data/spec/unit/plugins/softlayer_spec.rb +0 -60
  142. data/spec/unit/plugins/solaris2/cpu_spec.rb +0 -2926
  143. data/spec/unit/plugins/solaris2/dmi_spec.rb +0 -153
  144. data/spec/unit/plugins/solaris2/filesystem.rb +0 -407
  145. data/spec/unit/plugins/solaris2/hostname_spec.rb +0 -37
  146. data/spec/unit/plugins/solaris2/kernel_spec.rb +0 -183
  147. data/spec/unit/plugins/solaris2/memory_spec.rb +0 -43
  148. data/spec/unit/plugins/solaris2/network_spec.rb +0 -201
  149. data/spec/unit/plugins/solaris2/platform_spec.rb +0 -108
  150. data/spec/unit/plugins/solaris2/virtualization_spec.rb +0 -97
  151. data/spec/unit/plugins/ssh_host_keys_spec.rb +0 -116
  152. data/spec/unit/plugins/sysconf_spec.rb +0 -680
  153. data/spec/unit/plugins/timezone_spec.rb +0 -30
  154. data/spec/unit/plugins/vbox_host_spec.rb +0 -14
  155. data/spec/unit/plugins/virtualbox_spec.rb +0 -375
  156. data/spec/unit/plugins/vmware_spec.rb +0 -81
  157. data/spec/unit/plugins/windows/cpu_spec.rb +0 -118
  158. data/spec/unit/plugins/windows/filesystem_spec.rb +0 -226
  159. data/spec/unit/plugins/windows/fips_spec.rb +0 -60
  160. data/spec/unit/plugins/windows/kernel_spec.rb +0 -79
  161. data/spec/unit/plugins/windows/memory_spec.rb +0 -52
  162. data/spec/unit/plugins/windows/network_spec.rb +0 -137
  163. data/spec/unit/plugins/windows/system_enclosure_spec.rb +0 -45
  164. data/spec/unit/plugins/windows/uptime_spec.rb +0 -38
  165. data/spec/unit/plugins/windows/virtualization_spec.rb +0 -63
  166. data/spec/unit/plugins/zpools_spec.rb +0 -244
  167. data/spec/unit/provides_map_spec.rb +0 -208
  168. data/spec/unit/runner_spec.rb +0 -422
  169. data/spec/unit/system_spec.rb +0 -416
  170. data/spec/unit/util/file_helper_spec.rb +0 -47
  171. data/spec/unit/util/ip_helper_spec.rb +0 -128
@@ -1,53 +0,0 @@
1
- #
2
- # Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require "spec_helper"
19
-
20
- RSpec.describe "Ohai::Loader" do
21
- let(:loader) { Ohai::Loader.new(Ohai::System.new) }
22
-
23
- describe "#load_all" do
24
- context "when the plugin path contains backslash characters", :windows_only do
25
- let(:plugin_directory) { Dir.mktmpdir("plugins") }
26
- let(:plugin_path) { plugin_directory.tr("/", "\\") }
27
-
28
- before do
29
- Ohai.config[:plugin_path] = plugin_path
30
-
31
- plugin_content = <<~EOF
32
- Ohai.plugin(:Foo) do
33
- provides 'foo'
34
- end
35
- EOF
36
- File.open(File.join(plugin_directory, "foo.rb"), "w+") do |f|
37
- f.write(plugin_content)
38
- end
39
- end
40
-
41
- after do
42
- FileUtils.rm_rf(plugin_directory)
43
- end
44
-
45
- it "loads all the plugins" do
46
- loader.load_all
47
- loaded_plugins = loader.instance_variable_get(:@v7_plugin_classes)
48
- loaded_plugins_names = loaded_plugins.map(&:name)
49
- expect(loaded_plugins_names).to eq(["Ohai::NamedPlugin::Foo"])
50
- end
51
- end
52
- end
53
- end
@@ -1,88 +0,0 @@
1
- #
2
- # Copyright:: Copyright (c) 2014-2016 Chef Software, Inc.
3
- #
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
- require "spec_helper"
20
-
21
- describe Ohai::System, "languages plugin" do
22
- VERSION_MATCHING_REGEX = /^(?:[\d]+\.)+[\d]+$/.freeze
23
- describe "powershell plugin", :windows_only do
24
- RSpec.shared_examples "a version looking thing" do
25
- it "is present" do
26
- expect(subject).not_to be_nil
27
- end
28
- it "looks like a version" do
29
- expect(subject).to match(VERSION_MATCHING_REGEX)
30
- end
31
- end
32
- subject { @plugin[:languages][:powershell] }
33
-
34
- before(:all) do
35
- @plugin = get_plugin("powershell")
36
- @plugin[:languages] = Mash.new
37
- @plugin.run
38
- end
39
-
40
- it "has information about powershell" do
41
- expect(subject).not_to be_nil
42
- end
43
-
44
- describe :version do
45
- subject { @plugin.languages[:powershell][described_class] }
46
-
47
- it_behaves_like "a version looking thing"
48
- end
49
-
50
- describe :ws_man_stack_version do
51
- subject { @plugin.languages[:powershell][described_class] }
52
-
53
- it_behaves_like "a version looking thing"
54
- end
55
-
56
- describe :serialization_version do
57
- subject { @plugin.languages[:powershell][described_class] }
58
-
59
- it_behaves_like "a version looking thing"
60
- end
61
-
62
- describe :clr_version do
63
- subject { @plugin.languages[:powershell][described_class] }
64
-
65
- it_behaves_like "a version looking thing"
66
- end
67
-
68
- describe :build_version do
69
- subject { @plugin.languages[:powershell][described_class] }
70
-
71
- it_behaves_like "a version looking thing"
72
- end
73
-
74
- describe :remoting_protocol_version do
75
- subject { @plugin.languages[:powershell][described_class] }
76
-
77
- it_behaves_like "a version looking thing"
78
- end
79
-
80
- describe :compatible_versions do
81
- it "has compatible_versions that look like versions" do
82
- @plugin.languages[:powershell][described_class].each do |version|
83
- expect(version).to match(VERSION_MATCHING_REGEX)
84
- end
85
- end
86
- end
87
- end
88
- end
@@ -1,41 +0,0 @@
1
- #
2
- # Author:: Adam Edwards (<adamed@chef.io>)
3
- #
4
- # Copyright:: Copyright (c) 2014-2016 Chef Software, Inc.
5
- #
6
- # License:: Apache License, Version 2.0
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
-
21
- require "spec_helper"
22
-
23
- describe Ohai::System, "root_group plugin" do
24
- let(:plugin) { get_plugin("root_group") }
25
-
26
- describe "windows platform", :windows_only do
27
- let(:wmi) { WmiLite::Wmi.new }
28
-
29
- it "returns the system's administrators (root) group" do
30
- # Notethat the Win32_Group WMI provider can be slow if your
31
- # system is domain-joined and has hundreds of thousands of
32
- # groups in Active Directory -- not a typical test scenario, but
33
- # something to watch if you run this test in such an environment.
34
- groups = wmi.query("select * from Win32_Group where sid = 'S-1-5-32-544'")
35
- expect(groups.length).to eq(1)
36
- administrators_group = groups[0]["name"].downcase
37
- plugin.run
38
- expect(plugin[:root_group].downcase).to be == administrators_group
39
- end
40
- end
41
- end
@@ -1,51 +0,0 @@
1
- #
2
- # Author:: Aliasgar Batterywala (<aliasgar.batterywala@msystechnologies.com>)
3
- # Copyright:: Copyright (c) 2016 Chef Software, Inc.
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
- require "spec_helper"
20
-
21
- describe Ohai::System, "Windows plugin uptime" do
22
-
23
- context "for newer version of Windows" do
24
- let(:uptime_plugin) do
25
- get_plugin("uptime").tap do |plugin|
26
- plugin[:platform_version] = "6.3.9600"
27
- end
28
- end
29
-
30
- let(:wmi) do
31
- double("wmi", { first_of: { "lastbootuptime" => "20160912103128.597219+0000" },
32
- })
33
- end
34
-
35
- before do
36
- allow(uptime_plugin).to receive(:collect_os).and_return(:windows)
37
- allow(WmiLite::Wmi).to receive(:new).and_return(wmi)
38
- allow(Time).to receive_message_chain(:new, :to_i).and_return(1473756619)
39
- end
40
-
41
- it "sets uptime_seconds to uptime" do
42
- uptime_plugin.run
43
- expect(uptime_plugin[:uptime_seconds]).to be == 80331
44
- end
45
-
46
- it "sets uptime to a human readable value" do
47
- uptime_plugin.run
48
- expect(uptime_plugin[:uptime]).to eq("22 hours 18 minutes 51 seconds")
49
- end
50
- end
51
- end
@@ -1,27 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
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
- require "spec_helper"
20
-
21
- describe Ohai do
22
-
23
- it "has a version constant defined" do
24
- expect(Ohai::VERSION).to be_a_kind_of(String)
25
- end
26
-
27
- end
@@ -1,2 +0,0 @@
1
- --exclude
2
- spec,bin,/Library/Ruby
@@ -1,2 +0,0 @@
1
- --format specdoc
2
- --colour
@@ -1,124 +0,0 @@
1
- require "rspec/collection_matchers"
2
-
3
- # require 'pry-debugger'
4
- # require 'pry-stack_explorer'
5
-
6
- $:.unshift(File.expand_path("../..", __FILE__))
7
- $:.unshift(File.dirname(__FILE__) + "/../lib")
8
-
9
- require "spec/support/platform_helpers"
10
- require "spec/support/integration_helper"
11
- require "wmi-lite"
12
- require "ohai"
13
- Ohai.config[:log_level] = :error
14
-
15
- PLUGIN_PATH = File.expand_path("../../lib/ohai/plugins", __FILE__)
16
- SPEC_PLUGIN_PATH = File.expand_path("../data/plugins", __FILE__)
17
-
18
- RSpec.configure do |config|
19
- config.before { @object_pristine = Object.clone }
20
- config.after { remove_constants }
21
- end
22
-
23
- include Ohai::Mixin::ConstantHelper
24
-
25
- if Ohai::Mixin::OS.collect_os == /mswin|mingw32|windows/
26
- ENV["PATH"] = ""
27
- end
28
-
29
- def get_plugin(plugin, ohai = Ohai::System.new, path = PLUGIN_PATH)
30
- loader = Ohai::Loader.new(ohai)
31
- loader.load_plugin(File.join(path, "#{plugin}.rb"))
32
- end
33
-
34
- def convert_windows_output(stdout)
35
- stdout.gsub("\n", "\r\n")
36
- end
37
-
38
- def it_should_check_from(plugin, attribute, from, value)
39
- it "sets the #{attribute} to the value from '#{from}'" do
40
- @plugin.run
41
- expect(@plugin[attribute]).to eq(value)
42
- end
43
- end
44
-
45
- def it_should_check_from_mash(plugin, attribute, from, value)
46
- it "gets the #{plugin}[:#{attribute}] value from '#{from}'" do
47
- expect(@plugin).to receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
48
- @plugin.run
49
- end
50
-
51
- it "sets the #{plugin}[:#{attribute}] to the value from '#{from}'" do
52
- @plugin.run
53
- expect(@plugin[plugin][attribute]).to eq(value[1].split($/)[0])
54
- end
55
- end
56
-
57
- def mock_shell_out(exitstatus, stdout, stderr)
58
- shell_out = double("mixlib_shell_out")
59
- allow(shell_out).to receive(:exitstatus).and_return(exitstatus)
60
- allow(shell_out).to receive(:stdout).and_return(stdout)
61
- allow(shell_out).to receive(:stderr).and_return(stderr)
62
- shell_out
63
- end
64
-
65
- # the mash variable may be an array listing multiple levels of Mash hierarchy
66
- def it_should_check_from_deep_mash(plugin, mash, attribute, from, value)
67
- it "gets the #{mash.inspect}[:#{attribute}] value from '#{from}'" do
68
- expect(@plugin).to receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
69
- @plugin.run
70
- end
71
-
72
- it "sets the #{mash.inspect}[:#{attribute}] to the value from '#{from}'" do
73
- @plugin.run
74
- value = value[1].split($/)[0]
75
- if mash.is_a?(String)
76
- expect(@plugin[mash][attribute]).to eq(value)
77
- elsif mash.is_a?(Array)
78
- if mash.length == 2
79
- expect(@plugin[mash[0]][mash[1]][attribute]).to eq value
80
- elsif mash.length == 3
81
- expect(@plugin[mash[0]][mash[1]][mash[2]][attribute]).to eq value
82
- else
83
- return nil
84
- end
85
- else
86
- return nil
87
- end
88
- end
89
- end
90
-
91
- RSpec.configure do |config|
92
-
93
- # Not worth addressing warnings in Ohai until upstream ones in ffi-yajl are
94
- # fixed.
95
- # config.warnings = true
96
-
97
- config.raise_errors_for_deprecations!
98
-
99
- # `expect` should be preferred for new tests or when refactoring old tests,
100
- # but we're not going to do a "big bang" change at this time.
101
- config.expect_with :rspec do |c|
102
- c.syntax = :expect
103
- end
104
- config.mock_with :rspec do |c|
105
- c.syntax = :expect
106
- end
107
-
108
- config.filter_run focus: true
109
-
110
- config.filter_run_excluding windows_only: true unless windows?
111
- config.filter_run_excluding unix_only: true unless unix?
112
- config.filter_run_excluding requires_root: true unless ENV["USER"] == "root"
113
- config.filter_run_excluding requires_unprivileged_user: true if ENV["USER"] == "root"
114
-
115
- config.run_all_when_everything_filtered = true
116
-
117
- config.before do
118
- # TODO: Change to Ohai.config once Ohai::Config is deprecated fully. Needs
119
- # to stay Ohai::Config for now so that top-level attributes will get cleared
120
- # out between tests (config_spec should be the only place where top-level
121
- # config attributes are set).
122
- Ohai::Config.reset
123
- end
124
- end
@@ -1,61 +0,0 @@
1
- #
2
- # License:: Apache License, Version 2.0
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License"); you
5
- # may not use this file except in compliance with the License. You may
6
- # obtain a copy of the license at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or
13
- # implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License
16
- #
17
-
18
- require "tmpdir"
19
-
20
- module IntegrationSupport
21
- def when_plugins_directory(description, &block)
22
- context "When the plugins directory #{description}" do
23
-
24
- before do
25
- @plugins_directory = Dir.mktmpdir("ohai-plugins")
26
- end
27
-
28
- after do
29
- if @plugins_directory
30
- begin
31
- FileUtils.remove_entry_secure(@plugins_directory)
32
- ensure
33
- @plugins_directory = nil
34
- end
35
- end
36
- end
37
-
38
- def with_plugin(plugin_path, contents) # rubocop:disable Lint/NestedMethodDefinition
39
- filename = path_to(plugin_path)
40
- dir = File.dirname(filename)
41
- FileUtils.mkdir_p(dir) unless dir == "."
42
- File.open(filename, "w") do |file|
43
- file.write(contents)
44
- end
45
- end
46
-
47
- def path_to(plugin_path) # rubocop:disable Lint/NestedMethodDefinition
48
- File.expand_path(plugin_path, @plugins_directory)
49
- end
50
-
51
- def self.with_plugin(plugin_path, contents) # rubocop:disable Lint/NestedMethodDefinition
52
- before do
53
- with_plugin(plugin_path, contents)
54
- end
55
- end
56
-
57
- instance_eval(&block)
58
- end
59
- end
60
-
61
- end