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
@@ -23,7 +23,7 @@ require "spec_helper"
23
23
  describe Ohai::System, "Darwin virtualization platform" do
24
24
  let(:plugin) { get_plugin("darwin/virtualization") }
25
25
 
26
- before(:each) do
26
+ before do
27
27
  allow(plugin).to receive(:collect_os).and_return(:darwin)
28
28
  allow(plugin).to receive(:prlctl_exists?).and_return(false)
29
29
  allow(plugin).to receive(:ioreg_exists?).and_return(false)
@@ -35,12 +35,12 @@ describe Ohai::System, "Darwin virtualization platform" do
35
35
  end
36
36
 
37
37
  describe "when detecting OS X virtualization" do
38
- it "should not set virtualization keys if no binaries are found" do
38
+ it "does not set virtualization keys if no binaries are found" do
39
39
  plugin.run
40
40
  expect(plugin[:virtualization]).to eq({ "systems" => {} })
41
41
  end
42
42
 
43
- it "should set docker host if docker exists" do
43
+ it "sets docker host if docker exists" do
44
44
  allow(plugin).to receive(:docker_exists?).and_return(true)
45
45
  plugin.run
46
46
  expect(plugin[:virtualization][:system]).to eq("docker")
@@ -48,7 +48,7 @@ describe Ohai::System, "Darwin virtualization platform" do
48
48
  expect(plugin[:virtualization][:systems][:docker]).to eq("host")
49
49
  end
50
50
 
51
- it "should set vmware host if /Applications/VMware\ Fusion.app exists" do
51
+ it "sets vmware host if /Applications/VMware\ Fusion.app exists" do
52
52
  allow(plugin).to receive(:fusion_exists?).and_return(true)
53
53
  plugin.run
54
54
  expect(plugin[:virtualization][:system]).to eq("vmware")
@@ -56,7 +56,7 @@ describe Ohai::System, "Darwin virtualization platform" do
56
56
  expect(plugin[:virtualization][:systems][:vmware]).to eq("host")
57
57
  end
58
58
 
59
- it "should set vmware guest if hardware attributes mention vmware" do
59
+ it "sets vmware guest if hardware attributes mention vmware" do
60
60
  plugin[:hardware][:boot_rom_version] = "VMW71.00V.6997262.B64.1710270607"
61
61
  plugin.run
62
62
  expect(plugin[:virtualization][:system]).to eq("vmware")
@@ -64,7 +64,7 @@ describe Ohai::System, "Darwin virtualization platform" do
64
64
  expect(plugin[:virtualization][:systems][:vmware]).to eq("guest")
65
65
  end
66
66
 
67
- it "should set vbox host if /usr/local/bin/VBoxManage exists" do
67
+ it "sets vbox host if /usr/local/bin/VBoxManage exists" do
68
68
  allow(plugin).to receive(:vboxmanage_exists?).and_return("/usr/local/bin/VBoxManage")
69
69
  plugin.run
70
70
  expect(plugin[:virtualization][:system]).to eq("vbox")
@@ -72,7 +72,7 @@ describe Ohai::System, "Darwin virtualization platform" do
72
72
  expect(plugin[:virtualization][:systems][:vbox]).to eq("host")
73
73
  end
74
74
 
75
- it "should set vbox guest if hardware attributes mention virtualbox" do
75
+ it "sets vbox guest if hardware attributes mention virtualbox" do
76
76
  plugin[:hardware][:boot_rom_version] = "VirtualBox"
77
77
  plugin.run
78
78
  expect(plugin[:virtualization][:system]).to eq("vbox")
@@ -80,7 +80,7 @@ describe Ohai::System, "Darwin virtualization platform" do
80
80
  expect(plugin[:virtualization][:systems][:vbox]).to eq("guest")
81
81
  end
82
82
 
83
- it "should set parallels host if /usr/bin/prlctl exists" do
83
+ it "sets parallels host if /usr/bin/prlctl exists" do
84
84
  allow(plugin).to receive(:prlctl_exists?).and_return("/usr/bin/prlctl")
85
85
  plugin.run
86
86
  expect(plugin[:virtualization][:system]).to eq("parallels")
@@ -88,7 +88,7 @@ describe Ohai::System, "Darwin virtualization platform" do
88
88
  expect(plugin[:virtualization][:systems][:parallels]).to eq("host")
89
89
  end
90
90
 
91
- it "should set parallels guest if /usr/sbin/ioreg exists and its output contains pci1ab8,4000" do
91
+ it "sets parallels guest if /usr/sbin/ioreg exists and its output contains pci1ab8,4000" do
92
92
  allow(plugin).to receive(:ioreg_exists?).and_return(true)
93
93
  ioreg = <<-IOREG
94
94
  | | +-o pci1ab8,4000@3 <class IOPCIDevice, id 0x1000001d1, registered, matched, active, busy 0 (40 ms), retain 9>
@@ -122,7 +122,7 @@ describe Ohai::System, "Darwin virtualization platform" do
122
122
  expect(plugin[:virtualization][:systems][:parallels]).to eq("guest")
123
123
  end
124
124
 
125
- it "should not set parallels guest if /usr/sbin/ioreg exists and its output not contain pci1ab8,4000" do
125
+ it "does not set parallels guest if /usr/sbin/ioreg exists and its output not contain pci1ab8,4000" do
126
126
  allow(plugin).to receive(:ioreg_exists?).and_return(true)
127
127
  ioreg = <<-IOREG
128
128
  | | +-o pci8086,2445@1F,4 <class IOPCIDevice, id 0x1000001d4, registered, matched, active, busy 0 (974 ms), retain 11>
@@ -34,12 +34,12 @@ describe Ohai::System, "plugin digital_ocean" do
34
34
  }
35
35
  end
36
36
 
37
- before(:each) do
37
+ before do
38
38
  allow(plugin).to receive(:hint?).with("digital_ocean").and_return(false)
39
39
  end
40
40
 
41
41
  shared_examples_for "!digital_ocean" do
42
- it "should NOT attempt to fetch the digital_ocean metadata" do
42
+ it "does not attempt to fetch the digital_ocean metadata" do
43
43
  expect(plugin).not_to receive(:http_client)
44
44
  expect(plugin[:digital_ocean]).to be_nil
45
45
  plugin.run
@@ -47,7 +47,7 @@ describe Ohai::System, "plugin digital_ocean" do
47
47
  end
48
48
 
49
49
  shared_examples_for "digital_ocean" do
50
- before(:each) do
50
+ before do
51
51
  @http_client = double("Net::HTTP client")
52
52
  allow(plugin).to receive(:http_client).and_return(@http_client)
53
53
  allow(IO).to receive(:select).and_return([[], [1], []])
@@ -61,7 +61,7 @@ describe Ohai::System, "plugin digital_ocean" do
61
61
  '{"droplet_id":2756924,"hostname":"sample-droplet","vendor_data":"#cloud-config\ndisable_root: false\nmanage_etc_hosts: true\n\n# The modules that run in the \'init\' stage\ncloud_init_modules:\n - migrator\n - ubuntu-init-switch\n - seed_random\n - bootcmd\n - write-files\n - growpart\n - resizefs\n - set_hostname\n - update_hostname\n - [ update_etc_hosts, once-per-instance ]\n - ca-certs\n - rsyslog\n - users-groups\n - ssh\n\n# The modules that run in the \'config\' stage\ncloud_config_modules:\n - disk_setup\n - mounts\n - ssh-import-id\n - locale\n - set-passwords\n - grub-dpkg\n - apt-pipelining\n - apt-configure\n - package-update-upgrade-install\n - landscape\n - timezone\n - puppet\n - chef\n - salt-minion\n - mcollective\n - disable-ec2-metadata\n - runcmd\n - byobu\n\n# The modules that run in the \'final\' stage\ncloud_final_modules:\n - rightscale_userdata\n - scripts-vendor\n - scripts-per-once\n - scripts-per-boot\n - scripts-per-instance\n - scripts-user\n - ssh-authkey-fingerprints\n - keys-to-console\n - phone-home\n - final-message\n - power-state-change\n","public_keys":["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDAkMD3PYKHaH0KbDiXrRE6KCBo/OKcFqhM+fmnnb0+LUh4RalJWX4edeJmnT5bxLeqmLV/Yggjlpfq73R+Dy7JB4pbBLuM959mSM9ohBCSnByAGoT2iUPev4aZFZZ/ahUzTCylNxXrhZV/bopD399CvYREt7Q+FlauBv0O8MMuMGR8aC69Z3jNL+r+fGWNq98JVHGFO/UgoNL15wGCaidMhzfRqkt1u+m1nY77SFM5qWJz2R0CEC4fMlOiCg8mWBklnryV4yDEPgiXp2I8Rli1Eu2GHwuY1YX9elMeQS7n3Pzq7l6aIQmSgvcEWx6TgMD2V7nQUWpfcud/8dpp/t7z9UyfzLmNwnULHNmUeEp52sejcH5lYzISnkkWa1LzlKSeIrhF3y45m9AyxIfjEqyh/mlKQtUaW3NVXXLPwrNitxHtMIZPU5b16BODn0wb8bqPxpDNpUYrQd/BS7mWDxNpICP2ObLPhd9LW9KIYRNTzryE+uKwxm9NkMlhRku2fu415fH0G0+7aURsHviNN9SO4zct3Pj6QE5rnbVHqxt3biplUTOScdWxSk2Nv3V2dGdt/lBfu6iRPAV9IAS31s7Po3qK1t2jpEPCJwstaCBOM80kmoi3zAgotiAW50X8CelaWsHNrq5jBBgeHUZWgn/c8BkcI61pUE9l34Q6gsiEMQ== tsmith84@gmail.com"],"region":"nyc3","interfaces":{"public":[{"ipv4":{"ip_address":"159.203.92.161","netmask":"255.255.240.0","gateway":"159.203.80.1"},"ipv6":{"ip_address":"2604:A880:0800:00A1:0000:0000:0201:0001","cidr":64,"gateway":"2604:A880:0800:00A1:0000:0000:0000:0001"},"anchor_ipv4":{"ip_address":"10.17.0.5","netmask":"255.255.0.0","gateway":"10.17.0.1"},"mac":"04:01:e5:14:03:01","type":"public"}]},"floating_ip":{"ipv4":{"active":false}},"dns":{"nameservers":["2001:4860:4860::8844","2001:4860:4860::8888","8.8.8.8"]}}'
62
62
  end
63
63
 
64
- it "should fetch and properly parse json metadata" do
64
+ it "fetches and properly parse json metadata" do
65
65
  expect(@http_client).to receive(:get)
66
66
  .with("/metadata/v1.json")
67
67
  .and_return(double("Net::HTTP Response", body: body, code: "200"))
@@ -72,7 +72,7 @@ describe Ohai::System, "plugin digital_ocean" do
72
72
  expect(plugin[:digital_ocean]["hostname"]).to eq("sample-droplet")
73
73
  end
74
74
 
75
- it "should complete the run despite unavailable metadata" do
75
+ it "completes the run despite unavailable metadata" do
76
76
  expect(@http_client).to receive(:get)
77
77
  .with("/metadata/v1.json")
78
78
  .and_return(double("Net::HTTP Response", body: "", code: "404"))
@@ -83,22 +83,24 @@ describe Ohai::System, "plugin digital_ocean" do
83
83
  end
84
84
 
85
85
  describe "without hint or dmi data" do
86
- it_should_behave_like "!digital_ocean"
86
+ it_behaves_like "!digital_ocean"
87
87
  end
88
88
 
89
89
  describe "with digital_ocean hint file" do
90
- it_should_behave_like "digital_ocean"
91
-
92
- before(:each) do
90
+ before do
93
91
  allow(plugin).to receive(:hint?).with("digital_ocean").and_return(true)
94
92
  end
93
+
94
+ it_behaves_like "digital_ocean"
95
+
95
96
  end
96
97
 
97
98
  describe "with digital_ocean DMI data" do
98
- it_should_behave_like "digital_ocean"
99
-
100
- before(:each) do
99
+ before do
101
100
  plugin[:dmi] = { bios: { all_records: [ { Vendor: "DigitalOcean" } ] } }
102
101
  end
102
+
103
+ it_behaves_like "digital_ocean"
104
+
103
105
  end
104
106
  end
@@ -104,7 +104,7 @@ describe Ohai::System, "plugin dmi" do
104
104
  let(:plugin) { get_plugin("dmi") }
105
105
  let(:stdout) { DMI_OUT }
106
106
 
107
- before(:each) do
107
+ before do
108
108
  allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, stdout, ""))
109
109
  end
110
110
 
@@ -78,7 +78,7 @@ describe Ohai::System, "plugin docker" do
78
78
  let(:plugin) { get_plugin("docker") }
79
79
 
80
80
  context "if the machine does not have docker installed" do
81
- it "should not create a docker attribute" do
81
+ it "does not create a docker attribute" do
82
82
  plugin[:virtualization] = Mash.new
83
83
  plugin[:virtualization][:systems] = Mash.new
84
84
  plugin.run
@@ -87,7 +87,7 @@ describe Ohai::System, "plugin docker" do
87
87
  end
88
88
 
89
89
  context "if the machine has docker installed" do
90
- it "should create a docker attribute with correct data" do
90
+ it "creates a docker attribute with correct data" do
91
91
  plugin[:virtualization] = Mash.new
92
92
  plugin[:virtualization][:systems] = Mash.new
93
93
  plugin[:virtualization][:systems][:docker] = "host"
@@ -25,7 +25,7 @@ describe Ohai::System, "plugin ec2" do
25
25
 
26
26
  let(:plugin) { get_plugin("ec2") }
27
27
 
28
- before(:each) do
28
+ before do
29
29
  allow(plugin).to receive(:hint?).with("ec2").and_return(false)
30
30
  allow(File).to receive(:exist?).with("/sys/hypervisor/uuid").and_return(false)
31
31
  allow(File).to receive(:exist?).with("/sys/class/dmi/id/bios_vendor").and_return(false)
@@ -41,7 +41,7 @@ describe Ohai::System, "plugin ec2" do
41
41
  end
42
42
 
43
43
  shared_examples_for "ec2" do
44
- before(:each) do
44
+ before do
45
45
  @http_client = double("Net::HTTP client")
46
46
  allow(plugin).to receive(:http_client).and_return(@http_client)
47
47
  allow(IO).to receive(:select).and_return([[], [1], []])
@@ -335,62 +335,66 @@ describe Ohai::System, "plugin ec2" do
335
335
  end # shared examples for ec2
336
336
 
337
337
  describe "with amazon dmi bios version data" do
338
- it_behaves_like "ec2"
339
-
340
- before(:each) do
338
+ before do
341
339
  allow(File).to receive(:exist?).with("/sys/class/dmi/id/bios_version").and_return(true)
342
340
  allow(File).to receive(:read).with("/sys/class/dmi/id/bios_version").and_return("4.2.amazon\n")
343
341
  end
342
+
343
+ it_behaves_like "ec2"
344
+
344
345
  end
345
346
 
346
347
  describe "with non-amazon dmi bios version data" do
347
- it_behaves_like "!ec2"
348
-
349
- before(:each) do
348
+ before do
350
349
  allow(File).to receive(:exist?).with("/sys/class/dmi/id/bios_version").and_return(true)
351
350
  allow(File).to receive(:read).with("/sys/class/dmi/id/bios_version").and_return("1.0\n")
352
351
  end
352
+
353
+ it_behaves_like "!ec2"
354
+
353
355
  end
354
356
 
355
357
  describe "with amazon dmi bios vendor data" do
356
- it_behaves_like "ec2"
357
-
358
- before(:each) do
358
+ before do
359
359
  allow(File).to receive(:exist?).with("/sys/class/dmi/id/bios_vendor").and_return(true)
360
360
  allow(File).to receive(:read).with("/sys/class/dmi/id/bios_vendor").and_return("Amazon EC2\n")
361
361
  end
362
+
363
+ it_behaves_like "ec2"
364
+
362
365
  end
363
366
 
364
367
  describe "with non-amazon dmi bios vendor data" do
365
- it_behaves_like "!ec2"
366
-
367
- before(:each) do
368
+ before do
368
369
  allow(File).to receive(:exist?).with("/sys/class/dmi/id/bios_vendor").and_return(true)
369
370
  allow(File).to receive(:read).with("/sys/class/dmi/id/bios_vendor").and_return("Xen\n")
370
371
  end
372
+
373
+ it_behaves_like "!ec2"
374
+
371
375
  end
372
376
 
373
377
  describe "with EC2 Xen UUID" do
374
- it_behaves_like "ec2"
375
-
376
- before(:each) do
378
+ before do
377
379
  allow(File).to receive(:exist?).with("/sys/hypervisor/uuid").and_return(true)
378
380
  allow(File).to receive(:read).with("/sys/hypervisor/uuid").and_return("ec2a0561-e4d6-8e15-d9c8-2e0e03adcde8\n")
379
381
  end
382
+
383
+ it_behaves_like "ec2"
384
+
380
385
  end
381
386
 
382
387
  describe "with non-EC2 Xen UUID" do
383
- it_behaves_like "!ec2"
384
-
385
- before(:each) do
388
+ before do
386
389
  allow(File).to receive(:exist?).with("/sys/hypervisor/uuid").and_return(true)
387
390
  allow(File).to receive(:read).with("/sys/hypervisor/uuid").and_return("123a0561-e4d6-8e15-d9c8-2e0e03adcde8\n")
388
391
  end
392
+
393
+ it_behaves_like "!ec2"
394
+
389
395
  end
390
396
 
391
397
  describe "with EC2 Identifying Number", :windows_only do
392
- it_behaves_like "ec2"
393
-
394
398
  before do
395
399
  allow_any_instance_of(WmiLite::Wmi).to receive(:first_of).and_return(
396
400
  { "caption" => "Computer System Product",
@@ -403,11 +407,12 @@ describe Ohai::System, "plugin ec2" do
403
407
  "version" => "4.2.amazon" }
404
408
  )
405
409
  end
410
+
411
+ it_behaves_like "ec2"
412
+
406
413
  end
407
414
 
408
415
  describe "without EC2 Identifying Number", :windows_only do
409
- it_behaves_like "!ec2"
410
-
411
416
  before do
412
417
  allow_any_instance_of(WmiLite::Wmi).to receive(:first_of).and_return(
413
418
  { "caption" => "Computer System Product",
@@ -420,22 +425,28 @@ describe Ohai::System, "plugin ec2" do
420
425
  "version" => "1.2.3" }
421
426
  )
422
427
  end
428
+
429
+ it_behaves_like "!ec2"
430
+
423
431
  end
424
432
 
425
433
  describe "with ec2 hint file" do
426
- it_behaves_like "ec2"
427
-
428
- before(:each) do
434
+ before do
429
435
  allow(plugin).to receive(:hint?).with("ec2").and_return({})
430
436
  end
437
+
438
+ it_behaves_like "ec2"
439
+
431
440
  end
432
- describe "without any hints that it is an ec2 system" do
433
- it_behaves_like "!ec2"
434
441
 
435
- before(:each) do
442
+ describe "without any hints that it is an ec2 system" do
443
+ before do
436
444
  allow(plugin).to receive(:hint?).with("ec2").and_return(false)
437
445
  plugin[:dmi] = nil
438
446
  end
447
+
448
+ it_behaves_like "!ec2"
449
+
439
450
  end
440
451
 
441
452
  end
@@ -19,11 +19,11 @@ require "spec_helper"
19
19
  describe Ohai::System, "plugin elixir" do
20
20
  let(:plugin) { get_plugin("elixir") }
21
21
 
22
- before(:each) do
22
+ before do
23
23
  plugin[:languages] = Mash.new
24
24
  end
25
25
 
26
- it "should shellout to elixir -v" do
26
+ it "shellouts to elixir -v" do
27
27
  expect(plugin).to receive(:shell_out).with("elixir -v").and_return(mock_shell_out(0, "Elixir 1.0.2", ""))
28
28
  plugin.run
29
29
  end
@@ -22,7 +22,7 @@ require "spec_helper"
22
22
  describe Ohai::System, "plugin erlang" do
23
23
  let(:plugin) { get_plugin("erlang") }
24
24
 
25
- before(:each) do
25
+ before do
26
26
  plugin[:languages] = Mash.new
27
27
  erl_v_output = "Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 7.3\n"
28
28
  erl_systeminfo_output = "19.1,8.1,2.11"
@@ -31,7 +31,7 @@ describe Ohai::System, "plugin eucalyptus" do
31
31
  end
32
32
 
33
33
  shared_examples_for "eucalyptus" do
34
- before(:each) do
34
+ before do
35
35
  @http_client = double("Net::HTTP client")
36
36
  allow(plugin).to receive(:http_client).and_return(@http_client)
37
37
 
@@ -69,37 +69,41 @@ describe Ohai::System, "plugin eucalyptus" do
69
69
  end
70
70
 
71
71
  describe "with eucalyptus mac and metadata address connected" do
72
- it_behaves_like "eucalyptus"
73
-
74
- before(:each) do
72
+ before do
75
73
  allow(IO).to receive(:select).and_return([[], [1], []])
76
74
  plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "d0:0d:95:47:6E:ED" => { "family" => "lladdr" } } } } }
77
75
  end
76
+
77
+ it_behaves_like "eucalyptus"
78
+
78
79
  end
79
80
 
80
81
  describe "without eucalyptus mac and metadata address connected" do
81
- it_behaves_like "!eucalyptus"
82
-
83
- before(:each) do
82
+ before do
84
83
  plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "ff:ff:95:47:6E:ED" => { "family" => "lladdr" } } } } }
85
84
  end
85
+
86
+ it_behaves_like "!eucalyptus"
87
+
86
88
  end
87
89
 
88
90
  describe "with eucalyptus hint file" do
89
- it_behaves_like "eucalyptus"
90
-
91
- before(:each) do
91
+ before do
92
92
  allow(plugin).to receive(:hint?).with("eucalyptus").and_return(true)
93
93
  end
94
+
95
+ it_behaves_like "eucalyptus"
96
+
94
97
  end
95
98
 
96
99
  describe "without hint file" do
97
- it_behaves_like "!eucalyptus"
98
-
99
- before(:each) do
100
+ before do
100
101
  plugin[:network] = { interfaces: {} }
101
102
  allow(plugin).to receive(:hint?).with("eucalyptus").and_return(false)
102
103
  end
104
+
105
+ it_behaves_like "!eucalyptus"
106
+
103
107
  end
104
108
 
105
109
  end
@@ -30,13 +30,13 @@ shared_examples "a v7 loading failure" do
30
30
 
31
31
  end
32
32
 
33
- before(:each) do
33
+ before do
34
34
  fail_file = File.open("#{tmp}/plugins/fail.rb", "w+")
35
35
  fail_file.write(failstr)
36
36
  fail_file.close
37
37
  end
38
38
 
39
- after(:each) do
39
+ after do
40
40
  File.delete("#{tmp}/plugins/fail.rb")
41
41
  end
42
42
 
@@ -48,18 +48,18 @@ shared_examples "a v7 loading failure" do
48
48
 
49
49
  end
50
50
 
51
- before(:each) do
51
+ before do
52
52
  @ohai = Ohai::System.new
53
53
  @loader = Ohai::Loader.new(@ohai)
54
54
  end
55
55
 
56
- it "should not have attribute keys" do
56
+ it "does not have attribute keys" do
57
57
  @loader.load_plugin("#{tmp}/plugins/fail.rb")
58
58
  # @ohai.attributes.should_not have_key("fail")
59
59
  expect { @ohai.provides_map.find_providers_for(["fail"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound)
60
60
  end
61
61
 
62
- it "should write to Ohai::Log" do
62
+ it "writes to Ohai::Log" do
63
63
  expect(@loader.logger).to receive(:warn).once
64
64
  @loader.load_plugin("#{tmp}/plugins/fail.rb")
65
65
  end
@@ -74,13 +74,13 @@ shared_examples "a v7 loading success" do
74
74
 
75
75
  end
76
76
 
77
- before(:each) do
77
+ before do
78
78
  fail_file = File.open("#{tmp}/plugins/fail.rb", "w+")
79
79
  fail_file.write(failstr)
80
80
  fail_file.close
81
81
  end
82
82
 
83
- after(:each) do
83
+ after do
84
84
  File.delete("#{tmp}/plugins/fail.rb")
85
85
  end
86
86
 
@@ -92,17 +92,17 @@ shared_examples "a v7 loading success" do
92
92
 
93
93
  end
94
94
 
95
- before(:each) do
95
+ before do
96
96
  @ohai = Ohai::System.new
97
97
  @loader = Ohai::Loader.new(@ohai)
98
98
  end
99
99
 
100
- it "should have attribute keys" do
100
+ it "has attribute keys" do
101
101
  @loader.load_plugin("#{tmp}/plugins/fail.rb")
102
102
  expect(@ohai.provides_map).to have_key("fail")
103
103
  end
104
104
 
105
- it "should not write to Ohai::Log" do
105
+ it "does not write to Ohai::Log" do
106
106
  expect(@loader.logger).not_to receive(:warn)
107
107
  @loader.load_plugin("#{tmp}/plugins/fail.rb")
108
108
  end
@@ -117,13 +117,13 @@ shared_examples "a v7 run failure" do
117
117
 
118
118
  end
119
119
 
120
- before(:each) do
120
+ before do
121
121
  fail_file = File.open("#{tmp}/plugins/fail.rb", "w+")
122
122
  fail_file.write(failstr)
123
123
  fail_file.close
124
124
  end
125
125
 
126
- after(:each) do
126
+ after do
127
127
  File.delete("#{tmp}/plugins/fail.rb")
128
128
  end
129
129
 
@@ -135,17 +135,17 @@ shared_examples "a v7 run failure" do
135
135
 
136
136
  end
137
137
 
138
- before(:each) do
138
+ before do
139
139
  @ohai = Ohai::System.new
140
140
  @loader = Ohai::Loader.new(@ohai)
141
141
  end
142
142
 
143
- it "should not have new attribute keys" do
143
+ it "does not have new attribute keys" do
144
144
  @loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run
145
145
  expect(@ohai.provides_map).not_to have_key("other")
146
146
  end
147
147
 
148
- it "should write to Ohai::Log" do
148
+ it "writes to Ohai::Log" do
149
149
  expect(@loader.logger).to receive(:warn).once
150
150
  @loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run
151
151
  end