ohai 7.6.0.rc.1 → 8.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/lib/ohai/version.rb +1 -1
  3. data/spec/functional/plugins/powershell_spec.rb +4 -4
  4. data/spec/functional/plugins/root_group_spec.rb +1 -1
  5. data/spec/ohai_spec.rb +1 -1
  6. data/spec/spec_helper.rb +12 -12
  7. data/spec/unit/dsl/plugin_spec.rb +40 -40
  8. data/spec/unit/hints_spec.rb +3 -3
  9. data/spec/unit/loader_spec.rb +16 -16
  10. data/spec/unit/mixin/cloudstack_metadata_spec.rb +1 -1
  11. data/spec/unit/mixin/command_spec.rb +6 -6
  12. data/spec/unit/mixin/ec2_metadata_spec.rb +8 -8
  13. data/spec/unit/plugins/aix/cpu_spec.rb +15 -15
  14. data/spec/unit/plugins/aix/filesystem_spec.rb +15 -15
  15. data/spec/unit/plugins/aix/hostname_spec.rb +3 -3
  16. data/spec/unit/plugins/aix/kernel_spec.rb +14 -14
  17. data/spec/unit/plugins/aix/network_spec.rb +43 -43
  18. data/spec/unit/plugins/aix/platform_spec.rb +5 -5
  19. data/spec/unit/plugins/aix/uptime_spec.rb +7 -7
  20. data/spec/unit/plugins/aix/virtualization_spec.rb +3 -3
  21. data/spec/unit/plugins/azure_spec.rb +18 -18
  22. data/spec/unit/plugins/c_spec.rb +52 -52
  23. data/spec/unit/plugins/chef_spec.rb +1 -1
  24. data/spec/unit/plugins/cloud_spec.rb +31 -31
  25. data/spec/unit/plugins/cloud_v2_spec.rb +33 -33
  26. data/spec/unit/plugins/cloudstack_spec.rb +6 -6
  27. data/spec/unit/plugins/darwin/cpu_spec.rb +19 -19
  28. data/spec/unit/plugins/darwin/hostname_spec.rb +6 -6
  29. data/spec/unit/plugins/darwin/kernel_spec.rb +14 -14
  30. data/spec/unit/plugins/darwin/memory_spec.rb +7 -7
  31. data/spec/unit/plugins/darwin/network_spec.rb +358 -358
  32. data/spec/unit/plugins/darwin/platform_spec.rb +10 -10
  33. data/spec/unit/plugins/darwin/system_profiler_spec.rb +4 -4
  34. data/spec/unit/plugins/dmi_spec.rb +3 -3
  35. data/spec/unit/plugins/ec2_spec.rb +80 -80
  36. data/spec/unit/plugins/erlang_spec.rb +7 -7
  37. data/spec/unit/plugins/eucalyptus_spec.rb +28 -28
  38. data/spec/unit/plugins/fail_spec.rb +8 -8
  39. data/spec/unit/plugins/freebsd/cpu_spec.rb +10 -10
  40. data/spec/unit/plugins/freebsd/hostname_spec.rb +4 -4
  41. data/spec/unit/plugins/freebsd/kernel_spec.rb +6 -6
  42. data/spec/unit/plugins/freebsd/os_spec.rb +3 -3
  43. data/spec/unit/plugins/freebsd/platform_spec.rb +5 -5
  44. data/spec/unit/plugins/freebsd/virtualization_spec.rb +20 -20
  45. data/spec/unit/plugins/gce_spec.rb +18 -18
  46. data/spec/unit/plugins/go_spec.rb +5 -5
  47. data/spec/unit/plugins/groovy_spec.rb +5 -5
  48. data/spec/unit/plugins/hostname_spec.rb +24 -24
  49. data/spec/unit/plugins/init_package_spec.rb +5 -5
  50. data/spec/unit/plugins/ip_scopes_spec.rb +1 -1
  51. data/spec/unit/plugins/java_spec.rb +23 -23
  52. data/spec/unit/plugins/joyent_spec.rb +13 -13
  53. data/spec/unit/plugins/kernel_spec.rb +20 -20
  54. data/spec/unit/plugins/linode_spec.rb +18 -18
  55. data/spec/unit/plugins/linux/cpu_spec.rb +25 -25
  56. data/spec/unit/plugins/linux/filesystem_spec.rb +61 -60
  57. data/spec/unit/plugins/linux/hostname_spec.rb +7 -7
  58. data/spec/unit/plugins/linux/kernel_spec.rb +5 -5
  59. data/spec/unit/plugins/linux/lsb_spec.rb +23 -23
  60. data/spec/unit/plugins/linux/mdadm_spec.rb +11 -11
  61. data/spec/unit/plugins/linux/platform_spec.rb +167 -167
  62. data/spec/unit/plugins/linux/uptime_spec.rb +6 -6
  63. data/spec/unit/plugins/linux/virtualization_spec.rb +156 -156
  64. data/spec/unit/plugins/lua_spec.rb +5 -5
  65. data/spec/unit/plugins/mono_spec.rb +5 -5
  66. data/spec/unit/plugins/netbsd/hostname_spec.rb +6 -6
  67. data/spec/unit/plugins/netbsd/kernel_spec.rb +6 -6
  68. data/spec/unit/plugins/netbsd/platform_spec.rb +5 -5
  69. data/spec/unit/plugins/network_spec.rb +116 -116
  70. data/spec/unit/plugins/nodejs_spec.rb +5 -5
  71. data/spec/unit/plugins/ohai_spec.rb +1 -1
  72. data/spec/unit/plugins/ohai_time_spec.rb +5 -5
  73. data/spec/unit/plugins/openbsd/hostname_spec.rb +6 -6
  74. data/spec/unit/plugins/openbsd/kernel_spec.rb +6 -6
  75. data/spec/unit/plugins/openbsd/platform_spec.rb +4 -4
  76. data/spec/unit/plugins/openstack_spec.rb +8 -8
  77. data/spec/unit/plugins/os_spec.rb +5 -5
  78. data/spec/unit/plugins/passwd_spec.rb +13 -13
  79. data/spec/unit/plugins/perl_spec.rb +8 -8
  80. data/spec/unit/plugins/php_spec.rb +7 -7
  81. data/spec/unit/plugins/platform_spec.rb +9 -9
  82. data/spec/unit/plugins/powershell_spec.rb +10 -10
  83. data/spec/unit/plugins/rackspace_spec.rb +72 -70
  84. data/spec/unit/plugins/root_group_spec.rb +14 -14
  85. data/spec/unit/plugins/ruby_spec.rb +1 -1
  86. data/spec/unit/plugins/sigar/network_route_spec.rb +17 -17
  87. data/spec/unit/plugins/solaris2/cpu_spec.rb +18 -18
  88. data/spec/unit/plugins/solaris2/hostname_spec.rb +4 -4
  89. data/spec/unit/plugins/solaris2/kernel_spec.rb +8 -8
  90. data/spec/unit/plugins/solaris2/memory_spec.rb +3 -3
  91. data/spec/unit/plugins/solaris2/network_spec.rb +13 -13
  92. data/spec/unit/plugins/solaris2/platform_spec.rb +14 -14
  93. data/spec/unit/plugins/solaris2/virtualization_spec.rb +24 -24
  94. data/spec/unit/plugins/solaris2/zpools_spec.rb +6 -6
  95. data/spec/unit/plugins/ssh_host_keys_spec.rb +18 -18
  96. data/spec/unit/runner_spec.rb +26 -26
  97. data/spec/unit/system_spec.rb +54 -54
  98. data/spec/unit/util/file_helper_spec.rb +2 -2
  99. metadata +50 -95
@@ -22,28 +22,28 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
22
22
  describe Ohai::System, "Linux plugin uptime" do
23
23
  before(:each) do
24
24
  @plugin = get_plugin("uptime")
25
- @plugin.stub(:collect_os).and_return(:linux)
25
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
26
26
  @double_file = double("/proc/uptime", { :gets => "18423 989" })
27
- File.stub(:open).with("/proc/uptime").and_return(@double_file)
27
+ allow(File).to receive(:open).with("/proc/uptime").and_return(@double_file)
28
28
  end
29
29
 
30
30
  it "should set uptime_seconds to uptime" do
31
31
  @plugin.run
32
- @plugin[:uptime_seconds].should == 18423
32
+ expect(@plugin[:uptime_seconds]).to eq(18423)
33
33
  end
34
34
 
35
35
  it "should set uptime to a human readable date" do
36
36
  @plugin.run
37
- @plugin[:uptime].should == "5 hours 07 minutes 03 seconds"
37
+ expect(@plugin[:uptime]).to eq("5 hours 07 minutes 03 seconds")
38
38
  end
39
39
 
40
40
  it "should set idletime_seconds to uptime" do
41
41
  @plugin.run
42
- @plugin[:idletime_seconds].should == 989
42
+ expect(@plugin[:idletime_seconds]).to eq(989)
43
43
  end
44
44
 
45
45
  it "should set idletime to a human readable date" do
46
46
  @plugin.run
47
- @plugin[:idletime].should == "16 minutes 29 seconds"
47
+ expect(@plugin[:idletime]).to eq("16 minutes 29 seconds")
48
48
  end
49
49
  end
@@ -21,130 +21,130 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
21
21
  describe Ohai::System, "Linux virtualization platform" do
22
22
  before(:each) do
23
23
  @plugin = get_plugin("linux/virtualization")
24
- @plugin.stub(:collect_os).and_return(:linux)
24
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
25
25
 
26
26
  # default to all requested Files not existing
27
- File.stub(:exists?).with("/proc/xen").and_return(false)
28
- File.stub(:exists?).with("/proc/xen/capabilities").and_return(false)
29
- File.stub(:exists?).with("/proc/modules").and_return(false)
30
- File.stub(:exists?).with("/proc/cpuinfo").and_return(false)
31
- File.stub(:exists?).with("/usr/sbin/dmidecode").and_return(false)
32
- File.stub(:exists?).with("/proc/self/status").and_return(false)
33
- File.stub(:exists?).with("/proc/bc/0").and_return(false)
34
- File.stub(:exists?).with("/proc/vz").and_return(false)
35
- File.stub(:exists?).with("/proc/self/cgroup").and_return(false)
27
+ allow(File).to receive(:exists?).with("/proc/xen").and_return(false)
28
+ allow(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(false)
29
+ allow(File).to receive(:exists?).with("/proc/modules").and_return(false)
30
+ allow(File).to receive(:exists?).with("/proc/cpuinfo").and_return(false)
31
+ allow(File).to receive(:exists?).with("/usr/sbin/dmidecode").and_return(false)
32
+ allow(File).to receive(:exists?).with("/proc/self/status").and_return(false)
33
+ allow(File).to receive(:exists?).with("/proc/bc/0").and_return(false)
34
+ allow(File).to receive(:exists?).with("/proc/vz").and_return(false)
35
+ allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(false)
36
36
  end
37
37
 
38
38
  describe "when we are checking for xen" do
39
39
  it "should set xen guest if /proc/xen exists but /proc/xen/capabilities does not" do
40
- File.should_receive(:exists?).with("/proc/xen").and_return(true)
41
- File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(false)
40
+ expect(File).to receive(:exists?).with("/proc/xen").and_return(true)
41
+ expect(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(false)
42
42
  @plugin.run
43
- @plugin[:virtualization][:system].should == "xen"
44
- @plugin[:virtualization][:role].should == "guest"
45
- @plugin[:virtualization][:systems][:xen].should == "guest"
43
+ expect(@plugin[:virtualization][:system]).to eq("xen")
44
+ expect(@plugin[:virtualization][:role]).to eq("guest")
45
+ expect(@plugin[:virtualization][:systems][:xen]).to eq("guest")
46
46
  end
47
47
 
48
48
  it "should set xen host if /proc/xen/capabilities contains control_d " do
49
- File.should_receive(:exists?).with("/proc/xen").and_return(true)
50
- File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(true)
51
- File.stub(:read).with("/proc/xen/capabilities").and_return("control_d")
49
+ expect(File).to receive(:exists?).with("/proc/xen").and_return(true)
50
+ expect(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(true)
51
+ allow(File).to receive(:read).with("/proc/xen/capabilities").and_return("control_d")
52
52
  @plugin.run
53
- @plugin[:virtualization][:system].should == "xen"
54
- @plugin[:virtualization][:role].should == "host"
55
- @plugin[:virtualization][:systems][:xen].should == "host"
53
+ expect(@plugin[:virtualization][:system]).to eq("xen")
54
+ expect(@plugin[:virtualization][:role]).to eq("host")
55
+ expect(@plugin[:virtualization][:systems][:xen]).to eq("host")
56
56
  end
57
57
 
58
58
  it "should set xen guest if /proc/xen/capabilities exists but is empty" do
59
- File.should_receive(:exists?).with("/proc/xen").and_return(true)
60
- File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(true)
61
- File.stub(:read).with("/proc/xen/capabilities").and_return("")
59
+ expect(File).to receive(:exists?).with("/proc/xen").and_return(true)
60
+ expect(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(true)
61
+ allow(File).to receive(:read).with("/proc/xen/capabilities").and_return("")
62
62
  @plugin.run
63
- @plugin[:virtualization][:system].should == "xen"
64
- @plugin[:virtualization][:role].should == "guest"
65
- @plugin[:virtualization][:systems][:xen].should == "guest"
63
+ expect(@plugin[:virtualization][:system]).to eq("xen")
64
+ expect(@plugin[:virtualization][:role]).to eq("guest")
65
+ expect(@plugin[:virtualization][:systems][:xen]).to eq("guest")
66
66
  end
67
67
 
68
68
  it "should not set virtualization if xen isn't there" do
69
- File.should_receive(:exists?).at_least(:once).and_return(false)
69
+ expect(File).to receive(:exists?).at_least(:once).and_return(false)
70
70
  @plugin.run
71
- @plugin[:virtualization].should == {'systems' => {}}
71
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
72
72
  end
73
73
  end
74
74
 
75
75
  describe "when we are checking for kvm" do
76
76
  it "should set kvm host if /proc/modules contains kvm" do
77
- File.should_receive(:exists?).with("/proc/modules").and_return(true)
78
- File.stub(:read).with("/proc/modules").and_return("kvm 165872 1 kvm_intel")
77
+ expect(File).to receive(:exists?).with("/proc/modules").and_return(true)
78
+ allow(File).to receive(:read).with("/proc/modules").and_return("kvm 165872 1 kvm_intel")
79
79
  @plugin.run
80
- @plugin[:virtualization][:system].should == "kvm"
81
- @plugin[:virtualization][:role].should == "host"
82
- @plugin[:virtualization][:systems][:kvm].should == "host"
80
+ expect(@plugin[:virtualization][:system]).to eq("kvm")
81
+ expect(@plugin[:virtualization][:role]).to eq("host")
82
+ expect(@plugin[:virtualization][:systems][:kvm]).to eq("host")
83
83
  end
84
84
 
85
85
  it "should set kvm guest if /proc/cpuinfo contains QEMU Virtual CPU" do
86
- File.should_receive(:exists?).with("/proc/cpuinfo").and_return(true)
87
- File.stub(:read).with("/proc/cpuinfo").and_return("QEMU Virtual CPU")
86
+ expect(File).to receive(:exists?).with("/proc/cpuinfo").and_return(true)
87
+ allow(File).to receive(:read).with("/proc/cpuinfo").and_return("QEMU Virtual CPU")
88
88
  @plugin.run
89
- @plugin[:virtualization][:system].should == "kvm"
90
- @plugin[:virtualization][:role].should == "guest"
91
- @plugin[:virtualization][:systems][:kvm].should == "guest"
89
+ expect(@plugin[:virtualization][:system]).to eq("kvm")
90
+ expect(@plugin[:virtualization][:role]).to eq("guest")
91
+ expect(@plugin[:virtualization][:systems][:kvm]).to eq("guest")
92
92
  end
93
93
 
94
94
  it "should set kvm guest if /proc/cpuinfo contains Common KVM processor" do
95
- File.should_receive(:exists?).with("/proc/cpuinfo").and_return(true)
96
- File.stub(:read).with("/proc/cpuinfo").and_return("Common KVM processor")
95
+ expect(File).to receive(:exists?).with("/proc/cpuinfo").and_return(true)
96
+ allow(File).to receive(:read).with("/proc/cpuinfo").and_return("Common KVM processor")
97
97
  @plugin.run
98
- @plugin[:virtualization][:system].should == "kvm"
99
- @plugin[:virtualization][:role].should == "guest"
100
- @plugin[:virtualization][:systems][:kvm].should == "guest"
98
+ expect(@plugin[:virtualization][:system]).to eq("kvm")
99
+ expect(@plugin[:virtualization][:role]).to eq("guest")
100
+ expect(@plugin[:virtualization][:systems][:kvm]).to eq("guest")
101
101
  end
102
102
 
103
103
  it "should set kvm guest if /proc/cpuinfo contains Common 32-bit KVM processor" do
104
- File.should_receive(:exists?).with("/proc/cpuinfo").and_return(true)
105
- File.stub(:read).with("/proc/cpuinfo").and_return("Common 32-bit KVM processor")
104
+ expect(File).to receive(:exists?).with("/proc/cpuinfo").and_return(true)
105
+ allow(File).to receive(:read).with("/proc/cpuinfo").and_return("Common 32-bit KVM processor")
106
106
  @plugin.run
107
- @plugin[:virtualization][:system].should == "kvm"
108
- @plugin[:virtualization][:role].should == "guest"
109
- @plugin[:virtualization][:systems][:kvm].should == "guest"
107
+ expect(@plugin[:virtualization][:system]).to eq("kvm")
108
+ expect(@plugin[:virtualization][:role]).to eq("guest")
109
+ expect(@plugin[:virtualization][:systems][:kvm]).to eq("guest")
110
110
  end
111
111
 
112
112
  it "should not set virtualization if kvm isn't there" do
113
- File.should_receive(:exists?).at_least(:once).and_return(false)
113
+ expect(File).to receive(:exists?).at_least(:once).and_return(false)
114
114
  @plugin.run
115
- @plugin[:virtualization].should == {'systems' => {}}
115
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
116
116
  end
117
117
  end
118
118
 
119
119
  describe "when we are checking for VirtualBox" do
120
120
  it "should set vbox host if /proc/modules contains vboxdrv" do
121
- File.should_receive(:exists?).with("/proc/modules").and_return(true)
122
- File.stub(:read).with("/proc/modules").and_return("vboxdrv 268268 3 vboxnetadp,vboxnetflt")
121
+ expect(File).to receive(:exists?).with("/proc/modules").and_return(true)
122
+ allow(File).to receive(:read).with("/proc/modules").and_return("vboxdrv 268268 3 vboxnetadp,vboxnetflt")
123
123
  @plugin.run
124
- @plugin[:virtualization][:system].should == "vbox"
125
- @plugin[:virtualization][:role].should == "host"
126
- @plugin[:virtualization][:systems][:vbox].should == "host"
124
+ expect(@plugin[:virtualization][:system]).to eq("vbox")
125
+ expect(@plugin[:virtualization][:role]).to eq("host")
126
+ expect(@plugin[:virtualization][:systems][:vbox]).to eq("host")
127
127
  end
128
128
 
129
129
  it "should set vbox gues if /proc/modules contains vboxguest" do
130
- File.should_receive(:exists?).with("/proc/modules").and_return(true)
131
- File.stub(:read).with("/proc/modules").and_return("vboxguest 214901 2 vboxsf, Live 0xffffffffa00db000 (OF)")
130
+ expect(File).to receive(:exists?).with("/proc/modules").and_return(true)
131
+ allow(File).to receive(:read).with("/proc/modules").and_return("vboxguest 214901 2 vboxsf, Live 0xffffffffa00db000 (OF)")
132
132
  @plugin.run
133
- @plugin[:virtualization][:system].should == "vbox"
134
- @plugin[:virtualization][:role].should == "guest"
135
- @plugin[:virtualization][:systems][:vbox].should == "guest"
133
+ expect(@plugin[:virtualization][:system]).to eq("vbox")
134
+ expect(@plugin[:virtualization][:role]).to eq("guest")
135
+ expect(@plugin[:virtualization][:systems][:vbox]).to eq("guest")
136
136
  end
137
137
 
138
138
  it "should not set virtualization if vbox isn't there" do
139
- File.should_receive(:exists?).at_least(:once).and_return(false)
139
+ expect(File).to receive(:exists?).at_least(:once).and_return(false)
140
140
  @plugin.run
141
- @plugin[:virtualization].should == {'systems' => {}}
141
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
142
142
  end
143
143
  end
144
144
 
145
145
  describe "when we are parsing dmidecode" do
146
146
  before(:each) do
147
- File.should_receive(:exists?).with("/usr/sbin/dmidecode").and_return(true)
147
+ expect(File).to receive(:exists?).with("/usr/sbin/dmidecode").and_return(true)
148
148
  end
149
149
 
150
150
  it "should set virtualpc guest if dmidecode detects Microsoft Virtual Machine" do
@@ -157,11 +157,11 @@ System Information
157
157
  UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9
158
158
  Wake-up Type: Power Switch
159
159
  MSVPC
160
- @plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, ms_vpc_dmidecode, ""))
160
+ allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, ms_vpc_dmidecode, ""))
161
161
  @plugin.run
162
- @plugin[:virtualization][:system].should == "virtualpc"
163
- @plugin[:virtualization][:role].should == "guest"
164
- @plugin[:virtualization][:systems][:virtualpc].should == "guest"
162
+ expect(@plugin[:virtualization][:system]).to eq("virtualpc")
163
+ expect(@plugin[:virtualization][:role]).to eq("guest")
164
+ expect(@plugin[:virtualization][:systems][:virtualpc]).to eq("guest")
165
165
  end
166
166
 
167
167
  it "should set vmware guest if dmidecode detects VMware Virtual Platform" do
@@ -176,11 +176,11 @@ System Information
176
176
  SKU Number: Not Specified
177
177
  Family: Not Specified
178
178
  VMWARE
179
- @plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vmware_dmidecode, ""))
179
+ allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vmware_dmidecode, ""))
180
180
  @plugin.run
181
- @plugin[:virtualization][:system].should == "vmware"
182
- @plugin[:virtualization][:role].should == "guest"
183
- @plugin[:virtualization][:systems][:vmware].should == "guest"
181
+ expect(@plugin[:virtualization][:system]).to eq("vmware")
182
+ expect(@plugin[:virtualization][:role]).to eq("guest")
183
+ expect(@plugin[:virtualization][:systems][:vmware]).to eq("guest")
184
184
  end
185
185
 
186
186
  it "should set vbox guest if dmidecode detects Oracle Corporation" do
@@ -197,105 +197,105 @@ Base Board Information
197
197
  Type: Motherboard
198
198
  Contained Object Handles: 0
199
199
  VBOX
200
- @plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vbox_dmidecode, ""))
200
+ allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vbox_dmidecode, ""))
201
201
  @plugin.run
202
- @plugin[:virtualization][:system].should == "vbox"
203
- @plugin[:virtualization][:role].should == "guest"
204
- @plugin[:virtualization][:systems][:vbox].should == "guest"
202
+ expect(@plugin[:virtualization][:system]).to eq("vbox")
203
+ expect(@plugin[:virtualization][:role]).to eq("guest")
204
+ expect(@plugin[:virtualization][:systems][:vbox]).to eq("guest")
205
205
  end
206
206
 
207
207
  it "should run dmidecode and not set virtualization if nothing is detected" do
208
- @plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, "", ""))
208
+ allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, "", ""))
209
209
  @plugin.run
210
- @plugin[:virtualization].should == {'systems' => {}}
210
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
211
211
  end
212
212
  end
213
213
 
214
214
  describe "when we are checking for Linux-VServer" do
215
215
  it "should set Linux-VServer host if /proc/self/status contains s_context: 0" do
216
- File.should_receive(:exists?).with("/proc/self/status").and_return(true)
217
- File.stub(:read).with("/proc/self/status").and_return("s_context: 0")
216
+ expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
217
+ allow(File).to receive(:read).with("/proc/self/status").and_return("s_context: 0")
218
218
  @plugin.run
219
- @plugin[:virtualization][:system].should == "linux-vserver"
220
- @plugin[:virtualization][:role].should == "host"
221
- @plugin[:virtualization][:systems]['linux-vserver'].should == "host"
219
+ expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
220
+ expect(@plugin[:virtualization][:role]).to eq("host")
221
+ expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
222
222
  end
223
223
 
224
224
  it "should set Linux-VServer host if /proc/self/status contains VxID: 0" do
225
- File.should_receive(:exists?).with("/proc/self/status").and_return(true)
226
- File.stub(:read).with("/proc/self/status").and_return("VxID: 0")
225
+ expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
226
+ allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 0")
227
227
  @plugin.run
228
- @plugin[:virtualization][:system].should == "linux-vserver"
229
- @plugin[:virtualization][:role].should == "host"
230
- @plugin[:virtualization][:systems]['linux-vserver'].should == "host"
228
+ expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
229
+ expect(@plugin[:virtualization][:role]).to eq("host")
230
+ expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
231
231
  end
232
232
 
233
233
  it "should set Linux-VServer host if /proc/self/status contains multiple space VxID: 0" do
234
- File.should_receive(:exists?).with("/proc/self/status").and_return(true)
235
- File.stub(:read).with("/proc/self/status").and_return("VxID: 0")
234
+ expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
235
+ allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 0")
236
236
  @plugin.run
237
- @plugin[:virtualization][:system].should == "linux-vserver"
238
- @plugin[:virtualization][:role].should == "host"
239
- @plugin[:virtualization][:systems]['linux-vserver'].should == "host"
237
+ expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
238
+ expect(@plugin[:virtualization][:role]).to eq("host")
239
+ expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
240
240
  end
241
241
 
242
242
  it "should set Linux-VServer host if /proc/self/status contains tabbed VxID:\t0" do
243
- File.should_receive(:exists?).with("/proc/self/status").and_return(true)
244
- File.stub(:read).with("/proc/self/status").and_return("VxID:\t0")
243
+ expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
244
+ allow(File).to receive(:read).with("/proc/self/status").and_return("VxID:\t0")
245
245
  @plugin.run
246
- @plugin[:virtualization][:system].should == "linux-vserver"
247
- @plugin[:virtualization][:role].should == "host"
248
- @plugin[:virtualization][:systems]['linux-vserver'].should == "host"
246
+ expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
247
+ expect(@plugin[:virtualization][:role]).to eq("host")
248
+ expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
249
249
  end
250
250
 
251
251
  it "should set Linux-VServer guest if /proc/self/status contains s_context > 0" do
252
- File.should_receive(:exists?).with("/proc/self/status").and_return(true)
253
- File.stub(:read).with("/proc/self/status").and_return("s_context: 2")
252
+ expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
253
+ allow(File).to receive(:read).with("/proc/self/status").and_return("s_context: 2")
254
254
  @plugin.run
255
- @plugin[:virtualization][:system].should == "linux-vserver"
256
- @plugin[:virtualization][:role].should == "guest"
257
- @plugin[:virtualization][:systems]['linux-vserver'].should == "guest"
255
+ expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
256
+ expect(@plugin[:virtualization][:role]).to eq("guest")
257
+ expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("guest")
258
258
  end
259
259
 
260
260
  it "should set Linux-VServer guest if /proc/self/status contains VxID > 0" do
261
- File.should_receive(:exists?).with("/proc/self/status").and_return(true)
262
- File.stub(:read).with("/proc/self/status").and_return("VxID: 2")
261
+ expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
262
+ allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 2")
263
263
  @plugin.run
264
- @plugin[:virtualization][:system].should == "linux-vserver"
265
- @plugin[:virtualization][:role].should == "guest"
266
- @plugin[:virtualization][:systems]['linux-vserver'].should == "guest"
264
+ expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
265
+ expect(@plugin[:virtualization][:role]).to eq("guest")
266
+ expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("guest")
267
267
  end
268
268
 
269
269
  it "should not set virtualization if Linux-VServer isn't there" do
270
- File.should_receive(:exists?).at_least(:once).and_return(false)
270
+ expect(File).to receive(:exists?).at_least(:once).and_return(false)
271
271
  @plugin.run
272
- @plugin[:virtualization].should == {'systems' => {}}
272
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
273
273
  end
274
274
  end
275
275
 
276
276
  describe "when we are checking for openvz" do
277
277
  it "should set openvz host if /proc/bc/0 exists" do
278
- File.should_receive(:exists?).with("/proc/bc/0").and_return(true)
278
+ expect(File).to receive(:exists?).with("/proc/bc/0").and_return(true)
279
279
  @plugin.run
280
- @plugin[:virtualization][:system].should == "openvz"
281
- @plugin[:virtualization][:role].should == "host"
282
- @plugin[:virtualization][:systems][:openvz].should == "host"
280
+ expect(@plugin[:virtualization][:system]).to eq("openvz")
281
+ expect(@plugin[:virtualization][:role]).to eq("host")
282
+ expect(@plugin[:virtualization][:systems][:openvz]).to eq("host")
283
283
  end
284
284
 
285
285
  it "should set openvz guest if /proc/bc/0 doesn't exist and /proc/vz exists" do
286
- File.should_receive(:exists?).with("/proc/bc/0").and_return(false)
287
- File.should_receive(:exists?).with("/proc/vz").and_return(true)
286
+ expect(File).to receive(:exists?).with("/proc/bc/0").and_return(false)
287
+ expect(File).to receive(:exists?).with("/proc/vz").and_return(true)
288
288
  @plugin.run
289
- @plugin[:virtualization][:system].should == "openvz"
290
- @plugin[:virtualization][:role].should == "guest"
291
- @plugin[:virtualization][:systems][:openvz].should == "guest"
289
+ expect(@plugin[:virtualization][:system]).to eq("openvz")
290
+ expect(@plugin[:virtualization][:role]).to eq("guest")
291
+ expect(@plugin[:virtualization][:systems][:openvz]).to eq("guest")
292
292
  end
293
293
 
294
294
  it "should not set virtualization if openvz isn't there" do
295
- File.should_receive(:exists?).with("/proc/bc/0").and_return(false)
296
- File.should_receive(:exists?).with("/proc/vz").and_return(false)
295
+ expect(File).to receive(:exists?).with("/proc/bc/0").and_return(false)
296
+ expect(File).to receive(:exists?).with("/proc/vz").and_return(false)
297
297
  @plugin.run
298
- @plugin[:virtualization].should == {'systems' => {}}
298
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
299
299
  end
300
300
  end
301
301
 
@@ -311,12 +311,12 @@ VBOX
311
311
  2:cpu:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
312
312
  1:cpuset:/
313
313
  CGROUP
314
- File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
315
- File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
314
+ expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
315
+ allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
316
316
  @plugin.run
317
- @plugin[:virtualization][:system].should == "lxc"
318
- @plugin[:virtualization][:role].should == "guest"
319
- @plugin[:virtualization][:systems][:lxc].should == "guest"
317
+ expect(@plugin[:virtualization][:system]).to eq("lxc")
318
+ expect(@plugin[:virtualization][:role]).to eq("guest")
319
+ expect(@plugin[:virtualization][:systems][:lxc]).to eq("guest")
320
320
  end
321
321
 
322
322
  it "should set lxc guest if /proc/self/cgroup exist and there are /lxc/<name> mounts" do
@@ -330,12 +330,12 @@ CGROUP
330
330
  2:cpu:/lxc/vanilla
331
331
  1:cpuset:/lxc/vanilla
332
332
  CGROUP
333
- File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
334
- File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
333
+ expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
334
+ allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
335
335
  @plugin.run
336
- @plugin[:virtualization][:system].should == "lxc"
337
- @plugin[:virtualization][:role].should == "guest"
338
- @plugin[:virtualization][:systems][:lxc].should == "guest"
336
+ expect(@plugin[:virtualization][:system]).to eq("lxc")
337
+ expect(@plugin[:virtualization][:role]).to eq("guest")
338
+ expect(@plugin[:virtualization][:systems][:lxc]).to eq("guest")
339
339
  end
340
340
 
341
341
  it "should set lxc guest if /proc/self/cgroup exist and there are /docker/<name> mounts" do
@@ -351,12 +351,12 @@ CGROUP
351
351
  3:cpuset:/
352
352
  2:name=systemd:/system.slice/docker.service
353
353
  CGROUP
354
- File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
355
- File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
354
+ expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
355
+ allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
356
356
  @plugin.run
357
- @plugin[:virtualization][:system].should == "lxc"
358
- @plugin[:virtualization][:role].should == "guest"
359
- @plugin[:virtualization][:systems][:lxc].should == "guest"
357
+ expect(@plugin[:virtualization][:system]).to eq("lxc")
358
+ expect(@plugin[:virtualization][:role]).to eq("guest")
359
+ expect(@plugin[:virtualization][:systems][:lxc]).to eq("guest")
360
360
  end
361
361
 
362
362
  it "should set not set anything if /proc/self/cgroup exist and the cgroup is named arbitrarily, it isn't necessarily lxc." do
@@ -370,10 +370,10 @@ CGROUP
370
370
  2:cpu:/Charlie
371
371
  1:cpuset:/Charlie
372
372
  CGROUP
373
- File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
374
- File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
373
+ expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
374
+ allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
375
375
  @plugin.run
376
- @plugin[:virtualization].should == {'systems' => {}}
376
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
377
377
  end
378
378
 
379
379
  context "/proc/self/cgroup only has / mounts" do
@@ -388,47 +388,47 @@ CGROUP
388
388
  2:cpu:/
389
389
  1:cpuset:/
390
390
  CGROUP
391
- File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
392
- File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
391
+ expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
392
+ allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
393
393
  end
394
394
 
395
395
  it "sets lxc host if lxc-version exists" do
396
- @plugin.stub(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
396
+ allow(@plugin).to receive(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
397
397
  @plugin.run
398
- @plugin[:virtualization][:system].should == "lxc"
399
- @plugin[:virtualization][:role].should == "host"
400
- @plugin[:virtualization][:systems][:lxc].should == "host"
398
+ expect(@plugin[:virtualization][:system]).to eq("lxc")
399
+ expect(@plugin[:virtualization][:role]).to eq("host")
400
+ expect(@plugin[:virtualization][:systems][:lxc]).to eq("host")
401
401
  end
402
402
 
403
403
  it "does not set the old virtualization attributes if they are already set" do
404
- @plugin.stub(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
404
+ allow(@plugin).to receive(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
405
405
  @plugin[:virtualization] = Mash.new
406
406
  @plugin[:virtualization][:system] = "the cloud"
407
407
  @plugin[:virtualization][:role] = "cumulonimbus"
408
408
  @plugin.run
409
- @plugin[:virtualization][:system].should_not == "lxc"
410
- @plugin[:virtualization][:role].should_not == "host"
409
+ expect(@plugin[:virtualization][:system]).not_to eq("lxc")
410
+ expect(@plugin[:virtualization][:role]).not_to eq("host")
411
411
  end
412
412
 
413
413
  it "does not set lxc host if lxc-version does not exist" do
414
- @plugin.stub(:lxc_version_exists?).and_return(false)
414
+ allow(@plugin).to receive(:lxc_version_exists?).and_return(false)
415
415
  @plugin.run
416
- @plugin[:virtualization][:system].should be_nil
417
- @plugin[:virtualization][:role].should be_nil
418
- @plugin[:virtualization].should == {'systems' => {}}
416
+ expect(@plugin[:virtualization][:system]).to be_nil
417
+ expect(@plugin[:virtualization][:role]).to be_nil
418
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
419
419
  end
420
420
 
421
421
  end
422
422
 
423
423
  it "should not set virtualization if /proc/self/cgroup isn't there" do
424
- File.should_receive(:exists?).with("/proc/self/cgroup").and_return(false)
424
+ expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(false)
425
425
  @plugin.run
426
- @plugin[:virtualization].should == {'systems' => {}}
426
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
427
427
  end
428
428
  end
429
429
 
430
430
  it "should not set virtualization if no tests match" do
431
431
  @plugin.run
432
- @plugin[:virtualization].should == {'systems' => {}}
432
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
433
433
  end
434
434
  end