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
@@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
21
21
  describe Ohai::System, "Solaris2.X hostname plugin" do
22
22
  before(:each) do
23
23
  @plugin = get_plugin("hostname")
24
- @plugin.stub(:collect_os).and_return(:solaris2)
25
- @plugin.stub(:resolve_fqdn).and_return("kitteh.inurfridge.eatinurfoodz")
26
- @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "kitteh\n", ""))
24
+ allow(@plugin).to receive(:collect_os).and_return(:solaris2)
25
+ allow(@plugin).to receive(:resolve_fqdn).and_return("kitteh.inurfridge.eatinurfoodz")
26
+ allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "kitteh\n", ""))
27
27
  # Socket.stub(:getaddrinfo).and_return( [["AF_INET", 0, "kitteh.inurfridge.eatinurfoodz", "10.1.2.3", 2, 0, 0]] );
28
28
  end
29
29
 
@@ -31,7 +31,7 @@ describe Ohai::System, "Solaris2.X hostname plugin" do
31
31
 
32
32
  it "should get the fqdn value from #resolve_fqdn" do
33
33
  @plugin.run
34
- @plugin["fqdn"].should == "kitteh.inurfridge.eatinurfoodz"
34
+ expect(@plugin["fqdn"]).to eq("kitteh.inurfridge.eatinurfoodz")
35
35
  end
36
36
 
37
37
  end
@@ -135,10 +135,10 @@ describe Ohai::System, "Solaris2.X kernel plugin" do
135
135
 
136
136
  before(:each) do
137
137
  @plugin = get_plugin("kernel")
138
- @plugin.stub(:collect_os).and_return(:solaris2)
139
- @plugin.stub(:init_kernel).and_return({})
140
- @plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "SunOS\n", ""))
141
- @plugin.stub(:shell_out).with("modinfo").and_return(mock_shell_out(0, MODINFO, ""))
138
+ allow(@plugin).to receive(:collect_os).and_return(:solaris2)
139
+ allow(@plugin).to receive(:init_kernel).and_return({})
140
+ allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "SunOS\n", ""))
141
+ allow(@plugin).to receive(:shell_out).with("modinfo").and_return(mock_shell_out(0, MODINFO, ""))
142
142
  end
143
143
 
144
144
  it_should_check_from_deep_mash("solaris2::kernel", "kernel", "os", "uname -s", [0, "SunOS\n", ""])
@@ -146,15 +146,15 @@ describe Ohai::System, "Solaris2.X kernel plugin" do
146
146
  it "gives excruciating detail about kernel modules" do
147
147
  @plugin.run
148
148
 
149
- @plugin[:kernel][:modules].should have(107).modules
149
+ expect(@plugin[:kernel][:modules]).to have(107).modules
150
150
 
151
151
  # Teh daterz
152
152
  # Id Loadaddr Size Info Rev Module Name
153
153
  # 6 1180000 4623 1 1 specfs (filesystem for specfs)
154
154
  teh_daterz = { "id" => 6, "loadaddr" => "1180000", "size" => 17955, "description" => "filesystem for specfs"}
155
- @plugin[:kernel][:modules].keys.should include("specfs")
156
- @plugin[:kernel][:modules].keys.should_not include("Module")
157
- @plugin[:kernel][:modules]["specfs"].should == teh_daterz
155
+ expect(@plugin[:kernel][:modules].keys).to include("specfs")
156
+ expect(@plugin[:kernel][:modules].keys).not_to include("Module")
157
+ expect(@plugin[:kernel][:modules]["specfs"]).to eq(teh_daterz)
158
158
  end
159
159
 
160
160
  end
@@ -19,12 +19,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
19
19
  describe Ohai::System, "Solaris2.X memory plugin" do
20
20
  before(:each) do
21
21
  @plugin = get_plugin("solaris2/memory")
22
- @plugin.stub(:collect_os).and_return("solaris2")
23
- @plugin.stub(:shell_out).with("prtconf -m").and_return(mock_shell_out(0, "8194\n", ""))
22
+ allow(@plugin).to receive(:collect_os).and_return("solaris2")
23
+ allow(@plugin).to receive(:shell_out).with("prtconf -m").and_return(mock_shell_out(0, "8194\n", ""))
24
24
  end
25
25
 
26
26
  it "should get the total memory" do
27
27
  @plugin.run
28
- @plugin['memory']['total'].should eql(8194)
28
+ expect(@plugin['memory']['total']).to eql(8194)
29
29
  end
30
30
  end
@@ -112,40 +112,40 @@ ROUTE_GET
112
112
  @ifconfig_lines = @solaris_ifconfig.split("\n")
113
113
 
114
114
  @plugin = get_plugin("solaris2/network")
115
- @plugin.stub(:collect_os).and_return(:solaris2)
115
+ allow(@plugin).to receive(:collect_os).and_return(:solaris2)
116
116
  @plugin[:network] = Mash.new
117
117
 
118
- @plugin.stub(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_route_get, ""))
119
- @plugin.stub(:shell_out).with("arp -an").and_return(mock_shell_out(0, @solaris_arp_rn, ""))
120
- @plugin.stub(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @soalris_route_get, ""))
118
+ allow(@plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_route_get, ""))
119
+ allow(@plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, @solaris_arp_rn, ""))
120
+ allow(@plugin).to receive(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @soalris_route_get, ""))
121
121
  end
122
122
 
123
123
  describe "gathering IP layer address info" do
124
124
  before do
125
125
  @stdout = double("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get)
126
- @plugin.stub(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
127
- @plugin.stub(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_ifconfig, ""))
126
+ allow(@plugin).to receive(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
127
+ allow(@plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_ifconfig, ""))
128
128
  @plugin.run
129
129
  end
130
130
 
131
131
  it "completes the run" do
132
- @plugin['network'].should_not be_nil
132
+ expect(@plugin['network']).not_to be_nil
133
133
  end
134
134
 
135
135
  it "detects the interfaces" do
136
- @plugin['network']['interfaces'].keys.sort.should == ["e1000g0:3", "e1000g2:1", "eri0", "ip.tun0", "ip.tun0:1", "lo0", "lo0:3","net0", "qfe1"]
136
+ expect(@plugin['network']['interfaces'].keys.sort).to eq(["e1000g0:3", "e1000g2:1", "eri0", "ip.tun0", "ip.tun0:1", "lo0", "lo0:3","net0", "qfe1"])
137
137
  end
138
138
 
139
139
  it "detects the ip addresses of the interfaces" do
140
- @plugin['network']['interfaces']['e1000g0:3']['addresses'].keys.should include('72.2.115.28')
140
+ expect(@plugin['network']['interfaces']['e1000g0:3']['addresses'].keys).to include('72.2.115.28')
141
141
  end
142
142
 
143
143
  it "detects the encapsulation type of the interfaces" do
144
- @plugin['network']['interfaces']['e1000g0:3']['encapsulation'].should == 'Ethernet'
144
+ expect(@plugin['network']['interfaces']['e1000g0:3']['encapsulation']).to eq('Ethernet')
145
145
  end
146
146
 
147
147
  it "detects the L3PROTECT network flag" do
148
- @plugin['network']['interfaces']['net0']['flags'].should include('L3PROTECT')
148
+ expect(@plugin['network']['interfaces']['net0']['flags']).to include('L3PROTECT')
149
149
  end
150
150
  end
151
151
 
@@ -154,12 +154,12 @@ ROUTE_GET
154
154
  describe "setting the node's default IP address attribute" do
155
155
  before do
156
156
  @stdout = double("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get)
157
- @plugin.stub(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
157
+ allow(@plugin).to receive(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
158
158
  @plugin.run
159
159
  end
160
160
 
161
161
  it "finds the default interface by asking which iface has the default route" do
162
- @plugin[:network][:default_interface].should == 'e1000g0'
162
+ expect(@plugin[:network][:default_interface]).to eq('e1000g0')
163
163
  end
164
164
  end
165
165
  end
@@ -21,8 +21,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
21
21
  describe Ohai::System, "Solaris plugin platform" do
22
22
  before(:each) do
23
23
  @plugin = get_plugin("solaris2/platform")
24
- @plugin.stub(:collect_os).and_return(:solaris2)
25
- @plugin.stub(:shell_out).with("/sbin/uname -X")
24
+ allow(@plugin).to receive(:collect_os).and_return(:solaris2)
25
+ allow(@plugin).to receive(:shell_out).with("/sbin/uname -X")
26
26
  end
27
27
 
28
28
  describe "on SmartOS" do
@@ -41,26 +41,26 @@ Origin# = 1
41
41
  NumCPU = 16
42
42
  UNAME_X
43
43
 
44
- File.stub(:exists?).with("/sbin/uname").and_return(true)
45
- @plugin.stub(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
44
+ allow(File).to receive(:exists?).with("/sbin/uname").and_return(true)
45
+ allow(@plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
46
46
 
47
47
  @release = StringIO.new(" SmartOS 20120130T201844Z x86_64\n")
48
- File.stub(:open).with("/etc/release").and_yield(@release)
48
+ allow(File).to receive(:open).with("/etc/release").and_yield(@release)
49
49
  end
50
50
 
51
51
  it "should run uname and set platform and build" do
52
52
  @plugin.run
53
- @plugin[:platform_build].should == "joyent_20120130T201844Z"
53
+ expect(@plugin[:platform_build]).to eq("joyent_20120130T201844Z")
54
54
  end
55
55
 
56
56
  it "should set the platform" do
57
57
  @plugin.run
58
- @plugin[:platform].should == "smartos"
58
+ expect(@plugin[:platform]).to eq("smartos")
59
59
  end
60
60
 
61
61
  it "should set the platform_version" do
62
62
  @plugin.run
63
- @plugin[:platform_version].should == "5.11"
63
+ expect(@plugin[:platform_version]).to eq("5.11")
64
64
  end
65
65
 
66
66
  end
@@ -81,26 +81,26 @@ Origin# = 1
81
81
  NumCPU = 1
82
82
  UNAME_X
83
83
 
84
- File.stub(:exists?).with("/sbin/uname").and_return(true)
85
- @plugin.stub(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
84
+ allow(File).to receive(:exists?).with("/sbin/uname").and_return(true)
85
+ allow(@plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
86
86
 
87
87
  @release = StringIO.new(" Oracle Solaris 11.1 X86\n")
88
- File.stub(:open).with("/etc/release").and_yield(@release)
88
+ allow(File).to receive(:open).with("/etc/release").and_yield(@release)
89
89
  end
90
90
 
91
91
  it "should run uname and set platform and build" do
92
92
  @plugin.run
93
- @plugin[:platform_build].should == "11.1"
93
+ expect(@plugin[:platform_build]).to eq("11.1")
94
94
  end
95
95
 
96
96
  it "should set the platform" do
97
97
  @plugin.run
98
- @plugin[:platform].should == "solaris2"
98
+ expect(@plugin[:platform]).to eq("solaris2")
99
99
  end
100
100
 
101
101
  it "should set the platform_version" do
102
102
  @plugin.run
103
- @plugin[:platform_version].should == "5.11"
103
+ expect(@plugin[:platform_version]).to eq("5.11")
104
104
  end
105
105
 
106
106
  end
@@ -27,47 +27,47 @@ The physical processor has 1 virtual processor (0)
27
27
  PSRINFO_PV
28
28
 
29
29
  @plugin = get_plugin("solaris2/virtualization")
30
- @plugin.stub(:collect_os).and_return(:solaris2)
30
+ allow(@plugin).to receive(:collect_os).and_return(:solaris2)
31
31
 
32
32
  # default to all requested Files not existing
33
- File.stub(:exists?).with("/usr/sbin/psrinfo").and_return(false)
34
- File.stub(:exists?).with("/usr/sbin/smbios").and_return(false)
35
- File.stub(:exists?).with("/usr/sbin/zoneadm").and_return(false)
36
- @plugin.stub(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, "", ""))
37
- @plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "", ""))
33
+ allow(File).to receive(:exists?).with("/usr/sbin/psrinfo").and_return(false)
34
+ allow(File).to receive(:exists?).with("/usr/sbin/smbios").and_return(false)
35
+ allow(File).to receive(:exists?).with("/usr/sbin/zoneadm").and_return(false)
36
+ allow(@plugin).to receive(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, "", ""))
37
+ allow(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "", ""))
38
38
  end
39
39
 
40
40
  describe "when we are checking for kvm" do
41
41
  before(:each) do
42
- File.should_receive(:exists?).with("/usr/sbin/psrinfo").and_return(true)
42
+ expect(File).to receive(:exists?).with("/usr/sbin/psrinfo").and_return(true)
43
43
  end
44
44
 
45
45
  it "should run psrinfo -pv" do
46
- @plugin.should_receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv")
46
+ expect(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv")
47
47
  @plugin.run
48
48
  end
49
49
 
50
50
  it "Should set kvm guest if psrinfo -pv contains QEMU Virtual CPU" do
51
- @plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "QEMU Virtual CPU", ""))
51
+ allow(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "QEMU Virtual CPU", ""))
52
52
  @plugin.run
53
- @plugin[:virtualization][:system].should == "kvm"
54
- @plugin[:virtualization][:role].should == "guest"
53
+ expect(@plugin[:virtualization][:system]).to eq("kvm")
54
+ expect(@plugin[:virtualization][:role]).to eq("guest")
55
55
  end
56
56
 
57
57
  it "should not set virtualization if kvm isn't there" do
58
- @plugin.should_receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, @psrinfo_pv, ""))
58
+ expect(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, @psrinfo_pv, ""))
59
59
  @plugin.run
60
- @plugin[:virtualization].should == {}
60
+ expect(@plugin[:virtualization]).to eq({})
61
61
  end
62
62
  end
63
63
 
64
64
  describe "when we are parsing smbios" do
65
65
  before(:each) do
66
- File.should_receive(:exists?).with("/usr/sbin/smbios").and_return(true)
66
+ expect(File).to receive(:exists?).with("/usr/sbin/smbios").and_return(true)
67
67
  end
68
68
 
69
69
  it "should run smbios" do
70
- @plugin.should_receive(:shell_out).with("/usr/sbin/smbios")
70
+ expect(@plugin).to receive(:shell_out).with("/usr/sbin/smbios")
71
71
  @plugin.run
72
72
  end
73
73
 
@@ -84,10 +84,10 @@ ID SIZE TYPE
84
84
  UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9
85
85
  Wake-Up Event: 0x6 (power switch)
86
86
  MSVPC
87
- @plugin.stub(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, ms_vpc_smbios, ""))
87
+ allow(@plugin).to receive(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, ms_vpc_smbios, ""))
88
88
  @plugin.run
89
- @plugin[:virtualization][:system].should == "virtualpc"
90
- @plugin[:virtualization][:role].should == "guest"
89
+ expect(@plugin[:virtualization][:system]).to eq("virtualpc")
90
+ expect(@plugin[:virtualization][:role]).to eq("guest")
91
91
  end
92
92
 
93
93
  it "should set vmware guest if smbios detects VMware Virtual Platform" do
@@ -103,22 +103,22 @@ ID SIZE TYPE
103
103
  UUID: a86cc405-e1b9-447b-ad05-6f8db39d876a
104
104
  Wake-Up Event: 0x6 (power switch)
105
105
  VMWARE
106
- @plugin.stub(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, vmware_smbios, ""))
106
+ allow(@plugin).to receive(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, vmware_smbios, ""))
107
107
  @plugin.run
108
- @plugin[:virtualization][:system].should == "vmware"
109
- @plugin[:virtualization][:role].should == "guest"
108
+ expect(@plugin[:virtualization][:system]).to eq("vmware")
109
+ expect(@plugin[:virtualization][:role]).to eq("guest")
110
110
  end
111
111
 
112
112
  it "should run smbios and not set virtualization if nothing is detected" do
113
- @plugin.should_receive(:shell_out).with("/usr/sbin/smbios")
113
+ expect(@plugin).to receive(:shell_out).with("/usr/sbin/smbios")
114
114
  @plugin.run
115
- @plugin[:virtualization].should == {}
115
+ expect(@plugin[:virtualization]).to eq({})
116
116
  end
117
117
  end
118
118
 
119
119
  it "should not set virtualization if no tests match" do
120
120
  @plugin.run
121
- @plugin[:virtualization].should == {}
121
+ expect(@plugin[:virtualization]).to eq({})
122
122
  end
123
123
  end
124
124
 
@@ -18,7 +18,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
18
18
  describe Ohai::System, "Solaris 2.x zpool plugin" do
19
19
  before(:each) do
20
20
  @plugin = get_plugin("solaris2/zpools")
21
- @plugin.stub(:collect_os).and_return(:solaris2)
21
+ allow(@plugin).to receive(:collect_os).and_return(:solaris2)
22
22
 
23
23
  @zpool_status_rpool = <<-EOSR
24
24
  pool: rpool
@@ -62,9 +62,9 @@ EOST
62
62
  rpool 109G 66.2G 42.8G 60% 1.00x ONLINE 34
63
63
  tank 130T 4.91M 130T 0% 1.00x ONLINE 34
64
64
  EOZO
65
- @plugin.stub(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,""))
66
- @plugin.stub(:shell_out).with("su adm -c \"zpool status rpool\"").and_return(mock_shell_out(0,@zpool_status_rpool,""))
67
- @plugin.stub(:shell_out).with("su adm -c \"zpool status tank\"").and_return(mock_shell_out(0,@zpool_status_tank,""))
65
+ allow(@plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,""))
66
+ allow(@plugin).to receive(:shell_out).with("su adm -c \"zpool status rpool\"").and_return(mock_shell_out(0,@zpool_status_rpool,""))
67
+ allow(@plugin).to receive(:shell_out).with("su adm -c \"zpool status tank\"").and_return(mock_shell_out(0,@zpool_status_tank,""))
68
68
  end
69
69
 
70
70
  describe "On Solaris2 Common" do
@@ -123,7 +123,7 @@ EOZO
123
123
  rpool 109G 66.2G 42.8G 60% 1.00x ONLINE -
124
124
  tank 130T 4.91M 130T 0% 1.00x ONLINE -
125
125
  EOZO
126
- @plugin.stub(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,""))
126
+ allow(@plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,""))
127
127
  end
128
128
 
129
129
  it "Won't have a version number" do
@@ -140,7 +140,7 @@ EOZO
140
140
  rpool 109G 66.2G 42.8G 60% 1.00x ONLINE 34
141
141
  tank 130T 4.91M 130T 0% 1.00x ONLINE 34
142
142
  EOZO
143
- @plugin.stub(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,""))
143
+ allow(@plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,""))
144
144
  end
145
145
 
146
146
  it "Should have a version number" do
@@ -24,43 +24,43 @@ describe Ohai::System, "ssh_host_key plugin" do
24
24
  @plugin = get_plugin("ssh_host_key")
25
25
  @plugin[:keys] = Mash.new
26
26
 
27
- File.stub(:exists?).with("/etc/ssh/sshd_config").and_return(true)
28
- File.stub(:open).with("/etc/ssh/sshd_config").and_yield(sshd_config_file)
29
- File.stub(:exists?).and_return(true)
30
- File.stub(:exists?).with("/etc/ssh/ssh_host_dsa_key.pub").and_return(true)
31
- File.stub(:exists?).with("/etc/ssh/ssh_host_rsa_key.pub").and_return(true)
32
- File.stub(:exists?).with("/etc/ssh/ssh_host_ecdsa_key.pub").and_return(true)
27
+ allow(File).to receive(:exists?).with("/etc/ssh/sshd_config").and_return(true)
28
+ allow(File).to receive(:open).with("/etc/ssh/sshd_config").and_yield(sshd_config_file)
29
+ allow(File).to receive(:exists?).and_return(true)
30
+ allow(File).to receive(:exists?).with("/etc/ssh/ssh_host_dsa_key.pub").and_return(true)
31
+ allow(File).to receive(:exists?).with("/etc/ssh/ssh_host_rsa_key.pub").and_return(true)
32
+ allow(File).to receive(:exists?).with("/etc/ssh/ssh_host_ecdsa_key.pub").and_return(true)
33
33
 
34
34
  # Ensure we can still use IO.read
35
35
  io_read = IO.method(:read)
36
- IO.stub(:read) { |file| io_read.call(file) }
36
+ allow(IO).to receive(:read) { |file| io_read.call(file) }
37
37
 
38
38
  # Return fake public key files so we don't have to go digging for them in unit tests
39
39
  @dsa_key = "ssh-dss AAAAB3NzaC1kc3MAAACBAMHlT02xN8kietxPfhcb98xHueTzKCOTz6dZlP/dmKILHrQOAExuSEeNiA2uvmhHNVQvs/cBsRiDxgSKux3ie2q8+MB6vHCiSpSkoPjrL75iT57YDilCB4/sytt6IJpj+H42wRDWTX0/QRybMHUvmnmEL0cwZXykSvrIum0BKB6hAAAAFQDsi6WUCClhtZIiTY9uh8eAre+SbQAAAIEAgNnuw0uEuqtcVif+AYd/bCZvL9FPqg7DrmTkamNEcVinhUGwsPGJTLJf+o5ens1X4RzQoi1R6Y6zCTL2FN/hZgINJNO0z9BN402wWrZmQd+Vb1U5DyDtveuvipqyQS+fm9neRwdLuv36Fc9f9nkZ7YHpkGPJp+yJpG4OoeREhwgAAACBAIf9kKLf2XiXnlByzlJ2Naa55d/hp2E059VKCRsBS++xFKYKvSqjnDQBFiMtAUhb8EdTyBGyalqOgqogDQVtwHfTZWZwqHAhry9aM06y92Eu/xSey4tWjKeknOsnRe640KC4zmKDBRTrjjkuAdrKPN9k3jl+OCc669JHlIfo6kqf oppa"
40
40
  @rsa_key = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuhcVXV+nNapkyUC5p4TH1ymRxUjtMBKqYWmwyI29gVFnUNeHkKFHWon0KFeGJP2Rm8BfTiZa9ER9e8pRr4Nd+z1C1o0kVoxEEfB9tpSdTlpk1GG83D94l57fij8THRVIwuCEosViUlg1gDgC4SpxbqfdBkUN2qyf6JDOh7t2QpYh7berpDEWeBpb7BKdLEDT57uw7ijKzSNyaXqq8KkB9I+UFrRwpuos4W7ilX+PQ+mWLi2ZZJfTYZMxxVS+qJwiDtNxGCRwTOQZG03kI7eLBZG+igupr0uD4o6qeftPOr0kxgjoPU4nEKvYiGq8Rqd2vYrhiaJHLk9QB6xStQvS3Q== oppa"
41
41
  @ecdsa_key = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBx8VgvxmHxs/sIn/ATh0iUcuz1I2Xc0e1ejXCGHBMZ98IE3FBt1ezlqCpNMcHVV2skQQ8vyLbKxzweyZuNSDU8= oppa"
42
- IO.stub(:read).with("/etc/ssh/ssh_host_dsa_key.pub").and_return(@dsa_key)
43
- IO.stub(:read).with("/etc/ssh/ssh_host_rsa_key.pub").and_return(@rsa_key)
44
- IO.stub(:read).with("/etc/ssh/ssh_host_ecdsa_key.pub").and_return(@ecdsa_key)
42
+ allow(IO).to receive(:read).with("/etc/ssh/ssh_host_dsa_key.pub").and_return(@dsa_key)
43
+ allow(IO).to receive(:read).with("/etc/ssh/ssh_host_rsa_key.pub").and_return(@rsa_key)
44
+ allow(IO).to receive(:read).with("/etc/ssh/ssh_host_ecdsa_key.pub").and_return(@ecdsa_key)
45
45
  end
46
46
 
47
47
  shared_examples "loads keys" do
48
48
  it "reads the key and sets the dsa attribute correctly" do
49
49
  @plugin.run
50
- @plugin[:keys][:ssh][:host_dsa_public].should eql(@dsa_key.split[1])
51
- @plugin[:keys][:ssh][:host_dsa_type].should be_nil
50
+ expect(@plugin[:keys][:ssh][:host_dsa_public]).to eql(@dsa_key.split[1])
51
+ expect(@plugin[:keys][:ssh][:host_dsa_type]).to be_nil
52
52
  end
53
53
 
54
54
  it "reads the key and sets the rsa attribute correctly" do
55
55
  @plugin.run
56
- @plugin[:keys][:ssh][:host_rsa_public].should eql(@rsa_key.split[1])
57
- @plugin[:keys][:ssh][:host_rsa_type].should be_nil
56
+ expect(@plugin[:keys][:ssh][:host_rsa_public]).to eql(@rsa_key.split[1])
57
+ expect(@plugin[:keys][:ssh][:host_rsa_type]).to be_nil
58
58
  end
59
59
 
60
60
  it "reads the key and sets the ecdsa attribute correctly" do
61
61
  @plugin.run
62
- @plugin[:keys][:ssh][:host_ecdsa_public].should eql(@ecdsa_key.split[1])
63
- @plugin[:keys][:ssh][:host_ecdsa_type].should eql(@ecdsa_key.split[0])
62
+ expect(@plugin[:keys][:ssh][:host_ecdsa_public]).to eql(@ecdsa_key.split[1])
63
+ expect(@plugin[:keys][:ssh][:host_ecdsa_type]).to eql(@ecdsa_key.split[0])
64
64
  end
65
65
  end
66
66
 
@@ -93,8 +93,8 @@ EOS
93
93
  nil
94
94
  end
95
95
  before do
96
- File.stub(:exists?).with("/etc/ssh/sshd_config").and_return(false)
97
- File.stub(:exists?).with("/etc/sshd_config").and_return(false)
96
+ allow(File).to receive(:exists?).with("/etc/ssh/sshd_config").and_return(false)
97
+ allow(File).to receive(:exists?).with("/etc/sshd_config").and_return(false)
98
98
  end
99
99
 
100
100
  it_behaves_like "loads keys"
@@ -29,7 +29,7 @@ describe Ohai::Runner, "run_plugin" do
29
29
 
30
30
  describe "when running an invalid plugin" do
31
31
  it "should raise error" do
32
- lambda { @runner.run_plugin(double("Ohai::NotPlugin")) }.should raise_error(Ohai::Exceptions::InvalidPlugin)
32
+ expect { @runner.run_plugin(double("Ohai::NotPlugin")) }.to raise_error(Ohai::Exceptions::InvalidPlugin)
33
33
  end
34
34
  end
35
35
 
@@ -40,7 +40,7 @@ describe Ohai::Runner, "run_plugin" do
40
40
 
41
41
  describe "version 7" do
42
42
  it "should call run_v7_plugin" do
43
- @runner.should_receive(:run_v7_plugin)
43
+ expect(@runner).to receive(:run_v7_plugin)
44
44
  @runner.run_plugin(plugin)
45
45
  end
46
46
 
@@ -48,7 +48,7 @@ describe Ohai::Runner, "run_plugin" do
48
48
  let(:has_run) { true }
49
49
 
50
50
  it "should not run the plugin" do
51
- plugin.should_not_receive(:safe_run)
51
+ expect(plugin).not_to receive(:safe_run)
52
52
  @runner.run_plugin(plugin)
53
53
  end
54
54
  end
@@ -58,14 +58,14 @@ describe Ohai::Runner, "run_plugin" do
58
58
  let(:version) { :version6 }
59
59
 
60
60
  it "should call run_v6_plugin" do
61
- @runner.should_receive(:run_v6_plugin)
61
+ expect(@runner).to receive(:run_v6_plugin)
62
62
  @runner.run_plugin(plugin)
63
63
  end
64
64
 
65
65
  describe "if the plugin has not run before" do
66
66
  describe "if safe_run is not set" do
67
67
  it "safe_run should be called" do
68
- plugin.should_receive(:safe_run)
68
+ expect(plugin).to receive(:safe_run)
69
69
  @runner.run_plugin(plugin)
70
70
  end
71
71
  end
@@ -74,7 +74,7 @@ describe Ohai::Runner, "run_plugin" do
74
74
  let(:safe_run) { false }
75
75
 
76
76
  it "run should be called" do
77
- plugin.should_receive(:run)
77
+ expect(plugin).to receive(:run)
78
78
  @runner.run_plugin(plugin)
79
79
  end
80
80
  end
@@ -84,7 +84,7 @@ describe Ohai::Runner, "run_plugin" do
84
84
  let(:has_run) { true }
85
85
 
86
86
  it "should not run" do
87
- plugin.should_not_receive(:safe_run)
87
+ expect(plugin).not_to receive(:safe_run)
88
88
  @runner.run_plugin(plugin)
89
89
  end
90
90
 
@@ -95,7 +95,7 @@ describe Ohai::Runner, "run_plugin" do
95
95
  let(:version) { :versionBla }
96
96
 
97
97
  it "should raise error" do
98
- lambda { @runner.run_plugin(plugin) }.should raise_error(Ohai::Exceptions::InvalidPlugin)
98
+ expect { @runner.run_plugin(plugin) }.to raise_error(Ohai::Exceptions::InvalidPlugin)
99
99
  end
100
100
  end
101
101
  end
@@ -113,13 +113,13 @@ describe Ohai::Runner, "run_plugin" do
113
113
 
114
114
  it "should run the plugin" do
115
115
  @runner.run_plugin(plugin)
116
- plugin.has_run?.should be true
116
+ expect(plugin.has_run?).to be true
117
117
  end
118
118
 
119
119
  it "should add plugin data to Ohai::System.data" do
120
120
  @runner.run_plugin(plugin)
121
- @ohai.data.should have_key(:thing)
122
- @ohai.data[:thing].should eql({})
121
+ expect(@ohai.data).to have_key(:thing)
122
+ expect(@ohai.data[:thing]).to eql({})
123
123
  end
124
124
  end
125
125
 
@@ -142,7 +142,7 @@ describe Ohai::Runner, "run_plugin" do
142
142
 
143
143
  it "should not run the plugin" do
144
144
  expect{ @runner.run_plugin(@plugin) }.to raise_error
145
- @plugin.has_run?.should be false
145
+ expect(@plugin.has_run?).to be false
146
146
  end
147
147
  end
148
148
 
@@ -174,7 +174,7 @@ describe Ohai::Runner, "run_plugin" do
174
174
  it "should run the plugins" do
175
175
  @runner.run_plugin(@plugin2)
176
176
  @plugins.each do |plugin|
177
- plugin.has_run?.should be true
177
+ expect(plugin.has_run?).to be true
178
178
  end
179
179
  end
180
180
  end
@@ -208,7 +208,7 @@ describe Ohai::Runner, "run_plugin" do
208
208
  it "should run the plugins" do
209
209
  @runner.run_plugin(@plugin3)
210
210
  @plugins.each do |plugin|
211
- plugin.has_run?.should be true
211
+ expect(plugin.has_run?).to be true
212
212
  end
213
213
  end
214
214
  end
@@ -251,7 +251,7 @@ describe Ohai::Runner, "run_plugin" do
251
251
  it "should run the plugins" do
252
252
  @runner.run_plugin(@plugin3)
253
253
  @plugins.each do |plugin|
254
- plugin.has_run?.should be true
254
+ expect(plugin.has_run?).to be true
255
255
  end
256
256
  end
257
257
  end
@@ -306,8 +306,8 @@ describe Ohai::Runner, "run_plugin" do
306
306
  end
307
307
 
308
308
  it "should raise Ohai::Exceptions::DependencyCycle" do
309
- runner.stub(:fetch_plugins).with(["thing"]).and_return([@plugin1])
310
- runner.stub(:fetch_plugins).with(["other"]).and_return([@plugin2])
309
+ allow(runner).to receive(:fetch_plugins).with(["thing"]).and_return([@plugin1])
310
+ allow(runner).to receive(:fetch_plugins).with(["other"]).and_return([@plugin2])
311
311
  expected_error_string = "Dependency cycle detected. Please refer to the following plugins: Thing, Other"
312
312
  expect { runner.run_plugin(@plugin1) }.to raise_error(Ohai::Exceptions::DependencyCycle, expected_error_string)
313
313
  end
@@ -346,11 +346,11 @@ describe Ohai::Runner, "run_plugin" do
346
346
  @ohai.provides_map.set_providers_for(@pluginB, ["B"])
347
347
  @ohai.provides_map.set_providers_for(@pluginC, ["C"])
348
348
 
349
- Ohai::Log.should_not_receive(:error).with(/DependencyCycleError/)
349
+ expect(Ohai::Log).not_to receive(:error).with(/DependencyCycleError/)
350
350
  @runner.run_plugin(@pluginA)
351
351
 
352
352
  @plugins.each do |plugin|
353
- plugin.has_run?.should be true
353
+ expect(plugin.has_run?).to be true
354
354
  end
355
355
  end
356
356
 
@@ -359,11 +359,11 @@ describe Ohai::Runner, "run_plugin" do
359
359
  @ohai.provides_map.set_providers_for(@pluginC, ["C"])
360
360
  @ohai.provides_map.set_providers_for(@pluginB, ["B"])
361
361
 
362
- Ohai::Log.should_not_receive(:error).with(/DependencyCycleError/)
362
+ expect(Ohai::Log).not_to receive(:error).with(/DependencyCycleError/)
363
363
  @runner.run_plugin(@pluginA)
364
364
 
365
365
  @plugins.each do |plugin|
366
- plugin.has_run?.should be true
366
+ expect(plugin.has_run?).to be true
367
367
  end
368
368
  end
369
369
  end
@@ -382,7 +382,7 @@ describe Ohai::Runner, "fetch_plugins" do
382
382
  @ohai.provides_map.set_providers_for(plugin, ["top/middle/bottom"])
383
383
 
384
384
  dependency_providers = @runner.fetch_plugins(["top/middle/bottom"])
385
- dependency_providers.should eql([plugin])
385
+ expect(dependency_providers).to eql([plugin])
386
386
  end
387
387
 
388
388
  describe "when the attribute is not provided by any plugin" do
@@ -390,7 +390,7 @@ describe Ohai::Runner, "fetch_plugins" do
390
390
  it "should return the providers for the parent" do
391
391
  plugin = Ohai::DSL::Plugin.new(@ohai.data)
392
392
  @provides_map.set_providers_for(plugin, ["test/attribute"])
393
- @runner.fetch_plugins(["test/attribute/too_far"]).should eql([plugin])
393
+ expect(@runner.fetch_plugins(["test/attribute/too_far"])).to eql([plugin])
394
394
  end
395
395
  end
396
396
 
@@ -405,7 +405,7 @@ describe Ohai::Runner, "fetch_plugins" do
405
405
  it "should return unique providers" do
406
406
  plugin = Ohai::DSL::Plugin.new(@ohai.data)
407
407
  @provides_map.set_providers_for(plugin, ["test", "test/too_far/way_too_far"])
408
- @runner.fetch_plugins(["test", "test/too_far/way_too_far"]).should eql([plugin])
408
+ expect(@runner.fetch_plugins(["test", "test/too_far/way_too_far"])).to eql([plugin])
409
409
  end
410
410
  end
411
411
 
@@ -448,7 +448,7 @@ describe Ohai::Runner, "#get_cycle" do
448
448
  cycle_start = @plugin1
449
449
 
450
450
  cycle_names = @runner.get_cycle(cycle, cycle_start)
451
- cycle_names.should eql([@plugin1.name, @plugin2.name])
451
+ expect(cycle_names).to eql([@plugin1.name, @plugin2.name])
452
452
  end
453
453
 
454
454
  it "should return the sources for only the plugins in the cycle, when there are plugins before the cycle begins" do
@@ -456,6 +456,6 @@ describe Ohai::Runner, "#get_cycle" do
456
456
  cycle_start = @plugin1
457
457
 
458
458
  cycle_names = @runner.get_cycle(cycle, cycle_start)
459
- cycle_names.should eql([@plugin1.name, @plugin2.name])
459
+ expect(cycle_names).to eql([@plugin1.name, @plugin2.name])
460
460
  end
461
461
  end