diff options
author | danielsdeleo <dan@opscode.com> | 2013-07-15 12:04:32 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-07-15 12:04:32 -0700 |
commit | cec304ed516e4c4226849255fc0a23b1d06efcea (patch) | |
tree | 79c88ed819258ded003d347b522974bd70049b6c | |
parent | 8caceef01670266561bd2650314abae0dd37b9de (diff) | |
download | ohai-cec304ed516e4c4226849255fc0a23b1d06efcea.tar.gz |
Replace all calls to `stub!` with `stub`
`stub!` is deprecated as of RSpec 2.14.x.
56 files changed, 349 insertions, 349 deletions
diff --git a/spec/unit/mixin/ec2_metadata_spec.rb b/spec/unit/mixin/ec2_metadata_spec.rb index a91da4c1..b3f21087 100644 --- a/spec/unit/mixin/ec2_metadata_spec.rb +++ b/spec/unit/mixin/ec2_metadata_spec.rb @@ -23,8 +23,8 @@ describe Ohai::Mixin::Ec2Metadata do let(:mixin) { metadata_object = Object.new.extend(Ohai::Mixin::Ec2Metadata) http_client = mock("Net::HTTP client") - http_client.stub!(:get).and_return(response) - metadata_object.stub!(:http_client).and_return(http_client) + http_client.stub(:get).and_return(response) + metadata_object.stub(:http_client).and_return(http_client) metadata_object } diff --git a/spec/unit/plugins/azure_spec.rb b/spec/unit/plugins/azure_spec.rb index c347a273..30bc8cba 100644 --- a/spec/unit/plugins/azure_spec.rb +++ b/spec/unit/plugins/azure_spec.rb @@ -28,10 +28,10 @@ describe Ohai::System, "plugin azure" do describe "with azure cloud file" do before(:each) do - File.stub!(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(true) - File.stub!(:read).with('/etc/chef/ohai/hints/azure.json').and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}') - File.stub!(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(true) - File.stub!(:read).with('C:\chef\ohai\hints/azure.json').and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}') + File.stub(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(true) + File.stub(:read).with('/etc/chef/ohai/hints/azure.json').and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}') + File.stub(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(true) + File.stub(:read).with('C:\chef\ohai\hints/azure.json').and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}') @plugin.run end @@ -48,8 +48,8 @@ describe Ohai::System, "plugin azure" do describe "without azure cloud file" do before(:each) do - File.stub!(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(false) - File.stub!(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false) + File.stub(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(false) + File.stub(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false) end it 'should not behave like azure' do @@ -59,10 +59,10 @@ describe Ohai::System, "plugin azure" do describe "with rackspace cloud file" do before(:each) do - File.stub!(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true) - File.stub!(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('') - File.stub!(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true) - File.stub!(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('') + File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true) + File.stub(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('') + File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true) + File.stub(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('') end it 'should not behave like azure' do diff --git a/spec/unit/plugins/c_spec.rb b/spec/unit/plugins/c_spec.rb index 7cd832e7..a9d7dba0 100644 --- a/spec/unit/plugins/c_spec.rb +++ b/spec/unit/plugins/c_spec.rb @@ -110,19 +110,19 @@ describe Ohai::System, "plugin c" do @plugin[:languages] = Mash.new #gcc - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"gcc -v"}).and_return([0, "", C_GCC]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"gcc -v"}).and_return([0, "", C_GCC]) #glibc - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"/lib/libc.so.6"}).and_return([0, C_GLIBC_2_3_4, ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"/lib/libc.so.6"}).and_return([0, C_GLIBC_2_3_4, ""]) #ms cl - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"cl /\?"}).and_return([0, "", C_CL]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"cl /\?"}).and_return([0, "", C_CL]) #ms vs - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"devenv.com /\?"}).and_return([0, C_VS, ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"devenv.com /\?"}).and_return([0, C_VS, ""]) #ibm xlc - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"xlc -qversion"}).and_return([0, C_XLC, ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"xlc -qversion"}).and_return([0, C_XLC, ""]) #sun pro - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"cc -V -flags"}).and_return([0, "", C_SUN]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"cc -V -flags"}).and_return([0, "", C_SUN]) #hpux cc - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"what /opt/ansic/bin/cc"}).and_return([0, C_HPUX, ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"what /opt/ansic/bin/cc"}).and_return([0, C_HPUX, ""]) end #gcc @@ -142,7 +142,7 @@ describe Ohai::System, "plugin c" do end it "should not set the languages[:c][:gcc] tree up if gcc command fails" do - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"gcc -v"}).and_return([1, "", ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"gcc -v"}).and_return([1, "", ""]) @plugin.run @plugin[:languages][:c].should_not have_key(:gcc) if @plugin[:languages][:c] end @@ -164,14 +164,14 @@ describe Ohai::System, "plugin c" do end it "should not set the languages[:c][:glibc] tree up if glibc command fails" do - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"/lib/libc.so.6"}).and_return([1, "", ""]) - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"/lib64/libc.so.6"}).and_return([1, "", ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"/lib/libc.so.6"}).and_return([1, "", ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"/lib64/libc.so.6"}).and_return([1, "", ""]) @plugin.run @plugin[:languages][:c].should_not have_key(:glibc) if @plugin[:languages][:c] end it "should get the glibc x.x version from running /lib/libc.so.6" do - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"/lib/libc.so.6"}).and_return([0, C_GLIBC_2_5, ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"/lib/libc.so.6"}).and_return([0, C_GLIBC_2_5, ""]) @plugin.should_receive(:run_command).with({:no_status_check=>true, :command=>"/lib/libc.so.6"}).and_return([0, C_GLIBC_2_5, ""]) @plugin.run @plugin.languages[:c][:glibc][:version].should eql("2.5") @@ -194,7 +194,7 @@ describe Ohai::System, "plugin c" do end it "should not set the languages[:c][:cl] tree up if cl command fails" do - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"cl /\?"}).and_return([1, "", ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"cl /\?"}).and_return([1, "", ""]) @plugin.run @plugin[:languages][:c].should_not have_key(:cl) if @plugin[:languages][:c] end @@ -216,7 +216,7 @@ describe Ohai::System, "plugin c" do end it "should not set the languages[:c][:vs] tree up if devenv command fails" do - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"devenv.com /\?"}).and_return([1, "", ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"devenv.com /\?"}).and_return([1, "", ""]) @plugin.run @plugin[:languages][:c].should_not have_key(:vs) if @plugin[:languages][:c] end @@ -238,13 +238,13 @@ describe Ohai::System, "plugin c" do end it "should not set the languages[:c][:xlc] tree up if xlc command fails" do - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"xlc -qversion"}).and_return([1, "", ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"xlc -qversion"}).and_return([1, "", ""]) @plugin.run @plugin[:languages][:c].should_not have_key(:xlc) if @plugin[:languages][:c] end it "should set the languages[:c][:xlc] tree up if xlc exit status is 249" do - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"xlc -qversion"}).and_return([63744, "", ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"xlc -qversion"}).and_return([63744, "", ""]) @plugin.run @plugin[:languages][:c].should_not have_key(:xlc) if @plugin[:languages][:c] end @@ -266,7 +266,7 @@ describe Ohai::System, "plugin c" do end it "should not set the languages[:c][:sunpro] tree up if cc command fails" do - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"cc -V -flags"}).and_return([1, "", ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"cc -V -flags"}).and_return([1, "", ""]) @plugin.run @plugin[:languages][:c].should_not have_key(:sunpro) if @plugin[:languages][:c] end @@ -275,14 +275,14 @@ describe Ohai::System, "plugin c" do it "should not set the languages[:c][:sunpro] tree if the corresponding cc command fails on linux" do fedora_error_message = "cc: error trying to exec 'i686-redhat-linux-gcc--flags': execvp: No such file or directory" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"cc -V -flags"}).and_return([0, "", fedora_error_message]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"cc -V -flags"}).and_return([0, "", fedora_error_message]) @plugin.run @plugin[:languages][:c].should_not have_key(:sunpro) if @plugin[:languages][:c] end it "should not set the languages[:c][:sunpro] tree if the corresponding cc command fails on hpux" do hpux_error_message = "cc: warning 901: unknown option: `-flags': use +help for online documentation.\ncc: HP C/aC++ B3910B A.06.25 [Nov 30 2009]" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"cc -V -flags"}).and_return([0, "", hpux_error_message]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"cc -V -flags"}).and_return([0, "", hpux_error_message]) @plugin.run @plugin[:languages][:c].should_not have_key(:sunpro) if @plugin[:languages][:c] end @@ -304,7 +304,7 @@ describe Ohai::System, "plugin c" do end it "should not set the languages[:c][:hpcc] tree up if cc command fails" do - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"what /opt/ansic/bin/cc"}).and_return([1, "", ""]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"what /opt/ansic/bin/cc"}).and_return([1, "", ""]) @plugin.run @plugin[:languages][:c].should_not have_key(:hpcc) if @plugin[:languages][:c] end diff --git a/spec/unit/plugins/darwin/hostname_spec.rb b/spec/unit/plugins/darwin/hostname_spec.rb index 493bf861..f3d9e4f9 100644 --- a/spec/unit/plugins/darwin/hostname_spec.rb +++ b/spec/unit/plugins/darwin/hostname_spec.rb @@ -23,10 +23,10 @@ describe Ohai::System, "Darwin hostname plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("darwin/hostname.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:os] = "darwin" - @plugin.stub!(:from).with("hostname -s").and_return("katie") - @plugin.stub!(:from).with("hostname").and_return("katie.bethell") + @plugin.stub(:from).with("hostname -s").and_return("katie") + @plugin.stub(:from).with("hostname").and_return("katie.bethell") end it_should_check_from("darwin::hostname", "hostname", "hostname -s", "katie") diff --git a/spec/unit/plugins/darwin/kernel_spec.rb b/spec/unit/plugins/darwin/kernel_spec.rb index 5ce7c1ba..694c9488 100644 --- a/spec/unit/plugins/darwin/kernel_spec.rb +++ b/spec/unit/plugins/darwin/kernel_spec.rb @@ -29,19 +29,19 @@ describe Ohai::System, "Darwin kernel plugin" do end it "should not set kernel_machine to x86_64" do - @plugin.stub!(:from).with("sysctl -n hw.optional.x86_64").and_return("0") + @plugin.stub(:from).with("sysctl -n hw.optional.x86_64").and_return("0") @plugin.run @plugin[:kernel][:machine].should_not == 'x86_64' end it "should set kernel_machine to x86_64" do - @plugin.stub!(:from).with("sysctl -n hw.optional.x86_64").and_return("1") + @plugin.stub(:from).with("sysctl -n hw.optional.x86_64").and_return("1") @plugin.run @plugin[:kernel][:machine].should == 'x86_64' end it "should set the kernel_os to the kernel_name value" do - @plugin.stub!(:from).with("sysctl -n hw.optional.x86_64").and_return("1") + @plugin.stub(:from).with("sysctl -n hw.optional.x86_64").and_return("1") @plugin.run @plugin[:kernel][:os].should == @plugin[:kernel][:name] end diff --git a/spec/unit/plugins/darwin/network_spec.rb b/spec/unit/plugins/darwin/network_spec.rb index d475e8e2..26371ba2 100644 --- a/spec/unit/plugins/darwin/network_spec.rb +++ b/spec/unit/plugins/darwin/network_spec.rb @@ -434,8 +434,8 @@ net.smb.fs.tcprcvbuf: 261120 describe "gathering IP layer address info" do before do - @plugin.stub!(:popen4).with("arp -an").and_yield(nil, @stdin_arp, @arp_lines, nil) - @plugin.stub!(:popen4).with("ifconfig -a").and_yield(nil, @stdin_ifconfig, @ifconfig_lines, nil) + @plugin.stub(:popen4).with("arp -an").and_yield(nil, @stdin_arp, @arp_lines, nil) + @plugin.stub(:popen4).with("ifconfig -a").and_yield(nil, @stdin_ifconfig, @ifconfig_lines, nil) @plugin.stub(:popen4).with("netstat -i -d -l -b -n").and_yield(nil, @stdin_netstat, @netstat_lines, nil) @plugin.stub(:popen4).with("sysctl net").and_yield(nil, @stdin_sysctl, @sysctl_lines, nil) @plugin.run diff --git a/spec/unit/plugins/darwin/platform_spec.rb b/spec/unit/plugins/darwin/platform_spec.rb index ba5aeba9..460c1ce7 100644 --- a/spec/unit/plugins/darwin/platform_spec.rb +++ b/spec/unit/plugins/darwin/platform_spec.rb @@ -23,17 +23,17 @@ describe Ohai::System, "Darwin plugin platform" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("darwin/platform.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:os] = "darwin" @pid = 10 @stdin = mock("STDIN", { :close => true }) @stdout = mock("STDOUT") - @stdout.stub!(:each). + @stdout.stub(:each). and_yield("ProductName: Mac OS X"). and_yield("ProductVersion: 10.5.5"). and_yield("BuildVersion: 9F33") @stderr = mock("STDERR") - @plugin.stub!(:popen4).with("/usr/bin/sw_vers").and_yield(@pid, @stdin, @stdout, @stderr) + @plugin.stub(:popen4).with("/usr/bin/sw_vers").and_yield(@pid, @stdin, @stdout, @stderr) end it "should run sw_vers" do @@ -73,17 +73,17 @@ describe Ohai::System, "Darwin plugin platform" do describe "on os x server" do before(:each) do - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:os] = "darwin" @pid = 10 @stdin = mock("STDIN", { :close => true }) @stdout = mock("STDOUT") - @stdout.stub!(:each). + @stdout.stub(:each). and_yield("ProductName: Mac OS X Server"). and_yield("ProductVersion: 10.6.8"). and_yield("BuildVersion: 10K549") @stderr = mock("STDERR") - @plugin.stub!(:popen4).with("/usr/bin/sw_vers").and_yield(@pid, @stdin, @stdout, @stderr) + @plugin.stub(:popen4).with("/usr/bin/sw_vers").and_yield(@pid, @stdin, @stdout, @stderr) end it "should set platform to mac_os_x_server" do diff --git a/spec/unit/plugins/darwin/system_profiler_spec.rb b/spec/unit/plugins/darwin/system_profiler_spec.rb index d8cb6008..fae624bb 100644 --- a/spec/unit/plugins/darwin/system_profiler_spec.rb +++ b/spec/unit/plugins/darwin/system_profiler_spec.rb @@ -39,8 +39,8 @@ describe Ohai::System, "Darwin system_profiler plugin", :unix_only do mini_cmd += " SPPCIData SPParallelSCSIData SPPrintersSoftwareData SPPrintersData SPSASData SPSerialATAData" mini_cmd += " SPSoftwareData SPThunderboltData SPUSBData SPWWANData SPAirPortData" full_cmd = "system_profiler -xml -detailLevel full SPHardwareDataType" - @plugin.stub!(:popen4).with(full_cmd).and_yield(nil, StringIO.new, StringIO.new(SystemProfilerOutput::Full), nil) - @plugin.stub!(:popen4).with(mini_cmd).and_yield(nil, StringIO.new, StringIO.new(SystemProfilerOutput::Mini), nil) + @plugin.stub(:popen4).with(full_cmd).and_yield(nil, StringIO.new, StringIO.new(SystemProfilerOutput::Full), nil) + @plugin.stub(:popen4).with(mini_cmd).and_yield(nil, StringIO.new, StringIO.new(SystemProfilerOutput::Mini), nil) @plugin.run @plugin['system_profile'][18]["_items"][0]["serial_number"].should == 'ABCDEFG12345' end diff --git a/spec/unit/plugins/dmi_spec.rb b/spec/unit/plugins/dmi_spec.rb index 25f8fc2a..73d689a5 100644 --- a/spec/unit/plugins/dmi_spec.rb +++ b/spec/unit/plugins/dmi_spec.rb @@ -95,13 +95,13 @@ describe Ohai::System, "plugin dmi" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "dmi.rb")) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @stdin = mock("STDIN", { :close => true }) @pid = 10 @stderr = mock("STDERR") @stdout = StringIO.new(DMI_OUT) @status = 0 - @plugin.stub!(:popen4).with("dmidecode").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("dmidecode").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) end it "should run dmidecode" do diff --git a/spec/unit/plugins/ec2_spec.rb b/spec/unit/plugins/ec2_spec.rb index 828c28cb..f78d1ffe 100644 --- a/spec/unit/plugins/ec2_spec.rb +++ b/spec/unit/plugins/ec2_spec.rb @@ -38,11 +38,11 @@ describe Ohai::System, "plugin ec2" do shared_examples_for "ec2" do before(:each) do @http_client = mock("Net::HTTP client") - @plugin.stub!(:http_client).and_return(@http_client) - IO.stub!(:select).and_return([[],[1],[]]) + @plugin.stub(:http_client).and_return(@http_client) + IO.stub(:select).and_return([[],[1],[]]) t = mock("connection") - t.stub!(:connect_nonblock).and_raise(Errno::EINPROGRESS) - Socket.stub!(:new).and_return(t) + t.stub(:connect_nonblock).and_raise(Errno::EINPROGRESS) + Socket.stub(:new).and_return(t) @http_client.should_receive(:get). with("/").twice. and_return(mock("Net::HTTP Response", :body => "2012-01-12", :code => "200")) @@ -165,7 +165,7 @@ describe Ohai::System, "plugin ec2" do it_should_behave_like "ec2" before(:each) do - IO.stub!(:select).and_return([[],[1],[]]) + IO.stub(:select).and_return([[],[1],[]]) @plugin[:network][:interfaces][:eth0][:arp] = {"169.254.1.0"=>"fe:ff:ff:ff:ff:ff"} end end @@ -182,10 +182,10 @@ describe Ohai::System, "plugin ec2" do it_should_behave_like "ec2" before(:each) do - File.stub!(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true) - File.stub!(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('') - File.stub!(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true) - File.stub!(:read).with('C:\chef\ohai\hints/ec2.json').and_return('') + File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true) + File.stub(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('') + File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true) + File.stub(:read).with('C:\chef\ohai\hints/ec2.json').and_return('') end end @@ -193,8 +193,8 @@ describe Ohai::System, "plugin ec2" do it_should_behave_like "!ec2" before(:each) do - File.stub!(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false) - File.stub!(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false) + File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false) + File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false) end end @@ -202,13 +202,13 @@ describe Ohai::System, "plugin ec2" do it_should_behave_like "!ec2" before(:each) do - File.stub!(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false) - File.stub!(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false) + File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false) + File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false) - File.stub!(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true) - File.stub!(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('') - File.stub!(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true) - File.stub!(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('') + File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true) + File.stub(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('') + File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true) + File.stub(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('') end end diff --git a/spec/unit/plugins/erlang_spec.rb b/spec/unit/plugins/erlang_spec.rb index f7e2702f..7f1b2f00 100644 --- a/spec/unit/plugins/erlang_spec.rb +++ b/spec/unit/plugins/erlang_spec.rb @@ -28,7 +28,7 @@ describe Ohai::System, "plugin erlang" do @status = 0 @stdin = "" @stderr = "Erlang (ASYNC_THREADS,SMP,HIPE) (BEAM) emulator version 5.6.2\n" - @plugin.stub!(:run_command).with({:no_status_check => true, :command => "erl +V"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check => true, :command => "erl +V"}).and_return([@status, @stdout, @stderr]) end it "should get the erlang version from erl +V" do @@ -55,7 +55,7 @@ describe Ohai::System, "plugin erlang" do @status = 1 @stdin = "" @stderr = "Erlang (ASYNC_THREADS,SMP,HIPE) (BEAM) emulator version 5.6.2\n" - @plugin.stub!(:run_command).with({:no_status_check => true, :command => "erl +V"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check => true, :command => "erl +V"}).and_return([@status, @stdout, @stderr]) @plugin.run @plugin.languages.should_not have_key(:erlang) end diff --git a/spec/unit/plugins/eucalyptus_spec.rb b/spec/unit/plugins/eucalyptus_spec.rb index 2269a22c..2b2944cd 100644 --- a/spec/unit/plugins/eucalyptus_spec.rb +++ b/spec/unit/plugins/eucalyptus_spec.rb @@ -24,7 +24,7 @@ describe Ohai::System, "plugin eucalyptus" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "eucalyptus.rb")) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) end shared_examples_for "!eucalyptus" do @@ -37,7 +37,7 @@ describe Ohai::System, "plugin eucalyptus" do shared_examples_for "eucalyptus" do before(:each) do @http_client = mock("Net::HTTP client") - @plugin.stub!(:http_client).and_return(@http_client) + @plugin.stub(:http_client).and_return(@http_client) @http_client.should_receive(:get). with("/").twice. @@ -60,10 +60,10 @@ describe Ohai::System, "plugin eucalyptus" do end it "should recursively fetch all the eucalyptus metadata" do - IO.stub!(:select).and_return([[],[1],[]]) + IO.stub(:select).and_return([[],[1],[]]) t = mock("connection") - t.stub!(:connect_nonblock).and_raise(Errno::EINPROGRESS) - Socket.stub!(:new).and_return(t) + t.stub(:connect_nonblock).and_raise(Errno::EINPROGRESS) + Socket.stub(:new).and_return(t) @plugin.run @plugin[:eucalyptus].should_not be_nil @plugin[:eucalyptus]['instance_type'].should == "c1.medium" @@ -76,7 +76,7 @@ describe Ohai::System, "plugin eucalyptus" do it_should_behave_like "eucalyptus" before(:each) do - IO.stub!(:select).and_return([[],[1],[]]) + IO.stub(:select).and_return([[],[1],[]]) @plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "d0:0d:95:47:6E:ED"=> { "family" => "lladdr" } } } } } end end @@ -93,10 +93,10 @@ describe Ohai::System, "plugin eucalyptus" do it_should_behave_like "eucalyptus" before(:each) do - File.stub!(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(true) - File.stub!(:read).with('/etc/chef/ohai/hints/eucalyptus.json').and_return('') - File.stub!(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(true) - File.stub!(:read).with('C:\chef\ohai\hints/eucalyptus.json').and_return('') + File.stub(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(true) + File.stub(:read).with('/etc/chef/ohai/hints/eucalyptus.json').and_return('') + File.stub(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(true) + File.stub(:read).with('C:\chef\ohai\hints/eucalyptus.json').and_return('') end end @@ -105,8 +105,8 @@ describe Ohai::System, "plugin eucalyptus" do before(:each) do @plugin[:network] = {:interfaces => {}} - File.stub!(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false) - File.stub!(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false) + File.stub(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false) + File.stub(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false) end end @@ -116,12 +116,12 @@ describe Ohai::System, "plugin eucalyptus" do before(:each) do @plugin[:network] = {:interfaces => {}} - File.stub!(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false) - File.stub!(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false) - File.stub!(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true) - File.stub!(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true) - File.stub!(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('') - File.stub!(:read).with('C:\chef\ohai\hints/ec2.json').and_return('') + File.stub(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false) + File.stub(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false) + File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true) + File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true) + File.stub(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('') + File.stub(:read).with('C:\chef\ohai\hints/ec2.json').and_return('') end end diff --git a/spec/unit/plugins/freebsd/hostname_spec.rb b/spec/unit/plugins/freebsd/hostname_spec.rb index 938239d6..c4b74f81 100644 --- a/spec/unit/plugins/freebsd/hostname_spec.rb +++ b/spec/unit/plugins/freebsd/hostname_spec.rb @@ -23,10 +23,10 @@ describe Ohai::System, "FreeBSD hostname plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("freebsd/hostname.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:os] = "freebsd" - @plugin.stub!(:from).with("hostname -s").and_return("katie") - @plugin.stub!(:from).with("hostname -f").and_return("katie.bethell") + @plugin.stub(:from).with("hostname -s").and_return("katie") + @plugin.stub(:from).with("hostname -f").and_return("katie.bethell") end it_should_check_from("freebsd::hostname", "hostname", "hostname -s", "katie") diff --git a/spec/unit/plugins/freebsd/kernel_spec.rb b/spec/unit/plugins/freebsd/kernel_spec.rb index 1cf0cc20..8f660d5f 100644 --- a/spec/unit/plugins/freebsd/kernel_spec.rb +++ b/spec/unit/plugins/freebsd/kernel_spec.rb @@ -23,10 +23,10 @@ describe Ohai::System, "FreeBSD kernel plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("freebsd/kernel.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) - @plugin.stub!(:from).with("uname -i").and_return("foo") - @plugin.stub!(:from_with_regex).with("sysctl kern.securelevel", /kern.securelevel: (.+)$/).and_return("kern.securelevel: 1") - @plugin.stub!(:popen4).with("/sbin/kldstat").and_yield(0, StringIO.new, StringIO.new, StringIO.new) + @plugin.stub(:require_plugin).and_return(true) + @plugin.stub(:from).with("uname -i").and_return("foo") + @plugin.stub(:from_with_regex).with("sysctl kern.securelevel", /kern.securelevel: (.+)$/).and_return("kern.securelevel: 1") + @plugin.stub(:popen4).with("/sbin/kldstat").and_yield(0, StringIO.new, StringIO.new, StringIO.new) @plugin[:kernel] = Mash.new @plugin[:kernel][:name] = "freebsd" end diff --git a/spec/unit/plugins/freebsd/platform_spec.rb b/spec/unit/plugins/freebsd/platform_spec.rb index cbae5559..80cbbb3d 100644 --- a/spec/unit/plugins/freebsd/platform_spec.rb +++ b/spec/unit/plugins/freebsd/platform_spec.rb @@ -23,9 +23,9 @@ describe Ohai::System, "FreeBSD plugin platform" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("freebsd/platform.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) - @plugin.stub!(:from).with("uname -s").and_return("FreeBSD") - @plugin.stub!(:from).with("uname -r").and_return("7.1") + @plugin.stub(:require_plugin).and_return(true) + @plugin.stub(:from).with("uname -s").and_return("FreeBSD") + @plugin.stub(:from).with("uname -r").and_return("7.1") @plugin[:os] = "freebsd" end diff --git a/spec/unit/plugins/gce_spec.rb b/spec/unit/plugins/gce_spec.rb index 4c01480d..7cab041a 100644 --- a/spec/unit/plugins/gce_spec.rb +++ b/spec/unit/plugins/gce_spec.rb @@ -35,12 +35,12 @@ describe Ohai::System, "plugin gce" do shared_examples_for "gce" do before(:each) do @http_client = mock("Net::HTTP client") - @plugin.stub!(:http_client).and_return(@http_client) - IO.stub!(:select).and_return([[],[1],[]]) + @plugin.stub(:http_client).and_return(@http_client) + IO.stub(:select).and_return([[],[1],[]]) t = mock("connection") - t.stub!(:connect_nonblock).and_raise(Errno::EINPROGRESS) - Socket.stub!(:new).and_return(t) - Socket.stub!(:pack_sockaddr_in).and_return(nil) + t.stub(:connect_nonblock).and_raise(Errno::EINPROGRESS) + Socket.stub(:new).and_return(t) + Socket.stub(:pack_sockaddr_in).and_return(nil) end it "should recursively fetch metadata" do @@ -102,10 +102,10 @@ describe Ohai::System, "plugin gce" do it_should_behave_like "gce" before(:each) do - File.stub!(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(true) - File.stub!(:read).with('/etc/chef/ohai/hints/gce.json').and_return('') - File.stub!(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(true) - File.stub!(:read).with('C:\chef\ohai\hints/gce.json').and_return('') + File.stub(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(true) + File.stub(:read).with('/etc/chef/ohai/hints/gce.json').and_return('') + File.stub(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(true) + File.stub(:read).with('C:\chef\ohai\hints/gce.json').and_return('') end end @@ -115,8 +115,8 @@ describe Ohai::System, "plugin gce" do before(:each) do File.should_receive(:read).with('/sys/firmware/dmi/entries/1-0/raw').and_return('Test') - File.stub!(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(false) - File.stub!(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(false) + File.stub(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(false) + File.stub(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(false) end end @@ -126,13 +126,13 @@ describe Ohai::System, "plugin gce" do before(:each) do File.should_receive(:read).with('/sys/firmware/dmi/entries/1-0/raw').and_return('Test') - File.stub!(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(false) - File.stub!(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(false) + File.stub(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(false) + File.stub(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(false) - File.stub!(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true) - File.stub!(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('') - File.stub!(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true) - File.stub!(:read).with('C:\chef\ohai\hints/ec2.json').and_return('') + File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true) + File.stub(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('') + File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true) + File.stub(:read).with('C:\chef\ohai\hints/ec2.json').and_return('') end end end diff --git a/spec/unit/plugins/groovy_spec.rb b/spec/unit/plugins/groovy_spec.rb index 6c8cfca6..02ff0e65 100644 --- a/spec/unit/plugins/groovy_spec.rb +++ b/spec/unit/plugins/groovy_spec.rb @@ -25,11 +25,11 @@ describe Ohai::System, "plugin groovy" do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "groovy.rb")) @plugin[:languages] = Mash.new - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @status = 0 @stdout = "Groovy Version: 1.6.3 JVM: 1.6.0_0\n" @stderr = "" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"groovy -v"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"groovy -v"}).and_return([@status, @stdout, @stderr]) end it "should get the groovy version from running groovy -v" do @@ -46,7 +46,7 @@ describe Ohai::System, "plugin groovy" do @status = 1 @stdout = "Groovy Version: 1.6.3 JVM: 1.6.0_0\n" @stderr = "" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"groovy -v"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"groovy -v"}).and_return([@status, @stdout, @stderr]) @plugin.run @plugin.languages.should_not have_key(:groovy) end diff --git a/spec/unit/plugins/hostname_spec.rb b/spec/unit/plugins/hostname_spec.rb index adde2b30..2098fead 100644 --- a/spec/unit/plugins/hostname_spec.rb +++ b/spec/unit/plugins/hostname_spec.rb @@ -23,7 +23,7 @@ describe Ohai::System, "hostname plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "hostname.rb")) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) end it "should set the domain to everything after the first dot of the fqdn" do diff --git a/spec/unit/plugins/java_spec.rb b/spec/unit/plugins/java_spec.rb index 6b9bd607..1f4a9913 100644 --- a/spec/unit/plugins/java_spec.rb +++ b/spec/unit/plugins/java_spec.rb @@ -22,12 +22,12 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "java.rb")) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:languages] = Mash.new @status = 0 @stdout = "" @stderr = "java version \"1.5.0_16\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)\nJava HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)" - @plugin.stub!(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([@status, @stdout, @stderr]) end it "should run java -version" do @@ -64,7 +64,7 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do @status = 1 @stdout = "" @stderr = "Some error output here" - @plugin.stub!(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([@status, @stdout, @stderr]) @plugin.run @plugin.languages.should_not have_key(:java) end @@ -74,12 +74,12 @@ describe Ohai::System, "plugin java (Java6 Server VM)" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "java.rb")) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:languages] = Mash.new @status = 0 @stdout = "" @stderr = "java version \"1.6.0_22\"\nJava(TM) 2 Runtime Environment (build 1.6.0_22-b04)\nJava HotSpot(TM) Server VM (build 17.1-b03, mixed mode)" - @plugin.stub!(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([@status, @stdout, @stderr]) end it "should run java -version" do @@ -116,7 +116,7 @@ describe Ohai::System, "plugin java (Java6 Server VM)" do @status = 1 @stdout = "" @stderr = "Some error output here" - @plugin.stub!(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check => true, :command => "java -version"}).and_return([@status, @stdout, @stderr]) @plugin.run @plugin.languages.should_not have_key(:java) end diff --git a/spec/unit/plugins/kernel_spec.rb b/spec/unit/plugins/kernel_spec.rb index 70579537..fe85c5cc 100644 --- a/spec/unit/plugins/kernel_spec.rb +++ b/spec/unit/plugins/kernel_spec.rb @@ -24,14 +24,14 @@ describe Ohai::System, "plugin kernel" do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "kernel.rb")) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:languages] = Mash.new @plugin[:languages][:ruby] = Mash.new - @plugin.stub!(:from).with("uname -s").and_return("Darwin") - @plugin.stub!(:from).with("uname -r").and_return("9.5.0") - @plugin.stub!(:from).with("uname -v").and_return("Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386") - @plugin.stub!(:from).with("uname -m").and_return("i386") - @plugin.stub!(:from).with("uname -o").and_return("Linux") + @plugin.stub(:from).with("uname -s").and_return("Darwin") + @plugin.stub(:from).with("uname -r").and_return("9.5.0") + @plugin.stub(:from).with("uname -v").and_return("Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386") + @plugin.stub(:from).with("uname -m").and_return("i386") + @plugin.stub(:from).with("uname -o").and_return("Linux") end it_should_check_from_mash("kernel", "name", "uname -s", "Darwin") diff --git a/spec/unit/plugins/linode_spec.rb b/spec/unit/plugins/linode_spec.rb index 1566b97a..00c6bbf5 100644 --- a/spec/unit/plugins/linode_spec.rb +++ b/spec/unit/plugins/linode_spec.rb @@ -122,10 +122,10 @@ describe Ohai::System, "plugin linode" do describe "with linode cloud file" do before do - File.stub!(:exist?).with(hint_path_nix).and_return(true) - File.stub!(:read).with(hint_path_nix).and_return('') - File.stub!(:exist?).with(hint_path_win).and_return(true) - File.stub!(:read).with(hint_path_win).and_return('') + File.stub(:exist?).with(hint_path_nix).and_return(true) + File.stub(:read).with(hint_path_nix).and_return('') + File.stub(:exist?).with(hint_path_win).and_return(true) + File.stub(:read).with(hint_path_win).and_return('') end it_should_behave_like "linode" @@ -133,8 +133,8 @@ describe Ohai::System, "plugin linode" do describe "without cloud file" do before do - File.stub!(:exist?).with(hint_path_nix).and_return(false) - File.stub!(:exist?).with(hint_path_win).and_return(false) + File.stub(:exist?).with(hint_path_nix).and_return(false) + File.stub(:exist?).with(hint_path_win).and_return(false) end it_should_behave_like "!linode" @@ -145,13 +145,13 @@ describe Ohai::System, "plugin linode" do let(:ec2_hint_path_win) { 'C:\chef\ohai\hints/ec2.json' } before do - File.stub!(:exist?).with(hint_path_nix).and_return(false) - File.stub!(:exist?).with(hint_path_win).and_return(false) + File.stub(:exist?).with(hint_path_nix).and_return(false) + File.stub(:exist?).with(hint_path_win).and_return(false) - File.stub!(:exist?).with(ec2_hint_path_nix).and_return(true) - File.stub!(:read).with(ec2_hint_path_nix).and_return('') - File.stub!(:exist?).with(ec2_hint_path_win).and_return(true) - File.stub!(:read).with(ec2_hint_path_win).and_return('') + File.stub(:exist?).with(ec2_hint_path_nix).and_return(true) + File.stub(:read).with(ec2_hint_path_nix).and_return('') + File.stub(:exist?).with(ec2_hint_path_win).and_return(true) + File.stub(:read).with(ec2_hint_path_win).and_return('') end it_should_behave_like "!linode" diff --git a/spec/unit/plugins/linux/cpu_spec.rb b/spec/unit/plugins/linux/cpu_spec.rb index e2744d0a..0aff9572 100644 --- a/spec/unit/plugins/linux/cpu_spec.rb +++ b/spec/unit/plugins/linux/cpu_spec.rb @@ -23,10 +23,10 @@ describe Ohai::System, "Linux cpu plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("linux/cpu.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:os] = "linux" @mock_file = mock("/proc/cpuinfo") - @mock_file.stub!(:each). + @mock_file.stub(:each). and_yield("processor : 0"). and_yield("vendor_id : GenuineIntel"). and_yield("cpu family : 6"). @@ -46,7 +46,7 @@ describe Ohai::System, "Linux cpu plugin" do and_yield("flags : fpu pse tsc msr mce cx8 sep mtrr pge cmov"). and_yield("bogomips : 2575.86"). and_yield("clflush size : 32") - File.stub!(:open).with("/proc/cpuinfo").and_return(@mock_file) + File.stub(:open).with("/proc/cpuinfo").and_return(@mock_file) end it "should set cpu[:total] to 1" do diff --git a/spec/unit/plugins/linux/filesystem_spec.rb b/spec/unit/plugins/linux/filesystem_spec.rb index 44b46e89..f5a9d1a5 100644 --- a/spec/unit/plugins/linux/filesystem_spec.rb +++ b/spec/unit/plugins/linux/filesystem_spec.rb @@ -23,16 +23,16 @@ describe Ohai::System, "Linux filesystem plugin" do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("linux/filesystem.rb", PLUGIN_PATH)) @plugin[:os] = "linux" - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin.extend(SimpleFromFile) - @plugin.stub!(:popen4).with("df -P").and_return(false) - @plugin.stub!(:popen4).with("mount").and_return(false) - @plugin.stub!(:popen4).with("blkid -s TYPE").and_return(false) - @plugin.stub!(:popen4).with("blkid -s UUID").and_return(false) - @plugin.stub!(:popen4).with("blkid -s LABEL").and_return(false) + @plugin.stub(:popen4).with("df -P").and_return(false) + @plugin.stub(:popen4).with("mount").and_return(false) + @plugin.stub(:popen4).with("blkid -s TYPE").and_return(false) + @plugin.stub(:popen4).with("blkid -s UUID").and_return(false) + @plugin.stub(:popen4).with("blkid -s LABEL").and_return(false) - File.stub!(:exists?).with("/proc/mounts").and_return(false) + File.stub(:exists?).with("/proc/mounts").and_return(false) end describe "when gathering filesystem usage data from df" do @@ -43,7 +43,7 @@ describe Ohai::System, "Linux filesystem plugin" do @stdout = mock("STDOUT") @status = 0 - @stdout.stub!(:each). + @stdout.stub(:each). and_yield("Filesystem 1024-blocks Used Available Capacity Mounted on"). and_yield("/dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /"). and_yield("tmpfs 2030944 0 2030944 0% /lib/init/rw"). @@ -63,31 +63,31 @@ describe Ohai::System, "Linux filesystem plugin" do end it "should set kb_size to value from df -P" do - @plugin.stub!(:popen4).with("df -P").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("df -P").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_size].should be == "97605057" end it "should set kb_used to value from df -P" do - @plugin.stub!(:popen4).with("df -P").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("df -P").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_used].should be == "53563253" end it "should set kb_available to value from df -P" do - @plugin.stub!(:popen4).with("df -P").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("df -P").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_available].should be == "44041805" end it "should set percent_used to value from df -P" do - @plugin.stub!(:popen4).with("df -P").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("df -P").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:percent_used].should be == "56%" end it "should set mount to value from df -P" do - @plugin.stub!(:popen4).with("df -P").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("df -P").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount].should be == "/special" end @@ -101,7 +101,7 @@ describe Ohai::System, "Linux filesystem plugin" do @stdout = mock("STDOUT") @status = 0 - @stdout.stub!(:each). + @stdout.stub(:each). and_yield("/dev/mapper/sys.vg-root.lv on / type ext4 (rw,noatime,errors=remount-ro)"). and_yield("tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)"). and_yield("proc on /proc type proc (rw,noexec,nosuid,nodev)"). @@ -125,19 +125,19 @@ describe Ohai::System, "Linux filesystem plugin" do end it "should set mount to value from mount" do - @plugin.stub!(:popen4).with("mount").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("mount").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount].should be == "/special" end it "should set fs_type to value from mount" do - @plugin.stub!(:popen4).with("mount").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("mount").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type].should be == "xfs" end it "should set mount_options to an array of values from mount" do - @plugin.stub!(:popen4).with("mount").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("mount").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options].should be == [ "ro", "noatime" ] end @@ -151,7 +151,7 @@ describe Ohai::System, "Linux filesystem plugin" do @stdout = mock("STDOUT") @status = 0 - @stdout.stub!(:each). + @stdout.stub(:each). and_yield("/dev/sdb1: TYPE=\"linux_raid_member\" "). and_yield("/dev/sdb2: TYPE=\"linux_raid_member\" "). and_yield("/dev/sda1: TYPE=\"linux_raid_member\" "). @@ -172,7 +172,7 @@ describe Ohai::System, "Linux filesystem plugin" do end it "should set kb_size to value from blkid -s TYPE" do - @plugin.stub!(:popen4).with("blkid -s TYPE").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("blkid -s TYPE").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:filesystem]["/dev/md1"][:fs_type].should be == "LVM2_member" end @@ -186,7 +186,7 @@ describe Ohai::System, "Linux filesystem plugin" do @stdout = mock("STDOUT") @status = 0 - @stdout.stub!(:each). + @stdout.stub(:each). and_yield("/dev/sdb1: UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" "). and_yield("/dev/sdb2: UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" "). and_yield("/dev/sda1: UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" "). @@ -207,7 +207,7 @@ describe Ohai::System, "Linux filesystem plugin" do end it "should set kb_size to value from blkid -s UUID" do - @plugin.stub!(:popen4).with("blkid -s UUID").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("blkid -s UUID").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:filesystem]["/dev/sda2"][:uuid].should be == "e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa" end @@ -221,7 +221,7 @@ describe Ohai::System, "Linux filesystem plugin" do @stdout = mock("STDOUT") @status = 0 - @stdout.stub!(:each). + @stdout.stub(:each). and_yield("/dev/sda1: LABEL=\"fuego:0\" "). and_yield("/dev/sda2: LABEL=\"fuego:1\" "). and_yield("/dev/sdb1: LABEL=\"fuego:0\" "). @@ -240,7 +240,7 @@ describe Ohai::System, "Linux filesystem plugin" do end it "should set kb_size to value from blkid -s LABEL" do - @plugin.stub!(:popen4).with("blkid -s LABEL").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("blkid -s LABEL").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:filesystem]["/dev/md0"][:label].should be == "/boot" end @@ -248,10 +248,10 @@ describe Ohai::System, "Linux filesystem plugin" do describe "when gathering data from /proc/mounts" do before(:each) do - File.stub!(:exists?).with("/proc/mounts").and_return(true) + File.stub(:exists?).with("/proc/mounts").and_return(true) @mock_file = mock("/proc/mounts") - @mock_file.stub!(:read_nonblock).and_return(@mock_file) - @mock_file.stub!(:each_line). + @mock_file.stub(:read_nonblock).and_return(@mock_file) + @mock_file.stub(:each_line). and_yield("rootfs / rootfs rw 0 0"). and_yield("none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0"). and_yield("none /proc proc rw,nosuid,nodev,noexec,relatime 0 0"). @@ -268,7 +268,7 @@ describe Ohai::System, "Linux filesystem plugin" do and_yield("/dev/md0 /boot ext3 rw,noatime,errors=remount-ro,data=ordered 0 0"). and_yield("fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0"). and_yield("binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0") - File.stub!(:open).with("/proc/mounts").and_return(@mock_file) + File.stub(:open).with("/proc/mounts").and_return(@mock_file) end it "should set mount to value from /proc/mounts" do diff --git a/spec/unit/plugins/linux/hostname_spec.rb b/spec/unit/plugins/linux/hostname_spec.rb index 61db03b8..70ec0af4 100644 --- a/spec/unit/plugins/linux/hostname_spec.rb +++ b/spec/unit/plugins/linux/hostname_spec.rb @@ -23,10 +23,10 @@ describe Ohai::System, "Linux hostname plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("linux/hostname.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:os] = "linux" - @plugin.stub!(:from).with("hostname -s").and_return("katie") - @plugin.stub!(:from).with("hostname --fqdn").and_return("katie.bethell") + @plugin.stub(:from).with("hostname -s").and_return("katie") + @plugin.stub(:from).with("hostname --fqdn").and_return("katie.bethell") end it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie") diff --git a/spec/unit/plugins/linux/kernel_spec.rb b/spec/unit/plugins/linux/kernel_spec.rb index afd0349f..f33aea80 100644 --- a/spec/unit/plugins/linux/kernel_spec.rb +++ b/spec/unit/plugins/linux/kernel_spec.rb @@ -23,8 +23,8 @@ describe Ohai::System, "Linux kernel plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("linux/kernel.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) - @plugin.stub!(:from).with("uname -o").and_return("Linux") + @plugin.stub(:require_plugin).and_return(true) + @plugin.stub(:from).with("uname -o").and_return("Linux") @plugin.should_receive(:popen4).with("env lsmod").at_least(1).times @plugin[:kernel] = {} @plugin.run diff --git a/spec/unit/plugins/linux/lsb_spec.rb b/spec/unit/plugins/linux/lsb_spec.rb index 56acb135..869e5cd5 100644 --- a/spec/unit/plugins/linux/lsb_spec.rb +++ b/spec/unit/plugins/linux/lsb_spec.rb @@ -26,20 +26,20 @@ describe Ohai::System, "Linux lsb plugin" do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("linux/lsb.rb", PLUGIN_PATH)) @plugin[:os] = "linux" - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin.extend(SimpleFromFile) end describe "on systems with /etc/lsb-release" do before(:each) do @mock_file = mock("/etc/lsb-release") - @mock_file.stub!(:each). + @mock_file.stub(:each). and_yield("DISTRIB_ID=Ubuntu"). and_yield("DISTRIB_RELEASE=8.04"). and_yield("DISTRIB_CODENAME=hardy"). and_yield('DISTRIB_DESCRIPTION="Ubuntu 8.04"') - File.stub!(:open).with("/etc/lsb-release").and_return(@mock_file) - File.stub!(:exists?).with("/etc/lsb-release").and_return(true) + File.stub(:open).with("/etc/lsb-release").and_return(@mock_file) + File.stub(:exists?).with("/etc/lsb-release").and_return(true) end it "should set lsb[:id]" do @@ -65,8 +65,8 @@ describe Ohai::System, "Linux lsb plugin" do describe "on systems with /usr/bin/lsb_release" do before(:each) do - File.stub!(:exists?).with("/etc/lsb-release").and_return(false) - File.stub!(:exists?).with("/usr/bin/lsb_release").and_return(true) + File.stub(:exists?).with("/etc/lsb-release").and_return(false) + File.stub(:exists?).with("/usr/bin/lsb_release").and_return(true) @stdin = mock("STDIN", { :close => true }) @pid = 10 @@ -78,14 +78,14 @@ describe Ohai::System, "Linux lsb plugin" do describe "on Centos 5.4 correctly" do before(:each) do - @stdout.stub!(:each). + @stdout.stub(:each). and_yield("LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch"). and_yield("Distributor ID: CentOS"). and_yield("Description: CentOS release 5.4 (Final)"). and_yield("Release: 5.4"). and_yield("Codename: Final") - @plugin.stub!(:popen4).with("lsb_release -a").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("lsb_release -a").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) end it "should set lsb[:id]" do @@ -111,14 +111,14 @@ describe Ohai::System, "Linux lsb plugin" do describe "on Fedora 14 correctly" do before(:each) do - @stdout.stub!(:each). + @stdout.stub(:each). and_yield("LSB Version: :core-4.0-ia32:core-4.0-noarch"). and_yield("Distributor ID: Fedora"). and_yield("Description: Fedora release 14 (Laughlin)"). and_yield("Release: 14"). and_yield("Codename: Laughlin") - @plugin.stub!(:popen4).with("lsb_release -a").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("lsb_release -a").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) end it "should set lsb[:id]" do @@ -144,8 +144,8 @@ describe Ohai::System, "Linux lsb plugin" do end it "should not set any lsb values if /etc/lsb-release or /usr/bin/lsb_release do not exist " do - File.stub!(:exists?).with("/etc/lsb-release").and_return(false) - File.stub!(:exists?).with("/usr/bin/lsb_release").and_return(false) + File.stub(:exists?).with("/etc/lsb-release").and_return(false) + File.stub(:exists?).with("/usr/bin/lsb_release").and_return(false) @plugin.attribute?(:lsb).should be(false) end end diff --git a/spec/unit/plugins/linux/network_spec.rb b/spec/unit/plugins/linux/network_spec.rb index a53d37ae..7382d13a 100644 --- a/spec/unit/plugins/linux/network_spec.rb +++ b/spec/unit/plugins/linux/network_spec.rb @@ -38,15 +38,15 @@ def prepare_data end def do_stubs - @plugin.stub!(:from).with("route -n \| grep -m 1 ^0.0.0.0").and_return(@route_lines.last) - @plugin.stub!(:popen4).with("ifconfig -a").and_yield(nil, @stdin_ifconfig, @ifconfig_lines, nil) - @plugin.stub!(:popen4).with("arp -an").and_yield(nil, @stdin_arp, @arp_lines, nil) - @plugin.stub!(:popen4).with("ip -f inet neigh show").and_yield(nil, @stdin_ipneighbor, @ipneighbor_lines, nil) - @plugin.stub!(:popen4).with("ip -f inet6 neigh show").and_yield(nil, @stdin_ipneighbor_inet6, @ipneighbor_lines_inet6, nil) - @plugin.stub!(:popen4).with("ip addr").and_yield(nil, @stdin_ipaddr, @ipaddr_lines, nil) - @plugin.stub!(:popen4).with("ip -d -s link").and_yield(nil, @stdin_iplink, @iplink_lines, nil) - @plugin.stub!(:popen4).with("ip -f inet route show").and_yield(nil, @stdin_ip_route, @ip_route_lines, nil) - @plugin.stub!(:popen4).with("ip -f inet6 route show").and_yield(nil, @stdin_ip_route_inet6, @ip_route_inet6_lines, nil) + @plugin.stub(:from).with("route -n \| grep -m 1 ^0.0.0.0").and_return(@route_lines.last) + @plugin.stub(:popen4).with("ifconfig -a").and_yield(nil, @stdin_ifconfig, @ifconfig_lines, nil) + @plugin.stub(:popen4).with("arp -an").and_yield(nil, @stdin_arp, @arp_lines, nil) + @plugin.stub(:popen4).with("ip -f inet neigh show").and_yield(nil, @stdin_ipneighbor, @ipneighbor_lines, nil) + @plugin.stub(:popen4).with("ip -f inet6 neigh show").and_yield(nil, @stdin_ipneighbor_inet6, @ipneighbor_lines_inet6, nil) + @plugin.stub(:popen4).with("ip addr").and_yield(nil, @stdin_ipaddr, @ipaddr_lines, nil) + @plugin.stub(:popen4).with("ip -d -s link").and_yield(nil, @stdin_iplink, @iplink_lines, nil) + @plugin.stub(:popen4).with("ip -f inet route show").and_yield(nil, @stdin_ip_route, @ip_route_lines, nil) + @plugin.stub(:popen4).with("ip -f inet6 route show").and_yield(nil, @stdin_ip_route_inet6, @ip_route_inet6_lines, nil) end describe Ohai::System, "Linux Network Plugin" do @@ -285,14 +285,14 @@ IP_ROUTE_SCOPE Ohai::Log.should_receive(:warn).with(/unable to detect/).exactly(6).times @plugin.require_plugin("network") - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) end ["ifconfig","iproute2"].each do |network_method| describe "gathering IP layer address info via #{network_method}" do before do - File.stub!(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" ) + File.stub(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" ) do_stubs end @@ -415,7 +415,7 @@ IP_ROUTE_SCOPE describe "gathering interface counters via #{network_method}" do before do - File.stub!(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" ) + File.stub(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" ) do_stubs @plugin.run end @@ -454,7 +454,7 @@ IP_ROUTE_SCOPE describe "setting the node's default IP address attribute with #{network_method}" do before do - File.stub!(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" ) + File.stub(:exist?).with("/sbin/ip").and_return( network_method == "iproute2" ) do_stubs end @@ -531,7 +531,7 @@ ROUTE_N describe "for newer network features using iproute2 only" do before do - File.stub!(:exist?).with("/sbin/ip").and_return(true) # iproute2 only + File.stub(:exist?).with("/sbin/ip").and_return(true) # iproute2 only do_stubs end diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb index e90f29ea..10b3dd73 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -24,20 +24,20 @@ describe Ohai::System, "Linux plugin platform" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("linux/platform.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin.extend(SimpleFromFile) @plugin[:os] = "linux" @plugin[:lsb] = Mash.new - File.stub!(:exists?).with("/etc/debian_version").and_return(false) - File.stub!(:exists?).with("/etc/redhat-release").and_return(false) - File.stub!(:exists?).with("/etc/gentoo-release").and_return(false) - File.stub!(:exists?).with("/etc/SuSE-release").and_return(false) - File.stub!(:exists?).with("/etc/arch-release").and_return(false) - File.stub!(:exists?).with("/etc/system-release").and_return(false) - File.stub!(:exists?).with("/etc/slackware-version").and_return(false) - File.stub!(:exists?).with("/etc/enterprise-release").and_return(false) - File.stub!(:exists?).with("/etc/oracle-release").and_return(false) - File.stub!(:exists?).with("/usr/bin/raspi-config").and_return(false) + File.stub(:exists?).with("/etc/debian_version").and_return(false) + File.stub(:exists?).with("/etc/redhat-release").and_return(false) + File.stub(:exists?).with("/etc/gentoo-release").and_return(false) + File.stub(:exists?).with("/etc/SuSE-release").and_return(false) + File.stub(:exists?).with("/etc/arch-release").and_return(false) + File.stub(:exists?).with("/etc/system-release").and_return(false) + File.stub(:exists?).with("/etc/slackware-version").and_return(false) + File.stub(:exists?).with("/etc/enterprise-release").and_return(false) + File.stub(:exists?).with("/etc/oracle-release").and_return(false) + File.stub(:exists?).with("/usr/bin/raspi-config").and_return(false) end it "should require the lsb plugin" do @@ -288,8 +288,8 @@ describe Ohai::System, "Linux plugin platform" do it "should read the platform as oracle and version as 5.7" do @plugin[:lsb][:id] = "EnterpriseEnterpriseServer" @plugin[:lsb][:release] = "5.7" - File.stub!(:exists?).with("/etc/redhat-release").and_return(true) - File.stub!(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)") + File.stub(:exists?).with("/etc/redhat-release").and_return(true) + File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)") File.should_receive(:exists?).with("/etc/enterprise-release").and_return(true) File.should_receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)") @plugin.run @@ -300,8 +300,8 @@ describe Ohai::System, "Linux plugin platform" do it "should read the platform as oracle and version as 6.1" do @plugin[:lsb][:id] = "OracleServer" @plugin[:lsb][:release] = "6.1" - File.stub!(:exists?).with("/etc/redhat-release").and_return(true) - File.stub!(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)") + File.stub(:exists?).with("/etc/redhat-release").and_return(true) + File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)") File.should_receive(:exists?).with("/etc/oracle-release").and_return(true) File.should_receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1") @plugin.run @@ -316,8 +316,8 @@ describe Ohai::System, "Linux plugin platform" do end it "should read the platform as oracle and version as 5" do - File.stub!(:exists?).with("/etc/redhat-release").and_return(true) - File.stub!(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)") + File.stub(:exists?).with("/etc/redhat-release").and_return(true) + File.stub(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)") File.should_receive(:exists?).with("/etc/enterprise-release").and_return(true) File.should_receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)") @plugin.run @@ -326,8 +326,8 @@ describe Ohai::System, "Linux plugin platform" do end it "should read the platform as oracle and version as 5.1" do - File.stub!(:exists?).with("/etc/redhat-release").and_return(true) - File.stub!(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)") + File.stub(:exists?).with("/etc/redhat-release").and_return(true) + File.stub(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)") File.should_receive(:exists?).with("/etc/enterprise-release").and_return(true) File.should_receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)") @plugin.run @@ -336,8 +336,8 @@ describe Ohai::System, "Linux plugin platform" do end it "should read the platform as oracle and version as 5.7" do - File.stub!(:exists?).with("/etc/redhat-release").and_return(true) - File.stub!(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)") + File.stub(:exists?).with("/etc/redhat-release").and_return(true) + File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)") File.should_receive(:exists?).with("/etc/enterprise-release").and_return(true) File.should_receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)") @plugin.run @@ -346,8 +346,8 @@ describe Ohai::System, "Linux plugin platform" do end it "should read the platform as oracle and version as 6.0" do - File.stub!(:exists?).with("/etc/redhat-release").and_return(true) - File.stub!(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.0 (Santiago)") + File.stub(:exists?).with("/etc/redhat-release").and_return(true) + File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.0 (Santiago)") File.should_receive(:exists?).with("/etc/oracle-release").and_return(true) File.should_receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.0") @plugin.run @@ -356,8 +356,8 @@ describe Ohai::System, "Linux plugin platform" do end it "should read the platform as oracle and version as 6.1" do - File.stub!(:exists?).with("/etc/redhat-release").and_return(true) - File.stub!(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)") + File.stub(:exists?).with("/etc/redhat-release").and_return(true) + File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)") File.should_receive(:exists?).with("/etc/oracle-release").and_return(true) File.should_receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1") @plugin.run diff --git a/spec/unit/plugins/linux/uptime_spec.rb b/spec/unit/plugins/linux/uptime_spec.rb index 764dc1b8..ec998827 100644 --- a/spec/unit/plugins/linux/uptime_spec.rb +++ b/spec/unit/plugins/linux/uptime_spec.rb @@ -26,8 +26,8 @@ describe Ohai::System, "Linux plugin uptime" do @plugin[:os] = "linux" @plugin.require_plugin("uptime") @mock_file = mock("/proc/uptime", { :gets => "18423 989" }) - File.stub!(:open).with("/proc/uptime").and_return(@mock_file) - @plugin.stub!(:require_plugin).and_return(true) + File.stub(:open).with("/proc/uptime").and_return(@mock_file) + @plugin.stub(:require_plugin).and_return(true) end it "should set uptime_seconds to uptime" do diff --git a/spec/unit/plugins/linux/virtualization_spec.rb b/spec/unit/plugins/linux/virtualization_spec.rb index 62ec73bf..503cef69 100644 --- a/spec/unit/plugins/linux/virtualization_spec.rb +++ b/spec/unit/plugins/linux/virtualization_spec.rb @@ -23,18 +23,18 @@ describe Ohai::System, "Linux virtualization platform" do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("linux/virtualization.rb", PLUGIN_PATH)) @plugin[:os] = "linux" - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin.extend(SimpleFromFile) # default to all requested Files not existing - File.stub!(:exists?).with("/proc/xen").and_return(false) - File.stub!(:exists?).with("/proc/xen/capabilities").and_return(false) - File.stub!(:exists?).with("/proc/modules").and_return(false) - File.stub!(:exists?).with("/proc/cpuinfo").and_return(false) - File.stub!(:exists?).with("/usr/sbin/dmidecode").and_return(false) - File.stub!(:exists?).with("/proc/self/status").and_return(false) - File.stub!(:exists?).with("/proc/bc/0").and_return(false) - File.stub!(:exists?).with("/proc/vz").and_return(false) + File.stub(:exists?).with("/proc/xen").and_return(false) + File.stub(:exists?).with("/proc/xen/capabilities").and_return(false) + File.stub(:exists?).with("/proc/modules").and_return(false) + File.stub(:exists?).with("/proc/cpuinfo").and_return(false) + File.stub(:exists?).with("/usr/sbin/dmidecode").and_return(false) + File.stub(:exists?).with("/proc/self/status").and_return(false) + File.stub(:exists?).with("/proc/bc/0").and_return(false) + File.stub(:exists?).with("/proc/vz").and_return(false) end describe "when we are checking for xen" do @@ -49,7 +49,7 @@ describe Ohai::System, "Linux virtualization platform" do it "should set xen host if /proc/xen/capabilities contains control_d " do File.should_receive(:exists?).with("/proc/xen").and_return(true) File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(true) - File.stub!(:read).with("/proc/xen/capabilities").and_return("control_d") + File.stub(:read).with("/proc/xen/capabilities").and_return("control_d") @plugin.run @plugin[:virtualization][:system].should == "xen" @plugin[:virtualization][:role].should == "host" @@ -58,7 +58,7 @@ describe Ohai::System, "Linux virtualization platform" do it "should set xen guest if /proc/xen/capabilities exists but is empty" do File.should_receive(:exists?).with("/proc/xen").and_return(true) File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(true) - File.stub!(:read).with("/proc/xen/capabilities").and_return("") + File.stub(:read).with("/proc/xen/capabilities").and_return("") @plugin.run @plugin[:virtualization][:system].should == "xen" @plugin[:virtualization][:role].should == "guest" @@ -74,7 +74,7 @@ describe Ohai::System, "Linux virtualization platform" do describe "when we are checking for kvm" do it "should set kvm host if /proc/modules contains kvm" do File.should_receive(:exists?).with("/proc/modules").and_return(true) - File.stub!(:read).with("/proc/modules").and_return("kvm 165872 1 kvm_intel") + File.stub(:read).with("/proc/modules").and_return("kvm 165872 1 kvm_intel") @plugin.run @plugin[:virtualization][:system].should == "kvm" @plugin[:virtualization][:role].should == "host" @@ -82,7 +82,7 @@ describe Ohai::System, "Linux virtualization platform" do it "should set kvm guest if /proc/cpuinfo contains QEMU Virtual CPU" do File.should_receive(:exists?).with("/proc/cpuinfo").and_return(true) - File.stub!(:read).with("/proc/cpuinfo").and_return("QEMU Virtual CPU") + File.stub(:read).with("/proc/cpuinfo").and_return("QEMU Virtual CPU") @plugin.run @plugin[:virtualization][:system].should == "kvm" @plugin[:virtualization][:role].should == "guest" @@ -98,7 +98,7 @@ describe Ohai::System, "Linux virtualization platform" do describe "when we are checking for VirtualBox" do it "should set vbox host if /proc/modules contains vboxdrv" do File.should_receive(:exists?).with("/proc/modules").and_return(true) - File.stub!(:read).with("/proc/modules").and_return("vboxdrv 268268 3 vboxnetadp,vboxnetflt") + File.stub(:read).with("/proc/modules").and_return("vboxdrv 268268 3 vboxnetadp,vboxnetflt") @plugin.run @plugin[:virtualization][:system].should == "vbox" @plugin[:virtualization][:role].should == "host" @@ -106,7 +106,7 @@ describe Ohai::System, "Linux virtualization platform" do it "should set vbox guest if /proc/modules contains vboxguest" do File.should_receive(:exists?).with("/proc/modules").and_return(true) - File.stub!(:read).with("/proc/modules").and_return("vboxguest 177749 2 vboxsf") + File.stub(:read).with("/proc/modules").and_return("vboxguest 177749 2 vboxsf") @plugin.run @plugin[:virtualization][:system].should == "vbox" @plugin[:virtualization][:role].should == "guest" @@ -144,9 +144,9 @@ System Information UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9 Wake-up Type: Power Switch MSVPC - @stdout.stub!(:read).and_return(ms_vpc_dmidecode) + @stdout.stub(:read).and_return(ms_vpc_dmidecode) - @plugin.stub!(:popen4).with("dmidecode").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("dmidecode").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:virtualization][:system].should == "virtualpc" @plugin[:virtualization][:role].should == "guest" @@ -164,8 +164,8 @@ System Information SKU Number: Not Specified Family: Not Specified VMWARE - @stdout.stub!(:read).and_return(vmware_dmidecode) - @plugin.stub!(:popen4).with("dmidecode").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @stdout.stub(:read).and_return(vmware_dmidecode) + @plugin.stub(:popen4).with("dmidecode").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:virtualization][:system].should == "vmware" @plugin[:virtualization][:role].should == "guest" @@ -181,7 +181,7 @@ VMWARE describe "when we are checking for Linux-VServer" do it "should set Linux-VServer host if /proc/self/status contains s_context: 0" do File.should_receive(:exists?).with("/proc/self/status").and_return(true) - File.stub!(:read).with("/proc/self/status").and_return("s_context: 0") + File.stub(:read).with("/proc/self/status").and_return("s_context: 0") @plugin.run @plugin[:virtualization][:system].should == "linux-vserver" @plugin[:virtualization][:role].should == "host" @@ -189,7 +189,7 @@ VMWARE it "should set Linux-VServer host if /proc/self/status contains VxID: 0" do File.should_receive(:exists?).with("/proc/self/status").and_return(true) - File.stub!(:read).with("/proc/self/status").and_return("VxID: 0") + File.stub(:read).with("/proc/self/status").and_return("VxID: 0") @plugin.run @plugin[:virtualization][:system].should == "linux-vserver" @plugin[:virtualization][:role].should == "host" @@ -197,7 +197,7 @@ VMWARE it "should set Linux-VServer guest if /proc/self/status contains s_context > 0" do File.should_receive(:exists?).with("/proc/self/status").and_return(true) - File.stub!(:read).with("/proc/self/status").and_return("s_context: 2") + File.stub(:read).with("/proc/self/status").and_return("s_context: 2") @plugin.run @plugin[:virtualization][:system].should == "linux-vserver" @plugin[:virtualization][:role].should == "guest" @@ -205,7 +205,7 @@ VMWARE it "should set Linux-VServer guest if /proc/self/status contains VxID > 0" do File.should_receive(:exists?).with("/proc/self/status").and_return(true) - File.stub!(:read).with("/proc/self/status").and_return("VxID: 2") + File.stub(:read).with("/proc/self/status").and_return("VxID: 2") @plugin.run @plugin[:virtualization][:system].should == "linux-vserver" @plugin[:virtualization][:role].should == "guest" diff --git a/spec/unit/plugins/lua_spec.rb b/spec/unit/plugins/lua_spec.rb index 008f70bb..3883aabf 100644 --- a/spec/unit/plugins/lua_spec.rb +++ b/spec/unit/plugins/lua_spec.rb @@ -25,11 +25,11 @@ describe Ohai::System, "plugin lua" do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "lua.rb")) @plugin[:languages] = Mash.new - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @status = 0 @stdout = "" @stderr = "Lua 5.1.2 Copyright (C) 1994-2008 Lua.org, PUC-Rio\n" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"lua -v"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"lua -v"}).and_return([@status, @stdout, @stderr]) end it "should get the lua version from running lua -v" do @@ -46,7 +46,7 @@ describe Ohai::System, "plugin lua" do @status = 1 @stdout = "" @stderr = "Lua 5.1.2 Copyright (C) 1994-2008 Lua.org, PUC-Rio\n" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"lua -v"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"lua -v"}).and_return([@status, @stdout, @stderr]) @plugin.run @plugin.languages.should_not have_key(:lua) end diff --git a/spec/unit/plugins/mono_spec.rb b/spec/unit/plugins/mono_spec.rb index ca4c515e..a7543aec 100644 --- a/spec/unit/plugins/mono_spec.rb +++ b/spec/unit/plugins/mono_spec.rb @@ -25,11 +25,11 @@ describe Ohai::System, "plugin mono" do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "mono.rb")) @plugin[:languages] = Mash.new - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @status = 0 @stdout = "Mono JIT compiler version 1.2.6 (tarball)\nCopyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com\n" @stderr = "" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"mono -V"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"mono -V"}).and_return([@status, @stdout, @stderr]) end it "should get the mono version from running mono -V" do @@ -46,7 +46,7 @@ describe Ohai::System, "plugin mono" do @status = 1 @stdout = "Mono JIT compiler version 1.2.6 (tarball)\nCopyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com\n" @stderr = "" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"mono -V"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"mono -V"}).and_return([@status, @stdout, @stderr]) @plugin.run @plugin.languages.should_not have_key(:mono) end diff --git a/spec/unit/plugins/netbsd/hostname_spec.rb b/spec/unit/plugins/netbsd/hostname_spec.rb index 9cb0c7f5..caaf864b 100644 --- a/spec/unit/plugins/netbsd/hostname_spec.rb +++ b/spec/unit/plugins/netbsd/hostname_spec.rb @@ -23,10 +23,10 @@ describe Ohai::System, "NetBSD hostname plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("netbsd/hostname.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:os] = "netbsd" - @plugin.stub!(:from).with("hostname -s").and_return("katie") - @plugin.stub!(:from).with("hostname").and_return("katie.bethell") + @plugin.stub(:from).with("hostname -s").and_return("katie") + @plugin.stub(:from).with("hostname").and_return("katie.bethell") end it_should_check_from("netbsd::hostname", "hostname", "hostname -s", "katie") diff --git a/spec/unit/plugins/netbsd/kernel_spec.rb b/spec/unit/plugins/netbsd/kernel_spec.rb index 0169c340..8ec33dc3 100644 --- a/spec/unit/plugins/netbsd/kernel_spec.rb +++ b/spec/unit/plugins/netbsd/kernel_spec.rb @@ -23,9 +23,9 @@ describe Ohai::System, "NetBSD kernel plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("netbsd/kernel.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) - @plugin.stub!(:from).with("uname -i").and_return("foo") - @plugin.stub!(:from_with_regex).with("sysctl kern.securelevel", /kern.securelevel=(.+)$/).and_return("kern.securelevel: 1") + @plugin.stub(:require_plugin).and_return(true) + @plugin.stub(:from).with("uname -i").and_return("foo") + @plugin.stub(:from_with_regex).with("sysctl kern.securelevel", /kern.securelevel=(.+)$/).and_return("kern.securelevel: 1") @plugin.should_receive(:popen4).with("/usr/bin/modstat").and_yield(1, StringIO.new, StringIO.new, StringIO.new) @plugin[:kernel] = Mash.new @plugin[:kernel][:name] = "netbsd" diff --git a/spec/unit/plugins/netbsd/platform_spec.rb b/spec/unit/plugins/netbsd/platform_spec.rb index 13edd0ef..cf14cfb9 100644 --- a/spec/unit/plugins/netbsd/platform_spec.rb +++ b/spec/unit/plugins/netbsd/platform_spec.rb @@ -23,9 +23,9 @@ describe Ohai::System, "NetBSD plugin platform" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("netbsd/platform.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) - @plugin.stub!(:from).with("uname -s").and_return("NetBSD") - @plugin.stub!(:from).with("uname -r").and_return("4.5") + @plugin.stub(:require_plugin).and_return(true) + @plugin.stub(:from).with("uname -s").and_return("NetBSD") + @plugin.stub(:from).with("uname -r").and_return("4.5") @plugin[:os] = "netbsd" end diff --git a/spec/unit/plugins/network_spec.rb b/spec/unit/plugins/network_spec.rb index ad184d86..250c18f6 100644 --- a/spec/unit/plugins/network_spec.rb +++ b/spec/unit/plugins/network_spec.rb @@ -151,7 +151,7 @@ describe Ohai::System, "Network Plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "network.rb")) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin["network"] = basic_data["linux"]["network"] end @@ -627,7 +627,7 @@ describe Ohai::System, "Network Plugin" do basic_data.keys.sort.each do |os| describe "the #{os}::network has already set some of the {ip,mac,ip6}address attributes" do before(:each) do - @plugin.stub!(:require_plugin).twice.and_return(true) + @plugin.stub(:require_plugin).twice.and_return(true) @plugin["network"] = basic_data[os]["network"] end diff --git a/spec/unit/plugins/nodejs_spec.rb b/spec/unit/plugins/nodejs_spec.rb index 10e7e87c..0159bdad 100644 --- a/spec/unit/plugins/nodejs_spec.rb +++ b/spec/unit/plugins/nodejs_spec.rb @@ -28,7 +28,7 @@ describe Ohai::System, "plugin nodejs" do @status = 0 @stdout = "v0.8.11\n" @stderr = "" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"node -v"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"node -v"}).and_return([@status, @stdout, @stderr]) end it "should get the nodejs version from running node -v" do @@ -45,7 +45,7 @@ describe Ohai::System, "plugin nodejs" do @status = 1 @stdout = "v0.8.11\n" @stderr = "" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"node -v"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"node -v"}).and_return([@status, @stdout, @stderr]) @plugin.run @plugin.languages.should_not have_key(:nodejs) end diff --git a/spec/unit/plugins/ohai_spec.rb b/spec/unit/plugins/ohai_spec.rb index 7f51821d..c5cbd995 100644 --- a/spec/unit/plugins/ohai_spec.rb +++ b/spec/unit/plugins/ohai_spec.rb @@ -24,7 +24,7 @@ describe Ohai::System, "plugin ohai" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "ohai.rb")) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) end it "should set [:chef_packages][:ohai][:version] to the current version" do diff --git a/spec/unit/plugins/ohai_time_spec.rb b/spec/unit/plugins/ohai_time_spec.rb index 044c5145..12a5d7b0 100644 --- a/spec/unit/plugins/ohai_time_spec.rb +++ b/spec/unit/plugins/ohai_time_spec.rb @@ -23,7 +23,7 @@ describe Ohai::System, "plugin ohai_time" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "ohai_time.rb")) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) end it "should get the current time" do @@ -34,13 +34,13 @@ describe Ohai::System, "plugin ohai_time" do it "should turn the time into a floating point number" do time = Time.now time.should_receive(:to_f) - Time.stub!(:now).and_return(time) + Time.stub(:now).and_return(time) @plugin.run end it "should set ohai_time to the current time" do time = Time.now - Time.stub!(:now).and_return(time) + Time.stub(:now).and_return(time) @plugin.run @plugin[:ohai_time].should == time.to_f end diff --git a/spec/unit/plugins/openbsd/hostname_spec.rb b/spec/unit/plugins/openbsd/hostname_spec.rb index 95cc1739..f50b04c2 100644 --- a/spec/unit/plugins/openbsd/hostname_spec.rb +++ b/spec/unit/plugins/openbsd/hostname_spec.rb @@ -23,10 +23,10 @@ describe Ohai::System, "OpenBSD hostname plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("openbsd/hostname.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:os] = "openbsd" - @plugin.stub!(:from).with("hostname -s").and_return("katie") - @plugin.stub!(:from).with("hostname").and_return("katie.bethell") + @plugin.stub(:from).with("hostname -s").and_return("katie") + @plugin.stub(:from).with("hostname").and_return("katie.bethell") end it_should_check_from("openbsd::hostname", "hostname", "hostname -s", "katie") diff --git a/spec/unit/plugins/openbsd/kernel_spec.rb b/spec/unit/plugins/openbsd/kernel_spec.rb index 1c09a1a6..afcf1406 100644 --- a/spec/unit/plugins/openbsd/kernel_spec.rb +++ b/spec/unit/plugins/openbsd/kernel_spec.rb @@ -23,9 +23,9 @@ describe Ohai::System, "OpenBSD kernel plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("openbsd/kernel.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) - @plugin.stub!(:from).with("uname -i").and_return("foo") - @plugin.stub!(:from_with_regex).with("sysctl kern.securelevel", /kern.securelevel=(.+)$/).and_return("kern.securelevel: 1") + @plugin.stub(:require_plugin).and_return(true) + @plugin.stub(:from).with("uname -i").and_return("foo") + @plugin.stub(:from_with_regex).with("sysctl kern.securelevel", /kern.securelevel=(.+)$/).and_return("kern.securelevel: 1") @plugin.should_receive(:popen4).with("/usr/bin/modstat").and_yield(1, StringIO.new, StringIO.new, StringIO.new) @plugin[:kernel] = Mash.new @plugin[:kernel][:name] = "openbsd" diff --git a/spec/unit/plugins/openbsd/platform_spec.rb b/spec/unit/plugins/openbsd/platform_spec.rb index b84876fc..7de37054 100644 --- a/spec/unit/plugins/openbsd/platform_spec.rb +++ b/spec/unit/plugins/openbsd/platform_spec.rb @@ -23,9 +23,9 @@ describe Ohai::System, "OpenBSD plugin platform" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("openbsd/platform.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) - @plugin.stub!(:from).with("uname -s").and_return("OpenBSD") - @plugin.stub!(:from).with("uname -r").and_return("4.5") + @plugin.stub(:require_plugin).and_return(true) + @plugin.stub(:from).with("uname -s").and_return("OpenBSD") + @plugin.stub(:from).with("uname -r").and_return("4.5") @plugin[:os] = "openbsd" end diff --git a/spec/unit/plugins/os_spec.rb b/spec/unit/plugins/os_spec.rb index 87c3d93f..5ed74ea7 100644 --- a/spec/unit/plugins/os_spec.rb +++ b/spec/unit/plugins/os_spec.rb @@ -25,7 +25,7 @@ describe Ohai::System, "plugin os" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "os.rb")) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:languages] = Mash.new @plugin[:languages][:ruby] = Mash.new @plugin[:kernel] = Mash.new diff --git a/spec/unit/plugins/passwd_spec.rb b/spec/unit/plugins/passwd_spec.rb index b3470ea1..51cc912b 100644 --- a/spec/unit/plugins/passwd_spec.rb +++ b/spec/unit/plugins/passwd_spec.rb @@ -4,7 +4,7 @@ describe Ohai::System, "plugin etc" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "passwd.rb")) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) end PasswdEntry = Struct.new(:name, :uid, :gid, :dir, :shell, :gecos) @@ -35,7 +35,7 @@ describe Ohai::System, "plugin etc" do it "sets the encoding of strings to the default external encoding" do fields = ["root", 1, 1, '/root', '/bin/zsh', 'BOFH'] fields.each {|f| f.force_encoding(Encoding::ASCII_8BIT) if f.respond_to?(:force_encoding) } - Etc.stub!(:passwd).and_yield(PasswdEntry.new(*fields)) + Etc.stub(:passwd).and_yield(PasswdEntry.new(*fields)) @plugin.run root = @plugin[:etc][:passwd]['root'] root['gecos'].encoding.should == Encoding.default_external diff --git a/spec/unit/plugins/perl_spec.rb b/spec/unit/plugins/perl_spec.rb index d5d48846..4c95ea93 100644 --- a/spec/unit/plugins/perl_spec.rb +++ b/spec/unit/plugins/perl_spec.rb @@ -23,7 +23,7 @@ describe Ohai::System, "plugin perl" do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "perl.rb")) @plugin[:languages] = Mash.new - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @pid = 2342 @stderr = StringIO.new @stdout = StringIO.new(<<-OUT) @@ -32,7 +32,7 @@ archname='darwin-thread-multi-2level'; OUT @stdin = StringIO.new @status = 0 - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"perl -V:version -V:archname"}).and_return([ + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"perl -V:version -V:archname"}).and_return([ @status, @stdout, @stderr @@ -61,7 +61,7 @@ OUT it "should set languages[:perl] if perl command succeeds" do @status = 0 - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"perl -V:version -V:archname"}).and_return([ + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"perl -V:version -V:archname"}).and_return([ @status, @stdout, @stderr @@ -72,7 +72,7 @@ OUT it "should not set languages[:perl] if perl command fails" do @status = 1 - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"perl -V:version -V:archname"}).and_return([ + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"perl -V:version -V:archname"}).and_return([ @status, @stdout, @stderr diff --git a/spec/unit/plugins/php_spec.rb b/spec/unit/plugins/php_spec.rb index d673214d..084fa496 100644 --- a/spec/unit/plugins/php_spec.rb +++ b/spec/unit/plugins/php_spec.rb @@ -24,11 +24,11 @@ describe Ohai::System, "plugin php" do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "php.rb")) @plugin[:languages] = Mash.new - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @status = 0 @stdout = "PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)\nCopyright (c) 1997-2006 The PHP Group\nZend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies\n" @stderr = "" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"php -v"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"php -v"}).and_return([@status, @stdout, @stderr]) end it "should get the php version from running php -V" do @@ -45,7 +45,7 @@ describe Ohai::System, "plugin php" do @status = 1 @stdout = "PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)\nCopyright (c) 1997-2006 The PHP Group\nZend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies\n" @stderr = "" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"php -v"}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"php -v"}).and_return([@status, @stdout, @stderr]) @plugin.run @plugin.languages.should_not have_key(:php) end diff --git a/spec/unit/plugins/platform_spec.rb b/spec/unit/plugins/platform_spec.rb index 69c029ae..e33b46a4 100644 --- a/spec/unit/plugins/platform_spec.rb +++ b/spec/unit/plugins/platform_spec.rb @@ -23,7 +23,7 @@ describe Ohai::System, "plugin platform" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "platform.rb")) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:os] = 'monkey' @plugin[:os_version] = 'poop' end diff --git a/spec/unit/plugins/python_spec.rb b/spec/unit/plugins/python_spec.rb index 6d6f69eb..45725ab8 100644 --- a/spec/unit/plugins/python_spec.rb +++ b/spec/unit/plugins/python_spec.rb @@ -25,11 +25,11 @@ describe Ohai::System, "plugin python" do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "python.rb")) @plugin[:languages] = Mash.new - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @status = 0 @stdout = "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n" @stderr = "" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"python -c \"import sys; print sys.version\""}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"python -c \"import sys; print sys.version\""}).and_return([@status, @stdout, @stderr]) end it "should get the python version from printing sys.version and sys.platform" do @@ -46,7 +46,7 @@ describe Ohai::System, "plugin python" do @status = 1 @stdout = "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n" @stderr = "" - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"python -c \"import sys; print sys.version\""}).and_return([@status, @stdout, @stderr]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"python -c \"import sys; print sys.version\""}).and_return([@status, @stdout, @stderr]) @plugin.run @plugin.languages.should_not have_key(:python) end diff --git a/spec/unit/plugins/rackspace_spec.rb b/spec/unit/plugins/rackspace_spec.rb index f868cf9c..e66820c1 100644 --- a/spec/unit/plugins/rackspace_spec.rb +++ b/spec/unit/plugins/rackspace_spec.rb @@ -21,7 +21,7 @@ describe Ohai::System, "plugin rackspace" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "rackspace.rb")) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:network] = {:interfaces => {:eth0 => {"addresses"=> { "1.2.3.4"=> { "broadcast"=> "67.23.20.255", @@ -121,10 +121,10 @@ OUT it_should_behave_like "rackspace" before(:each) do - File.stub!(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true) - File.stub!(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('') - File.stub!(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true) - File.stub!(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('') + File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true) + File.stub(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('') + File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true) + File.stub(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('') end end @@ -132,8 +132,8 @@ OUT it_should_behave_like "!rackspace" before(:each) do - File.stub!(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false) - File.stub!(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false) + File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false) + File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false) end end @@ -141,13 +141,13 @@ OUT it_should_behave_like "!rackspace" before(:each) do - File.stub!(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true) - File.stub!(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('') - File.stub!(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true) - File.stub!(:read).with('C:\chef\ohai\hints/ec2.json').and_return('') + File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true) + File.stub(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('') + File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true) + File.stub(:read).with('C:\chef\ohai\hints/ec2.json').and_return('') - File.stub!(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false) - File.stub!(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false) + File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false) + File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false) end end @@ -158,7 +158,7 @@ OUT stderr = StringIO.new stdout = "Rackspace\n" status = 0 - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"xenstore-read vm-data/provider_data/provider"}).and_return([ status, stdout, stderr ]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"xenstore-read vm-data/provider_data/provider"}).and_return([ status, stdout, stderr ]) end end @@ -169,7 +169,7 @@ OUT stderr = StringIO.new stdout = "cumulonimbus\n" status = 0 - @plugin.stub!(:run_command).with({:no_status_check=>true, :command=>"xenstore-read vm-data/provider_data/provider"}).and_return([ status, stdout, stderr ]) + @plugin.stub(:run_command).with({:no_status_check=>true, :command=>"xenstore-read vm-data/provider_data/provider"}).and_return([ status, stdout, stderr ]) end end end diff --git a/spec/unit/plugins/root_group_spec.rb b/spec/unit/plugins/root_group_spec.rb index 31043d09..7dc26a77 100644 --- a/spec/unit/plugins/root_group_spec.rb +++ b/spec/unit/plugins/root_group_spec.rb @@ -33,15 +33,15 @@ describe Ohai::System, 'root_group' do # apparently didn't apply to this api. we're just trying to fake # Etc.getgrgid(Etc.getpwnam('root').gid).name @pwnam = Object.new - @pwnam.stub!(:gid).and_return(0) - Etc.stub!(:getpwnam).with('root').and_return(@pwnam) + @pwnam.stub(:gid).and_return(0) + Etc.stub(:getpwnam).with('root').and_return(@pwnam) @grgid = Object.new - Etc.stub!(:getgrgid).and_return(@grgid) + Etc.stub(:getgrgid).and_return(@grgid) end describe 'with wheel group' do before(:each) do - @grgid.stub!(:name).and_return('wheel') + @grgid.stub(:name).and_return('wheel') end it 'should have a root_group of wheel' do @plugin.run @@ -51,7 +51,7 @@ describe Ohai::System, 'root_group' do describe 'with root group' do before(:each) do - @grgid.stub!(:name).and_return('root') + @grgid.stub(:name).and_return('root') end it 'should have a root_group of root' do @plugin.run @@ -61,8 +61,8 @@ describe Ohai::System, 'root_group' do describe 'platform hpux with sys group' do before(:each) do - @pwnam.stub!(:gid).and_return(3) - @grgid.stub!(:name).and_return('sys') + @pwnam.stub(:gid).and_return(3) + @grgid.stub(:name).and_return('sys') end it 'should have a root_group of sys' do @plugin.run @@ -71,7 +71,7 @@ describe Ohai::System, 'root_group' do end describe 'platform aix with system group' do before(:each) do - @grgid.stub!(:name).and_return('system') + @grgid.stub(:name).and_return('system') end it 'should have a root_group of system' do @plugin.run @@ -95,7 +95,7 @@ describe Ohai::System, 'root_group' do @group = Object.new WMI::Win32_Group. - stub!(:find). + stub(:find). with(:first, :conditions => {:SID => 'S-1-5-32-544'}). and_return(@group) end @@ -107,7 +107,7 @@ describe Ohai::System, 'root_group' do describe 'with administrator group' do before(:each) do @group. - stub!(:[]). + stub(:[]). with('Name'). and_return('Administrator') end @@ -120,7 +120,7 @@ describe Ohai::System, 'root_group' do describe 'with renamed administrator group' do before(:each) do @group. - stub!(:[]). + stub(:[]). with('Name'). and_return('BOFH') end diff --git a/spec/unit/plugins/solaris2/hostname_spec.rb b/spec/unit/plugins/solaris2/hostname_spec.rb index cc6c9572..c7082213 100644 --- a/spec/unit/plugins/solaris2/hostname_spec.rb +++ b/spec/unit/plugins/solaris2/hostname_spec.rb @@ -22,10 +22,10 @@ describe Ohai::System, "Solaris2.X hostname plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("solaris2/hostname.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:os] = "solaris2" - @plugin.stub!(:from).with("hostname").and_return("kitteh") - Socket.stub!(:getaddrinfo).and_return( [["AF_INET", 0, "kitteh.inurfridge.eatinurfoodz", "10.1.2.3", 2, 0, 0]] ); + @plugin.stub(:from).with("hostname").and_return("kitteh") + Socket.stub(:getaddrinfo).and_return( [["AF_INET", 0, "kitteh.inurfridge.eatinurfoodz", "10.1.2.3", 2, 0, 0]] ); end it_should_check_from("solaris2::hostname", "hostname", "hostname", "kitteh") diff --git a/spec/unit/plugins/solaris2/kernel_spec.rb b/spec/unit/plugins/solaris2/kernel_spec.rb index 052b97c7..18bd9b6c 100644 --- a/spec/unit/plugins/solaris2/kernel_spec.rb +++ b/spec/unit/plugins/solaris2/kernel_spec.rb @@ -136,12 +136,12 @@ describe Ohai::System, "Solaris2.X kernel plugin" do before(:each) do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("solaris2/kernel.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:kernel] = Mash.new @plugin.stub(:from).with("uname -s").and_return("SunOS") stdin = StringIO.new @modinfo_stdout = StringIO.new(MODINFO) - @plugin.stub!(:popen4).with("modinfo").and_yield(nil, stdin, @modinfo_stdout, nil) + @plugin.stub(:popen4).with("modinfo").and_yield(nil, stdin, @modinfo_stdout, nil) end it_should_check_from_deep_mash("solaris2::kernel", "kernel", "os", "uname -s", "SunOS") diff --git a/spec/unit/plugins/solaris2/network_spec.rb b/spec/unit/plugins/solaris2/network_spec.rb index 17457ad9..268be494 100644 --- a/spec/unit/plugins/solaris2/network_spec.rb +++ b/spec/unit/plugins/solaris2/network_spec.rb @@ -91,7 +91,7 @@ ROUTE_GET @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("solaris2/network.rb", PLUGIN_PATH)) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:network] = Mash.new @plugin.stub(:popen4).with("ifconfig -a") @@ -101,8 +101,8 @@ ROUTE_GET describe "gathering IP layer address info" do before do @stdout = mock("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get) - @plugin.stub!(:popen4).with("route -n get default").and_yield(nil,StringIO.new, @stdout, nil) - @plugin.stub!(:popen4).with("ifconfig -a").and_yield(nil, StringIO.new, @ifconfig_lines, nil) + @plugin.stub(:popen4).with("route -n get default").and_yield(nil,StringIO.new, @stdout, nil) + @plugin.stub(:popen4).with("ifconfig -a").and_yield(nil, StringIO.new, @ifconfig_lines, nil) @plugin.run end @@ -132,7 +132,7 @@ ROUTE_GET describe "setting the node's default IP address attribute" do before do @stdout = mock("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get) - @plugin.stub!(:popen4).with("route -n get default").and_yield(nil,StringIO.new, @stdout, nil) + @plugin.stub(:popen4).with("route -n get default").and_yield(nil,StringIO.new, @stdout, nil) @plugin.run end diff --git a/spec/unit/plugins/solaris2/platform_spec.rb b/spec/unit/plugins/solaris2/platform_spec.rb index 8c853efd..334b5ded 100644 --- a/spec/unit/plugins/solaris2/platform_spec.rb +++ b/spec/unit/plugins/solaris2/platform_spec.rb @@ -23,9 +23,9 @@ describe Ohai::System, "Solaris plugin platform" do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("solaris2/platform.rb", PLUGIN_PATH)) @plugin.extend(SimpleFromFile) - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin[:os] = "solaris2" - @plugin.stub!(:popen4).with("/sbin/uname -X") + @plugin.stub(:popen4).with("/sbin/uname -X") end describe "on SmartOS" do @@ -50,11 +50,11 @@ UNAME_X @uname_x_lines = uname_x.split("\n") - File.stub!(:exists?).with("/sbin/uname").and_return(true) + File.stub(:exists?).with("/sbin/uname").and_return(true) @plugin.stub(:popen4).with("/sbin/uname -X").and_yield(@pid, @stdin, @uname_x_lines, @stderr).and_return(@status) @release = StringIO.new(" SmartOS 20120130T201844Z x86_64\n") - File.stub!(:open).with("/etc/release").and_yield(@release) + File.stub(:open).with("/etc/release").and_yield(@release) end it "should run uname and set platform and build" do diff --git a/spec/unit/plugins/solaris2/virtualization_spec.rb b/spec/unit/plugins/solaris2/virtualization_spec.rb index 498f65d7..71f6a01e 100644 --- a/spec/unit/plugins/solaris2/virtualization_spec.rb +++ b/spec/unit/plugins/solaris2/virtualization_spec.rb @@ -23,13 +23,13 @@ describe Ohai::System, "Solaris virtualization platform" do @ohai = Ohai::System.new @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("solaris2/virtualization.rb", PLUGIN_PATH)) @plugin[:os] = "solaris2" - @plugin.stub!(:require_plugin).and_return(true) + @plugin.stub(:require_plugin).and_return(true) @plugin.extend(SimpleFromFile) # default to all requested Files not existing - File.stub!(:exists?).with("/usr/sbin/psrinfo").and_return(false) - File.stub!(:exists?).with("/usr/sbin/smbios").and_return(false) - File.stub!(:exists?).with("/usr/sbin/zoneadm").and_return(false) + File.stub(:exists?).with("/usr/sbin/psrinfo").and_return(false) + File.stub(:exists?).with("/usr/sbin/smbios").and_return(false) + File.stub(:exists?).with("/usr/sbin/zoneadm").and_return(false) end describe "when we are checking for kvm" do @@ -48,8 +48,8 @@ describe Ohai::System, "Solaris virtualization platform" do end it "Should set kvm guest if psrinfo -pv contains QEMU Virtual CPU" do - @stdout.stub!(:read).and_return("QEMU Virtual CPU") - @plugin.stub!(:popen4).with("/usr/sbin/psrinfo -pv").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @stdout.stub(:read).and_return("QEMU Virtual CPU") + @plugin.stub(:popen4).with("/usr/sbin/psrinfo -pv").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:virtualization][:system].should == "kvm" @plugin[:virtualization][:role].should == "guest" @@ -90,9 +90,9 @@ ID SIZE TYPE UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9 Wake-Up Event: 0x6 (power switch) MSVPC - @stdout.stub!(:read).and_return(ms_vpc_smbios) + @stdout.stub(:read).and_return(ms_vpc_smbios) - @plugin.stub!(:popen4).with("/usr/sbin/smbios").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @plugin.stub(:popen4).with("/usr/sbin/smbios").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:virtualization][:system].should == "virtualpc" @plugin[:virtualization][:role].should == "guest" @@ -111,8 +111,8 @@ ID SIZE TYPE UUID: a86cc405-e1b9-447b-ad05-6f8db39d876a Wake-Up Event: 0x6 (power switch) VMWARE - @stdout.stub!(:read).and_return(vmware_smbios) - @plugin.stub!(:popen4).with("/usr/sbin/smbios").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) + @stdout.stub(:read).and_return(vmware_smbios) + @plugin.stub(:popen4).with("/usr/sbin/smbios").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @plugin.run @plugin[:virtualization][:system].should == "vmware" @plugin[:virtualization][:role].should == "guest" diff --git a/spec/unit/system_spec.rb b/spec/unit/system_spec.rb index 3f2ecc26..b2fcd536 100644 --- a/spec/unit/system_spec.rb +++ b/spec/unit/system_spec.rb @@ -74,8 +74,8 @@ end describe Ohai::System, "all_plugins" do before(:each) do @ohai = Ohai::System.new - @ohai.stub!(:from_file).and_return(true) - @ohai.stub!(:require_plugin).and_return(false) + @ohai.stub(:from_file).and_return(true) + @ohai.stub(:require_plugin).and_return(false) @ohai.data[:os] = "ubuntu" end |