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
@@ -27,7 +27,7 @@ describe Ohai::System, "plugin eucalyptus" do
27
27
 
28
28
  shared_examples_for "!eucalyptus" do
29
29
  it "should NOT attempt to fetch the eucalyptus metadata" do
30
- OpenURI.should_not_receive(:open)
30
+ expect(OpenURI).not_to receive(:open)
31
31
  @plugin.run
32
32
  end
33
33
  end
@@ -35,38 +35,38 @@ describe Ohai::System, "plugin eucalyptus" do
35
35
  shared_examples_for "eucalyptus" do
36
36
  before(:each) do
37
37
  @http_client = double("Net::HTTP client")
38
- @plugin.stub(:http_client).and_return(@http_client)
38
+ allow(@plugin).to receive(:http_client).and_return(@http_client)
39
39
 
40
- @http_client.should_receive(:get).
40
+ expect(@http_client).to receive(:get).
41
41
  with("/").twice.
42
42
  and_return(double("Net::HTTP Response", :body => "2012-01-12", :code => "200"))
43
- @http_client.should_receive(:get).
43
+ expect(@http_client).to receive(:get).
44
44
  with("/2012-01-12/meta-data/").
45
45
  and_return(double("Net::HTTP Response", :body => "instance_type\nami_id\nsecurity-groups", :code => "200"))
46
- @http_client.should_receive(:get).
46
+ expect(@http_client).to receive(:get).
47
47
  with("/2012-01-12/meta-data/instance_type").
48
48
  and_return(double("Net::HTTP Response", :body => "c1.medium", :code => "200"))
49
- @http_client.should_receive(:get).
49
+ expect(@http_client).to receive(:get).
50
50
  with("/2012-01-12/meta-data/ami_id").
51
51
  and_return(double("Net::HTTP Response", :body => "ami-5d2dc934", :code => "200"))
52
- @http_client.should_receive(:get).
52
+ expect(@http_client).to receive(:get).
53
53
  with("/2012-01-12/meta-data/security-groups").
54
54
  and_return(double("Net::HTTP Response", :body => "group1\ngroup2", :code => "200"))
55
- @http_client.should_receive(:get).
55
+ expect(@http_client).to receive(:get).
56
56
  with("/2012-01-12/user-data/").
57
57
  and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
58
58
  end
59
59
 
60
60
  it "should recursively fetch all the eucalyptus metadata" do
61
- IO.stub(:select).and_return([[],[1],[]])
61
+ allow(IO).to receive(:select).and_return([[],[1],[]])
62
62
  t = double("connection")
63
- t.stub(:connect_nonblock).and_raise(Errno::EINPROGRESS)
64
- Socket.stub(:new).and_return(t)
63
+ allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS)
64
+ allow(Socket).to receive(:new).and_return(t)
65
65
  @plugin.run
66
- @plugin[:eucalyptus].should_not be_nil
67
- @plugin[:eucalyptus]['instance_type'].should == "c1.medium"
68
- @plugin[:eucalyptus]['ami_id'].should == "ami-5d2dc934"
69
- @plugin[:eucalyptus]['security_groups'].should eql ['group1', 'group2']
66
+ expect(@plugin[:eucalyptus]).not_to be_nil
67
+ expect(@plugin[:eucalyptus]['instance_type']).to eq("c1.medium")
68
+ expect(@plugin[:eucalyptus]['ami_id']).to eq("ami-5d2dc934")
69
+ expect(@plugin[:eucalyptus]['security_groups']).to eql ['group1', 'group2']
70
70
  end
71
71
  end
72
72
 
@@ -74,7 +74,7 @@ describe Ohai::System, "plugin eucalyptus" do
74
74
  it_should_behave_like "eucalyptus"
75
75
 
76
76
  before(:each) do
77
- IO.stub(:select).and_return([[],[1],[]])
77
+ allow(IO).to receive(:select).and_return([[],[1],[]])
78
78
  @plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "d0:0d:95:47:6E:ED"=> { "family" => "lladdr" } } } } }
79
79
  end
80
80
  end
@@ -91,10 +91,10 @@ describe Ohai::System, "plugin eucalyptus" do
91
91
  it_should_behave_like "eucalyptus"
92
92
 
93
93
  before(:each) do
94
- File.stub(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(true)
95
- File.stub(:read).with('/etc/chef/ohai/hints/eucalyptus.json').and_return('')
96
- File.stub(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(true)
97
- File.stub(:read).with('C:\chef\ohai\hints/eucalyptus.json').and_return('')
94
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(true)
95
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/eucalyptus.json').and_return('')
96
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(true)
97
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/eucalyptus.json').and_return('')
98
98
  end
99
99
  end
100
100
 
@@ -103,8 +103,8 @@ describe Ohai::System, "plugin eucalyptus" do
103
103
 
104
104
  before(:each) do
105
105
  @plugin[:network] = {:interfaces => {}}
106
- File.stub(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false)
107
- File.stub(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false)
106
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false)
107
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false)
108
108
  end
109
109
  end
110
110
 
@@ -114,12 +114,12 @@ describe Ohai::System, "plugin eucalyptus" do
114
114
  before(:each) do
115
115
  @plugin[:network] = {:interfaces => {}}
116
116
 
117
- File.stub(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false)
118
- File.stub(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false)
119
- File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
120
- File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
121
- File.stub(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
122
- File.stub(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
117
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false)
118
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false)
119
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
120
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
121
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
122
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
123
123
  end
124
124
  end
125
125
 
@@ -56,16 +56,16 @@ shared_examples "a v7 loading failure" do
56
56
  it "should not have attribute keys" do
57
57
  @loader.load_plugin("#{tmp}/plugins/fail.rb")
58
58
  #@ohai.attributes.should_not have_key("fail")
59
- lambda { @ohai.provides_map.find_providers_for(["fail"]) }.should raise_error(Ohai::Exceptions::AttributeNotFound)
59
+ expect { @ohai.provides_map.find_providers_for(["fail"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound)
60
60
  end
61
61
 
62
62
  it "should not have source key" do
63
63
  @loader.load_plugin("#{tmp}/plugins/fail.rb")
64
- @ohai.v6_dependency_solver.should_not have_key("#{tmp}/plugins/fail.rb")
64
+ expect(@ohai.v6_dependency_solver).not_to have_key("#{tmp}/plugins/fail.rb")
65
65
  end
66
66
 
67
67
  it "should write to Ohai::Log" do
68
- Ohai::Log.should_receive(:warn).once
68
+ expect(Ohai::Log).to receive(:warn).once
69
69
  @loader.load_plugin("#{tmp}/plugins/fail.rb")
70
70
  end
71
71
  end
@@ -104,16 +104,16 @@ shared_examples "a v7 loading success" do
104
104
 
105
105
  it "should have attribute keys" do
106
106
  @loader.load_plugin("#{tmp}/plugins/fail.rb")
107
- @ohai.provides_map.should have_key("fail")
107
+ expect(@ohai.provides_map).to have_key("fail")
108
108
  end
109
109
 
110
110
  it "should have source key" do
111
111
  @loader.load_plugin("#{tmp}/plugins/fail.rb")
112
- @ohai.v6_dependency_solver.should have_key("#{tmp}/plugins/fail.rb")
112
+ expect(@ohai.v6_dependency_solver).to have_key("#{tmp}/plugins/fail.rb")
113
113
  end
114
114
 
115
115
  it "should not write to Ohai::Log" do
116
- Ohai::Log.should_not_receive(:warn)
116
+ expect(Ohai::Log).not_to receive(:warn)
117
117
  @loader.load_plugin("#{tmp}/plugins/fail.rb")
118
118
  end
119
119
  end
@@ -152,11 +152,11 @@ shared_examples "a v7 run failure" do
152
152
 
153
153
  it "should not have new attribute keys" do
154
154
  @loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run
155
- @ohai.provides_map.should_not have_key("other")
155
+ expect(@ohai.provides_map).not_to have_key("other")
156
156
  end
157
157
 
158
158
  it "should write to Ohai::Log" do
159
- Ohai::Log.should_receive(:warn).once
159
+ expect(Ohai::Log).to receive(:warn).once
160
160
  @loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run
161
161
  end
162
162
  end
@@ -21,10 +21,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
21
21
  describe Ohai::System, "FreeBSD cpu plugin" do
22
22
  before(:each) do
23
23
  @plugin = get_plugin("freebsd/cpu")
24
- @plugin.stub(:collect_os).and_return(:freebsd)
25
- @plugin.stub(:shell_out).with("sysctl -n hw.ncpu").and_return(mock_shell_out(0, "2", ""))
24
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
25
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.ncpu").and_return(mock_shell_out(0, "2", ""))
26
26
  @double_file = double("/var/run/dmesg.boot")
27
- @double_file.stub(:each).
27
+ allow(@double_file).to receive(:each).
28
28
  and_yield('CPU: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz (3516.61-MHz K8-class CPU)').
29
29
  and_yield(' Origin = "GenuineIntel" Id = 0x306a9 Family = 6 Model = 3a Stepping = 9').
30
30
  and_yield(' Features=0x783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2>').
@@ -32,37 +32,37 @@ describe Ohai::System, "FreeBSD cpu plugin" do
32
32
  and_yield(' AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>').
33
33
  and_yield(' AMD Features2=0x1<LAHF>').
34
34
  and_yield(' TSC: P-state invariant')
35
- File.stub(:open).with("/var/run/dmesg.boot").and_return(@double_file)
35
+ allow(File).to receive(:open).with("/var/run/dmesg.boot").and_return(@double_file)
36
36
  end
37
37
 
38
38
  it "detects all CPU flags" do
39
39
  @plugin.run
40
- @plugin[:cpu][:flags].should == %w{fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse sse2 sse3 mon ssse3 syscall nx rdtscp lm lahf}
40
+ expect(@plugin[:cpu][:flags]).to eq(%w{fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse sse2 sse3 mon ssse3 syscall nx rdtscp lm lahf})
41
41
  end
42
42
 
43
43
  it "detects all CPU model_name" do
44
44
  @plugin.run
45
- @plugin[:cpu][:model_name].should == "Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz"
45
+ expect(@plugin[:cpu][:model_name]).to eq("Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz")
46
46
  end
47
47
 
48
48
  it "detects all CPU mhz" do
49
49
  @plugin.run
50
- @plugin[:cpu][:mhz].should == "3516.61"
50
+ expect(@plugin[:cpu][:mhz]).to eq("3516.61")
51
51
  end
52
52
 
53
53
  it "detects all CPU vendor_id" do
54
54
  @plugin.run
55
- @plugin[:cpu][:vendor_id].should == "GenuineIntel"
55
+ expect(@plugin[:cpu][:vendor_id]).to eq("GenuineIntel")
56
56
  end
57
57
 
58
58
  it "detects all CPU stepping" do
59
59
  @plugin.run
60
- @plugin[:cpu][:stepping].should == "9"
60
+ expect(@plugin[:cpu][:stepping]).to eq("9")
61
61
  end
62
62
 
63
63
  it "detects all CPU total" do
64
64
  @plugin.run
65
- @plugin[:cpu][:total].should == 2
65
+ expect(@plugin[:cpu][:total]).to eq(2)
66
66
  end
67
67
 
68
68
  end
@@ -22,10 +22,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
22
22
  describe Ohai::System, "FreeBSD hostname plugin" do
23
23
  before(:each) do
24
24
  @plugin = get_plugin("hostname")
25
- @plugin.stub(:collect_os).and_return(:freebsd)
26
- @plugin.stub(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
27
- @plugin.stub(:shell_out).with("hostname -f").and_return(mock_shell_out(0, "katie.bethell", ""))
28
- @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
25
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
26
+ allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
27
+ allow(@plugin).to receive(:shell_out).with("hostname -f").and_return(mock_shell_out(0, "katie.bethell", ""))
28
+ allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
29
29
  end
30
30
 
31
31
  it_should_check_from("freebsd::hostname", "hostname", "hostname -s", "katie")
@@ -22,16 +22,16 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
22
22
  describe Ohai::System, "FreeBSD kernel plugin" do
23
23
  before(:each) do
24
24
  @plugin = get_plugin("kernel")
25
- @plugin.stub(:collect_os).and_return(:freebsd)
26
- @plugin.stub(:init_kernel).and_return({:name => "freebsd"})
27
- @plugin.stub(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo\n", ""))
28
- @plugin.stub(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1", ""))
29
- @plugin.stub(:shell_out).with( Ohai.abs_path( "/sbin/kldstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
25
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
26
+ allow(@plugin).to receive(:init_kernel).and_return({:name => "freebsd"})
27
+ allow(@plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo\n", ""))
28
+ allow(@plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1", ""))
29
+ allow(@plugin).to receive(:shell_out).with( Ohai.abs_path( "/sbin/kldstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
30
30
  end
31
31
 
32
32
  it "should set the kernel_os to the kernel_name value" do
33
33
  @plugin.run
34
- @plugin[:kernel][:os].should == @plugin[:kernel][:name]
34
+ expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
35
35
  end
36
36
 
37
37
  end
@@ -22,12 +22,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
22
22
  describe Ohai::System, "FreeBSD plugin os" do
23
23
  before(:each) do
24
24
  @plugin = get_plugin("freebsd/os")
25
- @plugin.stub(:shell_out).with("sysctl -n kern.osreldate").and_return(mock_shell_out(0, "902001\n", ""))
26
- @plugin.stub(:collect_os).and_return(:freebsd)
25
+ allow(@plugin).to receive(:shell_out).with("sysctl -n kern.osreldate").and_return(mock_shell_out(0, "902001\n", ""))
26
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
27
27
  end
28
28
 
29
29
  it "should set os_version to __FreeBSD_version" do
30
30
  @plugin.run
31
- @plugin[:os_version].should == "902001"
31
+ expect(@plugin[:os_version]).to eq("902001")
32
32
  end
33
33
  end
@@ -22,18 +22,18 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
22
22
  describe Ohai::System, "FreeBSD plugin platform" do
23
23
  before(:each) do
24
24
  @plugin = get_plugin("freebsd/platform")
25
- @plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "FreeBSD\n", ""))
26
- @plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "7.1\n", ""))
27
- @plugin.stub(:collect_os).and_return(:freebsd)
25
+ allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "FreeBSD\n", ""))
26
+ allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "7.1\n", ""))
27
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
28
28
  end
29
29
 
30
30
  it "should set platform to lowercased lsb[:id]" do
31
31
  @plugin.run
32
- @plugin[:platform].should == "freebsd"
32
+ expect(@plugin[:platform]).to eq("freebsd")
33
33
  end
34
34
 
35
35
  it "should set platform_version to lsb[:release]" do
36
36
  @plugin.run
37
- @plugin[:platform_version].should == "7.1"
37
+ expect(@plugin[:platform_version]).to eq("7.1")
38
38
  end
39
39
  end
@@ -21,28 +21,28 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
21
21
  describe Ohai::System, "FreeBSD virtualization plugin" do
22
22
  before(:each) do
23
23
  @plugin = get_plugin("freebsd/virtualization")
24
- @plugin.stub(:collect_os).and_return(:freebsd)
25
- @plugin.stub(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "0", ""))
26
- @plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/sbin/kldstat" )}").and_return(mock_shell_out(0, "", ""))
27
- @plugin.stub(:shell_out).with("jls -n").and_return(mock_shell_out(0, "",""))
28
- @plugin.stub(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, "", ""))
24
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
25
+ allow(@plugin).to receive(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "0", ""))
26
+ allow(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/sbin/kldstat" )}").and_return(mock_shell_out(0, "", ""))
27
+ allow(@plugin).to receive(:shell_out).with("jls -n").and_return(mock_shell_out(0, "",""))
28
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, "", ""))
29
29
  end
30
30
 
31
31
  context "jails" do
32
32
  it "detects we are in a jail" do
33
- @plugin.stub(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "1", ""))
33
+ allow(@plugin).to receive(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "1", ""))
34
34
  @plugin.run
35
- @plugin[:virtualization][:system].should == "jail"
36
- @plugin[:virtualization][:role].should == "guest"
35
+ expect(@plugin[:virtualization][:system]).to eq("jail")
36
+ expect(@plugin[:virtualization][:role]).to eq("guest")
37
37
  end
38
38
 
39
39
  it "detects we are hosting jails" do
40
40
  # from http://www.freebsd.org/doc/handbook/jails-application.html
41
41
  @jails = "JID IP Address Hostname Path\n 3 192.168.3.17 ns.example.org /home/j/ns\n 2 192.168.3.18 mail.example.org /home/j/mail\n 1 62.123.43.14 www.example.org /home/j/www"
42
- @plugin.stub(:shell_out).with("jls -n").and_return(mock_shell_out(0, @jails, ""))
42
+ allow(@plugin).to receive(:shell_out).with("jls -n").and_return(mock_shell_out(0, @jails, ""))
43
43
  @plugin.run
44
- @plugin[:virtualization][:system].should == "jail"
45
- @plugin[:virtualization][:role].should == "host"
44
+ expect(@plugin[:virtualization][:system]).to eq("jail")
45
+ expect(@plugin[:virtualization][:role]).to eq("host")
46
46
  end
47
47
  end
48
48
 
@@ -53,13 +53,13 @@ Id Refs Address Size Name
53
53
  1 40 0xffffffff80100000 d20428 kernel
54
54
  7 3 0xffffffff81055000 41e88 vboxguest.ko
55
55
  OUT
56
- @plugin.stub(:shell_out).with("#{ Ohai.abs_path("/sbin/kldstat")}").and_return(mock_shell_out(0, @vbox_guest, ""))
56
+ allow(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path("/sbin/kldstat")}").and_return(mock_shell_out(0, @vbox_guest, ""))
57
57
  end
58
58
 
59
59
  it "detects we are a guest" do
60
60
  @plugin.run
61
- @plugin[:virtualization][:system].should == "vbox"
62
- @plugin[:virtualization][:role].should == "guest"
61
+ expect(@plugin[:virtualization][:system]).to eq("vbox")
62
+ expect(@plugin[:virtualization][:role]).to eq("guest")
63
63
  end
64
64
  end
65
65
 
@@ -70,23 +70,23 @@ Id Refs Address Size Name
70
70
  1 40 0xffffffff80100000 d20428 kernel
71
71
  7 3 0xffffffff81055000 41e88 vboxdrv.ko
72
72
  OUT
73
- @plugin.stub(:shell_out).with("/sbin/kldstat").and_return(mock_shell_out(0, @stdout, ""))
73
+ allow(@plugin).to receive(:shell_out).with("/sbin/kldstat").and_return(mock_shell_out(0, @stdout, ""))
74
74
  end
75
75
 
76
76
  it "detects we are a host" do
77
77
  @plugin.run
78
- @plugin[:virtualization][:system].should == "vbox"
79
- @plugin[:virtualization][:role].should == "host"
78
+ expect(@plugin[:virtualization][:system]).to eq("vbox")
79
+ expect(@plugin[:virtualization][:role]).to eq("host")
80
80
  end
81
81
  end
82
82
 
83
83
  context "when on a QEMU guest" do
84
84
  it "detects we are a guest" do
85
85
  [ 'Common KVM processor', 'QEMU Virtual CPU version (cpu64-rhel6) ("GenuineIntel" 686-class)', 'Common 32-bit KVM processor'].each do |kvm_string|
86
- @plugin.stub(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, kvm_string, ""))
86
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, kvm_string, ""))
87
87
  @plugin.run
88
- @plugin[:virtualization][:system].should == "kvm"
89
- @plugin[:virtualization][:role].should == "guest"
88
+ expect(@plugin[:virtualization][:system]).to eq("kvm")
89
+ expect(@plugin[:virtualization][:role]).to eq("guest")
90
90
  end
91
91
  end
92
92
  end
@@ -25,7 +25,7 @@ describe Ohai::System, "plugin gce" do
25
25
 
26
26
  shared_examples_for "!gce" do
27
27
  it "should NOT attempt to fetch the gce metadata" do
28
- @plugin.should_not_receive(:http_client)
28
+ expect(@plugin).not_to receive(:http_client)
29
29
  @plugin.run
30
30
  end
31
31
  end
@@ -33,23 +33,23 @@ describe Ohai::System, "plugin gce" do
33
33
  shared_examples_for "gce" do
34
34
  before(:each) do
35
35
  @http_client = double("Net::HTTP client")
36
- @plugin.stub(:http_client).and_return(@http_client)
37
- IO.stub(:select).and_return([[],[1],[]])
36
+ allow(@plugin).to receive(:http_client).and_return(@http_client)
37
+ allow(IO).to receive(:select).and_return([[],[1],[]])
38
38
  t = double("connection")
39
- t.stub(:connect_nonblock).and_raise(Errno::EINPROGRESS)
40
- Socket.stub(:new).and_return(t)
41
- Socket.stub(:pack_sockaddr_in).and_return(nil)
39
+ allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS)
40
+ allow(Socket).to receive(:new).and_return(t)
41
+ allow(Socket).to receive(:pack_sockaddr_in).and_return(nil)
42
42
  end
43
43
 
44
44
  it "should recursively fetch and properly parse json metadata" do
45
- @http_client.should_receive(:get).
45
+ expect(@http_client).to receive(:get).
46
46
  with("/computeMetadata/v1beta1/?recursive=true/").
47
47
  and_return(double("Net::HTTP Response", :body => '{"instance":{"hostname":"test-host"}}', :code=>"200"))
48
48
 
49
49
  @plugin.run
50
50
 
51
- @plugin[:gce].should_not be_nil
52
- @plugin[:gce]['instance'].should eq("hostname"=>"test-host")
51
+ expect(@plugin[:gce]).not_to be_nil
52
+ expect(@plugin[:gce]['instance']).to eq("hostname"=>"test-host")
53
53
  end
54
54
 
55
55
  end
@@ -58,10 +58,10 @@ describe Ohai::System, "plugin gce" do
58
58
  it_should_behave_like "gce"
59
59
 
60
60
  before(:each) do
61
- File.stub(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(true)
62
- File.stub(:read).with('/etc/chef/ohai/hints/gce.json').and_return('')
63
- File.stub(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(true)
64
- File.stub(:read).with('C:\chef\ohai\hints/gce.json').and_return('')
61
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(true)
62
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/gce.json').and_return('')
63
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(true)
64
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/gce.json').and_return('')
65
65
  end
66
66
  end
67
67
 
@@ -69,15 +69,15 @@ describe Ohai::System, "plugin gce" do
69
69
  it_should_behave_like "!gce"
70
70
 
71
71
  before(:each) do
72
- File.stub(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(false)
73
- File.stub(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(false)
72
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(false)
73
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(false)
74
74
 
75
75
  # Raise Errno::ENOENT to simulate the scenario in which metadata server
76
76
  # can not be connected
77
77
  t = double("connection")
78
- t.stub(:connect_nonblock).and_raise(Errno::ENOENT)
79
- Socket.stub(:new).and_return(t)
80
- Socket.stub(:pack_sockaddr_in).and_return(nil)
78
+ allow(t).to receive(:connect_nonblock).and_raise(Errno::ENOENT)
79
+ allow(Socket).to receive(:new).and_return(t)
80
+ allow(Socket).to receive(:pack_sockaddr_in).and_return(nil)
81
81
  end
82
82
  end
83
83