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,51 +22,51 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
22
22
  describe Ohai::System, "Darwin plugin platform" do
23
23
  before(:each) do
24
24
  @plugin = get_plugin("darwin/platform")
25
- @plugin.stub(:collect_os).and_return(:darwin)
25
+ allow(@plugin).to receive(:collect_os).and_return(:darwin)
26
26
  @stdout = "ProductName: Mac OS X\nProductVersion: 10.5.5\nBuildVersion: 9F33"
27
- @plugin.stub(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
27
+ allow(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
28
28
  end
29
29
 
30
30
  it "should run sw_vers" do
31
- @plugin.should_receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
31
+ expect(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
32
32
  @plugin.run
33
33
  end
34
34
 
35
35
  it "should set platform to ProductName, downcased with _ for \\s" do
36
36
  @plugin.run
37
- @plugin[:platform].should == "mac_os_x"
37
+ expect(@plugin[:platform]).to eq("mac_os_x")
38
38
  end
39
39
 
40
40
  it "should set platform_version to ProductVersion" do
41
41
  @plugin.run
42
- @plugin[:platform_version].should == "10.5.5"
42
+ expect(@plugin[:platform_version]).to eq("10.5.5")
43
43
  end
44
44
 
45
45
  it "should set platform_build to BuildVersion" do
46
46
  @plugin.run
47
- @plugin[:platform_build].should == "9F33"
47
+ expect(@plugin[:platform_build]).to eq("9F33")
48
48
  end
49
49
 
50
50
  it "should set platform_family to mac_os_x" do
51
51
  @plugin.run
52
- @plugin[:platform_family].should == "mac_os_x"
52
+ expect(@plugin[:platform_family]).to eq("mac_os_x")
53
53
  end
54
54
 
55
55
  describe "on os x server" do
56
56
  before(:each) do
57
57
  @plugin[:os] = "darwin"
58
58
  @stdout = "ProductName: Mac OS X Server\nProductVersion: 10.6.8\nBuildVersion: 10K549"
59
- @plugin.stub(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
59
+ allow(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
60
60
  end
61
61
 
62
62
  it "should set platform to mac_os_x_server" do
63
63
  @plugin.run
64
- @plugin[:platform].should == "mac_os_x_server"
64
+ expect(@plugin[:platform]).to eq("mac_os_x_server")
65
65
  end
66
66
 
67
67
  it "should set platform_family to mac_os_x" do
68
68
  @plugin.run
69
- @plugin[:platform_family].should == "mac_os_x"
69
+ expect(@plugin[:platform_family]).to eq("mac_os_x")
70
70
  end
71
71
  end
72
72
  end
@@ -29,7 +29,7 @@ end
29
29
  describe Ohai::System, "Darwin system_profiler plugin", :unix_only do
30
30
  before(:each) do
31
31
  @plugin = get_plugin("darwin/system_profiler")
32
- @plugin.stub(:collect_os).and_return(:darwin)
32
+ allow(@plugin).to receive(:collect_os).and_return(:darwin)
33
33
  end
34
34
 
35
35
  it "should return the right serial number" do
@@ -39,9 +39,9 @@ describe Ohai::System, "Darwin system_profiler plugin", :unix_only do
39
39
  mini_cmd += " SPPCIData SPParallelSCSIData SPPrintersSoftwareData SPPrintersData SPSASData SPSerialATAData"
40
40
  mini_cmd += " SPSoftwareData SPThunderboltData SPUSBData SPWWANData SPAirPortData"
41
41
  full_cmd = "system_profiler -xml -detailLevel full SPHardwareDataType"
42
- @plugin.stub(:shell_out).with(full_cmd).and_return(mock_shell_out(0, SystemProfilerOutput::Full, ""))
43
- @plugin.stub(:shell_out).with(mini_cmd).and_return(mock_shell_out(0, SystemProfilerOutput::Mini, ""))
42
+ allow(@plugin).to receive(:shell_out).with(full_cmd).and_return(mock_shell_out(0, SystemProfilerOutput::Full, ""))
43
+ allow(@plugin).to receive(:shell_out).with(mini_cmd).and_return(mock_shell_out(0, SystemProfilerOutput::Mini, ""))
44
44
  @plugin.run
45
- @plugin['system_profile'][18]["_items"][0]["serial_number"].should == 'ABCDEFG12345'
45
+ expect(@plugin['system_profile'][18]["_items"][0]["serial_number"]).to eq('ABCDEFG12345')
46
46
  end
47
47
  end
@@ -95,11 +95,11 @@ describe Ohai::System, "plugin dmi" do
95
95
  before(:each) do
96
96
  @plugin = get_plugin("dmi")
97
97
  @stdout = DMI_OUT
98
- @plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, ""))
98
+ allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, ""))
99
99
  end
100
100
 
101
101
  it "should run dmidecode" do
102
- @plugin.should_receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, ""))
102
+ expect(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, ""))
103
103
  @plugin.run
104
104
  end
105
105
 
@@ -121,7 +121,7 @@ describe Ohai::System, "plugin dmi" do
121
121
  data.each do |attribute, value|
122
122
  it "should have [:dmi][:#{id}][:#{attribute}] set" do
123
123
  @plugin.run
124
- @plugin[:dmi][id][attribute].should eql(value)
124
+ expect(@plugin[:dmi][id][attribute]).to eql(value)
125
125
  end
126
126
  end
127
127
  end
@@ -24,13 +24,13 @@ describe Ohai::System, "plugin ec2" do
24
24
  before(:each) do
25
25
  @plugin = get_plugin("ec2")
26
26
  @plugin[:network] = {:interfaces => {:eth0 => {} } }
27
- File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
28
- File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
27
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
28
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
29
29
  end
30
30
 
31
31
  shared_examples_for "!ec2" do
32
32
  it "should NOT attempt to fetch the ec2 metadata" do
33
- @plugin.should_not_receive(:http_client)
33
+ expect(@plugin).not_to receive(:http_client)
34
34
  @plugin.run
35
35
  end
36
36
  end
@@ -38,196 +38,196 @@ describe Ohai::System, "plugin ec2" do
38
38
  shared_examples_for "ec2" do
39
39
  before(:each) do
40
40
  @http_client = double("Net::HTTP client")
41
- @plugin.stub(:http_client).and_return(@http_client)
42
- IO.stub(:select).and_return([[],[1],[]])
41
+ allow(@plugin).to receive(:http_client).and_return(@http_client)
42
+ allow(IO).to receive(:select).and_return([[],[1],[]])
43
43
  t = double("connection")
44
- t.stub(:connect_nonblock).and_raise(Errno::EINPROGRESS)
45
- Socket.stub(:new).and_return(t)
46
- @http_client.should_receive(:get).
44
+ allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS)
45
+ allow(Socket).to receive(:new).and_return(t)
46
+ expect(@http_client).to receive(:get).
47
47
  with("/").twice.
48
48
  and_return(double("Net::HTTP Response", :body => "2012-01-12", :code => "200"))
49
- File.stub(:exist?).and_return(false)
49
+ allow(File).to receive(:exist?).and_return(false)
50
50
  end
51
51
 
52
52
  it "should recursively fetch all the ec2 metadata" do
53
- @http_client.should_receive(:get).
53
+ expect(@http_client).to receive(:get).
54
54
  with("/2012-01-12/meta-data/").
55
55
  and_return(double("Net::HTTP Response", :body => "instance_type\nami_id\nsecurity-groups", :code => "200"))
56
- @http_client.should_receive(:get).
56
+ expect(@http_client).to receive(:get).
57
57
  with("/2012-01-12/meta-data/instance_type").
58
58
  and_return(double("Net::HTTP Response", :body => "c1.medium", :code => "200"))
59
- @http_client.should_receive(:get).
59
+ expect(@http_client).to receive(:get).
60
60
  with("/2012-01-12/meta-data/ami_id").
61
61
  and_return(double("Net::HTTP Response", :body => "ami-5d2dc934", :code => "200"))
62
- @http_client.should_receive(:get).
62
+ expect(@http_client).to receive(:get).
63
63
  with("/2012-01-12/meta-data/security-groups").
64
64
  and_return(double("Net::HTTP Response", :body => "group1\ngroup2", :code => "200"))
65
- @http_client.should_receive(:get).
65
+ expect(@http_client).to receive(:get).
66
66
  with("/2012-01-12/user-data/").
67
67
  and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
68
68
 
69
69
  @plugin.run
70
70
 
71
- @plugin[:ec2].should_not be_nil
72
- @plugin[:ec2]['instance_type'].should == "c1.medium"
73
- @plugin[:ec2]['ami_id'].should == "ami-5d2dc934"
74
- @plugin[:ec2]['security_groups'].should eql ['group1', 'group2']
71
+ expect(@plugin[:ec2]).not_to be_nil
72
+ expect(@plugin[:ec2]['instance_type']).to eq("c1.medium")
73
+ expect(@plugin[:ec2]['ami_id']).to eq("ami-5d2dc934")
74
+ expect(@plugin[:ec2]['security_groups']).to eql ['group1', 'group2']
75
75
  end
76
76
 
77
77
  it "should parse ec2 network/ directory as a multi-level hash" do
78
- @http_client.should_receive(:get).
78
+ expect(@http_client).to receive(:get).
79
79
  with("/2012-01-12/meta-data/").
80
80
  and_return(double("Net::HTTP Response", :body => "network/", :code => "200"))
81
- @http_client.should_receive(:get).
81
+ expect(@http_client).to receive(:get).
82
82
  with("/2012-01-12/meta-data/network/").
83
83
  and_return(double("Net::HTTP Response", :body => "interfaces/", :code => "200"))
84
- @http_client.should_receive(:get).
84
+ expect(@http_client).to receive(:get).
85
85
  with("/2012-01-12/meta-data/network/interfaces/").
86
86
  and_return(double("Net::HTTP Response", :body => "macs/", :code => "200"))
87
- @http_client.should_receive(:get).
87
+ expect(@http_client).to receive(:get).
88
88
  with("/2012-01-12/meta-data/network/interfaces/macs/").
89
89
  and_return(double("Net::HTTP Response", :body => "12:34:56:78:9a:bc/", :code => "200"))
90
- @http_client.should_receive(:get).
90
+ expect(@http_client).to receive(:get).
91
91
  with("/2012-01-12/meta-data/network/interfaces/macs/12:34:56:78:9a:bc/").
92
92
  and_return(double("Net::HTTP Response", :body => "public_hostname", :code => "200"))
93
- @http_client.should_receive(:get).
93
+ expect(@http_client).to receive(:get).
94
94
  with("/2012-01-12/meta-data/network/interfaces/macs/12:34:56:78:9a:bc/public_hostname").
95
95
  and_return(double("Net::HTTP Response", :body => "server17.opscode.com", :code => "200"))
96
- @http_client.should_receive(:get).
96
+ expect(@http_client).to receive(:get).
97
97
  with("/2012-01-12/user-data/").
98
98
  and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
99
99
 
100
100
  @plugin.run
101
101
 
102
- @plugin[:ec2].should_not be_nil
103
- @plugin[:ec2]['network_interfaces_macs']['12:34:56:78:9a:bc']['public_hostname'].should eql('server17.opscode.com')
102
+ expect(@plugin[:ec2]).not_to be_nil
103
+ expect(@plugin[:ec2]['network_interfaces_macs']['12:34:56:78:9a:bc']['public_hostname']).to eql('server17.opscode.com')
104
104
  end
105
105
 
106
106
  context "with ec2_iam cloud file" do
107
107
  before do
108
108
  if windows?
109
- File.stub(:exist?).with('C:\chef\ohai\hints/iam.json').and_return(true)
110
- File.stub(:read).with('C:\chef\ohai\hints/iam.json').and_return('')
109
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/iam.json').and_return(true)
110
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/iam.json').and_return('')
111
111
  else
112
- File.stub(:exist?).with('/etc/chef/ohai/hints/iam.json').and_return(true)
113
- File.stub(:read).with('/etc/chef/ohai/hints/iam.json').and_return('')
112
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/iam.json').and_return(true)
113
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/iam.json').and_return('')
114
114
  end
115
115
  end
116
116
 
117
117
  it "should parse ec2 iam/ directory and collect iam/security-credentials/" do
118
- @http_client.should_receive(:get).
118
+ expect(@http_client).to receive(:get).
119
119
  with("/2012-01-12/meta-data/").
120
120
  and_return(double("Net::HTTP Response", :body => "iam/", :code => "200"))
121
- @http_client.should_receive(:get).
121
+ expect(@http_client).to receive(:get).
122
122
  with("/2012-01-12/meta-data/iam/").
123
123
  and_return(double("Net::HTTP Response", :body => "security-credentials/", :code => "200"))
124
- @http_client.should_receive(:get).
124
+ expect(@http_client).to receive(:get).
125
125
  with("/2012-01-12/meta-data/iam/security-credentials/").
126
126
  and_return(double("Net::HTTP Response", :body => "MyRole", :code => "200"))
127
- @http_client.should_receive(:get).
127
+ expect(@http_client).to receive(:get).
128
128
  with("/2012-01-12/meta-data/iam/security-credentials/MyRole").
129
129
  and_return(double("Net::HTTP Response", :body => "{\n \"Code\" : \"Success\",\n \"LastUpdated\" : \"2012-08-22T07:47:22Z\",\n \"Type\" : \"AWS-HMAC\",\n \"AccessKeyId\" : \"AAAAAAAA\",\n \"SecretAccessKey\" : \"SSSSSSSS\",\n \"Token\" : \"12345678\",\n \"Expiration\" : \"2012-08-22T11:25:52Z\"\n}", :code => "200"))
130
- @http_client.should_receive(:get).
130
+ expect(@http_client).to receive(:get).
131
131
  with("/2012-01-12/user-data/").
132
132
  and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
133
133
 
134
134
  @plugin.run
135
135
 
136
- @plugin[:ec2].should_not be_nil
137
- @plugin[:ec2]['iam']['security-credentials']['MyRole']['Code'].should eql 'Success'
138
- @plugin[:ec2]['iam']['security-credentials']['MyRole']['Token'].should eql '12345678'
136
+ expect(@plugin[:ec2]).not_to be_nil
137
+ expect(@plugin[:ec2]['iam']['security-credentials']['MyRole']['Code']).to eql 'Success'
138
+ expect(@plugin[:ec2]['iam']['security-credentials']['MyRole']['Token']).to eql '12345678'
139
139
  end
140
140
  end
141
141
 
142
142
  context "without ec2_iam cloud file" do
143
143
  before do
144
144
  if windows?
145
- File.stub(:exist?).with('C:\chef\ohai\hints/iam.json').and_return(false)
145
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/iam.json').and_return(false)
146
146
  else
147
- File.stub(:exist?).with('/etc/chef/ohai/hints/iam.json').and_return(false)
147
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/iam.json').and_return(false)
148
148
  end
149
149
  end
150
150
 
151
151
  it "should parse ec2 iam/ directory and NOT collect iam/security-credentials/" do
152
- @http_client.should_receive(:get).
152
+ expect(@http_client).to receive(:get).
153
153
  with("/2012-01-12/meta-data/").
154
154
  and_return(double("Net::HTTP Response", :body => "iam/", :code => "200"))
155
- @http_client.should_receive(:get).
155
+ expect(@http_client).to receive(:get).
156
156
  with("/2012-01-12/meta-data/iam/").
157
157
  and_return(double("Net::HTTP Response", :body => "security-credentials/", :code => "200"))
158
- @http_client.should_receive(:get).
158
+ expect(@http_client).to receive(:get).
159
159
  with("/2012-01-12/meta-data/iam/security-credentials/").
160
160
  and_return(double("Net::HTTP Response", :body => "MyRole", :code => "200"))
161
- @http_client.should_receive(:get).
161
+ expect(@http_client).to receive(:get).
162
162
  with("/2012-01-12/meta-data/iam/security-credentials/MyRole").
163
163
  and_return(double("Net::HTTP Response", :body => "{\n \"Code\" : \"Success\",\n \"LastUpdated\" : \"2012-08-22T07:47:22Z\",\n \"Type\" : \"AWS-HMAC\",\n \"AccessKeyId\" : \"AAAAAAAA\",\n \"SecretAccessKey\" : \"SSSSSSSS\",\n \"Token\" : \"12345678\",\n \"Expiration\" : \"2012-08-22T11:25:52Z\"\n}", :code => "200"))
164
- @http_client.should_receive(:get).
164
+ expect(@http_client).to receive(:get).
165
165
  with("/2012-01-12/user-data/").
166
166
  and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
167
167
 
168
168
  @plugin.run
169
169
 
170
- @plugin[:ec2].should_not be_nil
171
- @plugin[:ec2]['iam'].should be_nil
170
+ expect(@plugin[:ec2]).not_to be_nil
171
+ expect(@plugin[:ec2]['iam']).to be_nil
172
172
  end
173
173
  end
174
174
 
175
175
  it "should ignore \"./\" and \"../\" on ec2 metadata paths to avoid infinity loops" do
176
- @http_client.should_receive(:get).
176
+ expect(@http_client).to receive(:get).
177
177
  with("/2012-01-12/meta-data/").
178
178
  and_return(double("Net::HTTP Response", :body => ".\n./\n..\n../\npath1/.\npath2/./\npath3/..\npath4/../", :code => "200"))
179
179
 
180
- @http_client.should_not_receive(:get).
180
+ expect(@http_client).not_to receive(:get).
181
181
  with("/2012-01-12/meta-data/.")
182
- @http_client.should_not_receive(:get).
182
+ expect(@http_client).not_to receive(:get).
183
183
  with("/2012-01-12/meta-data/./")
184
- @http_client.should_not_receive(:get).
184
+ expect(@http_client).not_to receive(:get).
185
185
  with("/2012-01-12/meta-data/..")
186
- @http_client.should_not_receive(:get).
186
+ expect(@http_client).not_to receive(:get).
187
187
  with("/2012-01-12/meta-data/../")
188
- @http_client.should_not_receive(:get).
188
+ expect(@http_client).not_to receive(:get).
189
189
  with("/2012-01-12/meta-data/path1/..")
190
190
 
191
- @http_client.should_receive(:get).
191
+ expect(@http_client).to receive(:get).
192
192
  with("/2012-01-12/meta-data/path1/").
193
193
  and_return(double("Net::HTTP Response", :body => "", :code => "200"))
194
- @http_client.should_receive(:get).
194
+ expect(@http_client).to receive(:get).
195
195
  with("/2012-01-12/meta-data/path2/").
196
196
  and_return(double("Net::HTTP Response", :body => "", :code => "200"))
197
- @http_client.should_receive(:get).
197
+ expect(@http_client).to receive(:get).
198
198
  with("/2012-01-12/meta-data/path3/").
199
199
  and_return(double("Net::HTTP Response", :body => "", :code => "200"))
200
- @http_client.should_receive(:get).
200
+ expect(@http_client).to receive(:get).
201
201
  with("/2012-01-12/meta-data/path4/").
202
202
  and_return(double("Net::HTTP Response", :body => "", :code => "200"))
203
- @http_client.should_receive(:get).
203
+ expect(@http_client).to receive(:get).
204
204
  with("/2012-01-12/user-data/").
205
205
  and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
206
206
 
207
207
  @plugin.run
208
208
 
209
- @plugin[:ec2].should_not be_nil
209
+ expect(@plugin[:ec2]).not_to be_nil
210
210
  end
211
211
 
212
212
  it "should complete the run despite unavailable metadata" do
213
- @http_client.should_receive(:get).
213
+ expect(@http_client).to receive(:get).
214
214
  with("/2012-01-12/meta-data/").
215
215
  and_return(double("Net::HTTP Response", :body => "metrics/", :code => "200"))
216
- @http_client.should_receive(:get).
216
+ expect(@http_client).to receive(:get).
217
217
  with("/2012-01-12/meta-data/metrics/").
218
218
  and_return(double("Net::HTTP Response", :body => "vhostmd", :code => "200"))
219
- @http_client.should_receive(:get).
219
+ expect(@http_client).to receive(:get).
220
220
  with("/2012-01-12/meta-data/metrics/vhostmd").
221
221
  and_return(double("Net::HTTP Response", :body => "", :code => "404"))
222
- @http_client.should_receive(:get).
222
+ expect(@http_client).to receive(:get).
223
223
  with("/2012-01-12/user-data/").
224
224
  and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
225
225
 
226
226
  @plugin.run
227
227
 
228
- @plugin[:ec2].should_not be_nil
229
- @plugin[:ec2]['metrics'].should be_nil
230
- @plugin[:ec2]['metrics_vhostmd'].should be_nil
228
+ expect(@plugin[:ec2]).not_to be_nil
229
+ expect(@plugin[:ec2]['metrics']).to be_nil
230
+ expect(@plugin[:ec2]['metrics_vhostmd']).to be_nil
231
231
  end
232
232
  end
233
233
 
@@ -235,7 +235,7 @@ describe Ohai::System, "plugin ec2" do
235
235
  it_should_behave_like "ec2"
236
236
 
237
237
  before(:each) do
238
- IO.stub(:select).and_return([[],[1],[]])
238
+ allow(IO).to receive(:select).and_return([[],[1],[]])
239
239
  @plugin[:network][:interfaces][:eth0][:arp] = {"169.254.1.0"=>"fe:ff:ff:ff:ff:ff"}
240
240
  end
241
241
  end
@@ -253,11 +253,11 @@ describe Ohai::System, "plugin ec2" do
253
253
 
254
254
  before(:each) do
255
255
  if windows?
256
- File.should_receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
257
- File.stub(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
256
+ expect(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
257
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
258
258
  else
259
- File.should_receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
260
- File.stub(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
259
+ expect(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
260
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
261
261
  end
262
262
  end
263
263
  end
@@ -266,8 +266,8 @@ describe Ohai::System, "plugin ec2" do
266
266
  it_should_behave_like "!ec2"
267
267
 
268
268
  before(:each) do
269
- File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
270
- File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
269
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
270
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
271
271
  end
272
272
  end
273
273
 
@@ -275,13 +275,13 @@ describe Ohai::System, "plugin ec2" do
275
275
  it_should_behave_like "!ec2"
276
276
 
277
277
  before(:each) do
278
- File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
279
- File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
278
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
279
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
280
280
 
281
- File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
282
- File.stub(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
283
- File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
284
- File.stub(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
281
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
282
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
283
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
284
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
285
285
  end
286
286
  end
287
287
 
@@ -25,36 +25,36 @@ describe Ohai::System, "plugin erlang" do
25
25
  @plugin = get_plugin("erlang")
26
26
  @plugin[:languages] = Mash.new
27
27
  @stderr = "Erlang (ASYNC_THREADS,SMP,HIPE) (BEAM) emulator version 5.6.2\n"
28
- @plugin.stub(:shell_out).with("erl +V").and_return(mock_shell_out(0, "", @stderr))
28
+ allow(@plugin).to receive(:shell_out).with("erl +V").and_return(mock_shell_out(0, "", @stderr))
29
29
  end
30
30
 
31
31
  it "should get the erlang version from erl +V" do
32
- @plugin.should_receive(:shell_out).with("erl +V").and_return(mock_shell_out(0, "", @stderr))
32
+ expect(@plugin).to receive(:shell_out).with("erl +V").and_return(mock_shell_out(0, "", @stderr))
33
33
  @plugin.run
34
34
  end
35
35
 
36
36
  it "should set languages[:erlang][:version]" do
37
37
  @plugin.run
38
- @plugin.languages[:erlang][:version].should eql("5.6.2")
38
+ expect(@plugin.languages[:erlang][:version]).to eql("5.6.2")
39
39
  end
40
40
 
41
41
  it "should set languages[:erlang][:options]" do
42
42
  @plugin.run
43
- @plugin.languages[:erlang][:options].should eql(["ASYNC_THREADS", "SMP", "HIPE"])
43
+ expect(@plugin.languages[:erlang][:options]).to eql(["ASYNC_THREADS", "SMP", "HIPE"])
44
44
  end
45
45
 
46
46
  it "should set languages[:erlang][:emulator]" do
47
47
  @plugin.run
48
- @plugin.languages[:erlang][:emulator].should eql("BEAM")
48
+ expect(@plugin.languages[:erlang][:emulator]).to eql("BEAM")
49
49
  end
50
50
 
51
51
  it "should not set the languages[:erlang] tree up if erlang command fails" do
52
52
  @status = 1
53
53
  @stdin = ""
54
54
  @stderr = "Erlang (ASYNC_THREADS,SMP,HIPE) (BEAM) emulator version 5.6.2\n"
55
- @plugin.stub(:shell_out).with("erl +V").and_return(mock_shell_out(1, "", @stderr))
55
+ allow(@plugin).to receive(:shell_out).with("erl +V").and_return(mock_shell_out(1, "", @stderr))
56
56
  @plugin.run
57
- @plugin.languages.should_not have_key(:erlang)
57
+ expect(@plugin.languages).not_to have_key(:erlang)
58
58
  end
59
59
 
60
60
  end