summaryrefslogtreecommitdiff
path: root/spec/unit/provider
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider')
-rw-r--r--spec/unit/provider/breakpoint_spec.rb10
-rw-r--r--spec/unit/provider/cookbook_file/content_spec.rb2
-rw-r--r--spec/unit/provider/cron/unix_spec.rb12
-rw-r--r--spec/unit/provider/cron_spec.rb72
-rw-r--r--spec/unit/provider/deploy/revision_spec.rb20
-rw-r--r--spec/unit/provider/deploy/timestamped_spec.rb4
-rw-r--r--spec/unit/provider/deploy_spec.rb92
-rw-r--r--spec/unit/provider/directory_spec.rb32
-rw-r--r--spec/unit/provider/env_spec.rb30
-rw-r--r--spec/unit/provider/erl_call_spec.rb2
-rw-r--r--spec/unit/provider/execute_spec.rb10
-rw-r--r--spec/unit/provider/file/content_spec.rb4
-rw-r--r--spec/unit/provider/git_spec.rb70
-rw-r--r--spec/unit/provider/group/dscl_spec.rb24
-rw-r--r--spec/unit/provider/group/gpasswd_spec.rb8
-rw-r--r--spec/unit/provider/group/groupadd_spec.rb20
-rw-r--r--spec/unit/provider/group/groupmod_spec.rb4
-rw-r--r--spec/unit/provider/group/pw_spec.rb14
-rw-r--r--spec/unit/provider/group/usermod_spec.rb22
-rw-r--r--spec/unit/provider/group/windows_spec.rb16
-rw-r--r--spec/unit/provider/group_spec.rb60
-rw-r--r--spec/unit/provider/http_request_spec.rb4
-rw-r--r--spec/unit/provider/ifconfig/aix_spec.rb14
-rw-r--r--spec/unit/provider/ifconfig/debian_spec.rb4
-rw-r--r--spec/unit/provider/ifconfig/redhat_spec.rb8
-rw-r--r--spec/unit/provider/ifconfig_spec.rb22
-rw-r--r--spec/unit/provider/link_spec.rb56
-rw-r--r--spec/unit/provider/mdadm_spec.rb8
-rw-r--r--spec/unit/provider/mount/aix_spec.rb10
-rw-r--r--spec/unit/provider/mount/mount_spec.rb88
-rw-r--r--spec/unit/provider/mount/windows_spec.rb32
-rw-r--r--spec/unit/provider/mount_spec.rb22
-rw-r--r--spec/unit/provider/ohai_spec.rb12
-rw-r--r--spec/unit/provider/package/aix_spec.rb20
-rw-r--r--spec/unit/provider/package/apt_spec.rb8
-rw-r--r--spec/unit/provider/package/dpkg_spec.rb20
-rw-r--r--spec/unit/provider/package/easy_install_spec.rb10
-rw-r--r--spec/unit/provider/package/freebsd_spec.rb46
-rw-r--r--spec/unit/provider/package/ips_spec.rb8
-rw-r--r--spec/unit/provider/package/macports_spec.rb10
-rw-r--r--spec/unit/provider/package/pacman_spec.rb30
-rw-r--r--spec/unit/provider/package/portage_spec.rb26
-rw-r--r--spec/unit/provider/package/rpm_spec.rb10
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb48
-rw-r--r--spec/unit/provider/package/smartos_spec.rb2
-rw-r--r--spec/unit/provider/package/solaris_spec.rb22
-rw-r--r--spec/unit/provider/package/yum_spec.rb128
-rw-r--r--spec/unit/provider/package/zypper_spec.rb14
-rw-r--r--spec/unit/provider/package_spec.rb42
-rw-r--r--spec/unit/provider/registry_key_spec.rb4
-rw-r--r--spec/unit/provider/remote_file/content_spec.rb32
-rw-r--r--spec/unit/provider/remote_file/ftp_spec.rb18
-rw-r--r--spec/unit/provider/remote_file/http_spec.rb4
-rw-r--r--spec/unit/provider/route_spec.rb46
-rw-r--r--spec/unit/provider/script_spec.rb10
-rw-r--r--spec/unit/provider/service/arch_service_spec.rb68
-rw-r--r--spec/unit/provider/service/debian_service_spec.rb34
-rw-r--r--spec/unit/provider/service/freebsd_service_spec.rb52
-rw-r--r--spec/unit/provider/service/gentoo_service_spec.rb30
-rw-r--r--spec/unit/provider/service/init_service_spec.rb22
-rw-r--r--spec/unit/provider/service/insserv_service_spec.rb6
-rw-r--r--spec/unit/provider/service/invokercd_service_spec.rb16
-rw-r--r--spec/unit/provider/service/macosx_spec.rb38
-rw-r--r--spec/unit/provider/service/redhat_spec.rb10
-rw-r--r--spec/unit/provider/service/simple_service_spec.rb14
-rw-r--r--spec/unit/provider/service/solaris_smf_service_spec.rb22
-rw-r--r--spec/unit/provider/service/systemd_service_spec.rb56
-rw-r--r--spec/unit/provider/service/upstart_service_spec.rb74
-rw-r--r--spec/unit/provider/service/windows_spec.rb36
-rw-r--r--spec/unit/provider/service_spec.rb18
-rw-r--r--spec/unit/provider/subversion_spec.rb58
-rw-r--r--spec/unit/provider/template/content_spec.rb10
-rw-r--r--spec/unit/provider/user/dscl_spec.rb16
-rw-r--r--spec/unit/provider/user/pw_spec.rb34
-rw-r--r--spec/unit/provider/user/solaris_spec.rb10
-rw-r--r--spec/unit/provider/user/windows_spec.rb14
-rw-r--r--spec/unit/provider/user_spec.rb52
77 files changed, 1028 insertions, 1028 deletions
diff --git a/spec/unit/provider/breakpoint_spec.rb b/spec/unit/provider/breakpoint_spec.rb
index 977624597a..ebdefd9bea 100644
--- a/spec/unit/provider/breakpoint_spec.rb
+++ b/spec/unit/provider/breakpoint_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Provider::Breakpoint do
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@collection = mock("resource collection")
- @run_context.stub!(:resource_collection).and_return(@collection)
+ @run_context.stub(:resource_collection).and_return(@collection)
@provider = Chef::Provider::Breakpoint.new(@resource, @run_context)
end
@@ -35,18 +35,18 @@ describe Chef::Provider::Breakpoint do
end
it "gets the iterator from @collection and pauses it" do
- Shell.stub!(:running?).and_return(true)
+ Shell.stub(:running?).and_return(true)
@iterator = mock("stepable_iterator")
- @collection.stub!(:iterator).and_return(@iterator)
+ @collection.stub(:iterator).and_return(@iterator)
@iterator.should_receive(:pause)
@provider.action_break
@resource.should be_updated
end
it "doesn't pause the iterator if chef-shell isn't running" do
- Shell.stub!(:running?).and_return(false)
+ Shell.stub(:running?).and_return(false)
@iterator = mock("stepable_iterator")
- @collection.stub!(:iterator).and_return(@iterator)
+ @collection.stub(:iterator).and_return(@iterator)
@iterator.should_not_receive(:pause)
@provider.action_break
end
diff --git a/spec/unit/provider/cookbook_file/content_spec.rb b/spec/unit/provider/cookbook_file/content_spec.rb
index b771b76aae..d2f1d3aef2 100644
--- a/spec/unit/provider/cookbook_file/content_spec.rb
+++ b/spec/unit/provider/cookbook_file/content_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Provider::CookbookFile::Content do
end
it "prefers the explicit cookbook name on the resource to the implicit one" do
- new_resource.stub!(:cookbook).and_return('nginx')
+ new_resource.stub(:cookbook).and_return('nginx')
content.send(:resource_cookbook).should == 'nginx'
end
diff --git a/spec/unit/provider/cron/unix_spec.rb b/spec/unit/provider/cron/unix_spec.rb
index ffdfa198b6..1683fad7a1 100644
--- a/spec/unit/provider/cron/unix_spec.rb
+++ b/spec/unit/provider/cron/unix_spec.rb
@@ -48,7 +48,7 @@ describe Chef::Provider::Cron::Unix do
# Another comment
CRONTAB
- @provider.stub!(:popen4).and_yield(1234, StringIO.new, @stdout, StringIO.new).and_return(@status)
+ @provider.stub(:popen4).and_yield(1234, StringIO.new, @stdout, StringIO.new).and_return(@status)
end
it "should call crontab -l with the user" do
@@ -70,13 +70,13 @@ CRONTAB
it "should return nil if the user has no crontab" do
status = mock("Status", :exitstatus => 1)
- @provider.stub!(:popen4).and_return(status)
+ @provider.stub(:popen4).and_return(status)
@provider.send(:read_crontab).should == nil
end
it "should raise an exception if another error occurs" do
status = mock("Status", :exitstatus => 2)
- @provider.stub!(:popen4).and_return(status)
+ @provider.stub(:popen4).and_return(status)
lambda do
@provider.send(:read_crontab)
end.should raise_error(Chef::Exceptions::Cron, "Error determining state of #{@new_resource.name}, exit: 2")
@@ -86,9 +86,9 @@ CRONTAB
describe "write_crontab" do
before :each do
@status = mock("Status", :exitstatus => 0)
- @provider.stub!(:run_command_and_return_stdout_stderr).and_return(@status, String.new, String.new)
+ @provider.stub(:run_command_and_return_stdout_stderr).and_return(@status, String.new, String.new)
@tempfile = mock("foo", :path => "/tmp/foo", :close => true)
- Tempfile.stub!(:new).and_return(@tempfile)
+ Tempfile.stub(:new).and_return(@tempfile)
@tempfile.should_receive(:flush)
@tempfile.should_receive(:chmod).with(420)
@tempfile.should_receive(:close!)
@@ -112,7 +112,7 @@ CRONTAB
it "should raise an exception if the command returns non-zero" do
@tempfile.should_receive(:<<).with("Foo")
- @status.stub!(:exitstatus).and_return(1)
+ @status.stub(:exitstatus).and_return(1)
lambda do
@provider.send(:write_crontab, "Foo")
end.should raise_error(Chef::Exceptions::Cron, /Error updating state of #{@new_resource.name}, exit: 1/)
diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb
index 35656e0ad6..ce5f0b7bf9 100644
--- a/spec/unit/provider/cron_spec.rb
+++ b/spec/unit/provider/cron_spec.rb
@@ -34,7 +34,7 @@ describe Chef::Provider::Cron do
describe "when examining the current system state" do
context "with no crontab for the user" do
before :each do
- @provider.stub!(:read_crontab).and_return(nil)
+ @provider.stub(:read_crontab).and_return(nil)
end
it "should set cron_empty" do
@@ -51,7 +51,7 @@ describe Chef::Provider::Cron do
context "with no matching entry in the user's crontab" do
before :each do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: something else
@@ -73,7 +73,7 @@ CRONTAB
end
it "should not fail if there's an existing cron with a numerical argument" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
# Chef Name: foo[bar] (baz)
21 */4 * * * some_prog 1234567
CRONTAB
@@ -85,7 +85,7 @@ CRONTAB
context "with a matching entry in the user's crontab" do
before :each do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -114,7 +114,7 @@ CRONTAB
end
it "should pull env vars out" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -142,7 +142,7 @@ CRONTAB
end
it "should parse and load generic and standard environment variables from cron entry" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
# Chef Name: cronhole some stuff
MAILTO=warn@example.com
TEST=lol
@@ -156,7 +156,7 @@ CRONTAB
end
it "should not break with variabels that match the cron resource internals" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
# Chef Name: cronhole some stuff
MINUTE=40
HOUR=midnight
@@ -179,7 +179,7 @@ CRONTAB
context "with a matching entry in the user's crontab using month names and weekday names (#CHEF-3178)" do
before :each do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -215,7 +215,7 @@ CRONTAB
context "with a matching entry without a crontab line" do
it "should set cron_exists and leave current_resource values at defaults" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -231,7 +231,7 @@ CRONTAB
end
it "should not pick up a commented out crontab line" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -248,7 +248,7 @@ CRONTAB
end
it "should not pick up a later crontab entry" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -304,8 +304,8 @@ CRONTAB
describe "action_create" do
before :each do
- @provider.stub!(:write_crontab)
- @provider.stub!(:read_crontab).and_return(nil)
+ @provider.stub(:write_crontab)
+ @provider.stub(:read_crontab).and_return(nil)
end
context "when there is no existing crontab" do
@@ -354,7 +354,7 @@ TEST=LOL
context "when there is a crontab with no matching section" do
before :each do
@provider.cron_exists = false
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: something else
@@ -416,8 +416,8 @@ TEST=LOL
context "when there is a crontab with a matching but different section" do
before :each do
@provider.cron_exists = true
- @provider.stub!(:cron_different?).and_return(true)
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:cron_different?).and_return(true)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -481,11 +481,11 @@ TEST=LOL
context "when there is a crontab with a matching section with no crontab line in it" do
before :each do
@provider.cron_exists = true
- @provider.stub!(:cron_different?).and_return(true)
+ @provider.stub(:cron_different?).and_return(true)
end
it "should add the crontab to the entry" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -500,7 +500,7 @@ TEST=LOL
end
it "should not blat any following entries" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -525,7 +525,7 @@ TEST=LOL
end
it "should handle env vars with no crontab" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -565,8 +565,8 @@ HOME=/home/foo
context "when there is a crontab with a matching and identical section" do
before :each do
@provider.cron_exists = true
- @provider.stub!(:cron_different?).and_return(false)
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:cron_different?).and_return(false)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -596,8 +596,8 @@ CRONTAB
describe "action_delete" do
before :each do
- @provider.stub!(:write_crontab)
- @provider.stub!(:read_crontab).and_return(nil)
+ @provider.stub(:write_crontab)
+ @provider.stub(:read_crontab).and_return(nil)
end
context "when the user's crontab has no matching section" do
@@ -620,7 +620,7 @@ CRONTAB
context "when the user has a crontab with a matching section" do
before :each do
@provider.cron_exists = true
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -645,7 +645,7 @@ CRONTAB
end
it "should remove any env vars with the entry" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -685,7 +685,7 @@ FOO=test
end
it "should remove the section" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -698,7 +698,7 @@ FOO=test
end
it "should not blat following sections" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -721,7 +721,7 @@ FOO=test
end
it "should remove any envvars with the section" do
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
0 2 * * * /some/other/command
# Chef Name: cronhole some stuff
@@ -757,7 +757,7 @@ MAILTO=foo@example.com
# Another comment
CRONTAB
- @provider.stub!(:popen4).and_yield(1234, StringIO.new, @stdout, StringIO.new).and_return(@status)
+ @provider.stub(:popen4).and_yield(1234, StringIO.new, @stdout, StringIO.new).and_return(@status)
end
it "should call crontab -l with the user" do
@@ -779,13 +779,13 @@ MAILTO=foo@example.com
it "should return nil if the user has no crontab" do
status = mock("Status", :exitstatus => 1)
- @provider.stub!(:popen4).and_return(status)
+ @provider.stub(:popen4).and_return(status)
@provider.send(:read_crontab).should == nil
end
it "should raise an exception if another error occurs" do
status = mock("Status", :exitstatus => 2)
- @provider.stub!(:popen4).and_return(status)
+ @provider.stub(:popen4).and_return(status)
lambda do
@provider.send(:read_crontab)
end.should raise_error(Chef::Exceptions::Cron, "Error determining state of #{@new_resource.name}, exit: 2")
@@ -796,7 +796,7 @@ MAILTO=foo@example.com
before :each do
@status = mock("Status", :exitstatus => 0)
@stdin = StringIO.new
- @provider.stub!(:popen4).and_yield(1234, @stdin, StringIO.new, StringIO.new).and_return(@status)
+ @provider.stub(:popen4).and_yield(1234, @stdin, StringIO.new, StringIO.new).and_return(@status)
end
it "should call crontab for the user" do
@@ -810,7 +810,7 @@ MAILTO=foo@example.com
end
it "should raise an exception if the command returns non-zero" do
- @status.stub!(:exitstatus).and_return(1)
+ @status.stub(:exitstatus).and_return(1)
lambda do
@provider.send(:write_crontab, "Foo")
end.should raise_error(Chef::Exceptions::Cron, "Error updating state of #{@new_resource.name}, exit: 1")
@@ -822,8 +822,8 @@ MAILTO=foo@example.com
raise Errno::EPIPE, "Test"
end
end
- @status.stub!(:exitstatus).and_return(1)
- @provider.stub!(:popen4).and_yield(1234, WriteErrPipe.new, StringIO.new, StringIO.new).and_return(@status)
+ @status.stub(:exitstatus).and_return(1)
+ @provider.stub(:popen4).and_yield(1234, WriteErrPipe.new, StringIO.new, StringIO.new).and_return(@status)
Chef::Log.should_receive(:debug).with("Broken pipe - Test")
diff --git a/spec/unit/provider/deploy/revision_spec.rb b/spec/unit/provider/deploy/revision_spec.rb
index e7be723d28..4f38f77762 100644
--- a/spec/unit/provider/deploy/revision_spec.rb
+++ b/spec/unit/provider/deploy/revision_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Provider::Deploy::Revision do
@provider = Chef::Provider::Deploy::Revision.new(@resource, @run_context)
@provider.load_current_resource
@runner = mock("runnah")
- Chef::Runner.stub!(:new).and_return(@runner)
+ Chef::Runner.stub(:new).and_return(@runner)
@expected_release_dir = "/my/deploy/dir/releases/8a3195bf3efa246f743c5dfa83683201880f935c"
end
@@ -43,7 +43,7 @@ describe Chef::Provider::Deploy::Revision do
it "uses the resolved revision from the SCM as the release slug" do
- @provider.scm_provider.stub!(:revision_slug).and_return("uglySlugly")
+ @provider.scm_provider.stub(:revision_slug).and_return("uglySlugly")
@provider.send(:release_slug).should == "uglySlugly"
end
@@ -52,10 +52,10 @@ describe Chef::Provider::Deploy::Revision do
end
it "stores the release dir in the file cache in the cleanup step" do
- FileUtils.stub!(:mkdir_p)
- FileUtils.stub!(:cp_r)
+ FileUtils.stub(:mkdir_p)
+ FileUtils.stub(:cp_r)
@provider.cleanup!
- @provider.stub!(:release_slug).and_return("73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2")
+ @provider.stub(:release_slug).and_return("73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2")
@provider.load_current_resource
@provider.cleanup!
second_release = "/my/deploy/dir/releases/73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2"
@@ -64,17 +64,17 @@ describe Chef::Provider::Deploy::Revision do
end
it "removes a release from the file cache when it's used again in another release and append it to the end" do
- FileUtils.stub!(:mkdir_p)
- FileUtils.stub!(:cp_r)
+ FileUtils.stub(:mkdir_p)
+ FileUtils.stub(:cp_r)
@provider.cleanup!
- @provider.stub!(:release_slug).and_return("73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2")
+ @provider.stub(:release_slug).and_return("73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2")
@provider.load_current_resource
@provider.cleanup!
second_release = "/my/deploy/dir/releases/73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2"
@provider.all_releases.should == [@expected_release_dir,second_release]
@provider.cleanup!
- @provider.stub!(:release_slug).and_return("8a3195bf3efa246f743c5dfa83683201880f935c")
+ @provider.stub(:release_slug).and_return("8a3195bf3efa246f743c5dfa83683201880f935c")
@provider.load_current_resource
@provider.cleanup!
@provider.all_releases.should == [second_release, @expected_release_dir]
@@ -89,7 +89,7 @@ describe Chef::Provider::Deploy::Revision do
end
@provider.all_releases.should == release_paths
- FileUtils.stub!(:rm_rf)
+ FileUtils.stub(:rm_rf)
@provider.cleanup!
expected_release_paths = (%w{second third fourth fifth} << @resource.revision).map do |release_name|
diff --git a/spec/unit/provider/deploy/timestamped_spec.rb b/spec/unit/provider/deploy/timestamped_spec.rb
index a9cea1142e..5e3d07d3d9 100644
--- a/spec/unit/provider/deploy/timestamped_spec.rb
+++ b/spec/unit/provider/deploy/timestamped_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Provider::Deploy::Timestamped do
before do
@release_time = Time.utc( 2004, 8, 15, 16, 23, 42)
- Time.stub!(:now).and_return(@release_time)
+ Time.stub(:now).and_return(@release_time)
@expected_release_dir = "/my/deploy/dir/releases/20040815162342"
@resource = Chef::Resource::Deploy.new("/my/deploy/dir")
@node = Chef::Node.new
@@ -30,7 +30,7 @@ describe Chef::Provider::Deploy::Timestamped do
@run_context = Chef::RunContext.new(@node, {}, @events)
@timestamped_deploy = Chef::Provider::Deploy::Timestamped.new(@resource, @run_context)
@runner = mock("runnah")
- Chef::Runner.stub!(:new).and_return(@runner)
+ Chef::Runner.stub(:new).and_return(@runner)
end
it "gives a timestamp for release_slug" do
diff --git a/spec/unit/provider/deploy_spec.rb b/spec/unit/provider/deploy_spec.rb
index d9b1619d72..cec971c31b 100644
--- a/spec/unit/provider/deploy_spec.rb
+++ b/spec/unit/provider/deploy_spec.rb
@@ -22,15 +22,15 @@ describe Chef::Provider::Deploy do
before do
@release_time = Time.utc( 2004, 8, 15, 16, 23, 42)
- Time.stub!(:now).and_return(@release_time)
+ Time.stub(:now).and_return(@release_time)
@expected_release_dir = "/my/deploy/dir/releases/20040815162342"
@resource = Chef::Resource::Deploy.new("/my/deploy/dir")
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@provider = Chef::Provider::Deploy.new(@resource, @run_context)
- @provider.stub!(:release_slug)
- @provider.stub!(:release_path).and_return(@expected_release_dir)
+ @provider.stub(:release_slug)
+ @provider.stub(:release_path).and_return(@expected_release_dir)
end
it "loads scm resource" do
@@ -61,7 +61,7 @@ describe Chef::Provider::Deploy do
before do
FileUtils.should_receive(:mkdir_p).with(@resource.deploy_to).ordered
FileUtils.should_receive(:mkdir_p).with(@resource.shared_path).ordered
- ::File.stub!(:directory?).and_return(false)
+ ::File.stub(:directory?).and_return(false)
@provider.stub(:symlink)
@provider.stub(:migrate)
@provider.stub(:copy_cached_repo)
@@ -77,7 +77,7 @@ describe Chef::Provider::Deploy do
end
it "does not create deploy_to dir if it exists" do
- ::File.stub!(:directory?).and_return(true)
+ ::File.stub(:directory?).and_return(true)
::Dir.should_receive(:chdir).with(@expected_release_dir).exactly(4).times
FileUtils.should_not_receive(:mkdir_p).with(@resource.deploy_to)
FileUtils.should_not_receive(:mkdir_p).with(@resource.shared_path)
@@ -122,22 +122,22 @@ describe Chef::Provider::Deploy do
end
it "should not deploy if there is already a deploy at release_path, and it is the current release" do
- @provider.stub!(:all_releases).and_return([@expected_release_dir])
- @provider.stub!(:current_release?).with(@expected_release_dir).and_return(true)
+ @provider.stub(:all_releases).and_return([@expected_release_dir])
+ @provider.stub(:current_release?).with(@expected_release_dir).and_return(true)
@provider.should_not_receive(:deploy)
@provider.run_action(:deploy)
end
it "should call action_rollback if there is already a deploy of this revision at release_path, and it is not the current release" do
- @provider.stub!(:all_releases).and_return([@expected_release_dir, "102021"])
- @provider.stub!(:current_release?).with(@expected_release_dir).and_return(false)
+ @provider.stub(:all_releases).and_return([@expected_release_dir, "102021"])
+ @provider.stub(:current_release?).with(@expected_release_dir).and_return(false)
@provider.should_receive(:rollback_to).with(@expected_release_dir)
@provider.should_receive(:current_release?)
@provider.run_action(:deploy)
end
it "calls deploy when deploying a new release" do
- @provider.stub!(:all_releases).and_return([])
+ @provider.stub(:all_releases).and_return([])
@provider.should_receive(:deploy)
@provider.run_action(:deploy)
end
@@ -149,22 +149,22 @@ describe Chef::Provider::Deploy do
end
it "Removes the old release before deploying when force deploying over it" do
- @provider.stub!(:all_releases).and_return([@expected_release_dir])
+ @provider.stub(:all_releases).and_return([@expected_release_dir])
FileUtils.should_receive(:rm_rf).with(@expected_release_dir)
@provider.should_receive(:deploy)
@provider.run_action(:force_deploy)
end
it "deploys as normal when force deploying and there's no prior release at the same path" do
- @provider.stub!(:all_releases).and_return([])
+ @provider.stub(:all_releases).and_return([])
@provider.should_receive(:deploy)
@provider.run_action(:force_deploy)
end
it "dont care by default if error happens on deploy" do
- @provider.stub!(:all_releases).and_return(['previous_release'])
- @provider.stub!(:deploy).and_return{ raise "Unexpected error" }
- @provider.stub!(:previous_release_path).and_return('previous_release')
+ @provider.stub(:all_releases).and_return(['previous_release'])
+ @provider.stub(:deploy).and_return{ raise "Unexpected error" }
+ @provider.stub(:previous_release_path).and_return('previous_release')
@provider.should_not_receive(:rollback)
lambda {
@provider.run_action(:deploy)
@@ -173,9 +173,9 @@ describe Chef::Provider::Deploy do
it "rollbacks to previous release if error happens on deploy" do
@resource.rollback_on_error true
- @provider.stub!(:all_releases).and_return(['previous_release'])
- @provider.stub!(:deploy).and_return{ raise "Unexpected error" }
- @provider.stub!(:previous_release_path).and_return('previous_release')
+ @provider.stub(:all_releases).and_return(['previous_release'])
+ @provider.stub(:deploy).and_return{ raise "Unexpected error" }
+ @provider.stub(:previous_release_path).and_return('previous_release')
@provider.should_receive(:rollback)
lambda {
@provider.run_action(:deploy)
@@ -184,9 +184,9 @@ describe Chef::Provider::Deploy do
describe "on systems without broken Dir.glob results" do
it "sets the release path to the penultimate release when one is not specified, symlinks, and rm's the last release on rollback" do
- @provider.stub!(:release_path).and_return("/my/deploy/dir/releases/3")
+ @provider.stub(:release_path).and_return("/my/deploy/dir/releases/3")
all_releases = ["/my/deploy/dir/releases/1", "/my/deploy/dir/releases/2", "/my/deploy/dir/releases/3", "/my/deploy/dir/releases/4", "/my/deploy/dir/releases/5"]
- Dir.stub!(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
+ Dir.stub(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
@provider.should_receive(:symlink)
FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/releases/4")
FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/releases/5")
@@ -195,10 +195,10 @@ describe Chef::Provider::Deploy do
end
it "sets the release path to the specified release, symlinks, and rm's any newer releases on rollback" do
- @provider.unstub!(:release_path)
+ @provider.unstub(:release_path)
all_releases = ["/my/deploy/dir/releases/20040815162342", "/my/deploy/dir/releases/20040700000000",
"/my/deploy/dir/releases/20040600000000", "/my/deploy/dir/releases/20040500000000"].sort!
- Dir.stub!(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
+ Dir.stub(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
@provider.should_receive(:symlink)
FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/releases/20040815162342")
@provider.run_action(:rollback)
@@ -206,12 +206,12 @@ describe Chef::Provider::Deploy do
end
it "sets the release path to the penultimate release, symlinks, and rm's the last release on rollback" do
- @provider.unstub!(:release_path)
+ @provider.unstub(:release_path)
all_releases = [ "/my/deploy/dir/releases/20040815162342",
"/my/deploy/dir/releases/20040700000000",
"/my/deploy/dir/releases/20040600000000",
"/my/deploy/dir/releases/20040500000000"]
- Dir.stub!(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
+ Dir.stub(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
@provider.should_receive(:symlink)
FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/releases/20040815162342")
@provider.run_action(:rollback)
@@ -221,9 +221,9 @@ describe Chef::Provider::Deploy do
describe "if there are no releases to fallback to" do
it "an exception is raised when there is only 1 release" do
- #@provider.unstub!(:release_path) -- unstub the release path on top to feed our own release path
+ #@provider.unstub(:release_path) -- unstub the release path on top to feed our own release path
all_releases = [ "/my/deploy/dir/releases/20040815162342"]
- Dir.stub!(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
+ Dir.stub(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
#@provider.should_receive(:symlink)
#FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/releases/20040815162342")
#@provider.run_action(:rollback)
@@ -235,7 +235,7 @@ describe Chef::Provider::Deploy do
it "an exception is raised when there are no releases" do
all_releases = []
- Dir.stub!(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
+ Dir.stub(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
lambda {
@provider.run_action(:rollback)
}.should raise_exception(RuntimeError, "There is no release to rollback to!")
@@ -245,12 +245,12 @@ describe Chef::Provider::Deploy do
describe "CHEF-628: on systems with broken Dir.glob results" do
it "sets the release path to the penultimate release, symlinks, and rm's the last release on rollback" do
- @provider.unstub!(:release_path)
+ @provider.unstub(:release_path)
all_releases = [ "/my/deploy/dir/releases/20040500000000",
"/my/deploy/dir/releases/20040600000000",
"/my/deploy/dir/releases/20040700000000",
"/my/deploy/dir/releases/20040815162342" ]
- Dir.stub!(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
+ Dir.stub(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
@provider.should_receive(:symlink)
FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/releases/20040815162342")
@provider.run_action(:rollback)
@@ -260,13 +260,13 @@ describe Chef::Provider::Deploy do
it "raises a runtime error when there's no release to rollback to" do
all_releases = []
- Dir.stub!(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
+ Dir.stub(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
lambda {@provider.run_action(:rollback)}.should raise_error(RuntimeError)
end
it "runs the new resource collection in the runner during a callback" do
@runner = mock("Runner")
- Chef::Runner.stub!(:new).and_return(@runner)
+ Chef::Runner.stub(:new).and_return(@runner)
@runner.should_receive(:converge)
callback_code = Proc.new { :noop }
@provider.callback(:whatevs, callback_code)
@@ -342,8 +342,8 @@ describe Chef::Provider::Deploy do
end
it "calls the internal callback :release_created when cleaning up the releases" do
- FileUtils.stub!(:mkdir_p)
- FileUtils.stub!(:cp_r)
+ FileUtils.stub(:mkdir_p)
+ FileUtils.stub(:cp_r)
@provider.should_receive(:release_created)
@provider.cleanup!
end
@@ -371,8 +371,8 @@ describe Chef::Provider::Deploy do
FileUtils.should_receive(:ln_sf).with("/my/deploy/dir/shared/config/database.yml", @expected_release_dir + "/config/database.yml")
@provider.should_receive(:enforce_ownership)
- STDOUT.stub!(:tty?).and_return(true)
- Chef::Log.stub!(:info?).and_return(true)
+ STDOUT.stub(:tty?).and_return(true)
+ Chef::Log.stub(:info?).and_return(true)
@provider.should_receive(:run_command).with(:command => "migration_foo", :cwd => @expected_release_dir,
:user => "deployNinja", :group => "deployNinjas",
:log_level => :info, :live_stream => STDOUT,
@@ -462,7 +462,7 @@ describe Chef::Provider::Deploy do
"/my/deploy/dir/20040600000000", "/my/deploy/dir/20040500000000",
"/my/deploy/dir/20040400000000", "/my/deploy/dir/20040300000000",
"/my/deploy/dir/20040200000000", "/my/deploy/dir/20040100000000"].sort!
- @provider.stub!(:all_releases).and_return(all_releases)
+ @provider.stub(:all_releases).and_return(all_releases)
FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/20040100000000")
FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/20040200000000")
FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/20040300000000")
@@ -475,7 +475,7 @@ describe Chef::Provider::Deploy do
"/my/deploy/dir/20040600000000", "/my/deploy/dir/20040500000000",
"/my/deploy/dir/20040400000000", "/my/deploy/dir/20040300000000",
"/my/deploy/dir/20040200000000", "/my/deploy/dir/20040100000000"].sort!
- @provider.stub!(:all_releases).and_return(all_releases)
+ @provider.stub(:all_releases).and_return(all_releases)
FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/20040100000000")
@provider.cleanup!
end
@@ -484,8 +484,8 @@ describe Chef::Provider::Deploy do
all_releases = ["/my/deploy/dir/20040815162342", "/my/deploy/dir/20040700000000",
"/my/deploy/dir/20040600000000", "/my/deploy/dir/20040500000000",
"/my/deploy/dir/20040400000000", "/my/deploy/dir/20040300000000"].sort!
- @provider.stub!(:all_releases).and_return(all_releases)
- FileUtils.stub!(:rm_rf)
+ @provider.stub(:all_releases).and_return(all_releases)
+ FileUtils.stub(:rm_rf)
@provider.should_receive(:release_deleted).with("/my/deploy/dir/20040300000000")
@provider.cleanup!
end
@@ -502,9 +502,9 @@ describe Chef::Provider::Deploy do
end
it "shouldn't give a no method error on migrate if the environment is nil" do
- @provider.stub!(:enforce_ownership)
- @provider.stub!(:run_symlinks_before_migrate)
- @provider.stub!(:run_command)
+ @provider.stub(:enforce_ownership)
+ @provider.stub(:run_symlinks_before_migrate)
+ @provider.stub(:run_command)
@provider.migrate
end
@@ -584,7 +584,7 @@ describe Chef::Provider::Deploy do
it "converts sudo and run to exec resources in hooks" do
runner = mock("tehRunner")
- Chef::Runner.stub!(:new).and_return(runner)
+ Chef::Runner.stub(:new).and_return(runner)
snitch = nil
@resource.user("tehCat")
@@ -607,7 +607,7 @@ describe Chef::Provider::Deploy do
describe "installing gems from a gems.yml" do
before do
- ::File.stub!(:exist?).with("#{@expected_release_dir}/gems.yml").and_return(true)
+ ::File.stub(:exist?).with("#{@expected_release_dir}/gems.yml").and_return(true)
@gem_list = [{:name=>"eventmachine", :version=>"0.12.9"}]
end
@@ -623,8 +623,8 @@ describe Chef::Provider::Deploy do
end
it "takes a list of gem providers converges them" do
- IO.stub!(:read)
- YAML.stub!(:load).and_return(@gem_list)
+ IO.stub(:read)
+ YAML.stub(:load).and_return(@gem_list)
expected_gem_resources = @provider.send(:gem_packages).map { |r| [r.name, r.version] }
gem_runner = @provider.send(:gem_resource_collection_runner)
# no one has heard of defining == to be meaningful so I have use this monstrosity
diff --git a/spec/unit/provider/directory_spec.rb b/spec/unit/provider/directory_spec.rb
index 61946d2664..62e9816340 100644
--- a/spec/unit/provider/directory_spec.rb
+++ b/spec/unit/provider/directory_spec.rb
@@ -48,18 +48,18 @@ describe Chef::Provider::Directory do
describe "scanning file security metadata on unix" do
before do
- Chef::Platform.stub!(:windows?).and_return(false)
+ Chef::Platform.stub(:windows?).and_return(false)
end
let(:mock_stat) do
cstats = mock("stats")
- cstats.stub!(:uid).and_return(500)
- cstats.stub!(:gid).and_return(500)
- cstats.stub!(:mode).and_return(0755)
+ cstats.stub(:uid).and_return(500)
+ cstats.stub(:gid).and_return(500)
+ cstats.stub(:mode).and_return(0755)
cstats
end
it "describes the access mode as a String of octal integers" do
- File.stub!(:exists?).and_return(true)
+ File.stub(:exists?).and_return(true)
File.should_receive(:stat).and_return(mock_stat)
@directory.load_current_resource
@directory.current_resource.mode.should == "0755"
@@ -67,7 +67,7 @@ describe Chef::Provider::Directory do
context "when user and group are specified with UID/GID" do
it "describes the current owner and group as UID and GID" do
- File.stub!(:exists?).and_return(true)
+ File.stub(:exists?).and_return(true)
File.should_receive(:stat).and_return(mock_stat)
@directory.load_current_resource
@directory.current_resource.path.should eql(@new_resource.path)
@@ -91,7 +91,7 @@ describe Chef::Provider::Directory do
Dir.should_receive(:mkdir).with(@new_resource.path).once.and_return(true)
@directory.should_receive(:do_acl_changes)
- @directory.stub!(:do_selinux)
+ @directory.stub(:do_selinux)
@directory.run_action(:create)
@directory.new_resource.should be_updated
end
@@ -117,7 +117,7 @@ describe Chef::Provider::Directory do
FileUtils.should_receive(:mkdir_p).with(@new_resource.path).and_return(true)
@directory.should_receive(:do_acl_changes)
- @directory.stub!(:do_selinux)
+ @directory.stub(:do_selinux)
@directory.run_action(:create)
@new_resource.should be_updated
end
@@ -152,14 +152,14 @@ describe Chef::Provider::Directory do
end
it "should raise an exception if it cannot delete the directory due to bad permissions" do
- File.stub!(:exists?).and_return(true)
- File.stub!(:writable?).and_return(false)
+ File.stub(:exists?).and_return(true)
+ File.stub(:writable?).and_return(false)
lambda { @directory.run_action(:delete) }.should raise_error(RuntimeError)
end
it "should take no action when deleting a target directory that does not exist" do
@new_resource.path "/an/invalid/path"
- File.stub!(:exists?).and_return(false)
+ File.stub(:exists?).and_return(false)
Dir.should_not_receive(:delete).with(@new_resource.path)
@directory.run_action(:delete)
@directory.new_resource.should_not be_updated
@@ -168,7 +168,7 @@ describe Chef::Provider::Directory do
it "should raise an exception when deleting a directory when target directory is a file" do
stub_file_cstats
@new_resource.path "/an/invalid/path"
- File.stub!(:exists?).and_return(true)
+ File.stub(:exists?).and_return(true)
File.should_receive(:directory?).and_return(false)
Dir.should_not_receive(:delete).with(@new_resource.path)
lambda { @directory.run_action(:delete) }.should raise_error(RuntimeError)
@@ -177,12 +177,12 @@ describe Chef::Provider::Directory do
def stub_file_cstats
cstats = mock("stats")
- cstats.stub!(:uid).and_return(500)
- cstats.stub!(:gid).and_return(500)
- cstats.stub!(:mode).and_return(0755)
+ cstats.stub(:uid).and_return(500)
+ cstats.stub(:gid).and_return(500)
+ cstats.stub(:mode).and_return(0755)
# File.stat is called in:
# - Chef::Provider::File.load_current_resource_attrs
# - Chef::ScanAccessControl via Chef::Provider::File.setup_acl
- File.stub!(:stat).and_return(cstats)
+ File.stub(:stat).and_return(cstats)
end
end
diff --git a/spec/unit/provider/env_spec.rb b/spec/unit/provider/env_spec.rb
index 673ba9798a..0bc5117e48 100644
--- a/spec/unit/provider/env_spec.rb
+++ b/spec/unit/provider/env_spec.rb
@@ -36,10 +36,10 @@ describe Chef::Provider::Env do
describe "when loading the current status" do
before do
#@current_resource = @new_resource.clone
- #Chef::Resource::Env.stub!(:new).and_return(@current_resource)
+ #Chef::Resource::Env.stub(:new).and_return(@current_resource)
@provider.current_resource = @current_resource
- @provider.stub!(:env_value).with("FOO").and_return("bar")
- @provider.stub!(:env_key_exists).and_return(true)
+ @provider.stub(:env_value).with("FOO").and_return("bar")
+ @provider.stub(:env_key_exists).and_return(true)
end
it "should create a current resource with the same name as the new resource" do
@@ -72,8 +72,8 @@ describe Chef::Provider::Env do
describe "action_create" do
before do
@provider.key_exists = false
- @provider.stub!(:create_env).and_return(true)
- @provider.stub!(:modify_env).and_return(true)
+ @provider.stub(:create_env).and_return(true)
+ @provider.stub(:modify_env).and_return(true)
end
it "should call create_env if the key does not exist" do
@@ -94,15 +94,15 @@ describe Chef::Provider::Env do
it "should call modify_env if the key exists and values are not equal" do
@provider.key_exists = true
- @provider.stub!(:compare_value).and_return(true)
+ @provider.stub(:compare_value).and_return(true)
@provider.should_receive(:modify_env).and_return(true)
@provider.action_create
end
it "should set the new_resources updated flag when it updates an existing value" do
@provider.key_exists = true
- @provider.stub!(:compare_value).and_return(true)
- @provider.stub!(:modify_env).and_return(true)
+ @provider.stub(:compare_value).and_return(true)
+ @provider.stub(:modify_env).and_return(true)
@provider.action_create
@new_resource.should be_updated
end
@@ -112,8 +112,8 @@ describe Chef::Provider::Env do
before(:each) do
@provider.current_resource = @current_resource
@provider.key_exists = false
- @provider.stub!(:delete_element).and_return(false)
- @provider.stub!(:delete_env).and_return(true)
+ @provider.stub(:delete_element).and_return(false)
+ @provider.stub(:delete_env).and_return(true)
end
it "should not call delete_env if the key does not exist" do
@@ -143,7 +143,7 @@ describe Chef::Provider::Env do
before(:each) do
@provider.current_resource = @current_resource
@provider.key_exists = true
- @provider.stub!(:modify_env).and_return(true)
+ @provider.stub(:modify_env).and_return(true)
end
it "should call modify_group if the key exists and values are not equal" do
@@ -153,8 +153,8 @@ describe Chef::Provider::Env do
end
it "should set the new resources updated flag to true if modify_env is called" do
- @provider.stub!(:compare_value).and_return(true)
- @provider.stub!(:modify_env).and_return(true)
+ @provider.stub(:compare_value).and_return(true)
+ @provider.stub(:modify_env).and_return(true)
@provider.action_modify
@new_resource.should be_updated
end
@@ -183,12 +183,12 @@ describe Chef::Provider::Env do
end
it "should return true if the element is not found" do
- @new_resource.stub!(:value).and_return("C:/baz/bin")
+ @new_resource.stub(:value).and_return("C:/baz/bin")
@provider.delete_element.should eql(true)
end
it "should return false if the delim not defined" do
- @new_resource.stub!(:delim).and_return(nil)
+ @new_resource.stub(:delim).and_return(nil)
@provider.delete_element.should eql(false)
end
diff --git a/spec/unit/provider/erl_call_spec.rb b/spec/unit/provider/erl_call_spec.rb
index fa85b6cda7..19e16f282f 100644
--- a/spec/unit/provider/erl_call_spec.rb
+++ b/spec/unit/provider/erl_call_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Provider::ErlCall do
@provider = Chef::Provider::ErlCall.new(@new_resource, @run_context)
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
@stdin = StringIO.new
@stdout = StringIO.new('{ok, woohoo}')
@stderr = StringIO.new
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb
index 0d108f521d..78216a89fa 100644
--- a/spec/unit/provider/execute_spec.rb
+++ b/spec/unit/provider/execute_spec.rb
@@ -33,12 +33,12 @@ describe Chef::Provider::Execute do
@provider.current_resource = @current_resource
Chef::Log.level = :info
# FIXME: There should be a test for how STDOUT.tty? changes the live_stream option being passed
- STDOUT.stub!(:tty?).and_return(true)
+ STDOUT.stub(:tty?).and_return(true)
end
it "should execute foo_resource" do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
opts = {}
opts[:timeout] = @new_resource.timeout
opts[:returns] = @new_resource.returns
@@ -53,7 +53,7 @@ describe Chef::Provider::Execute do
end
it "should do nothing if the sentinel file exists" do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
File.should_receive(:exists?).with(@new_resource.creates).and_return(true)
@provider.should_not_receive(:shell_out!)
Chef::Log.should_not_receive(:warn)
@@ -65,7 +65,7 @@ describe Chef::Provider::Execute do
it "should respect cwd options for 'creates'" do
@new_resource.cwd "/tmp"
@new_resource.creates "foo_resource"
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
File.should_receive(:exists?).with(@new_resource.creates).and_return(false)
File.should_receive(:exists?).with(File.join("/tmp", @new_resource.creates)).and_return(true)
Chef::Log.should_not_receive(:warn)
@@ -77,7 +77,7 @@ describe Chef::Provider::Execute do
it "should warn if user specified relative path without cwd" do
@new_resource.creates "foo_resource"
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
Chef::Log.should_receive(:warn).with(/relative path/)
File.should_receive(:exists?).with(@new_resource.creates).and_return(true)
@provider.should_not_receive(:shell_out!)
diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb
index 9262a35245..ca5a94afe3 100644
--- a/spec/unit/provider/file/content_spec.rb
+++ b/spec/unit/provider/file/content_spec.rb
@@ -53,7 +53,7 @@ describe Chef::Provider::File::Content do
describe "when the resource has a content attribute set" do
before do
- new_resource.stub!(:content).and_return("Do do do do, do do do do, do do do do, do do do do")
+ new_resource.stub(:content).and_return("Do do do do, do do do do, do do do do, do do do do")
end
it "returns a tempfile" do
@@ -81,7 +81,7 @@ describe Chef::Provider::File::Content do
describe "when the resource does not have a content attribute set" do
before do
- new_resource.stub!(:content).and_return(nil)
+ new_resource.stub(:content).and_return(nil)
end
it "should return nil instead of a tempfile" do
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb
index 4c54a17958..1f62ab1b03 100644
--- a/spec/unit/provider/git_spec.rb
+++ b/spec/unit/provider/git_spec.rb
@@ -21,7 +21,7 @@ require 'spec_helper'
describe Chef::Provider::Git do
before(:each) do
- STDOUT.stub!(:tty?).and_return(true)
+ STDOUT.stub(:tty?).and_return(true)
Chef::Log.level = :info
@current_resource = Chef::Resource::Git.new("web2.0 app")
@@ -68,7 +68,7 @@ describe Chef::Provider::Git do
end
it "creates a current_resource with the currently deployed revision when a clone exists in the destination dir" do
- @provider.stub!(:find_current_revision).and_return("681c9802d1c62a45b490786c18f0b8216b309440")
+ @provider.stub(:find_current_revision).and_return("681c9802d1c62a45b490786c18f0b8216b309440")
@provider.load_current_resource
@provider.current_resource.name.should eql(@resource.name)
@provider.current_resource.revision.should eql("681c9802d1c62a45b490786c18f0b8216b309440")
@@ -110,7 +110,7 @@ describe Chef::Provider::Git do
@resource.revision "origin/"
@provider.action = :checkout
@provider.define_resource_requirements
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
lambda {@provider.process_resource_requirements}.should raise_error(Chef::Exceptions::InvalidRemoteGitReference)
end
@@ -133,7 +133,7 @@ describe Chef::Provider::Git do
@stdout = "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n"
@provider.should_receive(:shell_out!).with(@git_ls_remote + "0.8-alpha*", {:log_tag=>"git[web2.0 app]"}).and_return(mock("ShellOut result", :stdout => @stdout))
@provider.action = :checkout
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
@provider.define_resource_requirements
lambda { @provider.process_resource_requirements }.should_not raise_error(RuntimeError)
end
@@ -179,7 +179,7 @@ SHAS
before do
@resource.user deploy_user
@resource.ssh_wrapper wrapper
- Etc.stub!(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja"))
+ Etc.stub(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja"))
end
context "without a timeout set" do
it "clones a repo with default git options" do
@@ -199,7 +199,7 @@ SHAS
it "runs a clone command with escaped destination" do
@resource.user "deployNinja"
- Etc.stub!(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja"))
+ Etc.stub(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja"))
@resource.destination "/Application Support/with/space"
@resource.ssh_wrapper "do_it_this_way.sh"
expected_cmd = "git clone \"git://github.com/opscode/chef.git\" \"/Application Support/with/space\""
@@ -255,7 +255,7 @@ SHAS
it "runs a sync command with the user and group specified in the resource" do
@resource.user("whois")
- Etc.stub!(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois"))
+ Etc.stub(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois"))
@resource.group("thisis")
@provider.should_receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository)
expected_cmd = "git fetch origin && git fetch origin --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
@@ -302,7 +302,7 @@ SHAS
it "runs the config with the user and group specified in the resource" do
@resource.user("whois")
@resource.group("thisis")
- Etc.stub!(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois"))
+ Etc.stub(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois"))
command_response = double('shell_out')
command_response.stub(:exitstatus) { 1 }
expected_command = "git config --get remote.#{@resource.remote}.url"
@@ -391,17 +391,17 @@ SHAS
end
it "raises an error if the git clone command would fail because the enclosing directory doesn't exist" do
- @provider.stub!(:shell_out!)
+ @provider.stub(:shell_out!)
lambda {@provider.run_action(:sync)}.should raise_error(Chef::Exceptions::MissingParentDirectory)
end
it "does a checkout by cloning the repo and then enabling submodules" do
# will be invoked in load_current_resource
- ::File.stub!(:exist?).with("/my/deploy/dir/.git").and_return(false)
+ ::File.stub(:exist?).with("/my/deploy/dir/.git").and_return(false)
- ::File.stub!(:exist?).with("/my/deploy/dir").and_return(true)
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
- ::Dir.stub!(:entries).with("/my/deploy/dir").and_return(['.','..'])
+ ::File.stub(:exist?).with("/my/deploy/dir").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
+ ::Dir.stub(:entries).with("/my/deploy/dir").and_return(['.','..'])
@provider.should_receive(:clone)
@provider.should_receive(:checkout)
@provider.should_receive(:enable_submodules)
@@ -413,11 +413,11 @@ SHAS
it "does not call checkout if enable_checkout is false" do
# will be invoked in load_current_resource
- ::File.stub!(:exist?).with("/my/deploy/dir/.git").and_return(false)
+ ::File.stub(:exist?).with("/my/deploy/dir/.git").and_return(false)
- ::File.stub!(:exist?).with("/my/deploy/dir").and_return(true)
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
- ::Dir.stub!(:entries).with("/my/deploy/dir").and_return(['.','..'])
+ ::File.stub(:exist?).with("/my/deploy/dir").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
+ ::Dir.stub(:entries).with("/my/deploy/dir").and_return(['.','..'])
@resource.enable_checkout false
@provider.should_receive(:clone)
@@ -429,10 +429,10 @@ SHAS
# REGRESSION TEST: on some OSes, the entries from an empty directory will be listed as
# ['..', '.'] but this shouldn't change the behavior
it "does a checkout by cloning the repo and then enabling submodules when the directory entries are listed as %w{.. .}" do
- ::File.stub!(:exist?).with("/my/deploy/dir/.git").and_return(false)
- ::File.stub!(:exist?).with("/my/deploy/dir").and_return(false)
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
- ::Dir.stub!(:entries).with("/my/deploy/dir").and_return(['..','.'])
+ ::File.stub(:exist?).with("/my/deploy/dir/.git").and_return(false)
+ ::File.stub(:exist?).with("/my/deploy/dir").and_return(false)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
+ ::Dir.stub(:entries).with("/my/deploy/dir").and_return(['..','.'])
@provider.should_receive(:clone)
@provider.should_receive(:checkout)
@provider.should_receive(:enable_submodules)
@@ -443,11 +443,11 @@ SHAS
it "should not checkout if the destination exists or is a non empty directory" do
# will be invoked in load_current_resource
- ::File.stub!(:exist?).with("/my/deploy/dir/.git").and_return(false)
+ ::File.stub(:exist?).with("/my/deploy/dir/.git").and_return(false)
- ::File.stub!(:exist?).with("/my/deploy/dir").and_return(true)
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
- ::Dir.stub!(:entries).with("/my/deploy/dir").and_return(['.','..','foo','bar'])
+ ::File.stub(:exist?).with("/my/deploy/dir").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
+ ::Dir.stub(:entries).with("/my/deploy/dir").and_return(['.','..','foo','bar'])
@provider.should_not_receive(:clone)
@provider.should_not_receive(:checkout)
@provider.should_not_receive(:enable_submodules)
@@ -458,7 +458,7 @@ SHAS
it "syncs the code by updating the source when the repo has already been checked out" do
::File.should_receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
@provider.should_receive(:find_current_revision).exactly(2).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
@provider.should_not_receive(:fetch_updates)
@provider.should_receive(:add_remotes)
@@ -468,10 +468,10 @@ SHAS
it "marks the resource as updated when the repo is updated and gets a new version" do
::File.should_receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
# invoked twice - first time from load_current_resource
@provider.should_receive(:find_current_revision).exactly(2).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
- @provider.stub!(:target_revision).and_return('28af684d8460ba4793eda3e7ac238c864a5d029a')
+ @provider.stub(:target_revision).and_return('28af684d8460ba4793eda3e7ac238c864a5d029a')
@provider.should_receive(:fetch_updates)
@provider.should_receive(:enable_submodules)
@provider.should_receive(:add_remotes)
@@ -481,9 +481,9 @@ SHAS
it "does not fetch any updates if the remote revision matches the current revision" do
::File.should_receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
- @provider.stub!(:find_current_revision).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
- @provider.stub!(:target_revision).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
+ @provider.stub(:find_current_revision).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
+ @provider.stub(:target_revision).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
@provider.should_not_receive(:fetch_updates)
@provider.should_receive(:add_remotes)
@provider.run_action(:sync)
@@ -491,7 +491,7 @@ SHAS
end
it "clones the repo instead of fetching it if the deploy directory doesn't exist" do
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
::File.should_receive(:exist?).with("/my/deploy/dir/.git").exactly(2).and_return(false)
@provider.should_receive(:action_checkout)
@provider.should_not_receive(:shell_out!)
@@ -501,9 +501,9 @@ SHAS
it "clones the repo instead of fetching updates if the deploy directory is empty" do
::File.should_receive(:exist?).with("/my/deploy/dir/.git").exactly(2).and_return(false)
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
- ::File.stub!(:directory?).with("/my/deploy/dir").and_return(true)
- @provider.stub!(:sync_command).and_return("huzzah!")
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy/dir").and_return(true)
+ @provider.stub(:sync_command).and_return("huzzah!")
@provider.should_receive(:action_checkout)
@provider.should_not_receive(:shell_out!).with("huzzah!", :cwd => "/my/deploy/dir")
@provider.run_action(:sync)
diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb
index 360a799b5f..5890ee43a1 100644
--- a/spec/unit/provider/group/dscl_spec.rb
+++ b/spec/unit/provider/group/dscl_spec.rb
@@ -32,7 +32,7 @@ describe Chef::Provider::Group::Dscl do
@stdin = StringIO.new
@stdout = StringIO.new("\n")
@stderr = StringIO.new("")
- @provider.stub!(:popen4).and_yield(@pid,@stdin,@stdout,@stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid,@stdin,@stdout,@stderr).and_return(@status)
end
it "should run popen4 with the supplied array of arguments appended to the dscl command" do
@@ -50,7 +50,7 @@ describe Chef::Provider::Group::Dscl do
before do
@node = Chef::Node.new
@provider = Chef::Provider::Group::Dscl.new(@node, @new_resource)
- @provider.stub!(:dscl).and_return(["cmd", @status, "stdout", "stderr"])
+ @provider.stub(:dscl).and_return(["cmd", @status, "stdout", "stderr"])
end
it "should run dscl with the supplied cmd /Path args" do
@@ -61,7 +61,7 @@ describe Chef::Provider::Group::Dscl do
describe "with the dscl command returning a non zero exit status for a delete" do
before do
@status = mock("Process::Status", :exitstatus => 1)
- @provider.stub!(:dscl).and_return(["cmd", @status, "stdout", "stderr"])
+ @provider.stub(:dscl).and_return(["cmd", @status, "stdout", "stderr"])
end
it "should return an empty string of standard output for a delete" do
@@ -77,7 +77,7 @@ describe Chef::Provider::Group::Dscl do
describe "with the dscl command returning no such key" do
before do
- @provider.stub!(:dscl).and_return(["cmd", @status, "No such key: ", "stderr"])
+ @provider.stub(:dscl).and_return(["cmd", @status, "No such key: ", "stderr"])
end
it "should raise an exception" do
@@ -98,7 +98,7 @@ describe Chef::Provider::Group::Dscl do
before do
@node = Chef::Node.new
@provider = Chef::Provider::Group::Dscl.new(@node, @new_resource)
- @provider.stub!(:safe_dscl).and_return("\naj 200\njt 201\n")
+ @provider.stub(:safe_dscl).and_return("\naj 200\njt 201\n")
end
it "should run safe_dscl with list /Groups gid" do
@@ -120,7 +120,7 @@ describe Chef::Provider::Group::Dscl do
before do
@node = Chef::Node.new
@provider = Chef::Provider::Group::Dscl.new(@node, @new_resource)
- @provider.stub!(:safe_dscl).and_return("\naj 500\n")
+ @provider.stub(:safe_dscl).and_return("\naj 500\n")
end
it "should run safe_dscl with list /Groups gid" do
@@ -144,7 +144,7 @@ describe Chef::Provider::Group::Dscl do
describe "set_gid" do
describe "with the new resource and a gid number which is already in use" do
before do
- @provider.stub!(:gid_used?).and_return(true)
+ @provider.stub(:gid_used?).and_return(true)
end
it "should raise an exception if the new resources gid is already in use" do
@@ -162,7 +162,7 @@ describe Chef::Provider::Group::Dscl do
describe "with blank gid number for the new resources" do
before do
@new_resource.instance_variable_set(:@gid, nil)
- @new_resource.stub!(:safe_dscl)
+ @new_resource.stub(:safe_dscl)
end
it "should run get_free_gid and return a valid, unused gid number" do
@@ -185,9 +185,9 @@ describe Chef::Provider::Group::Dscl do
describe "with existing members in the current resource and append set to false in the new resource" do
before do
- @new_resource.stub!(:members).and_return([])
- @new_resource.stub!(:append).and_return(false)
- @current_resource.stub!(:members).and_return(["all", "your", "base"])
+ @new_resource.stub(:members).and_return([])
+ @new_resource.stub(:append).and_return(false)
+ @current_resource.stub(:members).and_return(["all", "your", "base"])
end
it "should log an appropriate message" do
@@ -246,7 +246,7 @@ describe Chef::Provider::Group::Dscl do
end
it "doesn't raise an error if /usr/bin/dscl exists" do
- File.stub!(:exists?).and_return(true)
+ File.stub(:exists?).and_return(true)
lambda { @provider.process_resource_requirements }.should_not raise_error(Chef::Exceptions::Group)
end
end
diff --git a/spec/unit/provider/group/gpasswd_spec.rb b/spec/unit/provider/group/gpasswd_spec.rb
index f765667300..0436812501 100644
--- a/spec/unit/provider/group/gpasswd_spec.rb
+++ b/spec/unit/provider/group/gpasswd_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
@new_resource.members %w{lobster rage fist}
@new_resource.append false
@provider = Chef::Provider::Group::Gpasswd.new(@new_resource, @run_context)
- #@provider.stub!(:run_command).and_return(true)
+ #@provider.stub(:run_command).and_return(true)
end
describe "when determining the current group state" do
@@ -40,13 +40,13 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
# for Chef::Provider::Group - no need to repeat it here. We'll
# include only what's specific to this provider.
it "should raise an error if the required binary /usr/bin/gpasswd doesn't exist" do
- File.stub!(:exists?).and_return(true)
+ File.stub(:exists?).and_return(true)
File.should_receive(:exists?).with("/usr/bin/gpasswd").and_return(false)
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Group)
end
it "shouldn't raise an error if the required binaries exist" do
- File.stub!(:exists?).and_return(true)
+ File.stub(:exists?).and_return(true)
lambda { @provider.process_resource_requirements }.should_not raise_error(Chef::Exceptions::Group)
end
end
@@ -85,7 +85,7 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
describe "when the resource specifies group members" do
it "should log an appropriate debug message" do
Chef::Log.should_receive(:debug).with("group[wheel] setting group members to: lobster, rage, fist")
- @provider.stub!(:shell_out!)
+ @provider.stub(:shell_out!)
@provider.modify_group_members
end
diff --git a/spec/unit/provider/group/groupadd_spec.rb b/spec/unit/provider/group/groupadd_spec.rb
index 91073727c8..793615d04c 100644
--- a/spec/unit/provider/group/groupadd_spec.rb
+++ b/spec/unit/provider/group/groupadd_spec.rb
@@ -48,7 +48,7 @@ describe Chef::Provider::Group::Groupadd, "set_options" do
@provider.set_options
end
it "should set the option for #{attribute} if the new resources #{attribute} is not null" do
- @new_resource.stub!(attribute).and_return("wowaweea")
+ @new_resource.stub(attribute).and_return("wowaweea")
@provider.set_options.should eql(" #{option} '#{@new_resource.send(attribute)}' #{@new_resource.group_name}")
end
end
@@ -56,7 +56,7 @@ describe Chef::Provider::Group::Groupadd, "set_options" do
it "should combine all the possible options" do
match_string = ""
field_list.sort{ |a,b| a[0] <=> b[0] }.each do |attribute, option|
- @new_resource.stub!(attribute).and_return("hola")
+ @new_resource.stub(attribute).and_return("hola")
match_string << " #{option} 'hola'"
end
match_string << " aj"
@@ -93,10 +93,10 @@ describe Chef::Provider::Group::Groupadd, "create_group" do
@node = Chef::Node.new
@new_resource = Chef::Resource::Group.new("aj")
@provider = Chef::Provider::Group::Groupadd.new(@node, @new_resource)
- @provider.stub!(:run_command).and_return(true)
- @provider.stub!(:set_options).and_return(" monkey")
- @provider.stub!(:groupadd_options).and_return("")
- @provider.stub!(:modify_group_members).and_return(true)
+ @provider.stub(:run_command).and_return(true)
+ @provider.stub(:set_options).and_return(" monkey")
+ @provider.stub(:groupadd_options).and_return("")
+ @provider.stub(:modify_group_members).and_return(true)
end
it "should run groupadd with the return of set_options" do
@@ -117,14 +117,14 @@ describe Chef::Provider::Group::Groupadd do
@run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::Group.new("aj")
@provider = Chef::Provider::Group::Groupadd.new(@new_resource, @run_context)
- @provider.stub!(:run_command).and_return(true)
- @provider.stub!(:set_options).and_return(" monkey")
+ @provider.stub(:run_command).and_return(true)
+ @provider.stub(:set_options).and_return(" monkey")
end
describe "manage group" do
it "should run groupmod with the return of set_options" do
- @provider.stub!(:modify_group_members).and_return(true)
+ @provider.stub(:modify_group_members).and_return(true)
@provider.should_receive(:run_command).with({ :command => "groupmod monkey" }).and_return(true)
@provider.manage_group
end
@@ -151,7 +151,7 @@ describe Chef::Provider::Group::Groupadd do
describe "load_current_resource" do
before do
- File.stub!(:exists?).and_return(false)
+ File.stub(:exists?).and_return(false)
@provider.define_resource_requirements
end
it "should raise an error if the required binary /usr/sbin/groupadd doesn't exist" do
diff --git a/spec/unit/provider/group/groupmod_spec.rb b/spec/unit/provider/group/groupmod_spec.rb
index bfacfa5c26..3d49f667d4 100644
--- a/spec/unit/provider/group/groupmod_spec.rb
+++ b/spec/unit/provider/group/groupmod_spec.rb
@@ -43,7 +43,7 @@ describe Chef::Provider::Group::Groupmod do
end
it "shouldn't raise an error if the required binaries exist" do
- File.stub!(:exists?).and_return(true)
+ File.stub(:exists?).and_return(true)
lambda { @provider.load_current_resource }.should_not raise_error(Chef::Exceptions::Group)
end
end
@@ -89,7 +89,7 @@ describe Chef::Provider::Group::Groupmod do
end
it "updates group membership correctly" do
- Chef::Log.stub!(:debug)
+ Chef::Log.stub(:debug)
@provider.should_receive(:shell_out!).with("group mod -n wheel_bak wheel")
@provider.should_receive(:shell_out!).with("user mod -G wheel lobster")
@provider.should_receive(:shell_out!).with("group add -g '123' -o wheel")
diff --git a/spec/unit/provider/group/pw_spec.rb b/spec/unit/provider/group/pw_spec.rb
index a545f8ee70..103bc33bd4 100644
--- a/spec/unit/provider/group/pw_spec.rb
+++ b/spec/unit/provider/group/pw_spec.rb
@@ -77,8 +77,8 @@ describe Chef::Provider::Group::Pw do
describe "with an empty members array in both the new and current resource" do
before do
- @new_resource.stub!(:members).and_return([])
- @current_resource.stub!(:members).and_return([])
+ @new_resource.stub(:members).and_return([])
+ @current_resource.stub(:members).and_return([])
end
it "should set no options" do
@@ -88,8 +88,8 @@ describe Chef::Provider::Group::Pw do
describe "with an empty members array in the new resource and existing members in the current resource" do
before do
- @new_resource.stub!(:members).and_return([])
- @current_resource.stub!(:members).and_return(["all", "your", "base"])
+ @new_resource.stub(:members).and_return([])
+ @current_resource.stub(:members).and_return(["all", "your", "base"])
end
it "should log an appropriate message" do
@@ -104,8 +104,8 @@ describe Chef::Provider::Group::Pw do
describe "with supplied members array in the new resource and an empty members array in the current resource" do
before do
- @new_resource.stub!(:members).and_return(["all", "your", "base"])
- @current_resource.stub!(:members).and_return([])
+ @new_resource.stub(:members).and_return(["all", "your", "base"])
+ @current_resource.stub(:members).and_return([])
end
it "should log an appropriate debug message" do
@@ -130,7 +130,7 @@ describe Chef::Provider::Group::Pw do
end
it "shouldn't raise an error if /usr/sbin/pw exists" do
- File.stub!(:exists?).and_return(true)
+ File.stub(:exists?).and_return(true)
lambda { @provider.process_resource_requirements }.should_not raise_error(Chef::Exceptions::Group)
end
end
diff --git a/spec/unit/provider/group/usermod_spec.rb b/spec/unit/provider/group/usermod_spec.rb
index 1687cc0b65..cc3a28fb74 100644
--- a/spec/unit/provider/group/usermod_spec.rb
+++ b/spec/unit/provider/group/usermod_spec.rb
@@ -27,15 +27,15 @@ describe Chef::Provider::Group::Usermod do
@new_resource.members [ "all", "your", "base" ]
@new_resource.excluded_members [ ]
@provider = Chef::Provider::Group::Usermod.new(@new_resource, @run_context)
- @provider.stub!(:run_command)
+ @provider.stub(:run_command)
end
describe "modify_group_members" do
describe "with an empty members array" do
before do
- @new_resource.stub!(:append).and_return(true)
- @new_resource.stub!(:members).and_return([])
+ @new_resource.stub(:append).and_return(true)
+ @new_resource.stub(:members).and_return([])
end
it "should log an appropriate message" do
@@ -55,8 +55,8 @@ describe Chef::Provider::Group::Usermod do
}
before do
- @new_resource.stub!(:members).and_return(["all", "your", "base"])
- File.stub!(:exists?).and_return(true)
+ @new_resource.stub(:members).and_return(["all", "your", "base"])
+ File.stub(:exists?).and_return(true)
end
it "should raise an error when setting the entire group directly" do
@@ -72,8 +72,8 @@ describe Chef::Provider::Group::Usermod do
@provider.load_current_resource
@provider.instance_variable_set("@group_exists", true)
@provider.action = :modify
- @new_resource.stub!(:append).and_return(true)
- @new_resource.stub!(:excluded_members).and_return(["someone"])
+ @new_resource.stub(:append).and_return(true)
+ @new_resource.stub(:excluded_members).and_return(["someone"])
lambda { @provider.run_action(@provider.process_resource_requirements) }.should raise_error(Chef::Exceptions::Group, "excluded_members is not supported by #{@provider.to_s}")
end
@@ -83,7 +83,7 @@ describe Chef::Provider::Group::Usermod do
current_resource.members([ ])
@provider.current_resource = current_resource
@node.automatic_attrs[:platform] = platform
- @new_resource.stub!(:append).and_return(true)
+ @new_resource.stub(:append).and_return(true)
@provider.should_receive(:shell_out!).with("usermod #{flags} wheel all")
@provider.should_receive(:shell_out!).with("usermod #{flags} wheel your")
@provider.should_receive(:shell_out!).with("usermod #{flags} wheel base")
@@ -95,18 +95,18 @@ describe Chef::Provider::Group::Usermod do
describe "when loading the current resource" do
before(:each) do
- File.stub!(:exists?).and_return(false)
+ File.stub(:exists?).and_return(false)
@provider.define_resource_requirements
end
it "should raise an error if the required binary /usr/sbin/usermod doesn't exist" do
- File.stub!(:exists?).and_return(true)
+ File.stub(:exists?).and_return(true)
File.should_receive(:exists?).with("/usr/sbin/usermod").and_return(false)
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Group)
end
it "shouldn't raise an error if the required binaries exist" do
- File.stub!(:exists?).and_return(true)
+ File.stub(:exists?).and_return(true)
lambda { @provider.process_resource_requirements }.should_not raise_error(Chef::Exceptions::Group)
end
end
diff --git a/spec/unit/provider/group/windows_spec.rb b/spec/unit/provider/group/windows_spec.rb
index e8c1243ce5..b395ed96d8 100644
--- a/spec/unit/provider/group/windows_spec.rb
+++ b/spec/unit/provider/group/windows_spec.rb
@@ -34,7 +34,7 @@ describe Chef::Provider::Group::Windows do
@run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::Group.new("staff")
@net_group = mock("Chef::Util::Windows::NetGroup")
- Chef::Util::Windows::NetGroup.stub!(:new).and_return(@net_group)
+ Chef::Util::Windows::NetGroup.stub(:new).and_return(@net_group)
@provider = Chef::Provider::Group::Windows.new(@new_resource, @run_context)
end
@@ -52,21 +52,21 @@ describe Chef::Provider::Group::Windows do
@current_resource = Chef::Resource::Group.new("staff")
@current_resource.members [ "all", "your", "base" ]
- Chef::Util::Windows::NetGroup.stub!(:new).and_return(@net_group)
- @net_group.stub!(:local_add_members)
- @net_group.stub!(:local_set_members)
+ Chef::Util::Windows::NetGroup.stub(:new).and_return(@net_group)
+ @net_group.stub(:local_add_members)
+ @net_group.stub(:local_set_members)
@provider.stub(:local_group_name_to_sid)
@provider.current_resource = @current_resource
end
it "should call @net_group.local_set_members" do
- @new_resource.stub!(:append).and_return(false)
+ @new_resource.stub(:append).and_return(false)
@net_group.should_receive(:local_set_members).with(@new_resource.members)
@provider.manage_group
end
it "should call @net_group.local_add_members" do
- @new_resource.stub!(:append).and_return(true)
+ @new_resource.stub(:append).and_return(true)
@net_group.should_receive(:local_add_members).with(@new_resource.members)
@provider.manage_group
end
@@ -75,8 +75,8 @@ describe Chef::Provider::Group::Windows do
describe "remove_group" do
before do
- Chef::Util::Windows::NetGroup.stub!(:new).and_return(@net_group)
- @provider.stub!(:run_command).and_return(true)
+ Chef::Util::Windows::NetGroup.stub(:new).and_return(@net_group)
+ @provider.stub(:run_command).and_return(true)
end
it "should call @net_group.local_delete" do
diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb
index a076593511..ad6cfbff7c 100644
--- a/spec/unit/provider/group_spec.rb
+++ b/spec/unit/provider/group_spec.rb
@@ -41,7 +41,7 @@ describe Chef::Provider::User do
:gid => 20,
:mem => [ "root", "aj" ]
)
- Etc.stub!(:getgrnam).with('wheel').and_return(@pw_group)
+ Etc.stub(:getgrnam).with('wheel').and_return(@pw_group)
end
it "assumes the group exists by default" do
@@ -74,7 +74,7 @@ describe Chef::Provider::User do
end
it "should flip the value of exists if it cannot be found in /etc/group" do
- Etc.stub!(:getgrnam).and_raise(ArgumentError)
+ Etc.stub(:getgrnam).and_raise(ArgumentError)
@provider.load_current_resource
@provider.group_exists.should be_false
end
@@ -87,7 +87,7 @@ describe Chef::Provider::User do
describe "when determining if the system is already in the target state" do
[ :gid, :members ].each do |attribute|
it "should return true if #{attribute} doesn't match" do
- @current_resource.stub!(attribute).and_return("looooooooooooooooooool")
+ @current_resource.stub(attribute).and_return("looooooooooooooooooool")
@provider.compare_group.should be_true
end
end
@@ -98,26 +98,26 @@ describe Chef::Provider::User do
it "should return false if append is true and the group member(s) already exists" do
@current_resource.members << "extra_user"
- @new_resource.stub!(:append).and_return(true)
+ @new_resource.stub(:append).and_return(true)
@provider.compare_group.should be_false
end
it "should return true if append is true and the group member(s) do not already exist" do
@new_resource.members << "extra_user"
- @new_resource.stub!(:append).and_return(true)
+ @new_resource.stub(:append).and_return(true)
@provider.compare_group.should be_true
end
it "should return false if append is true and excluded_members include a non existing member" do
@new_resource.excluded_members << "extra_user"
- @new_resource.stub!(:append).and_return(true)
+ @new_resource.stub(:append).and_return(true)
@provider.compare_group.should be_false
end
it "should return true if the append is true and excluded_members include an existing user" do
@new_resource.members.each {|m| @new_resource.excluded_members << m }
@new_resource.members.clear
- @new_resource.stub!(:append).and_return(true)
+ @new_resource.stub(:append).and_return(true)
@provider.compare_group.should be_true
end
@@ -132,32 +132,32 @@ describe Chef::Provider::User do
it "should set the new_resources updated flag when it creates the group" do
@provider.group_exists = false
- @provider.stub!(:create_group)
+ @provider.stub(:create_group)
@provider.run_action(:create)
@provider.new_resource.should be_updated
end
it "should check to see if the group has mismatched attributes if the group exists" do
@provider.group_exists = true
- @provider.stub!(:compare_group).and_return(false)
- @provider.stub!(:change_desc).and_return([ ])
+ @provider.stub(:compare_group).and_return(false)
+ @provider.stub(:change_desc).and_return([ ])
@provider.run_action(:create)
@provider.new_resource.should_not be_updated
end
it "should call manage_group if the group exists and has mismatched attributes" do
@provider.group_exists = true
- @provider.stub!(:compare_group).and_return(true)
- @provider.stub!(:change_desc).and_return([ ])
+ @provider.stub(:compare_group).and_return(true)
+ @provider.stub(:change_desc).and_return([ ])
@provider.should_receive(:manage_group).and_return(true)
@provider.run_action(:create)
end
it "should set the new_resources updated flag when it creates the group if we call manage_group" do
@provider.group_exists = true
- @provider.stub!(:compare_group).and_return(true)
- @provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
- @provider.stub!(:manage_group).and_return(true)
+ @provider.stub(:compare_group).and_return(true)
+ @provider.stub(:change_desc).and_return(["Some changes are going to be done."])
+ @provider.stub(:manage_group).and_return(true)
@provider.run_action(:create)
@new_resource.should be_updated
end
@@ -183,20 +183,20 @@ describe Chef::Provider::User do
describe "when updating a group" do
before(:each) do
@provider.group_exists = true
- @provider.stub!(:manage_group).and_return(true)
+ @provider.stub(:manage_group).and_return(true)
end
it "should run manage_group if the group exists and has mismatched attributes" do
@provider.should_receive(:compare_group).and_return(true)
- @provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
+ @provider.stub(:change_desc).and_return(["Some changes are going to be done."])
@provider.should_receive(:manage_group).and_return(true)
@provider.run_action(:manage)
end
it "should set the new resources updated flag to true if manage_group is called" do
- @provider.stub!(:compare_group).and_return(true)
- @provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
- @provider.stub!(:manage_group).and_return(true)
+ @provider.stub(:compare_group).and_return(true)
+ @provider.stub(:change_desc).and_return(["Some changes are going to be done."])
+ @provider.stub(:manage_group).and_return(true)
@provider.run_action(:manage)
@new_resource.should be_updated
end
@@ -209,7 +209,7 @@ describe Chef::Provider::User do
it "should not run manage_group if the group exists but has no differing attributes" do
@provider.should_receive(:compare_group).and_return(false)
- @provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
+ @provider.stub(:change_desc).and_return(["Some changes are going to be done."])
@provider.should_not_receive(:manage_group)
@provider.run_action(:manage)
end
@@ -218,27 +218,27 @@ describe Chef::Provider::User do
describe "when modifying the group" do
before(:each) do
@provider.group_exists = true
- @provider.stub!(:manage_group).and_return(true)
+ @provider.stub(:manage_group).and_return(true)
end
it "should run manage_group if the group exists and has mismatched attributes" do
@provider.should_receive(:compare_group).and_return(true)
- @provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
+ @provider.stub(:change_desc).and_return(["Some changes are going to be done."])
@provider.should_receive(:manage_group).and_return(true)
@provider.run_action(:modify)
end
it "should set the new resources updated flag to true if manage_group is called" do
- @provider.stub!(:compare_group).and_return(true)
- @provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
- @provider.stub!(:manage_group).and_return(true)
+ @provider.stub(:compare_group).and_return(true)
+ @provider.stub(:change_desc).and_return(["Some changes are going to be done."])
+ @provider.stub(:manage_group).and_return(true)
@provider.run_action(:modify)
@new_resource.should be_updated
end
it "should not run manage_group if the group exists but has no differing attributes" do
@provider.should_receive(:compare_group).and_return(false)
- @provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
+ @provider.stub(:change_desc).and_return(["Some changes are going to be done."])
@provider.should_not_receive(:manage_group)
@provider.run_action(:modify)
end
@@ -253,20 +253,20 @@ describe Chef::Provider::User do
it "should report which group members are missing if members are missing and appending to the group" do
@new_resource.members << "user1"
@new_resource.members << "user2"
- @new_resource.stub!(:append).and_return true
+ @new_resource.stub(:append).and_return true
@provider.compare_group.should be_true
@provider.change_desc.should == [ "add missing member(s): user1, user2" ]
end
it "should report that the group members will be overwritten if not appending" do
@new_resource.members << "user1"
- @new_resource.stub!(:append).and_return false
+ @new_resource.stub(:append).and_return false
@provider.compare_group.should be_true
@provider.change_desc.should == [ "replace group members with new list of members" ]
end
it "should report the gid will be changed when it does not match" do
- @current_resource.stub!(:gid).and_return("BADF00D")
+ @current_resource.stub(:gid).and_return("BADF00D")
@provider.compare_group.should be_true
@provider.change_desc.should == [ "change gid #{@current_resource.gid} to #{@new_resource.gid}" ]
diff --git a/spec/unit/provider/http_request_spec.rb b/spec/unit/provider/http_request_spec.rb
index 3efdd6c5fd..d1ee5163a1 100644
--- a/spec/unit/provider/http_request_spec.rb
+++ b/spec/unit/provider/http_request_spec.rb
@@ -44,7 +44,7 @@ describe Chef::Provider::HttpRequest do
before(:each) do
# run_action(x) forces load_current_resource to run;
# that would overwrite our supplied mock Chef::Rest # object
- @provider.stub!(:load_current_resource).and_return(true)
+ @provider.stub(:load_current_resource).and_return(true)
@http = mock("Chef::REST")
@provider.http = @http
end
@@ -73,7 +73,7 @@ describe Chef::Provider::HttpRequest do
end
it "should inflate a message block at runtime" do
- @new_resource.stub!(:message).and_return(lambda { "return" })
+ @new_resource.stub(:message).and_return(lambda { "return" })
@http.should_receive(:put).with("http://www.opscode.com/", "return", {})
@provider.run_action(:put)
@new_resource.should be_updated
diff --git a/spec/unit/provider/ifconfig/aix_spec.rb b/spec/unit/provider/ifconfig/aix_spec.rb
index 39e9919740..24f5fb18f3 100644
--- a/spec/unit/provider/ifconfig/aix_spec.rb
+++ b/spec/unit/provider/ifconfig/aix_spec.rb
@@ -67,7 +67,7 @@ IFCONFIG
it "should add an interface if it does not exist" do
@new_resource.device "en10"
- @provider.stub!(:load_current_resource) do
+ @provider.stub(:load_current_resource) do
@provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
@provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
@@ -81,7 +81,7 @@ IFCONFIG
it "should raise exception if metric attribute is set" do
@new_resource.device "en0"
@new_resource.metric "1"
- @provider.stub!(:load_current_resource) do
+ @provider.stub(:load_current_resource) do
@provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
@provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
@@ -93,7 +93,7 @@ IFCONFIG
describe "#action_enable" do
it "should enable an interface if it does not exist" do
@new_resource.device "en10"
- @provider.stub!(:load_current_resource) do
+ @provider.stub(:load_current_resource) do
@provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
@provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
@@ -109,7 +109,7 @@ IFCONFIG
it "should not disable an interface if it does not exist" do
@new_resource.device "en10"
- @provider.stub!(:load_current_resource) do
+ @provider.stub(:load_current_resource) do
@provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
@provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
@@ -123,7 +123,7 @@ IFCONFIG
context "interface exists" do
before do
@new_resource.device "en10"
- @provider.stub!(:load_current_resource) do
+ @provider.stub(:load_current_resource) do
@provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
current_resource.device @new_resource.device
@@ -146,7 +146,7 @@ IFCONFIG
it "should not delete an interface if it does not exist" do
@new_resource.device "en10"
- @provider.stub!(:load_current_resource) do
+ @provider.stub(:load_current_resource) do
@provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
@provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
@@ -160,7 +160,7 @@ IFCONFIG
context "interface exists" do
before do
@new_resource.device "en10"
- @provider.stub!(:load_current_resource) do
+ @provider.stub(:load_current_resource) do
@provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
current_resource.device @new_resource.device
diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb
index 617e840e1f..93504b4096 100644
--- a/spec/unit/provider/ifconfig/debian_spec.rb
+++ b/spec/unit/provider/ifconfig/debian_spec.rb
@@ -37,8 +37,8 @@ describe Chef::Provider::Ifconfig::Debian do
status = mock("Status", :exitstatus => 0)
@provider.instance_variable_set("@status", status)
@provider.current_resource = @current_resource
- @provider.stub!(:load_current_resource)
- @provider.stub!(:run_command)
+ @provider.stub(:load_current_resource)
+ @provider.stub(:run_command)
@config_filename_ifaces = "/etc/network/interfaces"
@config_filename_ifcfg = "/etc/network/interfaces.d/ifcfg-#{@new_resource.device}"
diff --git a/spec/unit/provider/ifconfig/redhat_spec.rb b/spec/unit/provider/ifconfig/redhat_spec.rb
index b6f83ffea9..fc7ace5398 100644
--- a/spec/unit/provider/ifconfig/redhat_spec.rb
+++ b/spec/unit/provider/ifconfig/redhat_spec.rb
@@ -42,8 +42,8 @@ describe Chef::Provider::Ifconfig::Redhat do
describe "generate_config for action_add" do
it "should write network-script for centos" do
- @provider.stub!(:load_current_resource)
- @provider.stub!(:run_command)
+ @provider.stub(:load_current_resource)
+ @provider.stub(:run_command)
config_filename = "/etc/sysconfig/network-scripts/ifcfg-#{@new_resource.device}"
config_file = StringIO.new
File.should_receive(:new).with(config_filename, "w").and_return(config_file)
@@ -59,8 +59,8 @@ describe Chef::Provider::Ifconfig::Redhat do
it "should delete network-script if it exists for centos" do
@current_resource.device @new_resource.device
- @provider.stub!(:load_current_resource)
- @provider.stub!(:run_command)
+ @provider.stub(:load_current_resource)
+ @provider.stub(:run_command)
config_filename = "/etc/sysconfig/network-scripts/ifcfg-#{@new_resource.device}"
File.should_receive(:exist?).with(config_filename).and_return(true)
FileUtils.should_receive(:rm_f).with(config_filename, :verbose => false)
diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb
index f4fdc23353..80f623302f 100644
--- a/spec/unit/provider/ifconfig_spec.rb
+++ b/spec/unit/provider/ifconfig_spec.rb
@@ -57,8 +57,8 @@ describe Chef::Provider::Ifconfig do
describe Chef::Provider::Ifconfig, "action_add" do
it "should add an interface if it does not exist" do
- #@provider.stub!(:run_command).and_return(true)
- @provider.stub!(:load_current_resource)
+ #@provider.stub(:run_command).and_return(true)
+ @provider.stub(:load_current_resource)
@current_resource.inet_addr nil
command = "ifconfig eth0 10.0.0.1 netmask 255.255.254.0 metric 1 mtu 1500"
@provider.should_receive(:run_command).with(:command => command)
@@ -69,7 +69,7 @@ describe Chef::Provider::Ifconfig do
end
it "should not add an interface if it already exists" do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
@provider.should_not_receive(:run_command)
@current_resource.inet_addr "10.0.0.1"
@provider.should_not_receive(:generate_config)
@@ -86,7 +86,7 @@ describe Chef::Provider::Ifconfig do
describe Chef::Provider::Ifconfig, "action_enable" do
it "should enable interface if does not exist" do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
@current_resource.inet_addr nil
command = "ifconfig eth0 10.0.0.1 netmask 255.255.254.0 metric 1 mtu 1500"
@provider.should_receive(:run_command).with(:command => command)
@@ -97,7 +97,7 @@ describe Chef::Provider::Ifconfig do
end
it "should not enable interface if it already exists" do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
@provider.should_not_receive(:run_command)
@current_resource.inet_addr "10.0.0.1"
@provider.should_not_receive(:generate_config)
@@ -110,7 +110,7 @@ describe Chef::Provider::Ifconfig do
describe Chef::Provider::Ifconfig, "action_delete" do
it "should delete interface if it exists" do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
@current_resource.device "eth0"
command = "ifconfig #{@new_resource.device} down"
@provider.should_receive(:run_command).with(:command => command)
@@ -121,7 +121,7 @@ describe Chef::Provider::Ifconfig do
end
it "should not delete interface if it does not exist" do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
@provider.should_not_receive(:run_command)
@provider.should_not_receive(:delete_config)
@@ -133,7 +133,7 @@ describe Chef::Provider::Ifconfig do
describe Chef::Provider::Ifconfig, "action_disable" do
it "should disable interface if it exists" do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
@current_resource.device "eth0"
command = "ifconfig #{@new_resource.device} down"
@provider.should_receive(:run_command).with(:command => command)
@@ -144,7 +144,7 @@ describe Chef::Provider::Ifconfig do
end
it "should not delete interface if it does not exist" do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
@provider.should_not_receive(:run_command)
@provider.should_not_receive(:delete_config)
@@ -156,7 +156,7 @@ describe Chef::Provider::Ifconfig do
describe Chef::Provider::Ifconfig, "action_delete" do
it "should delete interface of it exists" do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
@current_resource.device "eth0"
command = "ifconfig #{@new_resource.device} down"
@provider.should_receive(:run_command).with(:command => command)
@@ -168,7 +168,7 @@ describe Chef::Provider::Ifconfig do
it "should not delete interface if it does not exist" do
# This is so that our fake values do not get overwritten
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
# This is so that nothing actually runs
@provider.should_not_receive(:run_command)
@provider.should_not_receive(:delete_config)
diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb
index bd3204510b..869796219d 100644
--- a/spec/unit/provider/link_spec.rb
+++ b/spec/unit/provider/link_spec.rb
@@ -45,12 +45,12 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
describe "when the target is a symlink" do
before(:each) do
lstat = mock("stats", :ino => 5)
- lstat.stub!(:uid).and_return(501)
- lstat.stub!(:gid).and_return(501)
- lstat.stub!(:mode).and_return(0777)
- File.stub!(:lstat).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(lstat)
- provider.file_class.stub!(:symlink?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(true)
- provider.file_class.stub!(:readlink).with("#{CHEF_SPEC_DATA}/fofile-link").and_return("#{CHEF_SPEC_DATA}/fofile")
+ lstat.stub(:uid).and_return(501)
+ lstat.stub(:gid).and_return(501)
+ lstat.stub(:mode).and_return(0777)
+ File.stub(:lstat).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(lstat)
+ provider.file_class.stub(:symlink?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(true)
+ provider.file_class.stub(:readlink).with("#{CHEF_SPEC_DATA}/fofile-link").and_return("#{CHEF_SPEC_DATA}/fofile")
end
describe "to a file that exists" do
@@ -95,9 +95,9 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
describe "to a file that doesn't exist" do
before do
- File.stub!(:exist?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
- provider.file_class.stub!(:symlink?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(true)
- provider.file_class.stub!(:readlink).with("#{CHEF_SPEC_DATA}/fofile-link").and_return("#{CHEF_SPEC_DATA}/fofile")
+ File.stub(:exist?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
+ provider.file_class.stub(:symlink?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(true)
+ provider.file_class.stub(:readlink).with("#{CHEF_SPEC_DATA}/fofile-link").and_return("#{CHEF_SPEC_DATA}/fofile")
new_resource.owner "501" # only loaded in current_resource if present in new
new_resource.group "501"
provider.load_current_resource
@@ -123,8 +123,8 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
describe "when the target doesn't exist" do
before do
- File.stub!(:exists?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
- provider.file_class.stub!(:symlink?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
+ File.stub(:exists?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
+ provider.file_class.stub(:symlink?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
provider.load_current_resource
end
@@ -145,18 +145,18 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
describe "when the target is a regular old file" do
before do
stat = mock("stats", :ino => 5)
- stat.stub!(:uid).and_return(501)
- stat.stub!(:gid).and_return(501)
- stat.stub!(:mode).and_return(0755)
- provider.file_class.stub!(:stat).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(stat)
+ stat.stub(:uid).and_return(501)
+ stat.stub(:gid).and_return(501)
+ stat.stub(:mode).and_return(0755)
+ provider.file_class.stub(:stat).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(stat)
- File.stub!(:exists?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(true)
- provider.file_class.stub!(:symlink?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
+ File.stub(:exists?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(true)
+ provider.file_class.stub(:symlink?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
end
describe "and the source does not exist" do
before do
- File.stub!(:exists?).with("#{CHEF_SPEC_DATA}/fofile").and_return(false)
+ File.stub(:exists?).with("#{CHEF_SPEC_DATA}/fofile").and_return(false)
provider.load_current_resource
end
@@ -177,13 +177,13 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
describe "and the source exists" do
before do
stat = mock("stats", :ino => 6)
- stat.stub!(:uid).and_return(502)
- stat.stub!(:gid).and_return(502)
- stat.stub!(:mode).and_return(0644)
+ stat.stub(:uid).and_return(502)
+ stat.stub(:gid).and_return(502)
+ stat.stub(:mode).and_return(0644)
- provider.file_class.stub!(:stat).with("#{CHEF_SPEC_DATA}/fofile").and_return(stat)
+ provider.file_class.stub(:stat).with("#{CHEF_SPEC_DATA}/fofile").and_return(stat)
- File.stub!(:exists?).with("#{CHEF_SPEC_DATA}/fofile").and_return(true)
+ File.stub(:exists?).with("#{CHEF_SPEC_DATA}/fofile").and_return(true)
provider.load_current_resource
end
@@ -204,13 +204,13 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
describe "and is hardlinked to the source" do
before do
stat = mock("stats", :ino => 5)
- stat.stub!(:uid).and_return(502)
- stat.stub!(:gid).and_return(502)
- stat.stub!(:mode).and_return(0644)
+ stat.stub(:uid).and_return(502)
+ stat.stub(:gid).and_return(502)
+ stat.stub(:mode).and_return(0644)
- provider.file_class.stub!(:stat).with("#{CHEF_SPEC_DATA}/fofile").and_return(stat)
+ provider.file_class.stub(:stat).with("#{CHEF_SPEC_DATA}/fofile").and_return(stat)
- File.stub!(:exists?).with("#{CHEF_SPEC_DATA}/fofile").and_return(true)
+ File.stub(:exists?).with("#{CHEF_SPEC_DATA}/fofile").and_return(true)
provider.load_current_resource
end
diff --git a/spec/unit/provider/mdadm_spec.rb b/spec/unit/provider/mdadm_spec.rb
index 25991e4732..6595728741 100644
--- a/spec/unit/provider/mdadm_spec.rb
+++ b/spec/unit/provider/mdadm_spec.rb
@@ -32,20 +32,20 @@ describe Chef::Provider::Mdadm do
describe "when determining the current metadevice status" do
it "should set the current resources mount point to the new resources mount point" do
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:status => 0))
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:status => 0))
@provider.load_current_resource
@provider.current_resource.name.should == '/dev/md1'
@provider.current_resource.raid_device.should == '/dev/md1'
end
it "determines that the metadevice exists when mdadm exit code is zero" do
- @provider.stub!(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0,4]).and_return(OpenStruct.new(:status => 0))
+ @provider.stub(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0,4]).and_return(OpenStruct.new(:status => 0))
@provider.load_current_resource
@provider.current_resource.exists.should be_true
end
it "determines that the metadevice does not exist when mdadm exit code is 4" do
- @provider.stub!(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0,4]).and_return(OpenStruct.new(:status => 4))
+ @provider.stub(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0,4]).and_return(OpenStruct.new(:status => 4))
@provider.load_current_resource
@provider.current_resource.exists.should be_false
end
@@ -55,7 +55,7 @@ describe Chef::Provider::Mdadm do
before(:each) do
@current_resource = Chef::Resource::Mdadm.new('/dev/md1')
@new_resource.level 5
- @provider.stub!(:load_current_resource).and_return(true)
+ @provider.stub(:load_current_resource).and_return(true)
@provider.current_resource = @current_resource
end
diff --git a/spec/unit/provider/mount/aix_spec.rb b/spec/unit/provider/mount/aix_spec.rb
index 89de47038a..dcd9170e1f 100644
--- a/spec/unit/provider/mount/aix_spec.rb
+++ b/spec/unit/provider/mount/aix_spec.rb
@@ -60,8 +60,8 @@ ENABLED
@provider = Chef::Provider::Mount::Aix.new(@new_resource, @run_context)
- ::File.stub!(:exists?).with("/dev/sdz1").and_return true
- ::File.stub!(:exists?).with("/tmp/foo").and_return true
+ ::File.stub(:exists?).with("/dev/sdz1").and_return true
+ ::File.stub(:exists?).with("/tmp/foo").and_return true
end
def stub_mounted(provider, mounted_output)
@@ -179,7 +179,7 @@ ENABLED
@new_resource.options("nodev,rw")
stub_mounted_enabled(@provider, @mounted_output, "")
filesystems = StringIO.new
- ::File.stub!(:open).with("/etc/filesystems", "a").and_yield(filesystems)
+ ::File.stub(:open).with("/etc/filesystems", "a").and_yield(filesystems)
@provider.run_action(:enable)
@@ -200,7 +200,7 @@ ENABLED
it "should disable mount if it is mounted and enabled" do
stub_mounted_enabled(@provider, @mounted_output, @enabled_output)
- ::File.stub!(:open).with("/etc/filesystems", "r").and_return(<<-ETCFILESYSTEMS)
+ ::File.stub(:open).with("/etc/filesystems", "r").and_return(<<-ETCFILESYSTEMS)
/tmp/foo:
dev = /dev/sdz1
vfs = jfs2
@@ -219,7 +219,7 @@ ENABLED
ETCFILESYSTEMS
filesystems = StringIO.new
- ::File.stub!(:open).with("/etc/filesystems", "w").and_yield(filesystems)
+ ::File.stub(:open).with("/etc/filesystems", "w").and_yield(filesystems)
@provider.run_action(:disable)
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index 38b907749e..2c304980d8 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -34,16 +34,16 @@ describe Chef::Provider::Mount::Mount do
@provider = Chef::Provider::Mount::Mount.new(@new_resource, @run_context)
- ::File.stub!(:exists?).with("/dev/sdz1").and_return true
- ::File.stub!(:exists?).with("/tmp/foo").and_return true
- ::File.stub!(:realpath).with("/dev/sdz1").and_return "/dev/sdz1"
- ::File.stub!(:realpath).with("/tmp/foo").and_return "/tmp/foo"
+ ::File.stub(:exists?).with("/dev/sdz1").and_return true
+ ::File.stub(:exists?).with("/tmp/foo").and_return true
+ ::File.stub(:realpath).with("/dev/sdz1").and_return "/dev/sdz1"
+ ::File.stub(:realpath).with("/tmp/foo").and_return "/tmp/foo"
end
describe "when discovering the current fs state" do
before do
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => ''))
- ::File.stub!(:foreach).with("/etc/fstab")
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => ''))
+ ::File.stub(:foreach).with("/etc/fstab")
end
it "should create a current resource with the same mount point and device" do
@@ -72,7 +72,7 @@ describe Chef::Provider::Mount::Mount do
it "should ignore trailing slash and set mounted to true for network mount (#{type})" do
@new_resource.device fs_spec
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n"))
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n"))
@provider.load_current_resource
@provider.current_resource.mounted.should be_true
end
@@ -80,12 +80,12 @@ describe Chef::Provider::Mount::Mount do
end
it "should raise an error if the mount device does not exist" do
- ::File.stub!(:exists?).with("/dev/sdz1").and_return false
+ ::File.stub(:exists?).with("/dev/sdz1").and_return false
lambda { @provider.load_current_resource();@provider.mountable? }.should raise_error(Chef::Exceptions::Mount)
end
it "should not call mountable? with load_current_resource - CHEF-1565" do
- ::File.stub!(:exists?).with("/dev/sdz1").and_return false
+ ::File.stub(:exists?).with("/dev/sdz1").and_return false
@provider.should_receive(:mounted?).and_return(true)
@provider.should_receive(:enabled?).and_return(true)
@provider.should_not_receive(:mountable?)
@@ -103,7 +103,7 @@ describe Chef::Provider::Mount::Mount do
end
it "should raise an error if the mount point does not exist" do
- ::File.stub!(:exists?).with("/tmp/foo").and_return false
+ ::File.stub(:exists?).with("/tmp/foo").and_return false
lambda { @provider.load_current_resource();@provider.mountable? }.should raise_error(Chef::Exceptions::Mount)
end
@@ -125,7 +125,7 @@ describe Chef::Provider::Mount::Mount do
end
it "should set mounted true if the mount point is found in the mounts list" do
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => '/dev/sdz1 on /tmp/foo'))
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => '/dev/sdz1 on /tmp/foo'))
@provider.load_current_resource()
@provider.current_resource.mounted.should be_true
end
@@ -133,10 +133,10 @@ describe Chef::Provider::Mount::Mount do
it "should set mounted true if the symlink target of the device is found in the mounts list" do
target = "/dev/mapper/target"
- ::File.stub!(:symlink?).with("#{@new_resource.device}").and_return(true)
- ::File.stub!(:readlink).with("#{@new_resource.device}").and_return(target)
+ ::File.stub(:symlink?).with("#{@new_resource.device}").and_return(true)
+ ::File.stub(:readlink).with("#{@new_resource.device}").and_return(target)
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/mapper/target on /tmp/foo type ext3 (rw)\n"))
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/mapper/target on /tmp/foo type ext3 (rw)\n"))
@provider.load_current_resource()
@provider.current_resource.mounted.should be_true
end
@@ -145,7 +145,7 @@ describe Chef::Provider::Mount::Mount do
mount = "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n"
mount << "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n"
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => mount))
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => mount))
@provider.load_current_resource()
@provider.current_resource.mounted.should be_true
end
@@ -154,13 +154,13 @@ describe Chef::Provider::Mount::Mount do
mount = "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n"
mount << "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n"
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => mount))
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => mount))
@provider.load_current_resource()
@provider.current_resource.mounted.should be_false
end
it "mounted should be false if the mount point is not found in the mounts list" do
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdy1 on /tmp/foo type ext3 (rw)\n"))
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdy1 on /tmp/foo type ext3 (rw)\n"))
@provider.load_current_resource()
@provider.current_resource.mounted.should be_false
end
@@ -169,7 +169,7 @@ describe Chef::Provider::Mount::Mount do
fstab1 = "/dev/sdy1 /tmp/foo ext3 defaults 1 2\n"
fstab2 = "#{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield(fstab1).and_yield(fstab2)
+ ::File.stub(:foreach).with("/etc/fstab").and_yield(fstab1).and_yield(fstab2)
@provider.load_current_resource
@provider.current_resource.enabled.should be_true
@@ -179,7 +179,7 @@ describe Chef::Provider::Mount::Mount do
fstab1 = "#{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n"
fstab2 = "/dev/sdy1 /tmp/foo/bar ext3 defaults 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield(fstab1).and_yield(fstab2)
+ ::File.stub(:foreach).with("/etc/fstab").and_yield(fstab1).and_yield(fstab2)
@provider.load_current_resource
@provider.current_resource.enabled.should be_true
@@ -188,12 +188,12 @@ describe Chef::Provider::Mount::Mount do
it "should set enabled to true if the symlink target is in fstab" do
target = "/dev/mapper/target"
- ::File.stub!(:symlink?).with("#{@new_resource.device}").and_return(true)
- ::File.stub!(:readlink).with("#{@new_resource.device}").and_return(target)
+ ::File.stub(:symlink?).with("#{@new_resource.device}").and_return(true)
+ ::File.stub(:readlink).with("#{@new_resource.device}").and_return(target)
fstab = "/dev/sdz1 /tmp/foo ext3 defaults 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield fstab
+ ::File.stub(:foreach).with("/etc/fstab").and_yield fstab
@provider.load_current_resource
@provider.current_resource.enabled.should be_true
@@ -201,7 +201,7 @@ describe Chef::Provider::Mount::Mount do
it "should set enabled to false if the mount point is not in fstab" do
fstab = "/dev/sdy1 #{@new_resource.mount_point} ext3 defaults 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield fstab
+ ::File.stub(:foreach).with("/etc/fstab").and_yield fstab
@provider.load_current_resource
@provider.current_resource.enabled.should be_false
@@ -209,7 +209,7 @@ describe Chef::Provider::Mount::Mount do
it "should ignore commented lines in fstab " do
fstab = "\# #{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield fstab
+ ::File.stub(:foreach).with("/etc/fstab").and_yield fstab
@provider.load_current_resource
@provider.current_resource.enabled.should be_false
@@ -218,7 +218,7 @@ describe Chef::Provider::Mount::Mount do
it "should set enabled to false if the mount point is not last in fstab" do
line_1 = "#{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n"
line_2 = "/dev/sdy1 #{@new_resource.mount_point} ext3 defaults 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield(line_1).and_yield(line_2)
+ ::File.stub(:foreach).with("/etc/fstab").and_yield(line_1).and_yield(line_2)
@provider.load_current_resource
@provider.current_resource.enabled.should be_false
@@ -228,11 +228,11 @@ describe Chef::Provider::Mount::Mount do
target = "/dev/mapper/target"
options = "rw,noexec,noauto"
- ::File.stub!(:symlink?).with(@new_resource.device).and_return(true)
- ::File.stub!(:readlink).with(@new_resource.device).and_return(target)
+ ::File.stub(:symlink?).with(@new_resource.device).and_return(true)
+ ::File.stub(:readlink).with(@new_resource.device).and_return(target)
fstab = "#{@new_resource.device} #{@new_resource.mount_point} #{@new_resource.fstype} #{options} 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield fstab
+ ::File.stub(:foreach).with("/etc/fstab").and_yield fstab
@provider.load_current_resource
@provider.current_resource.options.should eq(options.split(','))
end
@@ -241,11 +241,11 @@ describe Chef::Provider::Mount::Mount do
target = "/dev/mapper/target"
options = "rw,noexec,noauto"
- ::File.stub!(:symlink?).with(@new_resource.device).and_return(true)
- ::File.stub!(:readlink).with(@new_resource.device).and_return(target)
+ ::File.stub(:symlink?).with(@new_resource.device).and_return(true)
+ ::File.stub(:readlink).with(@new_resource.device).and_return(target)
fstab = "#{target} #{@new_resource.mount_point} #{@new_resource.fstype} #{options} 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield fstab
+ ::File.stub(:foreach).with("/etc/fstab").and_yield fstab
@provider.load_current_resource
@provider.current_resource.options.should eq(options.split(','))
end
@@ -279,15 +279,15 @@ describe Chef::Provider::Mount::Mount do
@new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a"
@new_resource.device_type :uuid
@stdout_findfs = mock("STDOUT", :first => "/dev/sdz1")
- @provider.stub!(:popen4).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_yield(@pid,@stdin,@stdout_findfs,@stderr).and_return(@status)
+ @provider.stub(:popen4).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_yield(@pid,@stdin,@stdout_findfs,@stderr).and_return(@status)
@stdout_mock = mock('stdout mock')
- @stdout_mock.stub!(:each).and_yield("#{@new_resource.device} on #{@new_resource.mount_point}")
+ @stdout_mock.stub(:each).and_yield("#{@new_resource.device} on #{@new_resource.mount_point}")
@provider.should_receive(:shell_out!).with("mount -t #{@new_resource.fstype} -o defaults -U #{@new_resource.device} #{@new_resource.mount_point}").and_return(@stdout_mock)
@provider.mount_fs()
end
it "should not mount the filesystem if it is mounted" do
- @current_resource.stub!(:mounted).and_return(true)
+ @current_resource.stub(:mounted).and_return(true)
@provider.should_not_receive(:shell_out!)
@provider.mount_fs()
end
@@ -339,7 +339,7 @@ describe Chef::Provider::Mount::Mount do
@current_resource.enabled(false)
@fstab = StringIO.new
- ::File.stub!(:open).with("/etc/fstab", "a").and_yield(@fstab)
+ ::File.stub(:open).with("/etc/fstab", "a").and_yield(@fstab)
@provider.enable_fs
@fstab.string.should match(%r{^/dev/sdz1\s+/tmp/foo\s+ext3\s+defaults\s+0\s+2\s*$})
end
@@ -378,9 +378,9 @@ describe Chef::Provider::Mount::Mount do
this_mount = "/dev/sdz1 /tmp/foo ext3 defaults 1 2\n"
@fstab_read = [this_mount, other_mount]
- ::File.stub!(:readlines).with("/etc/fstab").and_return(@fstab_read)
+ ::File.stub(:readlines).with("/etc/fstab").and_return(@fstab_read)
@fstab_write = StringIO.new
- ::File.stub!(:open).with("/etc/fstab", "w").and_yield(@fstab_write)
+ ::File.stub(:open).with("/etc/fstab", "w").and_yield(@fstab_write)
@provider.disable_fs
@fstab_write.string.should match(Regexp.escape(other_mount))
@@ -395,8 +395,8 @@ describe Chef::Provider::Mount::Mount do
%q{#/dev/sdz1 /tmp/foo ext3 defaults 1 2}]
fstab_write = StringIO.new
- ::File.stub!(:readlines).with("/etc/fstab").and_return(fstab_read)
- ::File.stub!(:open).with("/etc/fstab", "w").and_yield(fstab_write)
+ ::File.stub(:readlines).with("/etc/fstab").and_return(fstab_read)
+ ::File.stub(:open).with("/etc/fstab", "w").and_yield(fstab_write)
@provider.disable_fs
fstab_write.string.should match(%r{^/dev/sdy1 /tmp/foo ext3 defaults 1 2$})
@@ -405,23 +405,23 @@ describe Chef::Provider::Mount::Mount do
end
it "should disable only the last entry if enabled is true" do
- @current_resource.stub!(:enabled).and_return(true)
+ @current_resource.stub(:enabled).and_return(true)
fstab_read = ["/dev/sdz1 /tmp/foo ext3 defaults 1 2\n",
"/dev/sdy1 /tmp/foo ext3 defaults 1 2\n",
"/dev/sdz1 /tmp/foo ext3 defaults 1 2\n"]
fstab_write = StringIO.new
- ::File.stub!(:readlines).with("/etc/fstab").and_return(fstab_read)
- ::File.stub!(:open).with("/etc/fstab", "w").and_yield(fstab_write)
+ ::File.stub(:readlines).with("/etc/fstab").and_return(fstab_read)
+ ::File.stub(:open).with("/etc/fstab", "w").and_yield(fstab_write)
@provider.disable_fs
fstab_write.string.should == "/dev/sdz1 /tmp/foo ext3 defaults 1 2\n/dev/sdy1 /tmp/foo ext3 defaults 1 2\n"
end
it "should not disable if enabled is false" do
- @current_resource.stub!(:enabled).and_return(false)
+ @current_resource.stub(:enabled).and_return(false)
- ::File.stub!(:readlines).with("/etc/fstab").and_return([])
+ ::File.stub(:readlines).with("/etc/fstab").and_return([])
::File.should_not_receive(:open).and_yield(@fstab)
@provider.disable_fs
diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb
index 4c9916ae87..5a5cda6d7a 100644
--- a/spec/unit/provider/mount/windows_spec.rb
+++ b/spec/unit/provider/mount/windows_spec.rb
@@ -40,12 +40,12 @@ describe Chef::Provider::Mount::Windows do
@new_resource = Chef::Resource::Mount.new("X:")
@new_resource.device GUID
@current_resource = Chef::Resource::Mount.new("X:")
- Chef::Resource::Mount.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Mount.stub(:new).and_return(@current_resource)
@net_use = mock("Chef::Util::Windows::NetUse")
- Chef::Util::Windows::NetUse.stub!(:new).and_return(@net_use)
+ Chef::Util::Windows::NetUse.stub(:new).and_return(@net_use)
@vol = mock("Chef::Util::Windows::Volume")
- Chef::Util::Windows::Volume.stub!(:new).and_return(@vol)
+ Chef::Util::Windows::Volume.stub(:new).and_return(@vol)
@provider = Chef::Provider::Mount::Windows.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
@@ -53,13 +53,13 @@ describe Chef::Provider::Mount::Windows do
describe "when loading the current resource" do
it "should set mounted true if the mount point is found" do
- @vol.stub!(:device).and_return(@new_resource.device)
+ @vol.stub(:device).and_return(@new_resource.device)
@current_resource.should_receive(:mounted).with(true)
@provider.load_current_resource
end
it "should set mounted false if the mount point is not found" do
- @vol.stub!(:device).and_raise(ArgumentError)
+ @vol.stub(:device).and_raise(ArgumentError)
@current_resource.should_receive(:mounted).with(false)
@provider.load_current_resource
end
@@ -67,8 +67,8 @@ describe Chef::Provider::Mount::Windows do
describe "with a local device" do
before do
@new_resource.device GUID
- @vol.stub!(:device).and_return(@new_resource.device)
- @net_use.stub!(:device).and_raise(ArgumentError)
+ @vol.stub(:device).and_return(@new_resource.device)
+ @net_use.stub(:device).and_raise(ArgumentError)
end
it "should determine the device is a volume GUID" do
@@ -80,8 +80,8 @@ describe Chef::Provider::Mount::Windows do
describe "with a remote device" do
before do
@new_resource.device REMOTE
- @net_use.stub!(:device).and_return(@new_resource.device)
- @vol.stub!(:device).and_raise(ArgumentError)
+ @net_use.stub(:device).and_return(@new_resource.device)
+ @vol.stub(:device).and_raise(ArgumentError)
end
it "should determine the device is remote" do
@@ -93,8 +93,8 @@ describe Chef::Provider::Mount::Windows do
describe "when mounting a file system" do
before do
@new_resource.device GUID
- @vol.stub!(:add)
- @vol.stub!(:device).and_raise(ArgumentError)
+ @vol.stub(:add)
+ @vol.stub(:device).and_raise(ArgumentError)
@provider.load_current_resource
end
@@ -108,7 +108,7 @@ describe Chef::Provider::Mount::Windows do
it "should not mount the filesystem if it is mounted" do
@vol.should_not_receive(:add)
- @current_resource.stub!(:mounted).and_return(true)
+ @current_resource.stub(:mounted).and_return(true)
@provider.mount_fs
end
end
@@ -116,19 +116,19 @@ describe Chef::Provider::Mount::Windows do
describe "when unmounting a file system" do
before do
@new_resource.device GUID
- @vol.stub!(:delete)
- @vol.stub!(:device).and_raise(ArgumentError)
+ @vol.stub(:delete)
+ @vol.stub(:device).and_raise(ArgumentError)
@provider.load_current_resource
end
it "should umount the filesystem if it is mounted" do
- @current_resource.stub!(:mounted).and_return(true)
+ @current_resource.stub(:mounted).and_return(true)
@vol.should_receive(:delete)
@provider.umount_fs
end
it "should not umount the filesystem if it is not mounted" do
- @current_resource.stub!(:mounted).and_return(false)
+ @current_resource.stub(:mounted).and_return(false)
@vol.should_not_receive(:delete)
@provider.umount_fs
end
diff --git a/spec/unit/provider/mount_spec.rb b/spec/unit/provider/mount_spec.rb
index 451ab30a0e..d9bfeb3e0f 100644
--- a/spec/unit/provider/mount_spec.rb
+++ b/spec/unit/provider/mount_spec.rb
@@ -43,14 +43,14 @@ describe Chef::Provider::Mount do
describe "when the target state is a mounted filesystem" do
it "should mount the filesystem if it isn't mounted" do
- @current_resource.stub!(:mounted).and_return(false)
+ @current_resource.stub(:mounted).and_return(false)
@provider.should_receive(:mount_fs).with.and_return(true)
@provider.run_action(:mount)
@new_resource.should be_updated_by_last_action
end
it "should not mount the filesystem if it is mounted" do
- @current_resource.stub!(:mounted).and_return(true)
+ @current_resource.stub(:mounted).and_return(true)
@provider.should_not_receive(:mount_fs)
@provider.run_action(:mount)
@new_resource.should_not be_updated_by_last_action
@@ -60,14 +60,14 @@ describe Chef::Provider::Mount do
describe "when the target state is an unmounted filesystem" do
it "should umount the filesystem if it is mounted" do
- @current_resource.stub!(:mounted).and_return(true)
+ @current_resource.stub(:mounted).and_return(true)
@provider.should_receive(:umount_fs).with.and_return(true)
@provider.run_action(:umount)
@new_resource.should be_updated_by_last_action
end
it "should not umount the filesystem if it is not mounted" do
- @current_resource.stub!(:mounted).and_return(false)
+ @current_resource.stub(:mounted).and_return(false)
@provider.should_not_receive(:umount_fs)
@provider.run_action(:umount)
@new_resource.should_not be_updated_by_last_action
@@ -80,14 +80,14 @@ describe Chef::Provider::Mount do
end
it "should remount the filesystem if it is mounted" do
- @current_resource.stub!(:mounted).and_return(true)
+ @current_resource.stub(:mounted).and_return(true)
@provider.should_receive(:remount_fs).and_return(true)
@provider.run_action(:remount)
@new_resource.should be_updated_by_last_action
end
it "should not remount the filesystem if it is not mounted" do
- @current_resource.stub!(:mounted).and_return(false)
+ @current_resource.stub(:mounted).and_return(false)
@provider.should_not_receive(:remount_fs)
@provider.run_action(:remount)
@new_resource.should_not be_updated_by_last_action
@@ -107,7 +107,7 @@ describe Chef::Provider::Mount do
end
describe "when enabling the filesystem to be mounted" do
it "should enable the mount if it isn't enable" do
- @current_resource.stub!(:enabled).and_return(false)
+ @current_resource.stub(:enabled).and_return(false)
@provider.should_not_receive(:mount_options_unchanged?)
@provider.should_receive(:enable_fs).and_return(true)
@provider.run_action(:enable)
@@ -115,7 +115,7 @@ describe Chef::Provider::Mount do
end
it "should enable the mount if it is enabled and mount options have changed" do
- @current_resource.stub!(:enabled).and_return(true)
+ @current_resource.stub(:enabled).and_return(true)
@provider.should_receive(:mount_options_unchanged?).and_return(false)
@provider.should_receive(:enable_fs).and_return(true)
@provider.run_action(:enable)
@@ -123,7 +123,7 @@ describe Chef::Provider::Mount do
end
it "should not enable the mount if it is enabled and mount options have not changed" do
- @current_resource.stub!(:enabled).and_return(true)
+ @current_resource.stub(:enabled).and_return(true)
@provider.should_receive(:mount_options_unchanged?).and_return(true)
@provider.should_not_receive(:enable_fs)
@provider.run_action(:enable)
@@ -133,14 +133,14 @@ describe Chef::Provider::Mount do
describe "when the target state is to disable the mount" do
it "should disable the mount if it is enabled" do
- @current_resource.stub!(:enabled).and_return(true)
+ @current_resource.stub(:enabled).and_return(true)
@provider.should_receive(:disable_fs).with.and_return(true)
@provider.run_action(:disable)
@new_resource.should be_updated_by_last_action
end
it "should not disable the mount if it isn't enabled" do
- @current_resource.stub!(:enabled).and_return(false)
+ @current_resource.stub(:enabled).and_return(false)
@provider.should_not_receive(:disable_fs)
@provider.run_action(:disable)
@new_resource.should_not be_updated_by_last_action
diff --git a/spec/unit/provider/ohai_spec.rb b/spec/unit/provider/ohai_spec.rb
index 8402c92e97..8b8a6b5939 100644
--- a/spec/unit/provider/ohai_spec.rb
+++ b/spec/unit/provider/ohai_spec.rb
@@ -41,17 +41,17 @@ describe Chef::Provider::Ohai do
:newdata => "somevalue"
}
}
- mock_ohai.stub!(:all_plugins).and_return(true)
- mock_ohai.stub!(:require_plugin).and_return(true)
- mock_ohai.stub!(:data).and_return(mock_ohai[:data],
+ mock_ohai.stub(:all_plugins).and_return(true)
+ mock_ohai.stub(:require_plugin).and_return(true)
+ mock_ohai.stub(:data).and_return(mock_ohai[:data],
mock_ohai[:data2])
- Ohai::System.stub!(:new).and_return(mock_ohai)
- Chef::Platform.stub!(:find_platform_and_version).and_return({ "platform" => @platform,
+ Ohai::System.stub(:new).and_return(mock_ohai)
+ Chef::Platform.stub(:find_platform_and_version).and_return({ "platform" => @platform,
"platform_version" => @platform_version})
# Fake node with a dummy save
@node = Chef::Node.new
@node.name(@fqdn)
- @node.stub!(:save).and_return(@node)
+ @node.stub(:save).and_return(@node)
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::Ohai.new("ohai_reload")
diff --git a/spec/unit/provider/package/aix_spec.rb b/spec/unit/provider/package/aix_spec.rb
index 6e936156a0..83f4763664 100644
--- a/spec/unit/provider/package/aix_spec.rb
+++ b/spec/unit/provider/package/aix_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Provider::Package::Aix do
@new_resource.source("/tmp/samba.base")
@provider = Chef::Provider::Package::Aix.new(@new_resource, @run_context)
- ::File.stub!(:exists?).and_return(true)
+ ::File.stub(:exists?).and_return(true)
end
describe "assessing the current package status" do
@@ -40,20 +40,20 @@ describe Chef::Provider::Package::Aix do
end
it "should create a current resource with the name of new_resource" do
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
@provider.load_current_resource
@provider.current_resource.name.should == "samba.base"
end
it "should set the current resource bff package name to the new resource bff package name" do
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
@provider.load_current_resource
@provider.current_resource.package_name.should == "samba.base"
end
it "should raise an exception if a source is supplied but not found" do
- @provider.stub!(:popen4).and_return(@status)
- ::File.stub!(:exists?).and_return(false)
+ @provider.stub(:popen4).and_return(@status)
+ ::File.stub(:exists?).and_return(false)
@provider.define_resource_requirements
@provider.load_current_resource
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Package)
@@ -83,13 +83,13 @@ describe Chef::Provider::Package::Aix do
it "should raise an exception if the source is not set but we are installing" do
@new_resource = Chef::Resource::Package.new("samba.base")
@provider = Chef::Provider::Package::Aix.new(@new_resource, @run_context)
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
lambda { @provider.run_action(:install) }.should raise_error(Chef::Exceptions::Package)
end
it "should raise an exception if installp/lslpp fails to run" do
@status = mock("Status", :exitstatus => -1)
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package)
end
@@ -117,7 +117,7 @@ describe Chef::Provider::Package::Aix do
it "should throw and exception if the exitstatus is not 0" do
@status = mock("Status", :exitstatus => 1)
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
lambda { @provider.candidate_version }.should raise_error(Chef::Exceptions::Package)
end
@@ -142,7 +142,7 @@ describe Chef::Provider::Package::Aix do
end
it "should run installp with -eLogfile option." do
- @new_resource.stub!(:options).and_return("-e/tmp/installp.log")
+ @new_resource.stub(:options).and_return("-e/tmp/installp.log")
@provider.should_receive(:run_command_with_systems_locale).with({
:command => "installp -aYF -e/tmp/installp.log -d /tmp/samba.base samba.base"
})
@@ -159,7 +159,7 @@ describe Chef::Provider::Package::Aix do
end
it "should run installp -u -e/tmp/installp.log with options -e/tmp/installp.log" do
- @new_resource.stub!(:options).and_return("-e/tmp/installp.log")
+ @new_resource.stub(:options).and_return("-e/tmp/installp.log")
@provider.should_receive(:run_command_with_systems_locale).with({
:command => "installp -u -e/tmp/installp.log samba.base"
})
diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb
index 32b55163b4..5f0c823b7e 100644
--- a/spec/unit/provider/package/apt_spec.rb
+++ b/spec/unit/provider/package/apt_spec.rb
@@ -163,8 +163,8 @@ SHOWPKG_STDOUT
@new_resource = Chef::Resource::AptPackage.new("irssi", @run_context)
@provider = Chef::Provider::Package::Apt.new(@new_resource, @run_context)
- @new_resource.stub!(:default_release).and_return("lenny-backports")
- @new_resource.stub!(:provider).and_return("Chef::Provider::Package::Apt")
+ @new_resource.stub(:default_release).and_return("lenny-backports")
+ @new_resource.stub(:provider).and_return("Chef::Provider::Package::Apt")
@provider.should_receive(:shell_out!).with("apt-cache -o APT::Default-Release=lenny-backports policy irssi").and_return(@shell_out)
@provider.load_current_resource
end
@@ -256,7 +256,7 @@ SHOWPKG_STDOUT
describe "when preseeding a package" do
before(:each) do
- @provider.stub!(:get_preseed_file).and_return("/tmp/irssi-0.8.12-7.seed")
+ @provider.stub(:get_preseed_file).and_return("/tmp/irssi-0.8.12-7.seed")
end
it "should get the full path to the preseed response file" do
@@ -282,7 +282,7 @@ SHOWPKG_STDOUT
@provider.stub(:check_package_state)
@current_resource.version "0.8.11"
@new_resource.response_file "/tmp/file"
- @provider.stub!(:get_preseed_file).and_return(false)
+ @provider.stub(:get_preseed_file).and_return(false)
@provider.should_not_receive(:shell_out!)
@provider.run_action(:reconfig)
end
diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb
index 30021e31f3..03786ff00b 100644
--- a/spec/unit/provider/package/dpkg_spec.rb
+++ b/spec/unit/provider/package/dpkg_spec.rb
@@ -33,9 +33,9 @@ describe Chef::Provider::Package::Dpkg do
@status = mock("Status", :exitstatus => 0)
@stderr = StringIO.new
@pid = mock("PID")
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
- ::File.stub!(:exists?).and_return(true)
+ ::File.stub(:exists?).and_return(true)
end
describe "when loading the current resource state" do
@@ -48,14 +48,14 @@ describe Chef::Provider::Package::Dpkg do
it "should raise an exception if a source is supplied but not found" do
@provider.load_current_resource
@provider.define_resource_requirements
- ::File.stub!(:exists?).and_return(false)
+ ::File.stub(:exists?).and_return(false)
lambda { @provider.run_action(:install) }.should raise_error(Chef::Exceptions::Package)
end
describe 'gets the source package version from dpkg-deb' do
def check_version(version)
@stdout = StringIO.new("wget\t#{version}")
- @provider.stub!(:popen4).with("dpkg-deb -W #{@new_resource.source}").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).with("dpkg-deb -W #{@new_resource.source}").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@provider.current_resource.package_name.should == "wget"
@new_resource.version.should == version
@@ -76,7 +76,7 @@ describe Chef::Provider::Package::Dpkg do
it "gets the source package name from dpkg-deb correctly when the package name has `-', `+' or `.' characters" do
@stdout = StringIO.new("f.o.o-pkg++2\t1.11.4-1ubuntu1")
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@provider.current_resource.package_name.should == "f.o.o-pkg++2"
end
@@ -103,7 +103,7 @@ Config-Version: 1.11.4-1ubuntu1
Depends: libc6 (>= 2.8~20080505), libssl0.9.8 (>= 0.9.8f-5)
Conflicts: wget-ssl
DPKG_S
- @provider.stub!(:popen4).with("dpkg -s wget").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).with("dpkg -s wget").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@provider.current_resource.version.should == "1.11.4-1ubuntu1"
@@ -111,7 +111,7 @@ DPKG_S
it "should raise an exception if dpkg fails to run" do
@status = mock("Status", :exitstatus => -1)
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package)
end
end
@@ -158,7 +158,7 @@ DPKG_S
"DEBIAN_FRONTEND" => "noninteractive"
}
})
- @new_resource.stub!(:options).and_return("--force-yes")
+ @new_resource.stub(:options).and_return("--force-yes")
@provider.install_package("wget", "1.11.4-1ubuntu1")
end
@@ -186,7 +186,7 @@ DPKG_S
"DEBIAN_FRONTEND" => "noninteractive"
}
})
- @new_resource.stub!(:options).and_return("--force-yes")
+ @new_resource.stub(:options).and_return("--force-yes")
@provider.remove_package("wget", "1.11.4-1ubuntu1")
end
@@ -208,7 +208,7 @@ DPKG_S
"DEBIAN_FRONTEND" => "noninteractive"
}
})
- @new_resource.stub!(:options).and_return("--force-yes")
+ @new_resource.stub(:options).and_return("--force-yes")
@provider.purge_package("wget", "1.11.4-1ubuntu1")
end
diff --git a/spec/unit/provider/package/easy_install_spec.rb b/spec/unit/provider/package/easy_install_spec.rb
index 02f8399af8..8625619860 100644
--- a/spec/unit/provider/package/easy_install_spec.rb
+++ b/spec/unit/provider/package/easy_install_spec.rb
@@ -30,14 +30,14 @@ describe Chef::Provider::Package::EasyInstall do
@current_resource.version('1.8d')
@provider = Chef::Provider::Package::EasyInstall.new(@new_resource, @run_context)
- Chef::Resource::Package.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Package.stub(:new).and_return(@current_resource)
@stdin = StringIO.new
@stdout = StringIO.new
@status = mock("Status", :exitstatus => 0)
@stderr = StringIO.new
@pid = 2342
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
end
describe "easy_install_binary_path" do
@@ -47,7 +47,7 @@ describe Chef::Provider::Package::EasyInstall do
end
it "should set the current resources package name to the new resources package name" do
- $stdout.stub!(:write)
+ $stdout.stub(:write)
@current_resource.should_receive(:package_name).with(@new_resource.package_name)
@provider.load_current_resource
end
@@ -75,7 +75,7 @@ describe Chef::Provider::Package::EasyInstall do
@provider.should_receive(:run_command).with({
:command => "easy_install --always-unzip \"boto==1.8d\""
})
- @new_resource.stub!(:options).and_return("--always-unzip")
+ @new_resource.stub(:options).and_return("--always-unzip")
@provider.install_package("boto", "1.8d")
end
@@ -97,7 +97,7 @@ describe Chef::Provider::Package::EasyInstall do
@provider.should_receive(:run_command).with({
:command => "easy_install -x -m boto"
})
- @new_resource.stub!(:options).and_return("-x")
+ @new_resource.stub(:options).and_return("-x")
@provider.remove_package("boto", "1.8d")
end
diff --git a/spec/unit/provider/package/freebsd_spec.rb b/spec/unit/provider/package/freebsd_spec.rb
index 2901b84f49..037d559bc2 100644
--- a/spec/unit/provider/package/freebsd_spec.rb
+++ b/spec/unit/provider/package/freebsd_spec.rb
@@ -30,12 +30,12 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do
@provider = Chef::Provider::Package::Freebsd.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
- ::File.stub!(:exist?).with('/usr/ports/Makefile').and_return(false)
+ ::File.stub(:exist?).with('/usr/ports/Makefile').and_return(false)
end
describe "when determining the current package state" do
before do
- @provider.stub!(:ports_candidate_version).and_return("4.3.6")
+ @provider.stub(:ports_candidate_version).and_return("4.3.6")
end
it "should create a current resource with the name of the new_resource" do
@@ -79,14 +79,14 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do
pkg_info = OpenStruct.new(:stdout => "zsh-4.3.6_7")
@provider.should_receive(:shell_out!).with('pkg_info -E "zsh*"', :env => nil, :returns => [0,1]).and_return(pkg_info)
#@provider.should_receive(:popen4).with('pkg_info -E "zsh*"').and_yield(@pid, @stdin, ["zsh-4.3.6_7"], @stderr).and_return(@status)
- @provider.stub!(:package_name).and_return("zsh")
+ @provider.stub(:package_name).and_return("zsh")
@provider.current_installed_version.should == "4.3.6_7"
end
it "does not set the current version number when the package is not installed" do
pkg_info = OpenStruct.new(:stdout => "")
@provider.should_receive(:shell_out!).with('pkg_info -E "zsh*"', :env => nil, :returns => [0,1]).and_return(pkg_info)
- @provider.stub!(:package_name).and_return("zsh")
+ @provider.stub(:package_name).and_return("zsh")
@provider.current_installed_version.should be_nil
end
@@ -94,21 +94,21 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do
whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh")
@provider.should_receive(:shell_out!).with("whereis -s zsh", :env => nil).and_return(whereis)
#@provider.should_receive(:popen4).with("whereis -s zsh").and_yield(@pid, @stdin, ["zsh: /usr/ports/shells/zsh"], @stderr).and_return(@status)
- @provider.stub!(:port_name).and_return("zsh")
+ @provider.stub(:port_name).and_return("zsh")
@provider.port_path.should == "/usr/ports/shells/zsh"
end
# Not happy with the form of these tests as they are far too closely tied to the implementation and so very fragile.
it "should return the ports candidate version when given a valid port path" do
- @provider.stub!(:port_path).and_return("/usr/ports/shells/zsh")
+ @provider.stub(:port_path).and_return("/usr/ports/shells/zsh")
make_v = OpenStruct.new(:stdout => "4.3.6\n")
@provider.should_receive(:shell_out!).with("make -V PORTVERSION", {:cwd=>"/usr/ports/shells/zsh", :returns=>[0, 1], :env=>nil}).and_return(make_v)
@provider.ports_candidate_version.should == "4.3.6"
end
it "should figure out the package name when we have ports" do
- ::File.stub!(:exist?).with('/usr/ports/Makefile').and_return(true)
- @provider.stub!(:port_path).and_return("/usr/ports/shells/zsh")
+ ::File.stub(:exist?).with('/usr/ports/Makefile').and_return(true)
+ @provider.stub(:port_path).and_return("/usr/ports/shells/zsh")
make_v = OpenStruct.new(:stdout => "zsh-4.3.6_7\n")
@provider.should_receive(:shell_out!).with("make -V PKGNAME", {:cwd=>"/usr/ports/shells/zsh", :env=>nil, :returns=>[0, 1]}).and_return(make_v)
#@provider.should_receive(:ports_makefile_variable_value).with("PKGNAME").and_return("zsh-4.3.6_7")
@@ -121,9 +121,9 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do
@cmd_result = OpenStruct.new(:status => true)
@provider.current_resource = @current_resource
- @provider.stub!(:package_name).and_return("zsh")
- @provider.stub!(:latest_link_name).and_return("zsh")
- @provider.stub!(:port_path).and_return("/usr/ports/shells/zsh")
+ @provider.stub(:package_name).and_return("zsh")
+ @provider.stub(:latest_link_name).and_return("zsh")
+ @provider.stub(:port_path).and_return("/usr/ports/shells/zsh")
end
it "should run pkg_add -r with the package name" do
@@ -132,7 +132,7 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do
end
it "should run make install when installing from ports" do
- @new_resource.stub!(:source).and_return("ports")
+ @new_resource.stub(:source).and_return("ports")
@provider.should_not_receive(:shell_out!).with("make -DBATCH -f /usr/ports/shells/zsh/Makefile install", :timeout => 1200, :env=>nil)
@provider.should_receive(:shell_out!).with("make -DBATCH install", :timeout => 1200, :env=>nil, :cwd => @provider.port_path).and_return(@cmd_result)
@provider.install_package("zsh", "4.3.6_7")
@@ -177,9 +177,9 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do
@current_resource = Chef::Resource::Package.new("ruby-iconv")
@provider = Chef::Provider::Package::Freebsd.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
- @provider.stub!(:port_path).and_return("/usr/ports/converters/ruby-iconv")
- @provider.stub!(:package_name).and_return("ruby18-iconv")
- @provider.stub!(:latest_link_name).and_return("ruby18-iconv")
+ @provider.stub(:port_path).and_return("/usr/ports/converters/ruby-iconv")
+ @provider.stub(:package_name).and_return("ruby18-iconv")
+ @provider.stub(:latest_link_name).and_return("ruby18-iconv")
@install_result = OpenStruct.new(:status => true)
end
@@ -190,7 +190,7 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do
end
it "should run make install when installing from ports" do
- @new_resource.stub!(:source).and_return("ports")
+ @new_resource.stub(:source).and_return("ports")
@provider.should_receive(:shell_out!).with("make -DBATCH install", :timeout => 1200, :env=>nil, :cwd => @provider.port_path).and_return(@install_result)
@provider.install_package("ruby-iconv", "1.0")
end
@@ -202,7 +202,7 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do
@new_resource.version "4.3.6_7"
@current_resource.version "4.3.6_7"
@provider.current_resource = @current_resource
- @provider.stub!(:package_name).and_return("zsh")
+ @provider.stub(:package_name).and_return("zsh")
end
it "should run pkg_delete with the package name and version" do
@@ -227,14 +227,14 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do
it "should return the port path for a valid port name" do
whereis = OpenStruct.new(:stdout => "bonnie++: /usr/ports/benchmarks/bonnie++")
@provider.should_receive(:shell_out!).with("whereis -s bonnie++", :env => nil).and_return(whereis)
- @provider.stub!(:port_name).and_return("bonnie++")
+ @provider.stub(:port_name).and_return("bonnie++")
@provider.port_path.should == "/usr/ports/benchmarks/bonnie++"
end
it "should return the version number when it is installed" do
pkg_info = OpenStruct.new(:stdout => "bonnie++-1.96")
@provider.should_receive(:shell_out!).with('pkg_info -E "bonnie++*"', :env => nil, :returns => [0,1]).and_return(pkg_info)
- @provider.stub!(:package_name).and_return("bonnie++")
+ @provider.stub(:package_name).and_return("bonnie++")
@provider.current_installed_version.should == "1.96"
end
end
@@ -262,8 +262,8 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do
@current_resource = Chef::Resource::Package.new("perl5.8")
@provider = Chef::Provider::Package::Freebsd.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
- @provider.stub!(:package_name).and_return("perl")
- @provider.stub!(:latest_link_name).and_return("perl")
+ @provider.stub(:package_name).and_return("perl")
+ @provider.stub(:latest_link_name).and_return("perl")
cmd = OpenStruct.new(:status => true)
@provider.should_receive(:shell_out!).with("pkg_add -r perl", :env => nil).and_return(cmd)
@@ -276,8 +276,8 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do
@current_resource = Chef::Resource::Package.new("mysql50-server")
@provider = Chef::Provider::Package::Freebsd.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
- @provider.stub!(:package_name).and_return("mysql-server")
- @provider.stub!(:latest_link_name).and_return("mysql50-server")
+ @provider.stub(:package_name).and_return("mysql-server")
+ @provider.stub(:latest_link_name).and_return("mysql50-server")
cmd = OpenStruct.new(:status => true)
@provider.should_receive(:shell_out!).with("pkg_add -r mysql50-server", :env=>nil).and_return(cmd)
diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb
index 95839dbe89..53f8169623 100644
--- a/spec/unit/provider/package/ips_spec.rb
+++ b/spec/unit/provider/package/ips_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Provider::Package::Ips do
@run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::Package.new("crypto/gnupg", @run_context)
@current_resource = Chef::Resource::Package.new("crypto/gnupg", @run_context)
- Chef::Resource::Package.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Package.stub(:new).and_return(@current_resource)
@provider = Chef::Provider::Package::Ips.new(@new_resource, @run_context)
@stdin = StringIO.new
@@ -117,7 +117,7 @@ INSTALLED
@provider.should_receive(:run_command_with_systems_locale).with({
:command => "pkg --no-refresh install -q crypto/gnupg@2.0.17"
})
- @new_resource.stub!(:options).and_return("--no-refresh")
+ @new_resource.stub(:options).and_return("--no-refresh")
@provider.install_package("crypto/gnupg", "2.0.17")
end
@@ -168,7 +168,7 @@ PKG_STATUS
context "when accept_license is true" do
before do
- @new_resource.stub!(:accept_license).and_return(true)
+ @new_resource.stub(:accept_license).and_return(true)
end
it "should run pkg install with the --accept flag" do
@@ -202,7 +202,7 @@ PKG_STATUS
@provider.should_receive(:run_command_with_systems_locale).with({
:command => "pkg --no-refresh uninstall -q crypto/gnupg@2.0.17"
})
- @new_resource.stub!(:options).and_return("--no-refresh")
+ @new_resource.stub(:options).and_return("--no-refresh")
@provider.remove_package("crypto/gnupg", "2.0.17")
end
end
diff --git a/spec/unit/provider/package/macports_spec.rb b/spec/unit/provider/package/macports_spec.rb
index 2f0db3f7a8..79025f912b 100644
--- a/spec/unit/provider/package/macports_spec.rb
+++ b/spec/unit/provider/package/macports_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Provider::Package::Macports do
@current_resource = Chef::Resource::Package.new("zsh")
@provider = Chef::Provider::Package::Macports.new(@new_resource, @run_context)
- Chef::Resource::Package.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Package.stub(:new).and_return(@current_resource)
@status = mock("Status", :exitstatus => 0)
@stdin = StringIO.new
@@ -121,7 +121,7 @@ EOF
it "should add options to the port command when specified" do
@current_resource.should_receive(:version).and_return("4.1.6")
@provider.current_resource = @current_resource
- @new_resource.stub!(:options).and_return("-f")
+ @new_resource.stub(:options).and_return("-f")
@provider.should_receive(:run_command_with_systems_locale).with(:command => "port -f install zsh @4.2.7")
@provider.install_package("zsh", "4.2.7")
@@ -140,7 +140,7 @@ EOF
end
it "should add options to the port command when specified" do
- @new_resource.stub!(:options).and_return("-f")
+ @new_resource.stub(:options).and_return("-f")
@provider.should_receive(:run_command_with_systems_locale).with(:command => "port -f uninstall zsh @4.2.7")
@provider.purge_package("zsh", "4.2.7")
end
@@ -158,7 +158,7 @@ EOF
end
it "should add options to the port command when specified" do
- @new_resource.stub!(:options).and_return("-f")
+ @new_resource.stub(:options).and_return("-f")
@provider.should_receive(:run_command_with_systems_locale).with(:command => "port -f deactivate zsh @4.2.7")
@provider.remove_package("zsh", "4.2.7")
end
@@ -191,7 +191,7 @@ EOF
end
it "should add options to the port command when specified" do
- @new_resource.stub!(:options).and_return("-f")
+ @new_resource.stub(:options).and_return("-f")
@current_resource.should_receive(:version).at_least(:once).and_return("4.1.6")
@provider.current_resource = @current_resource
diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb
index 7e4abcb6d5..7dae87b799 100644
--- a/spec/unit/provider/package/pacman_spec.rb
+++ b/spec/unit/provider/package/pacman_spec.rb
@@ -28,8 +28,8 @@ describe Chef::Provider::Package::Pacman do
@status = mock("Status", :exitstatus => 0)
@provider = Chef::Provider::Package::Pacman.new(@new_resource, @run_context)
- Chef::Resource::Package.stub!(:new).and_return(@current_resource)
- @provider.stub!(:popen4).and_return(@status)
+ Chef::Resource::Package.stub(:new).and_return(@current_resource)
+ @provider.stub(:popen4).and_return(@status)
@stdin = StringIO.new
@stdout = StringIO.new(<<-ERR)
error: package "nano" not found
@@ -55,13 +55,13 @@ ERR
end
it "should read stdout on pacman" do
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@stdout.should_receive(:each).and_return(true)
@provider.load_current_resource
end
it "should set the installed version to nil on the current resource if pacman installed version not exists" do
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@current_resource.should_receive(:version).with(nil).and_return(true)
@provider.load_current_resource
end
@@ -88,17 +88,17 @@ Install Reason : Explicitly installed
Install Script : Yes
Description : Pico editor clone with enhancements
PACMAN
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@current_resource.version.should == "2.2.2-1"
end
it "should set the candidate version if pacman has one" do
- @stdout.stub!(:each).and_yield("core/nano 2.2.3-1 (base)").
+ @stdout.stub(:each).and_yield("core/nano 2.2.3-1 (base)").
and_yield(" Pico editor clone with enhancements").
and_yield("community/nanoblogger 3.4.1-1").
and_yield(" NanoBlogger is a small weblog engine written in Bash for the command line")
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@provider.candidate_version.should eql("2.2.3-1")
end
@@ -122,11 +122,11 @@ Include = /etc/pacman.d/mirrorlist
Include = /etc/pacman.d/mirrorlist
PACMAN_CONF
- ::File.stub!(:exists?).with("/etc/pacman.conf").and_return(true)
- ::File.stub!(:read).with("/etc/pacman.conf").and_return(@pacman_conf)
- @stdout.stub!(:each).and_yield("customrepo/nano 1.2.3-4").
+ ::File.stub(:exists?).with("/etc/pacman.conf").and_return(true)
+ ::File.stub(:read).with("/etc/pacman.conf").and_return(@pacman_conf)
+ @stdout.stub(:each).and_yield("customrepo/nano 1.2.3-4").
and_yield(" My custom package")
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@provider.candidate_version.should eql("1.2.3-4")
@@ -143,8 +143,8 @@ PACMAN_CONF
end
it "should raise an exception if pacman does not return a candidate version" do
- @stdout.stub!(:each).and_yield("")
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @stdout.stub(:each).and_yield("")
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
lambda { @provider.candidate_version }.should raise_error(Chef::Exceptions::Package)
end
@@ -165,7 +165,7 @@ PACMAN_CONF
@provider.should_receive(:run_command_with_systems_locale).with({
:command => "pacman --sync --noconfirm --noprogressbar --debug nano"
})
- @new_resource.stub!(:options).and_return("--debug")
+ @new_resource.stub(:options).and_return("--debug")
@provider.install_package("nano", "1.0")
end
@@ -190,7 +190,7 @@ PACMAN_CONF
@provider.should_receive(:run_command_with_systems_locale).with({
:command => "pacman --remove --noconfirm --noprogressbar --debug nano"
})
- @new_resource.stub!(:options).and_return("--debug")
+ @new_resource.stub(:options).and_return("--debug")
@provider.remove_package("nano", "1.0")
end
diff --git a/spec/unit/provider/package/portage_spec.rb b/spec/unit/provider/package/portage_spec.rb
index f44731b73a..684d776b37 100644
--- a/spec/unit/provider/package/portage_spec.rb
+++ b/spec/unit/provider/package/portage_spec.rb
@@ -27,70 +27,70 @@ describe Chef::Provider::Package::Portage, "load_current_resource" do
@current_resource = Chef::Resource::Package.new("dev-util/git")
@provider = Chef::Provider::Package::Portage.new(@new_resource, @run_context)
- Chef::Resource::Package.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Package.stub(:new).and_return(@current_resource)
end
describe "when determining the current state of the package" do
it "should create a current resource with the name of new_resource" do
- ::Dir.stub!(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0"])
+ ::Dir.stub(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0"])
Chef::Resource::Package.should_receive(:new).and_return(@current_resource)
@provider.load_current_resource
end
it "should set the current resource package name to the new resource package name" do
- ::Dir.stub!(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0"])
+ ::Dir.stub(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0"])
@current_resource.should_receive(:package_name).with(@new_resource.package_name)
@provider.load_current_resource
end
it "should return a current resource with the correct version if the package is found" do
- ::Dir.stub!(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/git-foobar-0.9", "/var/db/pkg/dev-util/git-1.0.0"])
+ ::Dir.stub(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/git-foobar-0.9", "/var/db/pkg/dev-util/git-1.0.0"])
@provider.load_current_resource
@provider.current_resource.version.should == "1.0.0"
end
it "should return a current resource with the correct version if the package is found with revision" do
- ::Dir.stub!(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0-r1"])
+ ::Dir.stub(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0-r1"])
@provider.load_current_resource
@provider.current_resource.version.should == "1.0.0-r1"
end
it "should return a current resource with a nil version if the package is not found" do
- ::Dir.stub!(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/notgit-1.0.0"])
+ ::Dir.stub(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/notgit-1.0.0"])
@provider.load_current_resource
@provider.current_resource.version.should be_nil
end
it "should return a package name match from /var/db/pkg/* if a category isn't specified and a match is found" do
- ::Dir.stub!(:[]).with("/var/db/pkg/*/git-*").and_return(["/var/db/pkg/dev-util/git-foobar-0.9", "/var/db/pkg/dev-util/git-1.0.0"])
+ ::Dir.stub(:[]).with("/var/db/pkg/*/git-*").and_return(["/var/db/pkg/dev-util/git-foobar-0.9", "/var/db/pkg/dev-util/git-1.0.0"])
@provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context)
@provider.load_current_resource
@provider.current_resource.version.should == "1.0.0"
end
it "should return a current resource with a nil version if a category isn't specified and a name match from /var/db/pkg/* is not found" do
- ::Dir.stub!(:[]).with("/var/db/pkg/*/git-*").and_return(["/var/db/pkg/dev-util/notgit-1.0.0"])
+ ::Dir.stub(:[]).with("/var/db/pkg/*/git-*").and_return(["/var/db/pkg/dev-util/notgit-1.0.0"])
@provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context)
@provider.load_current_resource
@provider.current_resource.version.should be_nil
end
it "should throw an exception if a category isn't specified and multiple packages are found" do
- ::Dir.stub!(:[]).with("/var/db/pkg/*/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0", "/var/db/pkg/funny-words/git-1.0.0"])
+ ::Dir.stub(:[]).with("/var/db/pkg/*/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0", "/var/db/pkg/funny-words/git-1.0.0"])
@provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context)
lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package)
end
it "should return a current resource with a nil version if a category is specified and multiple packages are found" do
- ::Dir.stub!(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0", "/var/db/pkg/funny-words/git-1.0.0"])
+ ::Dir.stub(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0", "/var/db/pkg/funny-words/git-1.0.0"])
@provider = Chef::Provider::Package::Portage.new(@new_resource, @run_context)
@provider.load_current_resource
@provider.current_resource.version.should be_nil
end
it "should return a current resource with a nil version if a category is not specified and multiple packages from the same category are found" do
- ::Dir.stub!(:[]).with("/var/db/pkg/*/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0", "/var/db/pkg/dev-util/git-1.0.1"])
+ ::Dir.stub(:[]).with("/var/db/pkg/*/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0", "/var/db/pkg/dev-util/git-1.0.1"])
@provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context)
@provider.load_current_resource
@provider.current_resource.version.should be_nil
@@ -108,7 +108,7 @@ describe Chef::Provider::Package::Portage, "load_current_resource" do
it "should throw an exception if the exitstatus is not 0" do
@status = mock("Status", :exitstatus => 1)
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
lambda { @provider.candidate_version }.should raise_error(Chef::Exceptions::Package)
end
@@ -295,7 +295,7 @@ EOF
@provider.should_receive(:run_command_with_systems_locale).with({
:command => "emerge -g --color n --nospinner --quiet --oneshot =dev-util/git-1.0.0"
})
- @new_resource.stub!(:options).and_return("--oneshot")
+ @new_resource.stub(:options).and_return("--oneshot")
@provider.install_package("dev-util/git", "1.0.0")
end
diff --git a/spec/unit/provider/package/rpm_spec.rb b/spec/unit/provider/package/rpm_spec.rb
index 86327be42b..ab8447b3e1 100644
--- a/spec/unit/provider/package/rpm_spec.rb
+++ b/spec/unit/provider/package/rpm_spec.rb
@@ -30,25 +30,25 @@ describe Chef::Provider::Package::Rpm do
@provider = Chef::Provider::Package::Rpm.new(@new_resource, @run_context)
@status = mock("Status", :exitstatus => 0)
- ::File.stub!(:exists?).and_return(true)
+ ::File.stub(:exists?).and_return(true)
end
describe "when determining the current state of the package" do
it "should create a current resource with the name of new_resource" do
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
@provider.load_current_resource
@provider.current_resource.name.should == "emacs"
end
it "should set the current reource package name to the new resource package name" do
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
@provider.load_current_resource
@provider.current_resource.package_name.should == 'emacs'
end
it "should raise an exception if a source is supplied but not found" do
- ::File.stub!(:exists?).and_return(false)
+ ::File.stub(:exists?).and_return(false)
lambda { @provider.run_action(:any) }.should raise_error(Chef::Exceptions::Package)
end
@@ -77,7 +77,7 @@ describe Chef::Provider::Package::Rpm do
it "should raise an exception if rpm fails to run" do
status = mock("Status", :exitstatus => -1)
- @provider.stub!(:popen4).and_return(status)
+ @provider.stub(:popen4).and_return(status)
lambda { @provider.run_action(:any) }.should raise_error(Chef::Exceptions::Package)
end
end
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index 7d0567314a..b6807f1b70 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -89,7 +89,7 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
it "finds a matching gem candidate version" do
dep = Gem::Dependency.new('rspec', '>= 0')
dep_installer = Gem::DependencyInstaller.new
- @gem_env.stub!(:dependency_installer).and_return(dep_installer)
+ @gem_env.stub(:dependency_installer).and_return(dep_installer)
latest = [[gemspec("rspec", Gem::Version.new("1.3.0")), "http://rubygems.org/"]]
dep_installer.should_receive(:find_gems_with_sources).with(dep).and_return(latest)
@gem_env.candidate_version_from_remote(Gem::Dependency.new('rspec', '>= 0')).should == Gem::Version.new('1.3.0')
@@ -98,7 +98,7 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
it "finds a matching gem candidate version on rubygems 2.0.0+" do
dep = Gem::Dependency.new('rspec', '>= 0')
dep_installer = Gem::DependencyInstaller.new
- @gem_env.stub!(:dependency_installer).and_return(dep_installer)
+ @gem_env.stub(:dependency_installer).and_return(dep_installer)
best_gem = mock("best gem match", :spec => gemspec("rspec", Gem::Version.new("1.3.0")), :source => "https://rubygems.org")
available_set = mock("Gem::AvailableSet test double")
available_set.should_receive(:pick_best!)
@@ -121,7 +121,7 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
Gem.const_set(:Format, Object.new)
@remove_gem_format = true
end
- Gem::Package.stub!(:respond_to?).with(:open).and_return(false)
+ Gem::Package.stub(:respond_to?).with(:open).and_return(false)
end
after do
@@ -142,7 +142,7 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
dep = Gem::Dependency.new('rspec', '>= 0')
latest = []
dep_installer = Gem::DependencyInstaller.new
- @gem_env.stub!(:dependency_installer).and_return(dep_installer)
+ @gem_env.stub(:dependency_installer).and_return(dep_installer)
dep_installer.should_receive(:find_gems_with_sources).with(dep).and_return(latest)
@gem_env.candidate_version_from_remote(Gem::Dependency.new('rspec', '>= 0')).should be_nil
end
@@ -159,7 +159,7 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
@gem_env.should_receive(:with_gem_sources).with('http://gems.example.com').and_yield
dep_installer = Gem::DependencyInstaller.new
- @gem_env.stub!(:dependency_installer).and_return(dep_installer)
+ @gem_env.stub(:dependency_installer).and_return(dep_installer)
dep_installer.should_receive(:find_gems_with_sources).with(dep).and_return(latest)
@gem_env.candidate_version_from_remote(Gem::Dependency.new('rspec', '>=0'), 'http://gems.example.com').should == Gem::Version.new('1.3.0')
end
@@ -230,7 +230,7 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do
end
it "builds the gems source index from the gem paths" do
- @gem_env.stub!(:gem_paths).and_return(['/path/to/gems', '/another/path/to/gems'])
+ @gem_env.stub(:gem_paths).and_return(['/path/to/gems', '/another/path/to/gems'])
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0')
@gem_env.gem_specification
Gem::Specification.dirs.should == [ '/path/to/gems/specifications', '/another/path/to/gems/specifications' ]
@@ -244,17 +244,17 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do
gems = [gemspec('rspec', Gem::Version.new('1.2.9')), gemspec('rspec', Gem::Version.new('1.3.0'))]
rspec_dep = Gem::Dependency.new('rspec', nil)
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0')
- @gem_env.stub!(:gem_specification).and_return(Gem::Specification)
+ @gem_env.stub(:gem_specification).and_return(Gem::Specification)
@gem_env.gem_specification.should_receive(:find_all_by_name).with(rspec_dep.name, rspec_dep.requirement).and_return(gems)
else
- @gem_env.stub!(:gem_source_index).and_return(Gem.source_index)
+ @gem_env.stub(:gem_source_index).and_return(Gem.source_index)
@gem_env.gem_source_index.should_receive(:search).with(rspec_dep).and_return(gems)
end
@gem_env.installed_versions(Gem::Dependency.new('rspec', nil)).should == gems
end
it "determines the installed versions of gems from the source index (part2: the unmockening)" do
- $stdout.stub!(:write)
+ $stdout.stub(:write)
path_to_gem = if windows?
`where gem`.split[1]
else
@@ -367,7 +367,7 @@ describe Chef::Provider::Package::Rubygems do
@run_context = Chef::RunContext.new(@node, {}, @events)
# We choose detect omnibus via RbConfig::CONFIG['bindir'] in Chef::Provider::Package::Rubygems.new
- RbConfig::CONFIG.stub!(:[]).with('bindir').and_return("/usr/bin/ruby")
+ RbConfig::CONFIG.stub(:[]).with('bindir').and_return("/usr/bin/ruby")
@provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context)
end
@@ -388,11 +388,11 @@ describe Chef::Provider::Package::Rubygems do
it "searches for a gem binary when running on Omnibus on Unix" do
platform_mock :unix do
- RbConfig::CONFIG.stub!(:[]).with('bindir').and_return("/opt/chef/embedded/bin")
- ENV.stub!(:[]).with('PATH').and_return("/usr/bin:/usr/sbin:/opt/chef/embedded/bin")
- File.stub!(:exists?).with('/usr/bin/gem').and_return(false)
- File.stub!(:exists?).with('/usr/sbin/gem').and_return(true)
- File.stub!(:exists?).with('/opt/chef/embedded/bin/gem').and_return(true) # should not get here
+ RbConfig::CONFIG.stub(:[]).with('bindir').and_return("/opt/chef/embedded/bin")
+ ENV.stub(:[]).with('PATH').and_return("/usr/bin:/usr/sbin:/opt/chef/embedded/bin")
+ File.stub(:exists?).with('/usr/bin/gem').and_return(false)
+ File.stub(:exists?).with('/usr/sbin/gem').and_return(true)
+ File.stub(:exists?).with('/opt/chef/embedded/bin/gem').and_return(true) # should not get here
provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context)
provider.gem_env.gem_binary_location.should == '/usr/sbin/gem'
end
@@ -400,13 +400,13 @@ describe Chef::Provider::Package::Rubygems do
it "searches for a gem binary when running on Omnibus on Windows" do
platform_mock :windows do
- RbConfig::CONFIG.stub!(:[]).with('bindir').and_return("d:/opscode/chef/embedded/bin")
- ENV.stub!(:[]).with('PATH').and_return('C:\windows\system32;C:\windows;C:\Ruby186\bin;d:\opscode\chef\embedded\bin')
- File.stub!(:exists?).with('C:\\windows\\system32\\gem').and_return(false)
- File.stub!(:exists?).with('C:\\windows\\gem').and_return(false)
- File.stub!(:exists?).with('C:\\Ruby186\\bin\\gem').and_return(true)
- File.stub!(:exists?).with('d:\\opscode\\chef\\bin\\gem').and_return(false) # should not get here
- File.stub!(:exists?).with('d:\\opscode\\chef\\embedded\\bin\\gem').and_return(false) # should not get here
+ RbConfig::CONFIG.stub(:[]).with('bindir').and_return("d:/opscode/chef/embedded/bin")
+ ENV.stub(:[]).with('PATH').and_return('C:\windows\system32;C:\windows;C:\Ruby186\bin;d:\opscode\chef\embedded\bin')
+ File.stub(:exists?).with('C:\\windows\\system32\\gem').and_return(false)
+ File.stub(:exists?).with('C:\\windows\\gem').and_return(false)
+ File.stub(:exists?).with('C:\\Ruby186\\bin\\gem').and_return(true)
+ File.stub(:exists?).with('d:\\opscode\\chef\\bin\\gem').and_return(false) # should not get here
+ File.stub(:exists?).with('d:\\opscode\\chef\\embedded\\bin\\gem').and_return(false) # should not get here
provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context)
provider.gem_env.gem_binary_location.should == 'C:\Ruby186\bin\gem'
end
@@ -475,7 +475,7 @@ describe Chef::Provider::Package::Rubygems do
@current_resource = Chef::Resource::GemPackage.new('rspec-core')
@provider.current_resource = @current_resource
@gem_dep = Gem::Dependency.new('rspec-core', @spec_version)
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
end
describe "in the current gem environment" do
@@ -508,7 +508,7 @@ describe Chef::Provider::Package::Rubygems do
# this catches 'gem_package "foo"' when "./foo" is a file in the cwd, and instead of installing './foo' it fetches the remote gem
it "installs the gem via the gems api, when the package has no file separator characters in it, but a matching file exists in cwd" do
- ::File.stub!(:exists?).and_return(true)
+ ::File.stub(:exists?).and_return(true)
@new_resource.package_name('rspec-core')
@provider.gem_env.should_receive(:install).with(@gem_dep, :sources => nil)
@provider.action_install.should be_true
diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb
index e5092f69d9..86ac159f69 100644
--- a/spec/unit/provider/package/smartos_spec.rb
+++ b/spec/unit/provider/package/smartos_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
@status = mock("Status", :exitstatus => 0)
@provider = Chef::Provider::Package::SmartOS.new(@new_resource, @run_context)
- Chef::Resource::Package.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Package.stub(:new).and_return(@current_resource)
@stdin = StringIO.new
@stdout = "varnish-2.1.5nb2\n"
@stderr = StringIO.new
diff --git a/spec/unit/provider/package/solaris_spec.rb b/spec/unit/provider/package/solaris_spec.rb
index dd7cea2aaa..be07eeb45f 100644
--- a/spec/unit/provider/package/solaris_spec.rb
+++ b/spec/unit/provider/package/solaris_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Provider::Package::Solaris do
@new_resource.source("/tmp/bash.pkg")
@provider = Chef::Provider::Package::Solaris.new(@new_resource, @run_context)
- ::File.stub!(:exists?).and_return(true)
+ ::File.stub(:exists?).and_return(true)
end
describe "assessing the current package status" do
@@ -50,20 +50,20 @@ PKGINFO
end
it "should create a current resource with the name of new_resource" do
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
@provider.load_current_resource
@provider.current_resource.name.should == "SUNWbash"
end
it "should set the current reource package name to the new resource package name" do
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
@provider.load_current_resource
@provider.current_resource.package_name.should == "SUNWbash"
end
it "should raise an exception if a source is supplied but not found" do
- @provider.stub!(:popen4).and_return(@status)
- ::File.stub!(:exists?).and_return(false)
+ @provider.stub(:popen4).and_return(@status)
+ ::File.stub(:exists?).and_return(false)
@provider.define_resource_requirements
@provider.load_current_resource
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Package)
@@ -93,13 +93,13 @@ PKGINFO
it "should raise an exception if the source is not set but we are installing" do
@new_resource = Chef::Resource::Package.new("SUNWbash")
@provider = Chef::Provider::Package::Solaris.new(@new_resource, @run_context)
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
lambda { @provider.run_action(:install) }.should raise_error(Chef::Exceptions::Package)
end
it "should raise an exception if pkginfo fails to run" do
@status = mock("Status", :exitstatus => -1)
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package)
end
@@ -121,14 +121,14 @@ PKGINFO
it "should lookup the candidate_version if the variable is not already set" do
@status = mock("Status", :exitstatus => 0)
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
@provider.should_receive(:popen4)
@provider.candidate_version
end
it "should throw and exception if the exitstatus is not 0" do
@status = mock("Status", :exitstatus => 1)
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
lambda { @provider.candidate_version }.should raise_error(Chef::Exceptions::Package)
end
@@ -153,7 +153,7 @@ PKGINFO
end
it "should run pkgadd -n -a /tmp/myadmin -d with the package options -a /tmp/myadmin" do
- @new_resource.stub!(:options).and_return("-a /tmp/myadmin")
+ @new_resource.stub(:options).and_return("-a /tmp/myadmin")
@provider.should_receive(:run_command_with_systems_locale).with({
:command => "pkgadd -n -a /tmp/myadmin -d /tmp/bash.pkg all"
})
@@ -170,7 +170,7 @@ PKGINFO
end
it "should run pkgrm -n -a /tmp/myadmin with options -a /tmp/myadmin" do
- @new_resource.stub!(:options).and_return("-a /tmp/myadmin")
+ @new_resource.stub(:options).and_return("-a /tmp/myadmin")
@provider.should_receive(:run_command_with_systems_locale).with({
:command => "pkgrm -n -a /tmp/myadmin SUNWbash"
})
diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb
index d2674f523d..0e417aae0d 100644
--- a/spec/unit/provider/package/yum_spec.rb
+++ b/spec/unit/provider/package/yum_spec.rb
@@ -37,7 +37,7 @@ describe Chef::Provider::Package::Yum do
:package_repository => "base",
:disable_extra_repo_control => true
)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@pid = mock("PID")
end
@@ -54,7 +54,7 @@ describe Chef::Provider::Package::Yum do
end
it "should set the installed version to nil on the current resource if no installed package" do
- @yum_cache.stub!(:installed_version).and_return(nil)
+ @yum_cache.stub(:installed_version).and_return(nil)
@provider.load_current_resource
@provider.current_resource.version.should be_nil
end
@@ -79,11 +79,11 @@ describe Chef::Provider::Package::Yum do
@yum_cache = mock(
'Chef::Provider::Yum::YumCache'
)
- @yum_cache.stub!(:installed_version) do |package_name, arch|
+ @yum_cache.stub(:installed_version) do |package_name, arch|
# nothing installed for package_name/new_package_name
nil
end
- @yum_cache.stub!(:candidate_version) do |package_name, arch|
+ @yum_cache.stub(:candidate_version) do |package_name, arch|
if package_name == "testing.noarch" || package_name == "testing.more.noarch"
nil
# candidate for new_package_name
@@ -91,9 +91,9 @@ describe Chef::Provider::Package::Yum do
"1.1"
end
end
- @yum_cache.stub!(:package_available?).and_return(true)
- @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ @yum_cache.stub(:package_available?).and_return(true)
+ @yum_cache.stub(:disable_extra_repo_control).and_return(true)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
@provider.new_resource.package_name.should == "testing"
@@ -113,7 +113,7 @@ describe Chef::Provider::Package::Yum do
@yum_cache = mock(
'Chef::Provider::Yum::YumCache'
)
- @yum_cache.stub!(:installed_version) do |package_name, arch|
+ @yum_cache.stub(:installed_version) do |package_name, arch|
# installed for package_name
if package_name == "testing.beta3" || package_name == "testing.beta3.more"
"1.1"
@@ -121,13 +121,13 @@ describe Chef::Provider::Package::Yum do
nil
end
end
- @yum_cache.stub!(:candidate_version) do |package_name, arch|
+ @yum_cache.stub(:candidate_version) do |package_name, arch|
# no candidate for package_name/new_package_name
nil
end
- @yum_cache.stub!(:package_available?).and_return(true)
- @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ @yum_cache.stub(:package_available?).and_return(true)
+ @yum_cache.stub(:disable_extra_repo_control).and_return(true)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
# annoying side effect of the fun stub'ing above
@provider.load_current_resource
@@ -148,17 +148,17 @@ describe Chef::Provider::Package::Yum do
@yum_cache = mock(
'Chef::Provider::Yum::YumCache'
)
- @yum_cache.stub!(:installed_version) do |package_name, arch|
+ @yum_cache.stub(:installed_version) do |package_name, arch|
# nothing installed for package_name/new_package_name
nil
end
- @yum_cache.stub!(:candidate_version) do |package_name, arch|
+ @yum_cache.stub(:candidate_version) do |package_name, arch|
# no candidate for package_name/new_package_name
nil
end
- @yum_cache.stub!(:package_available?).and_return(true)
- @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ @yum_cache.stub(:package_available?).and_return(true)
+ @yum_cache.stub(:disable_extra_repo_control).and_return(true)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
@provider.new_resource.package_name.should == "testing.beta3"
@@ -179,11 +179,11 @@ describe Chef::Provider::Package::Yum do
@yum_cache = mock(
'Chef::Provider::Yum::YumCache'
)
- @yum_cache.stub!(:installed_version) do |package_name, arch|
+ @yum_cache.stub(:installed_version) do |package_name, arch|
# nothing installed for package_name/new_package_name
nil
end
- @yum_cache.stub!(:candidate_version) do |package_name, arch|
+ @yum_cache.stub(:candidate_version) do |package_name, arch|
if package_name == "testing.noarch"
nil
# candidate for new_package_name
@@ -191,9 +191,9 @@ describe Chef::Provider::Package::Yum do
"1.1"
end
end.and_return("something")
- @yum_cache.stub!(:package_available?).and_return(true)
- @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ @yum_cache.stub(:package_available?).and_return(true)
+ @yum_cache.stub(:disable_extra_repo_control).and_return(true)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
@provider.new_resource.package_name.should == "testing.i386"
@@ -202,31 +202,31 @@ describe Chef::Provider::Package::Yum do
end
it "should flush the cache if :before is true" do
- @new_resource.stub!(:flush_cache).and_return({:after => false, :before => true})
+ @new_resource.stub(:flush_cache).and_return({:after => false, :before => true})
@yum_cache.should_receive(:reload).once
@provider.load_current_resource
end
it "should flush the cache if :before is false" do
- @new_resource.stub!(:flush_cache).and_return({:after => false, :before => false})
+ @new_resource.stub(:flush_cache).and_return({:after => false, :before => false})
@yum_cache.should_not_receive(:reload)
@provider.load_current_resource
end
it "should detect --enablerepo or --disablerepo when passed among options, collect them preserving order and notify the yum cache" do
- @new_resource.stub!(:options).and_return("--stuff --enablerepo=foo --otherthings --disablerepo=a,b,c --enablerepo=bar")
+ @new_resource.stub(:options).and_return("--stuff --enablerepo=foo --otherthings --disablerepo=a,b,c --enablerepo=bar")
@yum_cache.should_receive(:enable_extra_repo_control).with("--enablerepo=foo --disablerepo=a,b,c --enablerepo=bar")
@provider.load_current_resource
end
it "should let the yum cache know extra repos are disabled if --enablerepo or --disablerepo aren't among options" do
- @new_resource.stub!(:options).and_return("--stuff --otherthings")
+ @new_resource.stub(:options).and_return("--stuff --otherthings")
@yum_cache.should_receive(:disable_extra_repo_control)
@provider.load_current_resource
end
it "should let the yum cache know extra repos are disabled if options aren't set" do
- @new_resource.stub!(:options).and_return(nil)
+ @new_resource.stub(:options).and_return(nil)
@yum_cache.should_receive(:disable_extra_repo_control)
@provider.load_current_resource
end
@@ -242,7 +242,7 @@ describe Chef::Provider::Package::Yum do
:version_available? => true,
:disable_extra_repo_control => true
)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
pkg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "1.2.4-11.18.el5", "x86_64", [])
@yum_cache.should_receive(:packages_from_require).and_return([pkg])
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -261,7 +261,7 @@ describe Chef::Provider::Package::Yum do
:version_available? => true,
:disable_extra_repo_control => true
)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
pkg_x = Chef::Provider::Package::Yum::RPMPackage.new("test-package-x", "1.2.4-11.18.el5", "x86_64", [])
pkg_y = Chef::Provider::Package::Yum::RPMPackage.new("test-package-y", "1.2.6-11.3.el5", "i386", [])
@yum_cache.should_receive(:packages_from_require).and_return([pkg_x, pkg_y])
@@ -282,7 +282,7 @@ describe Chef::Provider::Package::Yum do
:version_available? => true,
:disable_extra_repo_control => true
)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
@yum_cache.should_receive(:packages_from_require).twice.and_return([])
@yum_cache.should_receive(:reload_provides)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -300,7 +300,7 @@ describe Chef::Provider::Package::Yum do
:version_available? => true,
:disable_extra_repo_control => true
)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@yum_cache.should_receive(:packages_from_require).once.and_return([])
@yum_cache.should_not_receive(:reload_provides)
@@ -324,7 +324,7 @@ describe Chef::Provider::Package::Yum do
:version_available? => true,
:disable_extra_repo_control => true
)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
@yum_cache.should_receive(:packages_from_require).twice.and_return([])
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
@@ -335,7 +335,7 @@ describe Chef::Provider::Package::Yum do
describe "when installing a package" do
it "should run yum install with the package name and version" do
@provider.load_current_resource
- Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
+ Chef::Provider::Package::Yum::RPMUtils.stub(:rpmvercmp).and_return(-1)
@provider.should_receive(:yum_command).with(
"yum -d0 -e0 -y install emacs-1.0"
)
@@ -343,7 +343,7 @@ describe Chef::Provider::Package::Yum do
end
it "should run yum localinstall if given a path to an rpm" do
- @new_resource.stub!(:source).and_return("/tmp/emacs-21.4-20.el5.i386.rpm")
+ @new_resource.stub(:source).and_return("/tmp/emacs-21.4-20.el5.i386.rpm")
@provider.should_receive(:yum_command).with(
"yum -d0 -e0 -y localinstall /tmp/emacs-21.4-20.el5.i386.rpm"
)
@@ -352,7 +352,7 @@ describe Chef::Provider::Package::Yum do
it "should run yum localinstall if given a path to an rpm as the package" do
@new_resource = Chef::Resource::Package.new("/tmp/emacs-21.4-20.el5.i386.rpm")
- ::File.stub!(:exists?).and_return(true)
+ ::File.stub(:exists?).and_return(true)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@new_resource.source.should == "/tmp/emacs-21.4-20.el5.i386.rpm"
@provider.should_receive(:yum_command).with(
@@ -363,8 +363,8 @@ describe Chef::Provider::Package::Yum do
it "should run yum install with the package name, version and arch" do
@provider.load_current_resource
- @new_resource.stub!(:arch).and_return("i386")
- Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
+ @new_resource.stub(:arch).and_return("i386")
+ Chef::Provider::Package::Yum::RPMUtils.stub(:rpmvercmp).and_return(-1)
@provider.should_receive(:yum_command).with(
"yum -d0 -e0 -y install emacs-21.4-20.el5.i386"
)
@@ -374,8 +374,8 @@ describe Chef::Provider::Package::Yum do
it "installs the package with the options given in the resource" do
@provider.load_current_resource
@provider.candidate_version = '11'
- @new_resource.stub!(:options).and_return("--disablerepo epmd")
- Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
+ @new_resource.stub(:options).and_return("--disablerepo epmd")
+ Chef::Provider::Package::Yum::RPMUtils.stub(:rpmvercmp).and_return(-1)
@provider.should_receive(:yum_command).with(
"yum -d0 -e0 -y --disablerepo epmd install cups-11"
)
@@ -393,13 +393,13 @@ describe Chef::Provider::Package::Yum do
:version_available? => nil,
:disable_extra_repo_control => true
)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
lambda { @provider.install_package("lolcats", "0.99") }.should raise_error(Chef::Exceptions::Package, %r{Version .* not found})
end
it "should raise an exception if candidate version is older than the installed version and allow_downgrade is false" do
- @new_resource.stub!(:allow_downgrade).and_return(false)
+ @new_resource.stub(:allow_downgrade).and_return(false)
@yum_cache = mock(
'Chef::Provider::Yum::YumCache',
:reload_installed => true,
@@ -411,7 +411,7 @@ describe Chef::Provider::Package::Yum do
:allow_multi_install => [ "kernel" ],
:disable_extra_repo_control => true
)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
lambda { @provider.install_package("cups", "1.2.4-11.15.el5") }.should raise_error(Chef::Exceptions::Package, %r{is newer than candidate package})
@@ -430,7 +430,7 @@ describe Chef::Provider::Package::Yum do
:package_repository => "base",
:disable_extra_repo_control => true
)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
@provider.should_receive(:yum_command).with(
@@ -440,7 +440,7 @@ describe Chef::Provider::Package::Yum do
end
it "should run yum downgrade if candidate version is older than the installed version and allow_downgrade is true" do
- @new_resource.stub!(:allow_downgrade).and_return(true)
+ @new_resource.stub(:allow_downgrade).and_return(true)
@yum_cache = mock(
'Chef::Provider::Yum::YumCache',
:reload_installed => true,
@@ -453,7 +453,7 @@ describe Chef::Provider::Package::Yum do
:package_repository => "base",
:disable_extra_repo_control => true
)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
@provider.should_receive(:yum_command).with(
@@ -463,9 +463,9 @@ describe Chef::Provider::Package::Yum do
end
it "should run yum install then flush the cache if :after is true" do
- @new_resource.stub!(:flush_cache).and_return({:after => true, :before => false})
+ @new_resource.stub(:flush_cache).and_return({:after => true, :before => false})
@provider.load_current_resource
- Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
+ Chef::Provider::Package::Yum::RPMUtils.stub(:rpmvercmp).and_return(-1)
@provider.should_receive(:yum_command).with(
"yum -d0 -e0 -y install emacs-1.0"
)
@@ -474,9 +474,9 @@ describe Chef::Provider::Package::Yum do
end
it "should run yum install then not flush the cache if :after is false" do
- @new_resource.stub!(:flush_cache).and_return({:after => false, :before => false})
+ @new_resource.stub(:flush_cache).and_return({:after => false, :before => false})
@provider.load_current_resource
- Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
+ Chef::Provider::Package::Yum::RPMUtils.stub(:rpmvercmp).and_return(-1)
@provider.should_receive(:yum_command).with(
"yum -d0 -e0 -y install emacs-1.0"
)
@@ -489,7 +489,7 @@ describe Chef::Provider::Package::Yum do
it "should run yum install if the package is installed and a version is given" do
@provider.load_current_resource
@provider.candidate_version = '11'
- Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
+ Chef::Provider::Package::Yum::RPMUtils.stub(:rpmvercmp).and_return(-1)
@provider.should_receive(:yum_command).with(
"yum -d0 -e0 -y install cups-11"
)
@@ -500,7 +500,7 @@ describe Chef::Provider::Package::Yum do
@provider.load_current_resource
@current_resource = Chef::Resource::Package.new('cups')
@provider.candidate_version = '11'
- Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
+ Chef::Provider::Package::Yum::RPMUtils.stub(:rpmvercmp).and_return(-1)
@provider.should_receive(:yum_command).with(
"yum -d0 -e0 -y install cups-11"
)
@@ -519,7 +519,7 @@ describe Chef::Provider::Package::Yum do
:allow_multi_install => [ "kernel" ],
:disable_extra_repo_control => true
)
- Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
+ Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
lambda { @provider.upgrade_package("cups", "1.2.4-11.15.el5") }.should raise_error(Chef::Exceptions::Package, %r{is newer than candidate package})
@@ -527,7 +527,7 @@ describe Chef::Provider::Package::Yum do
# Test our little workaround, some crossover into Chef::Provider::Package territory
it "should call action_upgrade in the parent if the current resource version is nil" do
- @yum_cache.stub!(:installed_version).and_return(nil)
+ @yum_cache.stub(:installed_version).and_return(nil)
@provider.load_current_resource
@current_resource = Chef::Resource::Package.new('cups')
@provider.candidate_version = '11'
@@ -558,7 +558,7 @@ describe Chef::Provider::Package::Yum do
end
it "should not call action_upgrade in the parent if the candidate is older" do
- @yum_cache.stub!(:installed_version).and_return("12")
+ @yum_cache.stub(:installed_version).and_return("12")
@provider.load_current_resource
@current_resource = Chef::Resource::Package.new('cups')
@provider.candidate_version = '11'
@@ -576,7 +576,7 @@ describe Chef::Provider::Package::Yum do
end
it "should run yum remove with the package name and arch" do
- @new_resource.stub!(:arch).and_return("x86_64")
+ @new_resource.stub(:arch).and_return("x86_64")
@provider.should_receive(:yum_command).with(
"yum -d0 -e0 -y remove emacs-1.0.x86_64"
)
@@ -596,7 +596,7 @@ describe Chef::Provider::Package::Yum do
describe "when running yum" do
it "should run yum once if it exits with a return code of 0" do
@status = mock("Status", :exitstatus => 0)
- @provider.stub!(:output_of_command).and_return([@status, "", ""])
+ @provider.stub(:output_of_command).and_return([@status, "", ""])
@provider.should_receive(:output_of_command).once.with(
"yum -d0 -e0 -y install emacs-1.0",
{:timeout => Chef::Config[:yum_timeout]}
@@ -606,7 +606,7 @@ describe Chef::Provider::Package::Yum do
it "should run yum once if it exits with a return code > 0 and no scriptlet failures" do
@status = mock("Status", :exitstatus => 2)
- @provider.stub!(:output_of_command).and_return([@status, "failure failure", "problem problem"])
+ @provider.stub(:output_of_command).and_return([@status, "failure failure", "problem problem"])
@provider.should_receive(:output_of_command).once.with(
"yum -d0 -e0 -y install emacs-1.0",
{:timeout => Chef::Config[:yum_timeout]}
@@ -616,7 +616,7 @@ describe Chef::Provider::Package::Yum do
it "should run yum once if it exits with a return code of 1 and %pre scriptlet failures" do
@status = mock("Status", :exitstatus => 1)
- @provider.stub!(:output_of_command).and_return([@status, "error: %pre(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", ""])
+ @provider.stub(:output_of_command).and_return([@status, "error: %pre(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", ""])
@provider.should_receive(:output_of_command).once.with(
"yum -d0 -e0 -y install emacs-1.0",
{:timeout => Chef::Config[:yum_timeout]}
@@ -627,7 +627,7 @@ describe Chef::Provider::Package::Yum do
it "should run yum twice if it exits with a return code of 1 and %post scriptlet failures" do
@status = mock("Status", :exitstatus => 1)
- @provider.stub!(:output_of_command).and_return([@status, "error: %post(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", ""])
+ @provider.stub(:output_of_command).and_return([@status, "error: %post(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", ""])
@provider.should_receive(:output_of_command).twice.with(
"yum -d0 -e0 -y install emacs-1.0",
{:timeout => Chef::Config[:yum_timeout]}
@@ -1592,7 +1592,7 @@ EOF
Chef::Provider::Package::Yum::YumCache.reset_instance
@yc = Chef::Provider::Package::Yum::YumCache.instance
# load valid data
- @yc.stub!(:shell_out!).and_return(@status)
+ @yc.stub(:shell_out!).and_return(@status)
end
describe "initialize" do
@@ -1643,28 +1643,28 @@ EOF
it "should warn about invalid data with too many separators" do
@status = mock("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_bad_separators, :stderr => @stderr)
- @yc.stub!(:shell_out!).and_return(@status)
+ @yc.stub(:shell_out!).and_return(@status)
Chef::Log.should_receive(:warn).exactly(3).times.with(%r{Problem parsing})
@yc.refresh
end
it "should warn about invalid data with an incorrect type" do
@status = mock("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_bad_type, :stderr => @stderr)
- @yc.stub!(:shell_out!).and_return(@status)
+ @yc.stub(:shell_out!).and_return(@status)
Chef::Log.should_receive(:warn).exactly(2).times.with(%r{Problem parsing})
@yc.refresh
end
it "should warn about no output from yum-dump.py" do
@status = mock("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_no_output, :stderr => @stderr)
- @yc.stub!(:shell_out!).and_return(@status)
+ @yc.stub(:shell_out!).and_return(@status)
Chef::Log.should_receive(:warn).exactly(1).times.with(%r{no output from yum-dump.py})
@yc.refresh
end
it "should raise exception yum-dump.py exits with a non zero status" do
@status = mock("Status", :exitstatus => 1, :stdin => @stdin, :stdout => @stdout_no_output, :stderr => @stderr)
- @yc.stub!(:shell_out!).and_return(@status)
+ @yc.stub(:shell_out!).and_return(@status)
lambda { @yc.refresh}.should raise_error(Chef::Exceptions::Package, %r{CentOS-Base.repo, line: 12})
end
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index cf0193993d..63f235a05c 100644
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -30,12 +30,12 @@ describe Chef::Provider::Package::Zypper do
@status = mock("Status", :exitstatus => 0)
@provider = Chef::Provider::Package::Zypper.new(@new_resource, @run_context)
- Chef::Resource::Package.stub!(:new).and_return(@current_resource)
- @provider.stub!(:popen4).and_return(@status)
+ Chef::Resource::Package.stub(:new).and_return(@current_resource)
+ @provider.stub(:popen4).and_return(@status)
@stderr = StringIO.new
@stdout = StringIO.new
@pid = mock("PID")
- @provider.stub!(:`).and_return("2.0")
+ @provider.stub(:`).and_return("2.0")
end
describe "when loading the current package state" do
@@ -55,14 +55,14 @@ describe Chef::Provider::Package::Zypper do
end
it "should set the installed version to nil on the current resource if zypper info installed version is (none)" do
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@current_resource.should_receive(:version).with(nil).and_return(true)
@provider.load_current_resource
end
it "should set the installed version if zypper info has one" do
@stdout = StringIO.new("Version: 1.0\nInstalled: Yes\n")
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@current_resource.should_receive(:version).with("1.0").and_return(true)
@provider.load_current_resource
end
@@ -70,7 +70,7 @@ describe Chef::Provider::Package::Zypper do
it "should set the candidate version if zypper info has one" do
@stdout = StringIO.new("Version: 1.0\nInstalled: No\nStatus: out-of-date (version 0.9 installed)")
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@provider.candidate_version.should eql("1.0")
end
@@ -191,7 +191,7 @@ describe Chef::Provider::Package::Zypper do
describe "on an older zypper" do
before(:each) do
- @provider.stub!(:`).and_return("0.11.6")
+ @provider.stub(:`).and_return("0.11.6")
end
describe "install_package" do
diff --git a/spec/unit/provider/package_spec.rb b/spec/unit/provider/package_spec.rb
index f80eed17bd..33b4f8186a 100644
--- a/spec/unit/provider/package_spec.rb
+++ b/spec/unit/provider/package_spec.rb
@@ -34,7 +34,7 @@ describe Chef::Provider::Package do
describe "when installing a package" do
before(:each) do
@provider.current_resource = @current_resource
- @provider.stub!(:install_package).and_return(true)
+ @provider.stub(:install_package).and_return(true)
end
it "should raise a Chef::Exceptions::Package if no version is specified, and no candidate is available" do
@@ -81,7 +81,7 @@ describe Chef::Provider::Package do
it "should install the package at the version specified if a different version is installed" do
@new_resource.version("1.0")
- @current_resource.stub!(:version).and_return("0.99")
+ @current_resource.stub(:version).and_return("0.99")
@provider.should_receive(:install_package).with(
@new_resource.name,
@new_resource.version
@@ -107,7 +107,7 @@ describe Chef::Provider::Package do
it "should call the candidate_version accessor only once if the package is already installed and no version is specified" do
@current_resource.version("1.0")
- @provider.stub!(:candidate_version).and_return("1.0")
+ @provider.stub(:candidate_version).and_return("1.0")
@provider.run_action(:install)
end
@@ -126,7 +126,7 @@ describe Chef::Provider::Package do
describe "when upgrading the package" do
before(:each) do
- @provider.stub!(:upgrade_package).and_return(true)
+ @provider.stub(:upgrade_package).and_return(true)
end
it "should upgrade the package if the current version is not the candidate version" do
@@ -151,14 +151,14 @@ describe Chef::Provider::Package do
end
it "should print the word 'uninstalled' if there was no original version" do
- @current_resource.stub!(:version).and_return(nil)
+ @current_resource.stub(:version).and_return(nil)
Chef::Log.should_receive(:info).with("package[emacs] upgraded from uninstalled to 1.0")
@provider.run_action(:upgrade)
@new_resource.should be_updated_by_last_action
end
it "should raise a Chef::Exceptions::Package if current version and candidate are nil" do
- @current_resource.stub!(:version).and_return(nil)
+ @current_resource.stub(:version).and_return(nil)
@provider.candidate_version = nil
lambda { @provider.run_action(:upgrade) }.should raise_error(Chef::Exceptions::Package)
end
@@ -174,7 +174,7 @@ describe Chef::Provider::Package do
describe "When removing the package" do
before(:each) do
- @provider.stub!(:remove_package).and_return(true)
+ @provider.stub(:remove_package).and_return(true)
@current_resource.version '1.4.2'
end
@@ -204,7 +204,7 @@ describe Chef::Provider::Package do
it "should not remove the package if it is not installed" do
@provider.should_not_receive(:remove_package)
- @current_resource.stub!(:version).and_return(nil)
+ @current_resource.stub(:version).and_return(nil)
@provider.run_action(:remove)
@new_resource.should_not be_updated_by_last_action
end
@@ -218,7 +218,7 @@ describe Chef::Provider::Package do
describe "When purging the package" do
before(:each) do
- @provider.stub!(:purge_package).and_return(true)
+ @provider.stub(:purge_package).and_return(true)
@current_resource.version '1.4.2'
end
@@ -264,15 +264,15 @@ describe Chef::Provider::Package do
describe "when reconfiguring the package" do
before(:each) do
- @provider.stub!(:reconfig_package).and_return(true)
+ @provider.stub(:reconfig_package).and_return(true)
end
it "should info log, reconfigure the package and update the resource" do
- @current_resource.stub!(:version).and_return('1.0')
- @new_resource.stub!(:response_file).and_return(true)
+ @current_resource.stub(:version).and_return('1.0')
+ @new_resource.stub(:response_file).and_return(true)
@provider.should_receive(:get_preseed_file).and_return('/var/cache/preseed-test')
- @provider.stub!(:preseed_package).and_return(true)
- @provider.stub!(:reconfig_package).and_return(true)
+ @provider.stub(:preseed_package).and_return(true)
+ @provider.stub(:reconfig_package).and_return(true)
Chef::Log.should_receive(:info).with("package[emacs] reconfigured")
@provider.should_receive(:reconfig_package)
@provider.run_action(:reconfig)
@@ -281,7 +281,7 @@ describe Chef::Provider::Package do
end
it "should debug log and not reconfigure the package if the package is not installed" do
- @current_resource.stub!(:version).and_return(nil)
+ @current_resource.stub(:version).and_return(nil)
Chef::Log.should_receive(:debug).with("package[emacs] is NOT installed - nothing to do")
@provider.should_not_receive(:reconfig_package)
@provider.run_action(:reconfig)
@@ -289,8 +289,8 @@ describe Chef::Provider::Package do
end
it "should debug log and not reconfigure the package if no response_file is given" do
- @current_resource.stub!(:version).and_return('1.0')
- @new_resource.stub!(:response_file).and_return(nil)
+ @current_resource.stub(:version).and_return('1.0')
+ @new_resource.stub(:response_file).and_return(nil)
Chef::Log.should_receive(:debug).with("package[emacs] no response_file provided - nothing to do")
@provider.should_not_receive(:reconfig_package)
@provider.run_action(:reconfig)
@@ -298,10 +298,10 @@ describe Chef::Provider::Package do
end
it "should debug log and not reconfigure the package if the response_file has not changed" do
- @current_resource.stub!(:version).and_return('1.0')
- @new_resource.stub!(:response_file).and_return(true)
+ @current_resource.stub(:version).and_return('1.0')
+ @new_resource.stub(:response_file).and_return(true)
@provider.should_receive(:get_preseed_file).and_return(false)
- @provider.stub!(:preseed_package).and_return(false)
+ @provider.stub(:preseed_package).and_return(false)
Chef::Log.should_receive(:debug).with("package[emacs] preseeding has not changed - nothing to do")
@provider.should_not_receive(:reconfig_package)
@provider.run_action(:reconfig)
@@ -362,7 +362,7 @@ describe Chef::Provider::Package do
end
it "sets the preseed resource's runcontext to its own run context" do
- Chef::FileCache.stub!(:create_cache_path).and_return("/tmp/preseed/java")
+ Chef::FileCache.stub(:create_cache_path).and_return("/tmp/preseed/java")
@provider.preseed_resource('java', '6').run_context.should_not be_nil
@provider.preseed_resource('java', '6').run_context.should equal(@provider.run_context)
end
diff --git a/spec/unit/provider/registry_key_spec.rb b/spec/unit/provider/registry_key_spec.rb
index 2f6f8179e6..f88d4c0a87 100644
--- a/spec/unit/provider/registry_key_spec.rb
+++ b/spec/unit/provider/registry_key_spec.rb
@@ -38,9 +38,9 @@ describe Chef::Provider::RegistryKey do
@provider = Chef::Provider::RegistryKey.new(@new_resource, @run_context)
- @provider.stub!(:running_on_windows!).and_return(true)
+ @provider.stub(:running_on_windows!).and_return(true)
@double_registry = double(Chef::Win32::Registry)
- @provider.stub!(:registry).and_return(@double_registry)
+ @provider.stub(:registry).and_return(@double_registry)
end
describe "when first created" do
diff --git a/spec/unit/provider/remote_file/content_spec.rb b/spec/unit/provider/remote_file/content_spec.rb
index 36ecfe1c8d..00999fc307 100644
--- a/spec/unit/provider/remote_file/content_spec.rb
+++ b/spec/unit/provider/remote_file/content_spec.rb
@@ -47,8 +47,8 @@ describe Chef::Provider::RemoteFile::Content do
describe "when the checksum of the current_resource matches the checksum set on the resource" do
before do
- new_resource.stub!(:checksum).and_return("0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa")
- current_resource.stub!(:checksum).and_return("0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa")
+ new_resource.stub(:checksum).and_return("0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa")
+ current_resource.stub(:checksum).and_return("0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa")
end
it "should return nil for the tempfile" do
@@ -62,8 +62,8 @@ describe Chef::Provider::RemoteFile::Content do
describe "when the checksum of the current_resource is a partial match for the checksum set on the resource" do
before do
- new_resource.stub!(:checksum).and_return("0fd012fd")
- current_resource.stub!(:checksum).and_return("0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa")
+ new_resource.stub(:checksum).and_return("0fd012fd")
+ current_resource.stub(:checksum).and_return("0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa")
end
it "should return nil for the tempfile" do
@@ -119,24 +119,24 @@ describe Chef::Provider::RemoteFile::Content do
describe "when the current_resource checksum is nil" do
before do
- new_resource.stub!(:checksum).and_return("fd012fd")
- current_resource.stub!(:checksum).and_return(nil)
+ new_resource.stub(:checksum).and_return("fd012fd")
+ current_resource.stub(:checksum).and_return(nil)
end
it_behaves_like "the resource needs fetching"
end
describe "when the new_resource checksum is nil" do
before do
- new_resource.stub!(:checksum).and_return(nil)
- current_resource.stub!(:checksum).and_return("0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa")
+ new_resource.stub(:checksum).and_return(nil)
+ current_resource.stub(:checksum).and_return("0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa")
end
it_behaves_like "the resource needs fetching"
end
describe "when the checksums are a partial match, but not to the leading portion" do
before do
- new_resource.stub!(:checksum).and_return("fd012fd")
- current_resource.stub!(:checksum).and_return("0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa")
+ new_resource.stub(:checksum).and_return("fd012fd")
+ current_resource.stub(:checksum).and_return("0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa")
end
it_behaves_like "the resource needs fetching"
end
@@ -144,8 +144,8 @@ describe Chef::Provider::RemoteFile::Content do
describe "when the fetcher throws an exception" do
before do
- new_resource.stub!(:checksum).and_return(nil)
- current_resource.stub!(:checksum).and_return(nil)
+ new_resource.stub(:checksum).and_return(nil)
+ current_resource.stub(:checksum).and_return(nil)
@uri = mock("URI")
URI.should_receive(:parse).with(new_resource.source[0]).and_return(@uri)
http_fetcher = mock("Chef::Provider::RemoteFile::HTTP")
@@ -162,8 +162,8 @@ describe Chef::Provider::RemoteFile::Content do
let(:source) { [ "http://opscode.com/seattle.txt", "http://opscode.com/nyc.txt" ] }
before do
- new_resource.stub!(:checksum).and_return(nil)
- current_resource.stub!(:checksum).and_return(nil)
+ new_resource.stub(:checksum).and_return(nil)
+ current_resource.stub(:checksum).and_return(nil)
@uri0 = mock("URI0")
@uri1 = mock("URI1")
URI.should_receive(:parse).with(new_resource.source[0]).and_return(@uri0)
@@ -205,8 +205,8 @@ describe Chef::Provider::RemoteFile::Content do
describe "when there is an array of sources and the first succeeds" do
let(:source) { [ "http://opscode.com/seattle.txt", "http://opscode.com/nyc.txt" ] }
before do
- new_resource.stub!(:checksum).and_return(nil)
- current_resource.stub!(:checksum).and_return(nil)
+ new_resource.stub(:checksum).and_return(nil)
+ current_resource.stub(:checksum).and_return(nil)
@uri0 = mock("URI0")
URI.should_receive(:parse).with(new_resource.source[0]).and_return(@uri0)
URI.should_not_receive(:parse).with(new_resource.source[1])
diff --git a/spec/unit/provider/remote_file/ftp_spec.rb b/spec/unit/provider/remote_file/ftp_spec.rb
index 8dd1ef248e..524405bb06 100644
--- a/spec/unit/provider/remote_file/ftp_spec.rb
+++ b/spec/unit/provider/remote_file/ftp_spec.rb
@@ -39,13 +39,13 @@ describe Chef::Provider::RemoteFile::FTP do
let(:ftp) do
ftp = mock(Net::FTP, { })
- ftp.stub!(:connect)
- ftp.stub!(:login)
- ftp.stub!(:voidcmd)
- ftp.stub!(:mtime).and_return(Time.now)
- ftp.stub!(:getbinaryfile)
- ftp.stub!(:close)
- ftp.stub!(:passive=)
+ ftp.stub(:connect)
+ ftp.stub(:login)
+ ftp.stub(:voidcmd)
+ ftp.stub(:mtime).and_return(Time.now)
+ ftp.stub(:getbinaryfile)
+ ftp.stub(:close)
+ ftp.stub(:passive=)
ftp
end
@@ -60,8 +60,8 @@ describe Chef::Provider::RemoteFile::FTP do
let(:uri) { URI.parse("ftp://opscode.com/seattle.txt") }
before(:each) do
- Net::FTP.stub!(:new).with().and_return(ftp)
- Tempfile.stub!(:new).and_return(tempfile)
+ Net::FTP.stub(:new).with().and_return(ftp)
+ Tempfile.stub(:new).and_return(tempfile)
end
describe "when first created" do
diff --git a/spec/unit/provider/remote_file/http_spec.rb b/spec/unit/provider/remote_file/http_spec.rb
index e763a60e6f..4411bff9cf 100644
--- a/spec/unit/provider/remote_file/http_spec.rb
+++ b/spec/unit/provider/remote_file/http_spec.rb
@@ -165,8 +165,8 @@ describe Chef::Provider::RemoteFile::HTTP do
let(:rest) do
rest = mock(Chef::HTTP::Simple)
- rest.stub!(:streaming_request).and_return(tempfile)
- rest.stub!(:last_response).and_return(last_response)
+ rest.stub(:streaming_request).and_return(tempfile)
+ rest.stub(:last_response).and_return(last_response)
rest
end
diff --git a/spec/unit/provider/route_spec.rb b/spec/unit/provider/route_spec.rb
index 863f12641c..2a6d48c79e 100644
--- a/spec/unit/provider/route_spec.rb
+++ b/spec/unit/provider/route_spec.rb
@@ -55,13 +55,13 @@ describe Chef::Provider::Route do
routing_table = "Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT\n" +
"eth0 0064A8C0 0984A8C0 0003 0 0 0 00FFFFFF 0 0 0\n"
route_file = StringIO.new(routing_table)
- File.stub!(:open).with("/proc/net/route", "r").and_return(route_file)
+ File.stub(:open).with("/proc/net/route", "r").and_return(route_file)
end
it "should set is_running to false when a route is not detected" do
resource = Chef::Resource::Route.new('10.10.10.0/24')
- resource.stub!(:gateway).and_return("10.0.0.1")
- resource.stub!(:device).and_return("eth0")
+ resource.stub(:gateway).and_return("10.0.0.1")
+ resource.stub(:device).and_return("eth0")
provider = Chef::Provider::Route.new(resource, @run_context)
provider.load_current_resource
@@ -70,8 +70,8 @@ describe Chef::Provider::Route do
it "should detect existing routes and set is_running attribute correctly" do
resource = Chef::Resource::Route.new('192.168.100.0/24')
- resource.stub!(:gateway).and_return("192.168.132.9")
- resource.stub!(:device).and_return("eth0")
+ resource.stub(:gateway).and_return("192.168.132.9")
+ resource.stub(:device).and_return("eth0")
provider = Chef::Provider::Route.new(resource, @run_context)
provider.load_current_resource
@@ -80,8 +80,8 @@ describe Chef::Provider::Route do
it "should use gateway value when matching routes" do
resource = Chef::Resource::Route.new('192.168.100.0/24')
- resource.stub!(:gateway).and_return("10.10.10.10")
- resource.stub!(:device).and_return("eth0")
+ resource.stub(:gateway).and_return("10.10.10.10")
+ resource.stub(:device).and_return("eth0")
provider = Chef::Provider::Route.new(resource, @run_context)
provider.load_current_resource
@@ -92,8 +92,8 @@ describe Chef::Provider::Route do
describe Chef::Provider::Route, "action_add" do
it "should add the route if it does not exist" do
- @provider.stub!(:run_command).and_return(true)
- @current_resource.stub!(:gateway).and_return(nil)
+ @provider.stub(:run_command).and_return(true)
+ @current_resource.stub(:gateway).and_return(nil)
@provider.should_receive(:generate_command).once.with(:add)
@provider.should_receive(:generate_config)
@provider.run_action(:add)
@@ -101,8 +101,8 @@ describe Chef::Provider::Route do
end
it "should not add the route if it exists" do
- @provider.stub!(:run_command).and_return(true)
- @provider.stub!(:is_running).and_return(true)
+ @provider.stub(:run_command).and_return(true)
+ @provider.stub(:is_running).and_return(true)
@provider.should_not_receive(:generate_command).with(:add)
@provider.should_receive(:generate_config)
@provider.run_action(:add)
@@ -116,7 +116,7 @@ describe Chef::Provider::Route do
File.should_receive(:new).and_return(route_file)
@resource_add = Chef::Resource::Route.new('192.168.1.0/24 via 192.168.0.1')
@run_context.resource_collection << @resource_add
- @provider.stub!(:run_command).and_return(true)
+ @provider.stub(:run_command).and_return(true)
@resource_add.action(:add)
@provider.run_action(:add)
@@ -127,16 +127,16 @@ describe Chef::Provider::Route do
describe Chef::Provider::Route, "action_delete" do
it "should delete the route if it exists" do
- @provider.stub!(:run_command).and_return(true)
+ @provider.stub(:run_command).and_return(true)
@provider.should_receive(:generate_command).once.with(:delete)
- @provider.stub!(:is_running).and_return(true)
+ @provider.stub(:is_running).and_return(true)
@provider.run_action(:delete)
@new_resource.should be_updated
end
it "should not delete the route if it does not exist" do
- @current_resource.stub!(:gateway).and_return(nil)
- @provider.stub!(:run_command).and_return(true)
+ @current_resource.stub(:gateway).and_return(nil)
+ @provider.stub(:run_command).and_return(true)
@provider.should_not_receive(:generate_command).with(:add)
@provider.run_action(:delete)
@new_resource.should_not be_updated
@@ -145,12 +145,12 @@ describe Chef::Provider::Route do
describe Chef::Provider::Route, "generate_command for action_add" do
it "should include a netmask when a one is specified" do
- @new_resource.stub!(:netmask).and_return('255.255.0.0')
+ @new_resource.stub(:netmask).and_return('255.255.0.0')
@provider.generate_command(:add).should match(/\/\d{1,2}\s/)
end
it "should not include a netmask when a one is specified" do
- @new_resource.stub!(:netmask).and_return(nil)
+ @new_resource.stub(:netmask).and_return(nil)
@provider.generate_command(:add).should_not match(/\/\d{1,2}\s/)
end
@@ -159,19 +159,19 @@ describe Chef::Provider::Route do
end
it "should not include ' via $gateway ' when a gateway is not specified" do
- @new_resource.stub!(:gateway).and_return(nil)
+ @new_resource.stub(:gateway).and_return(nil)
@provider.generate_command(:add).should_not match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}\s/)
end
end
describe Chef::Provider::Route, "generate_command for action_delete" do
it "should include a netmask when a one is specified" do
- @new_resource.stub!(:netmask).and_return('255.255.0.0')
+ @new_resource.stub(:netmask).and_return('255.255.0.0')
@provider.generate_command(:delete).should match(/\/\d{1,2}\s/)
end
it "should not include a netmask when a one is specified" do
- @new_resource.stub!(:netmask).and_return(nil)
+ @new_resource.stub(:netmask).and_return(nil)
@provider.generate_command(:delete).should_not match(/\/\d{1,2}\s/)
end
@@ -180,14 +180,14 @@ describe Chef::Provider::Route do
end
it "should not include ' via $gateway ' when a gateway is not specified" do
- @new_resource.stub!(:gateway).and_return(nil)
+ @new_resource.stub(:gateway).and_return(nil)
@provider.generate_command(:delete).should_not match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}\s/)
end
end
describe Chef::Provider::Route, "config_file_contents for action_add" do
it "should include a netmask when a one is specified" do
- @new_resource.stub!(:netmask).and_return('255.255.0.0')
+ @new_resource.stub(:netmask).and_return('255.255.0.0')
@provider.config_file_contents(:add, { :target => @new_resource.target, :netmask => @new_resource.netmask}).should match(/\/\d{1,2}.*\n$/)
end
diff --git a/spec/unit/provider/script_spec.rb b/spec/unit/provider/script_spec.rb
index 5111a94578..d072eddd04 100644
--- a/spec/unit/provider/script_spec.rb
+++ b/spec/unit/provider/script_spec.rb
@@ -30,9 +30,9 @@ describe Chef::Provider::Script, "action_run" do
@provider = Chef::Provider::Script.new(@new_resource, @run_context)
@script_file = StringIO.new
- @script_file.stub!(:path).and_return('/tmp/the_script_file')
+ @script_file.stub(:path).and_return('/tmp/the_script_file')
- @provider.stub!(:shell_out!).and_return(true)
+ @provider.stub(:shell_out!).and_return(true)
end
it "creates a temporary file to store the script" do
@@ -48,15 +48,15 @@ describe Chef::Provider::Script, "action_run" do
it "sets the owner and group for the script file" do
@new_resource.user 'toor'
@new_resource.group 'wheel'
- @provider.stub!(:script_file).and_return(@script_file)
+ @provider.stub(:script_file).and_return(@script_file)
FileUtils.should_receive(:chown).with('toor', 'wheel', "/tmp/the_script_file")
@provider.set_owner_and_group
end
context "with the script file set to the correct owner and group" do
before do
- @provider.stub!(:set_owner_and_group)
- @provider.stub!(:script_file).and_return(@script_file)
+ @provider.stub(:set_owner_and_group)
+ @provider.stub(:script_file).and_return(@script_file)
end
describe "when writing the script to the file" do
it "should put the contents of the script in the temp file" do
diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb
index 0865fdae86..cb0ea50e09 100644
--- a/spec/unit/provider/service/arch_service_spec.rb
+++ b/spec/unit/provider/service/arch_service_spec.rb
@@ -39,8 +39,8 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
@provider = Chef::Provider::Service::Arch.new(@new_resource, @run_context)
- ::File.stub!(:exists?).with("/etc/rc.conf").and_return(true)
- ::File.stub!(:read).with("/etc/rc.conf").and_return("DAEMONS=(network apache sshd)")
+ ::File.stub(:exists?).with("/etc/rc.conf").and_return(true)
+ ::File.stub(:read).with("/etc/rc.conf").and_return("DAEMONS=(network apache sshd)")
end
describe "when first created" do
@@ -63,19 +63,19 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
end
it "should set running to true if the status command returns 0" do
- @provider.stub!(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0))
+ @provider.stub(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0))
@provider.load_current_resource
@provider.current_resource.running.should be_true
end
it "should set running to false if the status command returns anything except 0" do
- @provider.stub!(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 1))
+ @provider.stub(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 1))
@provider.load_current_resource
@provider.current_resource.running.should be_false
end
it "should set running to false if the status command raises" do
- @provider.stub!(:shell_out).with("/etc/rc.d/chef status").and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ @provider.stub(:shell_out).with("/etc/rc.d/chef status").and_raise(Mixlib::ShellOut::ShellCommandFailed)
@provider.load_current_resource
@provider.current_resource.running.should be_false
end
@@ -111,12 +111,12 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
it "should fail if file /etc/rc.conf does not exist" do
- ::File.stub!(:exists?).with("/etc/rc.conf").and_return(false)
+ ::File.stub(:exists?).with("/etc/rc.conf").and_return(false)
lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Service)
end
it "should fail if file /etc/rc.conf does not contain DAEMONS array" do
- ::File.stub!(:read).with("/etc/rc.conf").and_return("")
+ ::File.stub(:read).with("/etc/rc.conf").and_return("")
lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Service)
end
@@ -128,7 +128,7 @@ aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb
DEFAULT_PS
@status = mock("Status", :exitstatus => 0, :stdout => @stdout)
- @provider.stub!(:shell_out!).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
@node.automatic_attrs[:command] = {:ps => "ps -ef"}
end
@@ -138,19 +138,19 @@ DEFAULT_PS
aj 7842 5057 0 21:26 pts/2 00:00:06 chef
aj 7842 5057 0 21:26 pts/2 00:00:06 poos
RUNNING_PS
- @status.stub!(:stdout).and_return(@stdout)
+ @status.stub(:stdout).and_return(@stdout)
@provider.load_current_resource
@provider.current_resource.running.should be_true
end
it "determines the service is not running when it does not appear in ps" do
- @provider.stub!(:shell_out!).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
@provider.load_current_resource
@provider.current_resource.running.should be_false
end
it "should raise an exception if ps fails" do
- @provider.stub!(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ @provider.stub(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
@provider.load_current_resource
@provider.action = :start
@provider.define_resource_requirements
@@ -159,7 +159,7 @@ RUNNING_PS
end
it "should return existing entries in DAEMONS array" do
- ::File.stub!(:read).with("/etc/rc.conf").and_return("DAEMONS=(network !apache ssh)")
+ ::File.stub(:read).with("/etc/rc.conf").and_return("DAEMONS=(network !apache ssh)")
@provider.daemons.should == ['network', '!apache', 'ssh']
end
@@ -177,14 +177,14 @@ RUNNING_PS
# :service_name => "chef",
# :running => false
# )
- # @new_resource.stub!(:start_command).and_return(false)
+ # @new_resource.stub(:start_command).and_return(false)
#
# @provider = Chef::Provider::Service::Arch.new(@node, @new_resource)
- # Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ # Chef::Resource::Service.stub(:new).and_return(@current_resource)
# end
it "should add chef to DAEMONS array" do
- ::File.stub!(:read).with("/etc/rc.conf").and_return("DAEMONS=(network)")
+ ::File.stub(:read).with("/etc/rc.conf").and_return("DAEMONS=(network)")
@provider.should_receive(:update_daemons).with(['network', 'chef'])
@provider.enable_service()
end
@@ -198,14 +198,14 @@ RUNNING_PS
# :service_name => "chef",
# :running => false
# )
- # @new_resource.stub!(:start_command).and_return(false)
+ # @new_resource.stub(:start_command).and_return(false)
#
# @provider = Chef::Provider::Service::Arch.new(@node, @new_resource)
- # Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ # Chef::Resource::Service.stub(:new).and_return(@current_resource)
# end
it "should remove chef from DAEMONS array" do
- ::File.stub!(:read).with("/etc/rc.conf").and_return("DAEMONS=(network chef)")
+ ::File.stub(:read).with("/etc/rc.conf").and_return("DAEMONS=(network chef)")
@provider.should_receive(:update_daemons).with(['network', '!chef'])
@provider.disable_service()
end
@@ -220,14 +220,14 @@ RUNNING_PS
# :service_name => "chef",
# :running => false
# )
- # @new_resource.stub!(:start_command).and_return(false)
+ # @new_resource.stub(:start_command).and_return(false)
#
# @provider = Chef::Provider::Service::Arch.new(@node, @new_resource)
- # Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ # Chef::Resource::Service.stub(:new).and_return(@current_resource)
# end
it "should call the start command if one is specified" do
- @new_resource.stub!(:start_command).and_return("/etc/rc.d/chef startyousillysally")
+ @new_resource.stub(:start_command).and_return("/etc/rc.d/chef startyousillysally")
@provider.should_receive(:shell_out!).with("/etc/rc.d/chef startyousillysally")
@provider.start_service()
end
@@ -246,14 +246,14 @@ RUNNING_PS
# :service_name => "chef",
# :running => false
# )
- # @new_resource.stub!(:stop_command).and_return(false)
+ # @new_resource.stub(:stop_command).and_return(false)
#
# @provider = Chef::Provider::Service::Arch.new(@node, @new_resource)
- # Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ # Chef::Resource::Service.stub(:new).and_return(@current_resource)
# end
it "should call the stop command if one is specified" do
- @new_resource.stub!(:stop_command).and_return("/etc/rc.d/chef itoldyoutostop")
+ @new_resource.stub(:stop_command).and_return("/etc/rc.d/chef itoldyoutostop")
@provider.should_receive(:shell_out!).with("/etc/rc.d/chef itoldyoutostop")
@provider.stop_service()
end
@@ -272,21 +272,21 @@ RUNNING_PS
# :service_name => "chef",
# :running => false
# )
- # @new_resource.stub!(:restart_command).and_return(false)
- # @new_resource.stub!(:supports).and_return({:restart => false})
+ # @new_resource.stub(:restart_command).and_return(false)
+ # @new_resource.stub(:supports).and_return({:restart => false})
#
# @provider = Chef::Provider::Service::Arch.new(@node, @new_resource)
- # Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ # Chef::Resource::Service.stub(:new).and_return(@current_resource)
# end
it "should call 'restart' on the service_name if the resource supports it" do
- @new_resource.stub!(:supports).and_return({:restart => true})
+ @new_resource.stub(:supports).and_return({:restart => true})
@provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} restart")
@provider.restart_service()
end
it "should call the restart_command if one has been specified" do
- @new_resource.stub!(:restart_command).and_return("/etc/rc.d/chef restartinafire")
+ @new_resource.stub(:restart_command).and_return("/etc/rc.d/chef restartinafire")
@provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} restartinafire")
@provider.restart_service()
end
@@ -307,21 +307,21 @@ RUNNING_PS
# :service_name => "chef",
# :running => false
# )
- # @new_resource.stub!(:reload_command).and_return(false)
- # @new_resource.stub!(:supports).and_return({:reload => false})
+ # @new_resource.stub(:reload_command).and_return(false)
+ # @new_resource.stub(:supports).and_return({:reload => false})
#
# @provider = Chef::Provider::Service::Arch.new(@node, @new_resource)
- # Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ # Chef::Resource::Service.stub(:new).and_return(@current_resource)
# end
it "should call 'reload' on the service if it supports it" do
- @new_resource.stub!(:supports).and_return({:reload => true})
+ @new_resource.stub(:supports).and_return({:reload => true})
@provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} reload")
@provider.reload_service()
end
it "should should run the user specified reload command if one is specified and the service doesn't support reload" do
- @new_resource.stub!(:reload_command).and_return("/etc/rc.d/chef lollerpants")
+ @new_resource.stub(:reload_command).and_return("/etc/rc.d/chef lollerpants")
@provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} lollerpants")
@provider.reload_service()
end
diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb
index 7d05b403de..ecc59e5e96 100644
--- a/spec/unit/provider/service/debian_service_spec.rb
+++ b/spec/unit/provider/service/debian_service_spec.rb
@@ -46,7 +46,7 @@ describe Chef::Provider::Service::Debian do
context "when update-rc.d shows init linked to rc*.d/" do
before do
- @provider.stub!(:assert_update_rcd_available)
+ @provider.stub(:assert_update_rcd_available)
result = <<-UPDATE_RC_D_SUCCESS
Removing any system startup links for /etc/init.d/chef ...
@@ -62,8 +62,8 @@ describe Chef::Provider::Service::Debian do
@stdout = StringIO.new(result)
@stderr = StringIO.new
@status = mock("Status", :exitstatus => 0, :stdout => @stdout)
- @provider.stub!(:shell_out!).and_return(@status)
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
end
it "says the service is enabled" do
@@ -71,7 +71,7 @@ describe Chef::Provider::Service::Debian do
end
it "stores the 'enabled' state" do
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@provider.load_current_resource.should equal(@current_resource)
@current_resource.enabled.should be_true
end
@@ -79,14 +79,14 @@ describe Chef::Provider::Service::Debian do
context "when update-rc.d shows init isn't linked to rc*.d/" do
before do
- @provider.stub!(:assert_update_rcd_available)
+ @provider.stub(:assert_update_rcd_available)
@status = mock("Status", :exitstatus => 0)
@stdout = StringIO.new(
" Removing any system startup links for /etc/init.d/chef ...")
@stderr = StringIO.new
@status = mock("Status", :exitstatus => 0, :stdout => @stdout)
- @provider.stub!(:shell_out!).and_return(@status)
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
end
it "says the service is disabled" do
@@ -94,7 +94,7 @@ describe Chef::Provider::Service::Debian do
end
it "stores the 'disabled' state" do
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@provider.load_current_resource.should equal(@current_resource)
@current_resource.enabled.should be_false
end
@@ -103,7 +103,7 @@ describe Chef::Provider::Service::Debian do
context "when update-rc.d fails" do
before do
@status = mock("Status", :exitstatus => -1)
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
end
it "raises an error" do
@@ -196,13 +196,13 @@ insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop
context "on #{model}" do
context "when update-rc.d shows init linked to rc*.d/" do
before do
- @provider.stub!(:assert_update_rcd_available)
+ @provider.stub(:assert_update_rcd_available)
@stdout = StringIO.new(expected_results["linked"]["stdout"])
@stderr = StringIO.new(expected_results["linked"]["stderr"])
@status = mock("Status", :exitstatus => 0, :stdout => @stdout)
- @provider.stub!(:shell_out!).and_return(@status)
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
end
it "says the service is enabled" do
@@ -210,7 +210,7 @@ insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop
end
it "stores the 'enabled' state" do
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@provider.load_current_resource.should equal(@current_resource)
@current_resource.enabled.should be_true
end
@@ -223,12 +223,12 @@ insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop
context "when update-rc.d shows init isn't linked to rc*.d/" do
before do
- @provider.stub!(:assert_update_rcd_available)
+ @provider.stub(:assert_update_rcd_available)
@stdout = StringIO.new(expected_results["not linked"]["stdout"])
@stderr = StringIO.new(expected_results["not linked"]["stderr"])
@status = mock("Status", :exitstatus => 0, :stdout => @stdout)
- @provider.stub!(:shell_out!).and_return(@status)
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
end
it "says the service is disabled" do
@@ -236,7 +236,7 @@ insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop
end
it "stores the 'disabled' state" do
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@provider.load_current_resource.should equal(@current_resource)
@current_resource.enabled.should be_false
end
diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb
index 7861764309..327aff1707 100644
--- a/spec/unit/provider/service/freebsd_service_spec.rb
+++ b/spec/unit/provider/service/freebsd_service_spec.rb
@@ -34,7 +34,7 @@ describe Chef::Provider::Service::Freebsd do
@provider = Chef::Provider::Service::Freebsd.new(@new_resource,@run_context)
@provider.action = :start
@init_command = "/usr/local/etc/rc.d/apache22"
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
end
describe "load_current_resource" do
@@ -45,20 +45,20 @@ describe Chef::Provider::Service::Freebsd do
545 ?? Ss 0:17.53 sendmail: accepting connections (sendmail)
PS_SAMPLE
@status = mock(:stdout => @stdout, :exitstatus => 0)
- @provider.stub!(:shell_out!).with(@node[:command][:ps]).and_return(@status)
+ @provider.stub(:shell_out!).with(@node[:command][:ps]).and_return(@status)
- ::File.stub!(:exists?).and_return(false)
- ::File.stub!(:exists?).with("/usr/local/etc/rc.d/#{@new_resource.service_name}").and_return(true)
+ ::File.stub(:exists?).and_return(false)
+ ::File.stub(:exists?).with("/usr/local/etc/rc.d/#{@new_resource.service_name}").and_return(true)
@lines = mock("lines")
- @lines.stub!(:each).and_yield("sshd_enable=\"YES\"").
+ @lines.stub(:each).and_yield("sshd_enable=\"YES\"").
and_yield("#{@new_resource.name}_enable=\"YES\"")
- ::File.stub!(:open).and_return(@lines)
+ ::File.stub(:open).and_return(@lines)
@rc_with_name = StringIO.new(<<-RC_SAMPLE)
name="apache22"
rcvar=`set_rcvar`
RC_SAMPLE
- ::File.stub!(:open).with("/usr/local/etc/rc.d/#{@new_resource.service_name}").and_return(@rc_with_name)
+ ::File.stub(:open).with("/usr/local/etc/rc.d/#{@new_resource.service_name}").and_return(@rc_with_name)
@provider.stub(:service_enable_variable_name).and_return nil
end
@@ -129,14 +129,14 @@ RC_SAMPLE
describe "when executing assertions" do
it "should verify that /etc/rc.conf exists" do
::File.should_receive(:exists?).with("/etc/rc.conf")
- @provider.stub!(:service_enable_variable_name).and_return("#{@current_resource.service_name}_enable")
+ @provider.stub(:service_enable_variable_name).and_return("#{@current_resource.service_name}_enable")
@provider.load_current_resource
end
context "and the init script is not found" do
[ "start", "reload", "restart", "enable" ].each do |action|
it "should raise an exception when the action is #{action}" do
- ::File.stub!(:exists?).and_return(false)
+ ::File.stub(:exists?).and_return(false)
@provider.load_current_resource
@provider.define_resource_requirements
@provider.instance_variable_get("@rcd_script_found").should be_false
@@ -160,7 +160,7 @@ RC_SAMPLE
end
it "update state when current resource enabled state could be determined" do
- ::File.stub!(:exist?).with("/usr/local/etc/rc.d/#{@new_resource.service_name}").and_return(true)
+ ::File.stub(:exist?).with("/usr/local/etc/rc.d/#{@new_resource.service_name}").and_return(true)
::File.should_receive(:exists?).with("/etc/rc.conf").and_return true
@provider.load_current_resource
@provider.instance_variable_get("@enabled_state_found").should be_false
@@ -189,26 +189,26 @@ RC_SAMPLE
end
it "should read stdout of the ps command" do
- @provider.stub!(:shell_out!).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
@stdout.should_receive(:each_line).and_return(true)
@provider.load_current_resource
end
it "should set running to true if the regex matches the output" do
- @stdout.stub!(:each_line).and_yield("555 ?? Ss 0:05.16 /usr/sbin/cron -s").
+ @stdout.stub(:each_line).and_yield("555 ?? Ss 0:05.16 /usr/sbin/cron -s").
and_yield(" 9881 ?? Ss 0:06.67 /usr/local/sbin/httpd -DNOHTTPACCEPT")
@provider.load_current_resource
@current_resource.running.should be_true
end
it "should set running to false if the regex doesn't match" do
- @provider.stub!(:shell_out!).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
@provider.load_current_resource
@current_resource.running.should be_false
end
it "should raise an exception if ps fails" do
- @provider.stub!(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ @provider.stub(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
@provider.load_current_resource
@provider.define_resource_requirements
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
@@ -270,7 +270,7 @@ RC_SAMPLE
@rc_without_name = StringIO.new(<<-RC_SAMPLE)
rcvar=`set_rcvar`
RC_SAMPLE
- ::File.stub!(:open).with("/usr/local/etc/rc.d/#{@current_resource.service_name}").and_return(@rc_with_noname)
+ ::File.stub(:open).with("/usr/local/etc/rc.d/#{@current_resource.service_name}").and_return(@rc_with_noname)
@provider.current_resource = @current_resource
end
@@ -283,12 +283,12 @@ RC_SAMPLE
# (default: "")
RCVAR_SAMPLE
@status = mock(:stdout => @rcvar_stdout, :exitstatus => 0)
- @provider.stub!(:shell_out!).with("/usr/local/etc/rc.d/#{@current_resource.service_name} rcvar").and_return(@status)
+ @provider.stub(:shell_out!).with("/usr/local/etc/rc.d/#{@current_resource.service_name} rcvar").and_return(@status)
end
it "should get the service name from rcvar if the rcscript does not have a name variable" do
@provider.load_current_resource
- @provider.unstub!(:service_enable_variable_name)
+ @provider.unstub(:service_enable_variable_name)
@provider.service_enable_variable_name.should == "#{@current_resource.service_name}_enable"
end
@@ -305,7 +305,7 @@ RCVAR_SAMPLE
#
RCVAR_SAMPLE
@status = mock(:stdout => @rcvar_stdout, :exitstatus => 0)
- @provider.stub!(:shell_out!).with("/usr/local/etc/rc.d/#{@current_resource.service_name} rcvar").and_return(@status)
+ @provider.stub(:shell_out!).with("/usr/local/etc/rc.d/#{@current_resource.service_name} rcvar").and_return(@status)
end
[ "start", "reload", "restart", "enable" ].each do |action|
@@ -319,7 +319,7 @@ RCVAR_SAMPLE
[ "stop", "disable" ].each do |action|
it "should not raise an error when the action is #{action}" do
- ::File.stub!(:exist?).with("/usr/local/etc/rc.d/#{@new_resource.service_name}").and_return(true)
+ ::File.stub(:exist?).with("/usr/local/etc/rc.d/#{@new_resource.service_name}").and_return(true)
@provider.action = action
@provider.load_current_resource
@provider.define_resource_requirements
@@ -333,25 +333,25 @@ RCVAR_SAMPLE
describe Chef::Provider::Service::Freebsd, "enable_service" do
before do
@provider.current_resource = @current_resource
- @provider.stub!(:service_enable_variable_name).and_return("#{@current_resource.service_name}_enable")
+ @provider.stub(:service_enable_variable_name).and_return("#{@current_resource.service_name}_enable")
end
it "should enable the service if it is not enabled" do
- @current_resource.stub!(:enabled).and_return(false)
+ @current_resource.stub(:enabled).and_return(false)
@provider.should_receive(:read_rc_conf).and_return([ "foo", "#{@current_resource.service_name}_enable=\"NO\"", "bar" ])
@provider.should_receive(:write_rc_conf).with(["foo", "bar", "#{@current_resource.service_name}_enable=\"YES\""])
@provider.enable_service()
end
it "should enable the service if it is not enabled and not already specified in the rc.conf file" do
- @current_resource.stub!(:enabled).and_return(false)
+ @current_resource.stub(:enabled).and_return(false)
@provider.should_receive(:read_rc_conf).and_return([ "foo", "bar" ])
@provider.should_receive(:write_rc_conf).with(["foo", "bar", "#{@current_resource.service_name}_enable=\"YES\""])
@provider.enable_service()
end
it "should not enable the service if it is already enabled" do
- @current_resource.stub!(:enabled).and_return(true)
+ @current_resource.stub(:enabled).and_return(true)
@provider.should_not_receive(:write_rc_conf)
@provider.enable_service
end
@@ -360,18 +360,18 @@ RCVAR_SAMPLE
describe Chef::Provider::Service::Freebsd, "disable_service" do
before do
@provider.current_resource = @current_resource
- @provider.stub!(:service_enable_variable_name).and_return("#{@current_resource.service_name}_enable")
+ @provider.stub(:service_enable_variable_name).and_return("#{@current_resource.service_name}_enable")
end
it "should should disable the service if it is not disabled" do
- @current_resource.stub!(:enabled).and_return(true)
+ @current_resource.stub(:enabled).and_return(true)
@provider.should_receive(:read_rc_conf).and_return([ "foo", "#{@current_resource.service_name}_enable=\"YES\"", "bar" ])
@provider.should_receive(:write_rc_conf).with(["foo", "bar", "#{@current_resource.service_name}_enable=\"NO\""])
@provider.disable_service()
end
it "should not disable the service if it is already disabled" do
- @current_resource.stub!(:enabled).and_return(false)
+ @current_resource.stub(:enabled).and_return(false)
@provider.should_not_receive(:write_rc_conf)
@provider.disable_service()
end
diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb
index b658cab4d8..274c0f72fc 100644
--- a/spec/unit/provider/service/gentoo_service_spec.rb
+++ b/spec/unit/provider/service/gentoo_service_spec.rb
@@ -29,13 +29,13 @@ describe Chef::Provider::Service::Gentoo do
@current_resource = Chef::Resource::Service.new("chef")
@provider = Chef::Provider::Service::Gentoo.new(@new_resource, @run_context)
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@status = mock("Status", :exitstatus => 0, :stdout => @stdout)
- @provider.stub!(:shell_out).and_return(@status)
- File.stub!(:exists?).with("/etc/init.d/chef").and_return(true)
- File.stub!(:exists?).with("/sbin/rc-update").and_return(true)
- File.stub!(:exists?).with("/etc/runlevels/default/chef").and_return(false)
- File.stub!(:readable?).with("/etc/runlevels/default/chef").and_return(false)
+ @provider.stub(:shell_out).and_return(@status)
+ File.stub(:exists?).with("/etc/init.d/chef").and_return(true)
+ File.stub(:exists?).with("/sbin/rc-update").and_return(true)
+ File.stub(:exists?).with("/etc/runlevels/default/chef").and_return(false)
+ File.stub(:readable?).with("/etc/runlevels/default/chef").and_return(false)
end
# new test: found_enabled state
#
@@ -52,7 +52,7 @@ describe Chef::Provider::Service::Gentoo do
end
it "should track when service file is found in /etc/runlevels/**/" do
- Dir.stub!(:glob).with("/etc/runlevels/**/chef").and_return(["/etc/runlevels/default/chef"])
+ Dir.stub(:glob).with("/etc/runlevels/**/chef").and_return(["/etc/runlevels/default/chef"])
@provider.load_current_resource
@provider.instance_variable_get("@found_script").should be_true
end
@@ -60,13 +60,13 @@ describe Chef::Provider::Service::Gentoo do
describe "when detecting the service enable state" do
describe "and the glob returns a default service script file" do
before do
- Dir.stub!(:glob).with("/etc/runlevels/**/chef").and_return(["/etc/runlevels/default/chef"])
+ Dir.stub(:glob).with("/etc/runlevels/**/chef").and_return(["/etc/runlevels/default/chef"])
end
describe "and the file exists and is readable" do
before do
- File.stub!(:exists?).with("/etc/runlevels/default/chef").and_return(true)
- File.stub!(:readable?).with("/etc/runlevels/default/chef").and_return(true)
+ File.stub(:exists?).with("/etc/runlevels/default/chef").and_return(true)
+ File.stub(:readable?).with("/etc/runlevels/default/chef").and_return(true)
end
it "should set enabled to true" do
@provider.load_current_resource
@@ -76,8 +76,8 @@ describe Chef::Provider::Service::Gentoo do
describe "and the file exists but is not readable" do
before do
- File.stub!(:exists?).with("/etc/runlevels/default/chef").and_return(true)
- File.stub!(:readable?).with("/etc/runlevels/default/chef").and_return(false)
+ File.stub(:exists?).with("/etc/runlevels/default/chef").and_return(true)
+ File.stub(:readable?).with("/etc/runlevels/default/chef").and_return(false)
end
it "should set enabled to false" do
@@ -88,8 +88,8 @@ describe Chef::Provider::Service::Gentoo do
describe "and the file does not exist" do
before do
- File.stub!(:exists?).with("/etc/runlevels/default/chef").and_return(false)
- File.stub!(:readable?).with("/etc/runlevels/default/chef").and_return("foobarbaz")
+ File.stub(:exists?).with("/etc/runlevels/default/chef").and_return(false)
+ File.stub(:readable?).with("/etc/runlevels/default/chef").and_return("foobarbaz")
end
it "should set enabled to false" do
@@ -124,7 +124,7 @@ describe Chef::Provider::Service::Gentoo do
end
describe "action_methods" do
- before(:each) { @provider.stub!(:load_current_resource).and_return(@current_resource) }
+ before(:each) { @provider.stub(:load_current_resource).and_return(@current_resource) }
describe Chef::Provider::Service::Gentoo, "enable_service" do
it "should call rc-update add *service* default" do
diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb
index c7d47e6281..2fcddb82e3 100644
--- a/spec/unit/provider/service/init_service_spec.rb
+++ b/spec/unit/provider/service/init_service_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Provider::Service::Init, "load_current_resource" do
@current_resource = Chef::Resource::Service.new("chef")
@provider = Chef::Provider::Service::Init.new(@new_resource, @run_context)
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@stdout = StringIO.new(<<-PS)
aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
@@ -38,7 +38,7 @@ aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb
PS
@status = mock("Status", :exitstatus => 0, :stdout => @stdout)
- @provider.stub!(:shell_out!).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
end
it "should create a current resource with the name of the new resource" do
@@ -62,20 +62,20 @@ PS
end
it "should set running to true if the status command returns 0" do
- @provider.stub!(:shell_out).with("/etc/init.d/#{@current_resource.service_name} status").and_return(@status)
+ @provider.stub(:shell_out).with("/etc/init.d/#{@current_resource.service_name} status").and_return(@status)
@provider.load_current_resource
@current_resource.running.should be_true
end
it "should set running to false if the status command returns anything except 0" do
- @status.stub!(:exitstatus).and_return(1)
- @provider.stub!(:shell_out).with("/etc/init.d/#{@current_resource.service_name} status").and_return(@status)
+ @status.stub(:exitstatus).and_return(1)
+ @provider.stub(:shell_out).with("/etc/init.d/#{@current_resource.service_name} status").and_return(@status)
@provider.load_current_resource
@current_resource.running.should be_false
end
it "should set running to false if the status command raises" do
- @provider.stub!(:shell_out).and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ @provider.stub(:shell_out).and_raise(Mixlib::ShellOut::ShellCommandFailed)
@provider.load_current_resource
@current_resource.running.should be_false
end
@@ -83,7 +83,7 @@ PS
describe "when a status command has been specified" do
before do
- @new_resource.stub!(:status_command).and_return("/etc/init.d/chefhasmonkeypants status")
+ @new_resource.stub(:status_command).and_return("/etc/init.d/chefhasmonkeypants status")
end
it "should run the services status command if one has been specified" do
@@ -95,7 +95,7 @@ PS
describe "when an init command has been specified" do
before do
- @new_resource.stub!(:init_command).and_return("/opt/chef-server/service/erchef")
+ @new_resource.stub(:init_command).and_return("/opt/chef-server/service/erchef")
@provider = Chef::Provider::Service::Init.new(@new_resource, @run_context)
end
@@ -138,19 +138,19 @@ PS
aj 7842 5057 0 21:26 pts/2 00:00:06 chef
aj 7842 5057 0 21:26 pts/2 00:00:06 poos
RUNNING_PS
- @status.stub!(:stdout).and_return(@stdout)
+ @status.stub(:stdout).and_return(@stdout)
@provider.load_current_resource
@current_resource.running.should be_true
end
it "should set running to false if the regex doesn't match" do
- @provider.stub!(:shell_out!).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
@provider.load_current_resource
@current_resource.running.should be_false
end
it "should raise an exception if ps fails" do
- @provider.stub!(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ @provider.stub(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
@provider.load_current_resource
@provider.action = :start
@provider.define_resource_requirements
diff --git a/spec/unit/provider/service/insserv_service_spec.rb b/spec/unit/provider/service/insserv_service_spec.rb
index 8b5f09e78c..e0c0d9682a 100644
--- a/spec/unit/provider/service/insserv_service_spec.rb
+++ b/spec/unit/provider/service/insserv_service_spec.rb
@@ -30,13 +30,13 @@ describe Chef::Provider::Service::Insserv do
@provider = Chef::Provider::Service::Insserv.new(@new_resource, @run_context)
@status = mock("Process::Status mock", :exitstatus => 0, :stdout => "")
- @provider.stub!(:shell_out!).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
end
describe "load_current_resource" do
describe "when startup links exist" do
before do
- Dir.stub!(:glob).with("/etc/rc**/S*initgrediant").and_return(["/etc/rc5.d/S18initgrediant", "/etc/rc2.d/S18initgrediant", "/etc/rc4.d/S18initgrediant", "/etc/rc3.d/S18initgrediant"])
+ Dir.stub(:glob).with("/etc/rc**/S*initgrediant").and_return(["/etc/rc5.d/S18initgrediant", "/etc/rc2.d/S18initgrediant", "/etc/rc4.d/S18initgrediant", "/etc/rc3.d/S18initgrediant"])
end
it "sets the current enabled status to true" do
@@ -47,7 +47,7 @@ describe Chef::Provider::Service::Insserv do
describe "when startup links do not exist" do
before do
- Dir.stub!(:glob).with("/etc/rc**/S*initgrediant").and_return([])
+ Dir.stub(:glob).with("/etc/rc**/S*initgrediant").and_return([])
end
it "sets the current enabled status to false" do
diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb
index ca20657405..3df6f002c7 100644
--- a/spec/unit/provider/service/invokercd_service_spec.rb
+++ b/spec/unit/provider/service/invokercd_service_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Provider::Service::Invokercd, "load_current_resource" do
@current_resource = Chef::Resource::Service.new("chef")
@provider = Chef::Provider::Service::Invokercd.new(@new_resource, @run_context)
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@stdout = StringIO.new(<<-PS)
aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
@@ -38,7 +38,7 @@ aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb
PS
@status = mock("Status", :exitstatus => 0, :stdout => @stdout)
- @provider.stub!(:shell_out!).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
end
it "should create a current resource with the name of the new resource" do
@@ -62,20 +62,20 @@ PS
end
it "should set running to true if the status command returns 0" do
- @provider.stub!(:shell_out).with("/usr/sbin/invoke-rc.d #{@current_resource.service_name} status").and_return(@status)
+ @provider.stub(:shell_out).with("/usr/sbin/invoke-rc.d #{@current_resource.service_name} status").and_return(@status)
@provider.load_current_resource
@current_resource.running.should be_true
end
it "should set running to false if the status command returns anything except 0" do
- @status.stub!(:exitstatus).and_return(1)
- @provider.stub!(:shell_out).with("/usr/sbin/invoke-rc.d #{@current_resource.service_name} status").and_return(@status)
+ @status.stub(:exitstatus).and_return(1)
+ @provider.stub(:shell_out).with("/usr/sbin/invoke-rc.d #{@current_resource.service_name} status").and_return(@status)
@provider.load_current_resource
@current_resource.running.should be_false
end
it "should set running to false if the status command raises" do
- @provider.stub!(:shell_out).with("/usr/sbin/invoke-rc.d #{@current_resource.service_name} status").and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ @provider.stub(:shell_out).with("/usr/sbin/invoke-rc.d #{@current_resource.service_name} status").and_raise(Mixlib::ShellOut::ShellCommandFailed)
@provider.load_current_resource
@current_resource.running.should be_false
end
@@ -83,7 +83,7 @@ PS
describe "when a status command has been specified" do
before do
- @new_resource.stub!(:status_command).and_return("/usr/sbin/invoke-rc.d chefhasmonkeypants status")
+ @new_resource.stub(:status_command).and_return("/usr/sbin/invoke-rc.d chefhasmonkeypants status")
end
it "should run the services status command if one has been specified" do
@@ -137,7 +137,7 @@ RUNNING_PS
end
it "should raise an exception if ps fails" do
- @provider.stub!(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ @provider.stub(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
@provider.action = :start
@provider.load_current_resource
@provider.define_resource_requirements
diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb
index 61bd5583e1..814320f64f 100644
--- a/spec/unit/provider/service/macosx_spec.rb
+++ b/spec/unit/provider/service/macosx_spec.rb
@@ -50,12 +50,12 @@ describe Chef::Provider::Service::Macosx do
["redis-server", "io.redis.redis-server"].each do |service_name|
before do
- Dir.stub!(:glob).and_return(["/Users/igor/Library/LaunchAgents/io.redis.redis-server.plist"], [])
- provider.stub!(:shell_out!).
+ Dir.stub(:glob).and_return(["/Users/igor/Library/LaunchAgents/io.redis.redis-server.plist"], [])
+ provider.stub(:shell_out!).
with("launchctl list", {:group => 1001, :user => 101}).
and_return(mock("ouput", :stdout => stdout))
- File.stub!(:stat).and_return(mock("stat", :gid => 1001, :uid => 101))
+ File.stub(:stat).and_return(mock("stat", :gid => 1001, :uid => 101))
end
context "#{service_name}" do
@@ -85,7 +85,7 @@ describe Chef::Provider::Service::Macosx do
describe "running unsupported actions" do
before do
- Dir.stub!(:glob).and_return(["/Users/igor/Library/LaunchAgents/io.redis.redis-server.plist"], [])
+ Dir.stub(:glob).and_return(["/Users/igor/Library/LaunchAgents/io.redis.redis-server.plist"], [])
end
it "should throw an exception when enable action is attempted" do
lambda {provider.run_action(:enable)}.should raise_error(Chef::Exceptions::UnsupportedAction)
@@ -130,7 +130,7 @@ describe Chef::Provider::Service::Macosx do
context "and plist for service is not available" do
before do
- Dir.stub!(:glob).and_return([])
+ Dir.stub(:glob).and_return([])
provider.load_current_resource
end
@@ -141,7 +141,7 @@ describe Chef::Provider::Service::Macosx do
context "and plist for service is available" do
before do
- Dir.stub!(:glob).and_return(["/Users/igor/Library/LaunchAgents/io.redis.redis-server.plist"], [])
+ Dir.stub(:glob).and_return(["/Users/igor/Library/LaunchAgents/io.redis.redis-server.plist"], [])
provider.load_current_resource
end
@@ -152,7 +152,7 @@ describe Chef::Provider::Service::Macosx do
describe "and several plists match service name" do
it "throws exception" do
- Dir.stub!(:glob).and_return(["/Users/igor/Library/LaunchAgents/io.redis.redis-server.plist",
+ Dir.stub(:glob).and_return(["/Users/igor/Library/LaunchAgents/io.redis.redis-server.plist",
"/Users/wtf/something.plist"])
provider.load_current_resource
provider.define_resource_requirements
@@ -163,20 +163,20 @@ describe Chef::Provider::Service::Macosx do
end
describe "#start_service" do
before do
- Chef::Resource::Service.stub!(:new).and_return(current_resource)
+ Chef::Resource::Service.stub(:new).and_return(current_resource)
provider.load_current_resource
- current_resource.stub!(:running).and_return(false)
+ current_resource.stub(:running).and_return(false)
end
it "calls the start command if one is specified and service is not running" do
- new_resource.stub!(:start_command).and_return("cowsay dirty")
+ new_resource.stub(:start_command).and_return("cowsay dirty")
provider.should_receive(:shell_out!).with("cowsay dirty")
provider.start_service
end
it "shows warning message if service is already running" do
- current_resource.stub!(:running).and_return(true)
+ current_resource.stub(:running).and_return(true)
Chef::Log.should_receive(:debug).with("service[#{service_name}] already running, not starting")
provider.start_service
@@ -194,21 +194,21 @@ describe Chef::Provider::Service::Macosx do
describe "#stop_service" do
before do
- Chef::Resource::Service.stub!(:new).and_return(current_resource)
+ Chef::Resource::Service.stub(:new).and_return(current_resource)
provider.load_current_resource
- current_resource.stub!(:running).and_return(true)
+ current_resource.stub(:running).and_return(true)
end
it "calls the stop command if one is specified and service is running" do
- new_resource.stub!(:stop_command).and_return("kill -9 123")
+ new_resource.stub(:stop_command).and_return("kill -9 123")
provider.should_receive(:shell_out!).with("kill -9 123")
provider.stop_service
end
it "shows warning message if service is not running" do
- current_resource.stub!(:running).and_return(false)
+ current_resource.stub(:running).and_return(false)
Chef::Log.should_receive(:debug).with("service[#{service_name}] not running, not stopping")
provider.stop_service
@@ -226,15 +226,15 @@ describe Chef::Provider::Service::Macosx do
describe "#restart_service" do
before do
- Chef::Resource::Service.stub!(:new).and_return(current_resource)
+ Chef::Resource::Service.stub(:new).and_return(current_resource)
provider.load_current_resource
- current_resource.stub!(:running).and_return(true)
- provider.stub!(:sleep)
+ current_resource.stub(:running).and_return(true)
+ provider.stub(:sleep)
end
it "issues a command if given" do
- new_resource.stub!(:restart_command).and_return("reload that thing")
+ new_resource.stub(:restart_command).and_return("reload that thing")
provider.should_receive(:shell_out!).with("reload that thing")
provider.restart_service
diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb
index 3ce4301026..0de93fe430 100644
--- a/spec/unit/provider/service/redhat_spec.rb
+++ b/spec/unit/provider/service/redhat_spec.rb
@@ -21,9 +21,9 @@ require 'ostruct'
shared_examples_for "define_resource_requirements_common" do
it "should raise an error if /sbin/chkconfig does not exist" do
- File.stub!(:exists?).with("/sbin/chkconfig").and_return(false)
- @provider.stub!(:shell_out).with("/sbin/service chef status").and_raise(Errno::ENOENT)
- @provider.stub!(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_raise(Errno::ENOENT)
+ File.stub(:exists?).with("/sbin/chkconfig").and_return(false)
+ @provider.stub(:shell_out).with("/sbin/service chef status").and_raise(Errno::ENOENT)
+ @provider.stub(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_raise(Errno::ENOENT)
@provider.load_current_resource
@provider.define_resource_requirements
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
@@ -54,8 +54,8 @@ describe "Chef::Provider::Service::Redhat" do
@provider = Chef::Provider::Service::Redhat.new(@new_resource, @run_context)
@provider.action = :start
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
- File.stub!(:exists?).with("/sbin/chkconfig").and_return(true)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
+ File.stub(:exists?).with("/sbin/chkconfig").and_return(true)
end
describe "while not in why run mode" do
diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb
index 73cb3766d2..7265399f58 100644
--- a/spec/unit/provider/service/simple_service_spec.rb
+++ b/spec/unit/provider/service/simple_service_spec.rb
@@ -29,7 +29,7 @@ describe Chef::Provider::Service::Simple, "load_current_resource" do
@current_resource = Chef::Resource::Service.new("chef")
@provider = Chef::Provider::Service::Simple.new(@new_resource, @run_context)
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@stdout = StringIO.new(<<-NOMOCKINGSTRINGSPLZ)
aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
@@ -37,7 +37,7 @@ aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
aj 8119 6041 0 21:34 pts/3 00:00:03 vi simple_service_spec.rb
NOMOCKINGSTRINGSPLZ
@status = mock("Status", :exitstatus => 0, :stdout => @stdout)
- @provider.stub!(:shell_out!).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
end
it "should create a current resource with the name of the new resource" do
@@ -69,7 +69,7 @@ NOMOCKINGSTRINGSPLZ
end
it "should read stdout of the ps command" do
- @provider.stub!(:shell_out!).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
@stdout.should_receive(:each_line).and_return(true)
@provider.load_current_resource
end
@@ -80,19 +80,19 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 chef
aj 7842 5057 0 21:26 pts/2 00:00:06 poos
NOMOCKINGSTRINGSPLZ
@status = mock("Status", :exitstatus => 0, :stdout => @stdout)
- @provider.stub!(:shell_out!).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
@provider.load_current_resource
@current_resource.running.should be_true
end
it "should set running to false if the regex doesn't match" do
- @provider.stub!(:shell_out!).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
@provider.load_current_resource
@current_resource.running.should be_false
end
it "should raise an exception if ps fails" do
- @provider.stub!(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ @provider.stub(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
@provider.action = :start
@provider.load_current_resource
@provider.define_resource_requirements
@@ -108,7 +108,7 @@ NOMOCKINGSTRINGSPLZ
describe "when starting the service" do
it "should call the start command if one is specified" do
- @new_resource.stub!(:start_command).and_return("#{@new_resource.start_command}")
+ @new_resource.stub(:start_command).and_return("#{@new_resource.start_command}")
@provider.should_receive(:shell_out!).with("#{@new_resource.start_command}")
@provider.start_service()
end
diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb
index 64afee078c..7dd6d7161c 100644
--- a/spec/unit/provider/service/solaris_smf_service_spec.rb
+++ b/spec/unit/provider/service/solaris_smf_service_spec.rb
@@ -29,16 +29,16 @@ describe Chef::Provider::Service::Solaris do
@current_resource = Chef::Resource::Service.new('chef')
@provider = Chef::Provider::Service::Solaris.new(@new_resource, @run_context)
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@stdin = StringIO.new
@stdout = StringIO.new
@stderr = StringIO.new
@pid = 2342
@stdout_string = "state disabled"
- @stdout.stub!(:gets).and_return(@stdout_string)
+ @stdout.stub(:gets).and_return(@stdout_string)
@status = mock("Status", :exitstatus => 0, :stdout => @stdout)
- @provider.stub!(:shell_out!).and_return(@status)
+ @provider.stub(:shell_out!).and_return(@status)
end
it "should raise an error if /bin/svcs does not exist" do
@@ -49,19 +49,19 @@ describe Chef::Provider::Service::Solaris do
describe "on a host with /bin/svcs" do
before do
- File.stub!(:exists?).with('/bin/svcs').and_return(true)
+ File.stub(:exists?).with('/bin/svcs').and_return(true)
end
describe "when discovering the current service state" do
it "should create a current resource with the name of the new resource" do
- @provider.stub!(:popen4).with("/bin/svcs -l chef").and_return(@status)
+ @provider.stub(:popen4).with("/bin/svcs -l chef").and_return(@status)
Chef::Resource::Service.should_receive(:new).and_return(@current_resource)
@provider.load_current_resource
end
it "should return the current resource" do
- @provider.stub!(:popen4).with("/bin/svcs -l chef").and_return(@status)
+ @provider.stub(:popen4).with("/bin/svcs -l chef").and_return(@status)
@provider.load_current_resource.should eql(@current_resource)
end
@@ -71,14 +71,14 @@ describe Chef::Provider::Service::Solaris do
end
it "should mark service as not running" do
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@current_resource.should_receive(:running).with(false)
@provider.load_current_resource
end
it "should mark service as running" do
- @stdout.stub!(:each).and_yield("state online")
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @stdout.stub(:each).and_yield("state online")
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@current_resource.should_receive(:running).with(true)
@provider.load_current_resource
end
@@ -91,14 +91,14 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm enable -s chef" do
- @new_resource.stub!(:enable_command).and_return("#{@new_resource.enable_command}")
+ @new_resource.stub(:enable_command).and_return("#{@new_resource.enable_command}")
@provider.should_receive(:shell_out!).with("/usr/sbin/svcadm enable -s #{@current_resource.service_name}").and_return(@status)
@provider.enable_service.should be_true
@current_resource.enabled.should be_true
end
it "should call svcadm enable -s chef for start_service" do
- @new_resource.stub!(:start_command).and_return("#{@new_resource.start_command}")
+ @new_resource.stub(:start_command).and_return("#{@new_resource.start_command}")
@provider.should_receive(:shell_out!).with("/usr/sbin/svcadm enable -s #{@current_resource.service_name}").and_return(@status)
@provider.start_service.should be_true
@current_resource.enabled.should be_true
diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb
index a107888b0b..f631bfc31d 100644
--- a/spec/unit/provider/service/systemd_service_spec.rb
+++ b/spec/unit/provider/service/systemd_service_spec.rb
@@ -30,10 +30,10 @@ describe Chef::Provider::Service::Systemd do
describe "load_current_resource" do
before(:each) do
@current_resource = Chef::Resource::Service.new('rsyslog.service')
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
- @provider.stub!(:is_active?).and_return(false)
- @provider.stub!(:is_enabled?).and_return(false)
+ @provider.stub(:is_active?).and_return(false)
+ @provider.stub(:is_enabled?).and_return(false)
end
it "should create a current resource with the name of the new resource" do
@@ -52,42 +52,42 @@ describe Chef::Provider::Service::Systemd do
end
it "should set running to true if the service is running" do
- @provider.stub!(:is_active?).and_return(true)
+ @provider.stub(:is_active?).and_return(true)
@current_resource.should_receive(:running).with(true)
@provider.load_current_resource
end
it "should set running to false if the service is not running" do
- @provider.stub!(:is_active?).and_return(false)
+ @provider.stub(:is_active?).and_return(false)
@current_resource.should_receive(:running).with(false)
@provider.load_current_resource
end
describe "when a status command has been specified" do
before do
- @new_resource.stub!(:status_command).and_return("/bin/chefhasmonkeypants status")
+ @new_resource.stub(:status_command).and_return("/bin/chefhasmonkeypants status")
end
it "should run the services status command if one has been specified" do
- @provider.stub!(:run_command_with_systems_locale).with({:command => "/bin/chefhasmonkeypants status"}).and_return(0)
+ @provider.stub(:run_command_with_systems_locale).with({:command => "/bin/chefhasmonkeypants status"}).and_return(0)
@current_resource.should_receive(:running).with(true)
@provider.load_current_resource
end
it "should run the services status command if one has been specified and properly set status check state" do
- @provider.stub!(:run_command_with_systems_locale).with({:command => "/bin/chefhasmonkeypants status"}).and_return(0)
+ @provider.stub(:run_command_with_systems_locale).with({:command => "/bin/chefhasmonkeypants status"}).and_return(0)
@provider.load_current_resource
@provider.instance_variable_get("@status_check_success").should be_true
end
it "should set running to false if it catches a Chef::Exceptions::Exec when using a status command" do
- @provider.stub!(:run_command_with_systems_locale).and_raise(Chef::Exceptions::Exec)
+ @provider.stub(:run_command_with_systems_locale).and_raise(Chef::Exceptions::Exec)
@current_resource.should_receive(:running).with(false)
@provider.load_current_resource
end
it "should update state to indicate status check failed when an exception is thrown using a status command" do
- @provider.stub!(:run_command_with_systems_locale).and_raise(Chef::Exceptions::Exec)
+ @provider.stub(:run_command_with_systems_locale).and_raise(Chef::Exceptions::Exec)
@provider.load_current_resource
@provider.instance_variable_get("@status_check_success").should be_false
end
@@ -99,13 +99,13 @@ describe Chef::Provider::Service::Systemd do
end
it "should set enabled to true if the service is enabled" do
- @provider.stub!(:is_enabled?).and_return(true)
+ @provider.stub(:is_enabled?).and_return(true)
@current_resource.should_receive(:enabled).with(true)
@provider.load_current_resource
end
it "should set enabled to false if the service is not enabled" do
- @provider.stub!(:is_enabled?).and_return(false)
+ @provider.stub(:is_enabled?).and_return(false)
@current_resource.should_receive(:enabled).with(false)
@provider.load_current_resource
end
@@ -118,12 +118,12 @@ describe Chef::Provider::Service::Systemd do
describe "start and stop service" do
before(:each) do
@current_resource = Chef::Resource::Service.new('rsyslog.service')
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@provider.current_resource = @current_resource
end
it "should call the start command if one is specified" do
- @new_resource.stub!(:start_command).and_return("/sbin/rsyslog startyousillysally")
+ @new_resource.stub(:start_command).and_return("/sbin/rsyslog startyousillysally")
@provider.should_receive(:shell_out!).with("/sbin/rsyslog startyousillysally")
@provider.start_service
end
@@ -134,52 +134,52 @@ describe Chef::Provider::Service::Systemd do
end
it "should not call '/bin/systemctl start service_name' if it is already running" do
- @current_resource.stub!(:running).and_return(true)
+ @current_resource.stub(:running).and_return(true)
@provider.should_not_receive(:run_command_with_systems_locale).with({:command => "/bin/systemctl start #{@new_resource.service_name}"})
@provider.start_service
end
it "should call the restart command if one is specified" do
- @current_resource.stub!(:running).and_return(true)
- @new_resource.stub!(:restart_command).and_return("/sbin/rsyslog restartyousillysally")
+ @current_resource.stub(:running).and_return(true)
+ @new_resource.stub(:restart_command).and_return("/sbin/rsyslog restartyousillysally")
@provider.should_receive(:shell_out!).with("/sbin/rsyslog restartyousillysally")
@provider.restart_service
end
it "should call '/bin/systemctl restart service_name' if no restart command is specified" do
- @current_resource.stub!(:running).and_return(true)
+ @current_resource.stub(:running).and_return(true)
@provider.should_receive(:run_command_with_systems_locale).with({:command => "/bin/systemctl restart #{@new_resource.service_name}"}).and_return(0)
@provider.restart_service
end
it "should call the reload command if one is specified" do
- @current_resource.stub!(:running).and_return(true)
- @new_resource.stub!(:reload_command).and_return("/sbin/rsyslog reloadyousillysally")
+ @current_resource.stub(:running).and_return(true)
+ @new_resource.stub(:reload_command).and_return("/sbin/rsyslog reloadyousillysally")
@provider.should_receive(:shell_out!).with("/sbin/rsyslog reloadyousillysally")
@provider.reload_service
end
it "should call '/bin/systemctl reload service_name' if no reload command is specified" do
- @current_resource.stub!(:running).and_return(true)
+ @current_resource.stub(:running).and_return(true)
@provider.should_receive(:run_command_with_systems_locale).with({:command => "/bin/systemctl reload #{@new_resource.service_name}"}).and_return(0)
@provider.reload_service
end
it "should call the stop command if one is specified" do
- @current_resource.stub!(:running).and_return(true)
- @new_resource.stub!(:stop_command).and_return("/sbin/rsyslog stopyousillysally")
+ @current_resource.stub(:running).and_return(true)
+ @new_resource.stub(:stop_command).and_return("/sbin/rsyslog stopyousillysally")
@provider.should_receive(:shell_out!).with("/sbin/rsyslog stopyousillysally")
@provider.stop_service
end
it "should call '/bin/systemctl stop service_name' if no stop command is specified" do
- @current_resource.stub!(:running).and_return(true)
+ @current_resource.stub(:running).and_return(true)
@provider.should_receive(:run_command_with_systems_locale).with({:command => "/bin/systemctl stop #{@new_resource.service_name}"}).and_return(0)
@provider.stop_service
end
it "should not call '/bin/systemctl stop service_name' if it is already stopped" do
- @current_resource.stub!(:running).and_return(false)
+ @current_resource.stub(:running).and_return(false)
@provider.should_not_receive(:run_command_with_systems_locale).with({:command => "/bin/systemctl stop #{@new_resource.service_name}"})
@provider.stop_service
end
@@ -188,7 +188,7 @@ describe Chef::Provider::Service::Systemd do
describe "enable and disable service" do
before(:each) do
@current_resource = Chef::Resource::Service.new('rsyslog.service')
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@provider.current_resource = @current_resource
end
@@ -206,7 +206,7 @@ describe Chef::Provider::Service::Systemd do
describe "is_active?" do
before(:each) do
@current_resource = Chef::Resource::Service.new('rsyslog.service')
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
end
it "should return true if '/bin/systemctl is-active service_name' returns 0" do
@@ -223,7 +223,7 @@ describe Chef::Provider::Service::Systemd do
describe "is_enabled?" do
before(:each) do
@current_resource = Chef::Resource::Service.new('rsyslog.service')
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
end
it "should return true if '/bin/systemctl is-enabled service_name' returns 0" do
diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb
index 8628a4eaf7..1c9a94af2e 100644
--- a/spec/unit/provider/service/upstart_service_spec.rb
+++ b/spec/unit/provider/service/upstart_service_spec.rb
@@ -39,7 +39,7 @@ describe Chef::Provider::Service::Upstart do
it "should return /etc/event.d as the upstart job directory when running on Ubuntu 9.04" do
@node.automatic_attrs[:platform_version] = '9.04'
- #Chef::Platform.stub!(:find_platform_and_version).and_return([ "ubuntu", "9.04" ])
+ #Chef::Platform.stub(:find_platform_and_version).and_return([ "ubuntu", "9.04" ])
@provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
@provider.instance_variable_get(:@upstart_job_dir).should == "/etc/event.d"
@provider.instance_variable_get(:@upstart_conf_suffix).should == ""
@@ -65,17 +65,17 @@ describe Chef::Provider::Service::Upstart do
@node.automatic_attrs[:command] = {:ps => "ps -ax"}
@current_resource = Chef::Resource::Service.new("rsyslog")
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@status = mock("Status", :exitstatus => 0)
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
@stdin = StringIO.new
@stdout = StringIO.new
@stderr = StringIO.new
@pid = mock("PID")
- ::File.stub!(:exists?).and_return(true)
- ::File.stub!(:open).and_return(true)
+ ::File.stub(:exists?).and_return(true)
+ ::File.stub(:open).and_return(true)
end
it "should create a current resource with the name of the new resource" do
@@ -99,14 +99,14 @@ describe Chef::Provider::Service::Upstart do
it "should set running to true if the status command returns 0" do
@stdout = StringIO.new("rsyslog start/running")
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@current_resource.running.should be_true
end
it "should set running to false if the status command returns anything except 0" do
@stdout = StringIO.new("rsyslog stop/waiting")
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@current_resource.running.should be_false
end
@@ -115,41 +115,41 @@ describe Chef::Provider::Service::Upstart do
describe "when the status command uses the old format" do
it "should set running to true if the status command returns 0" do
@stdout = StringIO.new("rsyslog (start) running, process 32225")
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@current_resource.running.should be_true
end
it "should set running to false if the status command returns anything except 0" do
@stdout = StringIO.new("rsyslog (stop) waiting")
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@current_resource.running.should be_false
end
end
it "should set running to false if it catches a Chef::Exceptions::Exec" do
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_raise(Chef::Exceptions::Exec)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_raise(Chef::Exceptions::Exec)
@current_resource.should_receive(:running).with(false)
@provider.load_current_resource
end
it "should set enabled to true when it finds 'starts on'" do
@lines = mock("start on filesystem", :gets => "start on filesystem")
- ::File.stub!(:open).and_yield(@lines)
+ ::File.stub(:open).and_yield(@lines)
@current_resource.should_receive(:running).with(false)
@provider.load_current_resource
end
it "should set enabled to false when it finds '#starts on'" do
@lines = mock("start on filesystem", :gets => "#start on filesystem")
- ::File.stub!(:open).and_yield(@lines)
+ ::File.stub(:open).and_yield(@lines)
@current_resource.should_receive(:running).with(false)
@provider.load_current_resource
end
it "should assume disable when no job configuration file is found" do
- ::File.stub!(:exists?).and_return(false)
+ ::File.stub(:exists?).and_return(false)
@current_resource.should_receive(:running).with(false)
@provider.load_current_resource
end
@@ -163,23 +163,23 @@ describe Chef::Provider::Service::Upstart do
describe "when a status command has been specified" do
before do
- @new_resource.stub!(:status_command).and_return("/bin/chefhasmonkeypants status")
+ @new_resource.stub(:status_command).and_return("/bin/chefhasmonkeypants status")
end
it "should run the services status command if one has been specified" do
- @provider.stub!(:run_command_with_systems_locale).with({:command => "/bin/chefhasmonkeypants status"}).and_return(0)
+ @provider.stub(:run_command_with_systems_locale).with({:command => "/bin/chefhasmonkeypants status"}).and_return(0)
@current_resource.should_receive(:running).with(true)
@provider.load_current_resource
end
it "should track state when the user-provided status command fails" do
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_raise(Chef::Exceptions::Exec)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_raise(Chef::Exceptions::Exec)
@provider.load_current_resource
@provider.instance_variable_get("@command_success").should == false
end
it "should set running to false if it catches a Chef::Exceptions::Exec when using a status command" do
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_raise(Chef::Exceptions::Exec)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_raise(Chef::Exceptions::Exec)
@current_resource.should_receive(:running).with(false)
@provider.load_current_resource
end
@@ -201,15 +201,15 @@ describe Chef::Provider::Service::Upstart do
describe "enable and disable service" do
before(:each) do
@current_resource = Chef::Resource::Service.new('rsyslog')
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@provider.current_resource = @current_resource
- Chef::Util::FileEdit.stub!(:new)
+ Chef::Util::FileEdit.stub(:new)
end
it "should enable the service if it is not enabled" do
@file = Object.new
- Chef::Util::FileEdit.stub!(:new).and_return(@file)
- @current_resource.stub!(:enabled).and_return(false)
+ Chef::Util::FileEdit.stub(:new).and_return(@file)
+ @current_resource.stub(:enabled).and_return(false)
@file.should_receive(:search_file_replace)
@file.should_receive(:write_file)
@provider.enable_service()
@@ -217,8 +217,8 @@ describe Chef::Provider::Service::Upstart do
it "should disable the service if it is enabled" do
@file = Object.new
- Chef::Util::FileEdit.stub!(:new).and_return(@file)
- @current_resource.stub!(:enabled).and_return(true)
+ Chef::Util::FileEdit.stub(:new).and_return(@file)
+ @current_resource.stub(:enabled).and_return(true)
@file.should_receive(:search_file_replace)
@file.should_receive(:write_file)
@provider.disable_service()
@@ -230,12 +230,12 @@ describe Chef::Provider::Service::Upstart do
before(:each) do
@current_resource = Chef::Resource::Service.new('rsyslog')
- Chef::Resource::Service.stub!(:new).and_return(@current_resource)
+ Chef::Resource::Service.stub(:new).and_return(@current_resource)
@provider.current_resource = @current_resource
end
it "should call the start command if one is specified" do
- @new_resource.stub!(:start_command).and_return("/sbin/rsyslog startyousillysally")
+ @new_resource.stub(:start_command).and_return("/sbin/rsyslog startyousillysally")
@provider.should_receive(:shell_out!).with("/sbin/rsyslog startyousillysally")
@provider.start_service()
end
@@ -246,7 +246,7 @@ describe Chef::Provider::Service::Upstart do
end
it "should not call '/sbin/start service_name' if it is already running" do
- @current_resource.stub!(:running).and_return(true)
+ @current_resource.stub(:running).and_return(true)
@provider.should_not_receive(:run_command_with_systems_locale).with({:command => "/sbin/start #{@new_resource.service_name}"})
@provider.start_service()
end
@@ -261,52 +261,52 @@ describe Chef::Provider::Service::Upstart do
end
it "should call the restart command if one is specified" do
- @current_resource.stub!(:running).and_return(true)
- @new_resource.stub!(:restart_command).and_return("/sbin/rsyslog restartyousillysally")
+ @current_resource.stub(:running).and_return(true)
+ @new_resource.stub(:restart_command).and_return("/sbin/rsyslog restartyousillysally")
@provider.should_receive(:shell_out!).with("/sbin/rsyslog restartyousillysally")
@provider.restart_service()
end
it "should call '/sbin/restart service_name' if no restart command is specified" do
- @current_resource.stub!(:running).and_return(true)
+ @current_resource.stub(:running).and_return(true)
@provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/restart #{@new_resource.service_name}"}).and_return(0)
@provider.restart_service()
end
it "should call '/sbin/start service_name' if restart_service is called for a stopped service" do
- @current_resource.stub!(:running).and_return(false)
+ @current_resource.stub(:running).and_return(false)
@provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/start #{@new_resource.service_name}"}).and_return(0)
@provider.restart_service()
end
it "should call the reload command if one is specified" do
- @current_resource.stub!(:running).and_return(true)
- @new_resource.stub!(:reload_command).and_return("/sbin/rsyslog reloadyousillysally")
+ @current_resource.stub(:running).and_return(true)
+ @new_resource.stub(:reload_command).and_return("/sbin/rsyslog reloadyousillysally")
@provider.should_receive(:shell_out!).with("/sbin/rsyslog reloadyousillysally")
@provider.reload_service()
end
it "should call '/sbin/reload service_name' if no reload command is specified" do
- @current_resource.stub!(:running).and_return(true)
+ @current_resource.stub(:running).and_return(true)
@provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/reload #{@new_resource.service_name}"}).and_return(0)
@provider.reload_service()
end
it "should call the stop command if one is specified" do
- @current_resource.stub!(:running).and_return(true)
- @new_resource.stub!(:stop_command).and_return("/sbin/rsyslog stopyousillysally")
+ @current_resource.stub(:running).and_return(true)
+ @new_resource.stub(:stop_command).and_return("/sbin/rsyslog stopyousillysally")
@provider.should_receive(:shell_out!).with("/sbin/rsyslog stopyousillysally")
@provider.stop_service()
end
it "should call '/sbin/stop service_name' if no stop command is specified" do
- @current_resource.stub!(:running).and_return(true)
+ @current_resource.stub(:running).and_return(true)
@provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/stop #{@new_resource.service_name}"}).and_return(0)
@provider.stop_service()
end
it "should not call '/sbin/stop service_name' if it is already stopped" do
- @current_resource.stub!(:running).and_return(false)
+ @current_resource.stub(:running).and_return(false)
@provider.should_not_receive(:run_command_with_systems_locale).with({:command => "/sbin/stop #{@new_resource.service_name}"})
@provider.stop_service()
end
diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb
index 7ec4ccf96a..5f4d9ca7d6 100644
--- a/spec/unit/provider/service/windows_spec.rb
+++ b/spec/unit/provider/service/windows_spec.rb
@@ -31,11 +31,11 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
Win32::Service = Class.new
Win32::Service::AUTO_START = 0x00000002
Win32::Service::DISABLED = 0x00000004
- Win32::Service.stub!(:status).with(@new_resource.service_name).and_return(
+ Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
mock("StatusStruct", :current_state => "running"))
- Win32::Service.stub!(:config_info).with(@new_resource.service_name).and_return(
+ Win32::Service.stub(:config_info).with(@new_resource.service_name).and_return(
mock("ConfigStruct", :start_type => "auto start"))
- Win32::Service.stub!(:exists?).and_return(true)
+ Win32::Service.stub(:exists?).and_return(true)
end
it "should set the current resources service name to the new resources service name" do
@@ -59,7 +59,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
describe Chef::Provider::Service::Windows, "start_service" do
before(:each) do
- Win32::Service.stub!(:status).with(@new_resource.service_name).and_return(
+ Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
mock("StatusStruct", :current_state => "stopped"),
mock("StatusStruct", :current_state => "running"))
end
@@ -78,14 +78,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
end
it "should do nothing if the service does not exist" do
- Win32::Service.stub!(:exists?).with(@new_resource.service_name).and_return(false)
+ Win32::Service.stub(:exists?).with(@new_resource.service_name).and_return(false)
Win32::Service.should_not_receive(:start).with(@new_resource.service_name)
@provider.start_service
@new_resource.updated_by_last_action?.should be_false
end
it "should do nothing if the service is running" do
- Win32::Service.stub!(:status).with(@new_resource.service_name).and_return(
+ Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
mock("StatusStruct", :current_state => "running"))
@provider.load_current_resource
Win32::Service.should_not_receive(:start).with(@new_resource.service_name)
@@ -97,7 +97,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
describe Chef::Provider::Service::Windows, "stop_service" do
before(:each) do
- Win32::Service.stub!(:status).with(@new_resource.service_name).and_return(
+ Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
mock("StatusStruct", :current_state => "running"),
mock("StatusStruct", :current_state => "stopped"))
end
@@ -116,14 +116,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
end
it "should do nothing if the service does not exist" do
- Win32::Service.stub!(:exists?).with(@new_resource.service_name).and_return(false)
+ Win32::Service.stub(:exists?).with(@new_resource.service_name).and_return(false)
Win32::Service.should_not_receive(:stop).with(@new_resource.service_name)
@provider.stop_service
@new_resource.updated_by_last_action?.should be_false
end
it "should do nothing if the service is stopped" do
- Win32::Service.stub!(:status).with(@new_resource.service_name).and_return(
+ Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
mock("StatusStruct", :current_state => "stopped"))
@provider.load_current_resource
Win32::Service.should_not_receive(:stop).with(@new_resource.service_name)
@@ -142,7 +142,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
end
it "should stop then start the service if it is running" do
- Win32::Service.stub!(:status).with(@new_resource.service_name).and_return(
+ Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
mock("StatusStruct", :current_state => "running"),
mock("StatusStruct", :current_state => "stopped"),
mock("StatusStruct", :current_state => "stopped"),
@@ -154,7 +154,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
end
it "should just start the service if it is stopped" do
- Win32::Service.stub!(:status).with(@new_resource.service_name).and_return(
+ Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
mock("StatusStruct", :current_state => "stopped"),
mock("StatusStruct", :current_state => "stopped"),
mock("StatusStruct", :current_state => "running"))
@@ -164,7 +164,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
end
it "should do nothing if the service does not exist" do
- Win32::Service.stub!(:exists?).with(@new_resource.service_name).and_return(false)
+ Win32::Service.stub(:exists?).with(@new_resource.service_name).and_return(false)
Win32::Service.should_not_receive(:stop).with(@new_resource.service_name)
Win32::Service.should_not_receive(:start).with(@new_resource.service_name)
@provider.restart_service
@@ -176,7 +176,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
describe Chef::Provider::Service::Windows, "enable_service" do
before(:each) do
- Win32::Service.stub!(:config_info).with(@new_resource.service_name).and_return(
+ Win32::Service.stub(:config_info).with(@new_resource.service_name).and_return(
mock("ConfigStruct", :start_type => "disabled"))
end
@@ -187,14 +187,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
end
it "should do nothing if the service does not exist" do
- Win32::Service.stub!(:exists?).with(@new_resource.service_name).and_return(false)
+ Win32::Service.stub(:exists?).with(@new_resource.service_name).and_return(false)
Win32::Service.should_not_receive(:configure)
@provider.enable_service
@new_resource.updated_by_last_action?.should be_false
end
it "should do nothing if the service is enabled" do
- Win32::Service.stub!(:config_info).with(@new_resource.service_name).and_return(
+ Win32::Service.stub(:config_info).with(@new_resource.service_name).and_return(
mock("ConfigStruct", :start_type => "auto start"))
Win32::Service.should_not_receive(:configure)
@provider.enable_service
@@ -205,7 +205,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
describe Chef::Provider::Service::Windows, "disable_service" do
before(:each) do
- Win32::Service.stub!(:config_info).with(@new_resource.service_name).and_return(
+ Win32::Service.stub(:config_info).with(@new_resource.service_name).and_return(
mock("ConfigStruct", :start_type => "auto start"))
end
@@ -216,14 +216,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
end
it "should do nothing if the service does not exist" do
- Win32::Service.stub!(:exists?).with(@new_resource.service_name).and_return(false)
+ Win32::Service.stub(:exists?).with(@new_resource.service_name).and_return(false)
Win32::Service.should_not_receive(:configure)
@provider.disable_service
@new_resource.updated_by_last_action?.should be_false
end
it "should do nothing if the service is disabled" do
- Win32::Service.stub!(:config_info).with(@new_resource.service_name).and_return(
+ Win32::Service.stub(:config_info).with(@new_resource.service_name).and_return(
mock("ConfigStruct", :start_type => "disabled"))
@provider.load_current_resource
Win32::Service.should_not_receive(:configure)
diff --git a/spec/unit/provider/service_spec.rb b/spec/unit/provider/service_spec.rb
index 3719af56f2..7ddc01ff0b 100644
--- a/spec/unit/provider/service_spec.rb
+++ b/spec/unit/provider/service_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Provider::Service do
@provider = Chef::Provider::Service.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
end
describe "when enabling the service" do
@@ -52,14 +52,14 @@ describe Chef::Provider::Service do
describe "when disabling the service" do
it "should disable the service if enabled and set the resource as updated" do
- @current_resource.stub!(:enabled).and_return(true)
+ @current_resource.stub(:enabled).and_return(true)
@provider.should_receive(:disable_service).and_return(true)
@provider.run_action(:disable)
@provider.new_resource.should be_updated
end
it "should not disable the service if already disabled" do
- @current_resource.stub!(:enabled).and_return(false)
+ @current_resource.stub(:enabled).and_return(false)
@provider.should_not_receive(:disable_service)
@provider.run_action(:disable)
@provider.new_resource.should_not be_updated
@@ -84,14 +84,14 @@ describe Chef::Provider::Service do
describe "action_stop" do
it "should stop the service if it is running and set the resource as updated" do
- @current_resource.stub!(:running).and_return(true)
+ @current_resource.stub(:running).and_return(true)
@provider.should_receive(:stop_service).and_return(true)
@provider.run_action(:stop)
@provider.new_resource.should be_updated
end
it "should not stop the service if it's already stopped" do
- @current_resource.stub!(:running).and_return(false)
+ @current_resource.stub(:running).and_return(false)
@provider.should_not_receive(:stop_service)
@provider.run_action(:stop)
@provider.new_resource.should_not be_updated
@@ -110,7 +110,7 @@ describe Chef::Provider::Service do
end
it "should restart the service even if it isn't running and set the resource as updated" do
- @current_resource.stub!(:running).and_return(false)
+ @current_resource.stub(:running).and_return(false)
@provider.should_receive(:restart_service).and_return(true)
@provider.run_action(:restart)
@provider.new_resource.should be_updated
@@ -124,19 +124,19 @@ describe Chef::Provider::Service do
it "should raise an exception if reload isn't supported" do
@new_resource.supports(:reload => false)
- @new_resource.stub!(:reload_command).and_return(false)
+ @new_resource.stub(:reload_command).and_return(false)
lambda { @provider.run_action(:reload) }.should raise_error(Chef::Exceptions::UnsupportedAction)
end
it "should reload the service if it is running and set the resource as updated" do
- @current_resource.stub!(:running).and_return(true)
+ @current_resource.stub(:running).and_return(true)
@provider.should_receive(:reload_service).and_return(true)
@provider.run_action(:reload)
@provider.new_resource.should be_updated
end
it "should not reload the service if it's stopped" do
- @current_resource.stub!(:running).and_return(false)
+ @current_resource.stub(:running).and_return(false)
@provider.should_not_receive(:reload_service)
@provider.run_action(:stop)
@provider.new_resource.should_not be_updated
diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb
index dd020d4597..123ce1cf35 100644
--- a/spec/unit/provider/subversion_spec.rb
+++ b/spec/unit/provider/subversion_spec.rb
@@ -66,9 +66,9 @@ describe Chef::Provider::Subversion do
::File.should_receive(:exist?).at_least(1).times.with("/my/deploy/dir/.svn").and_return(true)
::File.should_receive(:directory?).with("/my/deploy/dir").and_return(true)
::Dir.should_receive(:chdir).with("/my/deploy/dir").and_yield
- @stdout.stub!(:string).and_return(example_svn_info)
- @stderr.stub!(:string).and_return("")
- @exitstatus.stub!(:exitstatus).and_return(0)
+ @stdout.stub(:string).and_return(example_svn_info)
+ @stderr.stub(:string).and_return("")
+ @exitstatus.stub(:exitstatus).and_return(0)
expected_command = ["svn info", {:cwd=>"/my/deploy/dir"}]
@provider.should_receive(:popen4).with(*expected_command).
and_yield("no-pid", "no-stdin", @stdout,@stderr).
@@ -81,9 +81,9 @@ describe Chef::Provider::Subversion do
::File.should_receive(:exist?).with("/my/deploy/dir/.svn").and_return(true)
::File.should_receive(:directory?).with("/my/deploy/dir").and_return(true)
::Dir.should_receive(:chdir).with("/my/deploy/dir").and_yield
- @stdout.stub!(:string).and_return(example_svn_info)
- @stderr.stub!(:string).and_return("")
- @exitstatus.stub!(:exitstatus).and_return(1)
+ @stdout.stub(:string).and_return(example_svn_info)
+ @stderr.stub(:string).and_return("")
+ @exitstatus.stub(:exitstatus).and_return(1)
@provider.should_receive(:popen4).and_yield("no-pid", "no-stdin", @stdout,@stderr).
and_return(@exitstatus)
@provider.find_current_revision.should be_nil
@@ -99,7 +99,7 @@ describe Chef::Provider::Subversion do
end
it "creates the current_resource object and sets its revision to the current deployment's revision as long as we're not exporting" do
- @provider.stub!(:find_current_revision).and_return("11410")
+ @provider.stub(:find_current_revision).and_return("11410")
@provider.new_resource.instance_variable_set :@action, [:checkout]
@provider.load_current_resource
@provider.current_resource.name.should eql(@resource.name)
@@ -129,10 +129,10 @@ describe Chef::Provider::Subversion do
"Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision
"Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n"
exitstatus = mock("exitstatus")
- exitstatus.stub!(:exitstatus).and_return(0)
+ exitstatus.stub(:exitstatus).and_return(0)
@resource.revision "HEAD"
- @stdout.stub!(:string).and_return(example_svn_info)
- @stderr.stub!(:string).and_return("")
+ @stdout.stub(:string).and_return(example_svn_info)
+ @stderr.stub(:string).and_return("")
expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", {:cwd=>Dir.tmpdir}]
@provider.should_receive(:popen4).with(*expected_command).
and_yield("no-pid","no-stdin",@stdout,@stderr).
@@ -143,10 +143,10 @@ describe Chef::Provider::Subversion do
it "returns a helpful message if data from `svn info` can't be parsed" do
example_svn_info = "some random text from an error message\n"
exitstatus = mock("exitstatus")
- exitstatus.stub!(:exitstatus).and_return(0)
+ exitstatus.stub(:exitstatus).and_return(0)
@resource.revision "HEAD"
- @stdout.stub!(:string).and_return(example_svn_info)
- @stderr.stub!(:string).and_return("")
+ @stdout.stub(:string).and_return(example_svn_info)
+ @stderr.stub(:string).and_return("")
@provider.should_receive(:popen4).and_yield("no-pid","no-stdin",@stdout,@stderr).
and_return(exitstatus)
lambda {@provider.revision_int}.should raise_error(RuntimeError, "Could not parse `svn info` data: some random text from an error message")
@@ -197,7 +197,7 @@ describe Chef::Provider::Subversion do
end
it "runs an export with the --force option" do
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
expected_cmd = "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
@provider.should_receive(:run_command).with(:command => expected_cmd)
@provider.run_action(:force_export)
@@ -205,7 +205,7 @@ describe Chef::Provider::Subversion do
end
it "runs the checkout command for action_checkout" do
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
expected_cmd = "svn checkout -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
@provider.should_receive(:run_command).with(:command => expected_cmd)
@provider.run_action(:checkout)
@@ -217,17 +217,17 @@ describe Chef::Provider::Subversion do
end
it "should not checkout if the destination exists or is a non empty directory" do
- ::File.stub!(:exist?).with("/my/deploy/dir/.svn").and_return(false)
- ::File.stub!(:exist?).with("/my/deploy/dir").and_return(true)
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
- ::Dir.stub!(:entries).with("/my/deploy/dir").and_return(['.','..','foo','bar'])
+ ::File.stub(:exist?).with("/my/deploy/dir/.svn").and_return(false)
+ ::File.stub(:exist?).with("/my/deploy/dir").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
+ ::Dir.stub(:entries).with("/my/deploy/dir").and_return(['.','..','foo','bar'])
@provider.should_not_receive(:checkout_command)
@provider.run_action(:checkout)
@resource.should_not be_updated
end
it "runs commands with the user and group specified in the resource" do
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
@resource.user "whois"
@resource.group "thisis"
expected_cmd = "svn checkout -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
@@ -237,24 +237,24 @@ describe Chef::Provider::Subversion do
end
it "does a checkout for action_sync if there's no deploy dir" do
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
::File.should_receive(:exist?).with("/my/deploy/dir/.svn").twice.and_return(false)
@provider.should_receive(:action_checkout)
@provider.run_action(:sync)
end
it "does a checkout for action_sync if the deploy dir exists but is empty" do
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
::File.should_receive(:exist?).with("/my/deploy/dir/.svn").twice.and_return(false)
@provider.should_receive(:action_checkout)
@provider.run_action(:sync)
end
it "runs the sync_command on action_sync if the deploy dir exists and isn't empty" do
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
::File.should_receive(:exist?).with("/my/deploy/dir/.svn").and_return(true)
- @provider.stub!(:find_current_revision).and_return("11410")
- @provider.stub!(:current_revision_matches_target_revision?).and_return(false)
+ @provider.stub(:find_current_revision).and_return("11410")
+ @provider.stub(:current_revision_matches_target_revision?).and_return(false)
expected_cmd = "svn update -q -r12345 /my/deploy/dir"
@provider.should_receive(:run_command).with(:command => expected_cmd)
@provider.run_action(:sync)
@@ -262,16 +262,16 @@ describe Chef::Provider::Subversion do
end
it "does not fetch any updates if the remote revision matches the current revision" do
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
::File.should_receive(:exist?).with("/my/deploy/dir/.svn").and_return(true)
- @provider.stub!(:find_current_revision).and_return('12345')
- @provider.stub!(:current_revision_matches_target_revision?).and_return(true)
+ @provider.stub(:find_current_revision).and_return('12345')
+ @provider.stub(:current_revision_matches_target_revision?).and_return(true)
@provider.run_action(:sync)
@resource.should_not be_updated
end
it "runs the export_command on action_export" do
- ::File.stub!(:directory?).with("/my/deploy").and_return(true)
+ ::File.stub(:directory?).with("/my/deploy").and_return(true)
expected_cmd = "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
@provider.should_receive(:run_command).with(:command => expected_cmd)
@provider.run_action(:export)
diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb
index 4061d99d7b..1251f96bd3 100644
--- a/spec/unit/provider/template/content_spec.rb
+++ b/spec/unit/provider/template/content_spec.rb
@@ -58,15 +58,15 @@ describe Chef::Provider::Template::Content do
end
it "finds the template file locally if it is local" do
- new_resource.stub!(:local).and_return(true)
- new_resource.stub!(:source).and_return('/tmp/its_on_disk.erb')
+ new_resource.stub(:local).and_return(true)
+ new_resource.stub(:source).and_return('/tmp/its_on_disk.erb')
content.template_location.should == '/tmp/its_on_disk.erb'
end
it "should use the cookbook name if defined in the template resource" do
- new_resource.stub!(:cookbook_name).and_return('apache2')
- new_resource.stub!(:cookbook).and_return('openldap')
- new_resource.stub!(:source).and_return("test.erb")
+ new_resource.stub(:cookbook_name).and_return('apache2')
+ new_resource.stub(:cookbook).and_return('openldap')
+ new_resource.stub(:source).and_return("test.erb")
content.template_location.should == CHEF_SPEC_DATA + '/cookbooks/openldap/templates/default/test.erb'
end
diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb
index dd98c55bd1..2e0de1364c 100644
--- a/spec/unit/provider/user/dscl_spec.rb
+++ b/spec/unit/provider/user/dscl_spec.rb
@@ -64,7 +64,7 @@ describe Chef::Provider::User::Dscl do
describe "get_free_uid" do
before do
- @provider.stub!(:safe_dscl).and_return("\nwheel 200\nstaff 201\n")
+ @provider.stub(:safe_dscl).and_return("\nwheel 200\nstaff 201\n")
end
it "should run safe_dscl with list /Users uid" do
@@ -84,7 +84,7 @@ describe Chef::Provider::User::Dscl do
describe "uid_used?" do
before do
- @provider.stub!(:safe_dscl).and_return("\naj 500\n")
+ @provider.stub(:safe_dscl).and_return("\naj 500\n")
end
it "should run safe_dscl with list /Users uid" do
@@ -107,7 +107,7 @@ describe Chef::Provider::User::Dscl do
describe "when determining the uid to set" do
it "raises RequestedUIDUnavailable if the requested uid is already in use" do
- @provider.stub!(:uid_used?).and_return(true)
+ @provider.stub(:uid_used?).and_return(true)
@provider.should_receive(:get_free_uid).and_return(501)
lambda { @provider.set_uid }.should raise_error(Chef::Exceptions::RequestedUIDUnavailable)
end
@@ -156,8 +156,8 @@ describe Chef::Provider::User::Dscl do
current_home_files = [current_home + '/my-dot-emacs', current_home + '/my-dot-vim']
@current_resource.home(current_home)
@new_resource.gid(23)
- ::File.stub!(:exists?).with('/old/home/toor').and_return(true)
- ::File.stub!(:exists?).with('/Users/toor').and_return(true)
+ ::File.stub(:exists?).with('/old/home/toor').and_return(true)
+ ::File.stub(:exists?).with('/Users/toor').and_return(true)
FileUtils.should_receive(:mkdir_p).with('/Users/toor').and_return(true)
FileUtils.should_receive(:rmdir).with(current_home)
@@ -170,7 +170,7 @@ describe Chef::Provider::User::Dscl do
end
it "should raise an exception when the systems user template dir (skel) cannot be found" do
- ::File.stub!(:exists?).and_return(false,false,false)
+ ::File.stub(:exists?).and_return(false,false,false)
lambda { @provider.modify_home }.should raise_error(Chef::Exceptions::User)
end
@@ -284,7 +284,7 @@ describe Chef::Provider::User::Dscl do
uuid = "B398449E-CEE0-45E0-80F8-B0B5B1BFDEAA"
File.should_receive(:open).with('/var/db/shadow/hash/B398449E-CEE0-45E0-80F8-B0B5B1BFDEAA', "w", 384).and_yield(@output)
@new_resource.password("password")
- OpenSSL::Random.stub!(:random_bytes).and_return("\377\377\377\377\377\377\377\377")
+ OpenSSL::Random.stub(:random_bytes).and_return("\377\377\377\377\377\377\377\377")
expected_salted_sha1 = "F"*8+"SHA1-"*8
expected_shadow_hash = "00000000"*155
expected_shadow_hash[168] = expected_salted_sha1
@@ -324,7 +324,7 @@ describe Chef::Provider::User::Dscl do
end
it "shouldn't raise an error if /usr/bin/dscl exists" do
- ::File.stub!(:exists?).and_return(true)
+ ::File.stub(:exists?).and_return(true)
lambda { @provider.load_current_resource }.should_not raise_error(Chef::Exceptions::User)
end
end
diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb
index ea5bcfe740..ed22984c62 100644
--- a/spec/unit/provider/user/pw_spec.rb
+++ b/spec/unit/provider/user/pw_spec.rb
@@ -62,13 +62,13 @@ describe Chef::Provider::User::Pw do
end
it "should set the option for #{attribute} if the new resources #{attribute} is not null" do
- @new_resource.stub!(attribute).and_return("hola")
+ @new_resource.stub(attribute).and_return("hola")
@provider.set_options.should eql(" #{@new_resource.username} #{option} '#{@new_resource.send(attribute)}' -m")
end
it "should set the option for #{attribute} if the new resources #{attribute} is not null, without homedir management" do
- @new_resource.stub!(:supports).and_return({:manage_home => false})
- @new_resource.stub!(attribute).and_return("hola")
+ @new_resource.stub(:supports).and_return({:manage_home => false})
+ @new_resource.stub(attribute).and_return("hola")
@provider.set_options.should eql(" #{@new_resource.username} #{option} '#{@new_resource.send(attribute)}'")
end
end
@@ -76,7 +76,7 @@ describe Chef::Provider::User::Pw do
it "should combine all the possible options" do
match_string = " adam"
field_list.sort{ |a,b| a[0] <=> b[0] }.each do |attribute, option|
- @new_resource.stub!(attribute).and_return("hola")
+ @new_resource.stub(attribute).and_return("hola")
match_string << " #{option} 'hola'"
end
match_string << " -m"
@@ -86,8 +86,8 @@ describe Chef::Provider::User::Pw do
describe "create_user" do
before(:each) do
- @provider.stub!(:run_command).and_return(true)
- @provider.stub!(:modify_password).and_return(true)
+ @provider.stub(:run_command).and_return(true)
+ @provider.stub(:modify_password).and_return(true)
end
it "should run pw useradd with the return of set_options" do
@@ -103,8 +103,8 @@ describe Chef::Provider::User::Pw do
describe "manage_user" do
before(:each) do
- @provider.stub!(:run_command).and_return(true)
- @provider.stub!(:modify_password).and_return(true)
+ @provider.stub(:run_command).and_return(true)
+ @provider.stub(:modify_password).and_return(true)
end
it "should run pw usermod with the return of set_options" do
@@ -133,12 +133,12 @@ describe Chef::Provider::User::Pw do
describe "determining if the user is locked" do
it "should return true if user is locked" do
- @current_resource.stub!(:password).and_return("*LOCKED*abracadabra")
+ @current_resource.stub(:password).and_return("*LOCKED*abracadabra")
@provider.check_lock.should eql(true)
end
it "should return false if user is not locked" do
- @current_resource.stub!(:password).and_return("abracadabra")
+ @current_resource.stub(:password).and_return("abracadabra")
@provider.check_lock.should eql(false)
end
end
@@ -160,7 +160,7 @@ describe Chef::Provider::User::Pw do
describe "when modifying the password" do
before(:each) do
@status = mock("Status", :exitstatus => 0)
- @provider.stub!(:popen4).and_return(@status)
+ @provider.stub(:popen4).and_return(@status)
@pid, @stdin, @stdout, @stderr = nil, nil, nil, nil
end
@@ -172,8 +172,8 @@ describe Chef::Provider::User::Pw do
describe "and the passwords are identical" do
before(:each) do
- @new_resource.stub!(:password).and_return("abracadabra")
- @current_resource.stub!(:password).and_return("abracadabra")
+ @new_resource.stub(:password).and_return("abracadabra")
+ @current_resource.stub(:password).and_return("abracadabra")
end
it "logs an appropriate message" do
@@ -184,8 +184,8 @@ describe Chef::Provider::User::Pw do
describe "and the passwords are different" do
before(:each) do
- @new_resource.stub!(:password).and_return("abracadabra")
- @current_resource.stub!(:password).and_return("sesame")
+ @new_resource.stub(:password).and_return("abracadabra")
+ @current_resource.stub(:password).and_return("sesame")
end
it "should log an appropriate message" do
@@ -200,7 +200,7 @@ describe Chef::Provider::User::Pw do
it "should send the new password to the stdin of pw usermod" do
@stdin = StringIO.new
- @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.modify_password
@stdin.string.should == "abracadabra\n"
end
@@ -228,7 +228,7 @@ describe Chef::Provider::User::Pw do
end
it "shouldn't raise an error if /usr/sbin/pw exists" do
- File.stub!(:exists?).and_return(true)
+ File.stub(:exists?).and_return(true)
lambda { @provider.load_current_resource }.should_not raise_error(Chef::Exceptions::User)
end
end
diff --git a/spec/unit/provider/user/solaris_spec.rb b/spec/unit/provider/user/solaris_spec.rb
index 5500eac812..d8bd0f9e75 100644
--- a/spec/unit/provider/user/solaris_spec.rb
+++ b/spec/unit/provider/user/solaris_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Provider::User::Solaris do
p.current_resource = @current_resource
# Prevent the useradd-based provider tests from trying to write /etc/shadow
- p.stub!(:write_shadow_file)
+ p.stub(:write_shadow_file)
p
end
@@ -52,12 +52,12 @@ describe Chef::Provider::User::Solaris do
@new_resource.password "hocus-pocus"
# Let these tests run #write_shadow_file
- provider.unstub!(:write_shadow_file)
+ provider.unstub(:write_shadow_file)
end
it "should use its own shadow file writer to set the password" do
provider.should_receive(:write_shadow_file)
- provider.stub!(:shell_out!).and_return(true)
+ provider.stub(:shell_out!).and_return(true)
provider.manage_user
end
@@ -66,10 +66,10 @@ describe Chef::Provider::User::Solaris do
password_file.puts "adam:existingpassword:15441::::::"
password_file.close
provider.password_file = password_file.path
- provider.stub!(:shell_out!).and_return(true)
+ provider.stub(:shell_out!).and_return(true)
# may not be able to write to /etc for tests...
temp_file = Tempfile.new("shadow")
- Tempfile.stub!(:new).with("shadow", "/etc").and_return(temp_file)
+ Tempfile.stub(:new).with("shadow", "/etc").and_return(temp_file)
@new_resource.password "verysecurepassword"
provider.manage_user
::File.open(password_file.path, "r").read.should =~ /adam:verysecurepassword:/
diff --git a/spec/unit/provider/user/windows_spec.rb b/spec/unit/provider/user/windows_spec.rb
index b11eeaebe5..9cdb2b5d79 100644
--- a/spec/unit/provider/user/windows_spec.rb
+++ b/spec/unit/provider/user/windows_spec.rb
@@ -36,7 +36,7 @@ describe Chef::Provider::User::Windows do
@current_resource = Chef::Resource::User.new("monkey")
@net_user = mock("Chef::Util::Windows::NetUser")
- Chef::Util::Windows::NetUser.stub!(:new).and_return(@net_user)
+ Chef::Util::Windows::NetUser.stub(:new).and_return(@net_user)
@provider = Chef::Provider::User::Windows.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
@@ -120,7 +120,7 @@ describe Chef::Provider::User::Windows do
describe "when creating the user" do
it "should call @net_user.add with the return of set_options" do
- @provider.stub!(:set_options).and_return(:name=> "monkey")
+ @provider.stub(:set_options).and_return(:name=> "monkey")
@net_user.should_receive(:add).with(:name=> "monkey")
@provider.create_user
end
@@ -128,7 +128,7 @@ describe Chef::Provider::User::Windows do
describe "manage_user" do
before(:each) do
- @provider.stub!(:set_options).and_return(:name=> "monkey")
+ @provider.stub(:set_options).and_return(:name=> "monkey")
end
it "should call @net_user.update with the return of set_options" do
@@ -150,19 +150,19 @@ describe Chef::Provider::User::Windows do
end
it "should return true if user is locked" do
- @net_user.stub!(:check_enabled).and_return(true)
+ @net_user.stub(:check_enabled).and_return(true)
@provider.check_lock.should eql(true)
end
it "should return false if user is not locked" do
- @net_user.stub!(:check_enabled).and_return(false)
+ @net_user.stub(:check_enabled).and_return(false)
@provider.check_lock.should eql(false)
end
end
describe "locking the user" do
it "should call @net_user.disable_account" do
- @net_user.stub!(:check_enabled).and_return(true)
+ @net_user.stub(:check_enabled).and_return(true)
@net_user.should_receive(:disable_account)
@provider.lock_user
end
@@ -170,7 +170,7 @@ describe Chef::Provider::User::Windows do
describe "unlocking the user" do
it "should call @net_user.enable_account" do
- @net_user.stub!(:check_enabled).and_return(false)
+ @net_user.stub(:check_enabled).and_return(false)
@net_user.should_receive(:enable_account)
@provider.unlock_user
end
diff --git a/spec/unit/provider/user_spec.rb b/spec/unit/provider/user_spec.rb
index d5e694b79c..7b29e51c3f 100644
--- a/spec/unit/provider/user_spec.rb
+++ b/spec/unit/provider/user_spec.rb
@@ -69,7 +69,7 @@ describe Chef::Provider::User do
# :password => nil,
# :updated => nil
#)
- Chef::Resource::User.stub!(:new).and_return(@current_resource)
+ Chef::Resource::User.stub(:new).and_return(@current_resource)
@pw_user = EtcPwnamIsh.new
@pw_user.name = "adam"
@pw_user.gid = 1000
@@ -78,7 +78,7 @@ describe Chef::Provider::User do
@pw_user.dir = "/home/adam"
@pw_user.shell = "/usr/bin/zsh"
@pw_user.passwd = "*"
- Etc.stub!(:getpwnam).and_return(@pw_user)
+ Etc.stub(:getpwnam).and_return(@pw_user)
end
it "should create a current resource with the same name as the new resource" do
@@ -129,7 +129,7 @@ describe Chef::Provider::User do
end
it "shouldn't try and convert the group gid if none has been supplied" do
- @new_resource.stub!(:gid).and_return(nil)
+ @new_resource.stub(:gid).and_return(nil)
@provider.should_not_receive(:convert_group_name)
@provider.load_current_resource
end
@@ -156,7 +156,7 @@ describe Chef::Provider::User do
user.name = "root"
user.passwd = "x"
@new_resource.password "some new password"
- Etc.stub!(:getpwnam).and_return(user)
+ Etc.stub(:getpwnam).and_return(user)
end
unless shadow_lib_unavail?
@@ -225,7 +225,7 @@ describe Chef::Provider::User do
describe "action_create" do
before(:each) do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
# @current_resource = mock("Chef::Resource::User",
# :null_object => true,
# :username => "adam",
@@ -240,8 +240,8 @@ describe Chef::Provider::User do
# @provider = Chef::Provider::User.new(@node, @new_resource)
# @provider.current_resource = @current_resource
# @provider.user_exists = false
- # @provider.stub!(:create_user).and_return(true)
- # @provider.stub!(:manage_user).and_return(true)
+ # @provider.stub(:create_user).and_return(true)
+ # @provider.stub(:manage_user).and_return(true)
end
it "should call create_user if the user does not exist" do
@@ -254,15 +254,15 @@ describe Chef::Provider::User do
it "should call manage_user if the user exists and has mismatched attributes" do
@provider.user_exists = true
- @provider.stub!(:compare_user).and_return(true)
+ @provider.stub(:compare_user).and_return(true)
@provider.should_receive(:manage_user).and_return(true)
@provider.action_create
end
it "should set the new_resources updated flag when it creates the user if we call manage_user" do
@provider.user_exists = true
- @provider.stub!(:compare_user).and_return(true)
- @provider.stub!(:manage_user).and_return(true)
+ @provider.stub(:compare_user).and_return(true)
+ @provider.stub(:manage_user).and_return(true)
@provider.action_create
@provider.set_updated_status
@new_resource.should be_updated
@@ -271,7 +271,7 @@ describe Chef::Provider::User do
describe "action_remove" do
before(:each) do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
end
it "should not call remove_user if the user does not exist" do
@@ -297,7 +297,7 @@ describe Chef::Provider::User do
describe "action_manage" do
before(:each) do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
# @node = Chef::Node.new
# @new_resource = mock("Chef::Resource::User",
# :null_object => true
@@ -308,7 +308,7 @@ describe Chef::Provider::User do
# @provider = Chef::Provider::User.new(@node, @new_resource)
# @provider.current_resource = @current_resource
# @provider.user_exists = true
- # @provider.stub!(:manage_user).and_return(true)
+ # @provider.stub(:manage_user).and_return(true)
end
it "should run manage_user if the user exists and has mismatched attributes" do
@@ -318,8 +318,8 @@ describe Chef::Provider::User do
end
it "should set the new resources updated flag to true if manage_user is called" do
- @provider.stub!(:compare_user).and_return(true)
- @provider.stub!(:manage_user).and_return(true)
+ @provider.stub(:compare_user).and_return(true)
+ @provider.stub(:manage_user).and_return(true)
@provider.action_manage
@provider.set_updated_status
@new_resource.should be_updated
@@ -340,7 +340,7 @@ describe Chef::Provider::User do
describe "action_modify" do
before(:each) do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
# @node = Chef::Node.new
# @new_resource = mock("Chef::Resource::User",
# :null_object => true
@@ -351,7 +351,7 @@ describe Chef::Provider::User do
# @provider = Chef::Provider::User.new(@node, @new_resource)
# @provider.current_resource = @current_resource
# @provider.user_exists = true
- # @provider.stub!(:manage_user).and_return(true)
+ # @provider.stub(:manage_user).and_return(true)
end
it "should run manage_user if the user exists and has mismatched attributes" do
@@ -361,8 +361,8 @@ describe Chef::Provider::User do
end
it "should set the new resources updated flag to true if manage_user is called" do
- @provider.stub!(:compare_user).and_return(true)
- @provider.stub!(:manage_user).and_return(true)
+ @provider.stub(:compare_user).and_return(true)
+ @provider.stub(:manage_user).and_return(true)
@provider.action_modify
@provider.set_updated_status
@new_resource.should be_updated
@@ -383,16 +383,16 @@ describe Chef::Provider::User do
describe "action_lock" do
before(:each) do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
end
it "should lock the user if it exists and is unlocked" do
- @provider.stub!(:check_lock).and_return(false)
+ @provider.stub(:check_lock).and_return(false)
@provider.should_receive(:lock_user).and_return(true)
@provider.action_lock
end
it "should set the new resources updated flag to true if lock_user is called" do
- @provider.stub!(:check_lock).and_return(false)
+ @provider.stub(:check_lock).and_return(false)
@provider.should_receive(:lock_user)
@provider.action_lock
@provider.set_updated_status
@@ -409,7 +409,7 @@ describe Chef::Provider::User do
describe "action_unlock" do
before(:each) do
- @provider.stub!(:load_current_resource)
+ @provider.stub(:load_current_resource)
# @node = Chef::Node.new
# @new_resource = mock("Chef::Resource::User",
# :null_object => true
@@ -420,12 +420,12 @@ describe Chef::Provider::User do
# @provider = Chef::Provider::User.new(@node, @new_resource)
# @provider.current_resource = @current_resource
# @provider.user_exists = true
- # @provider.stub!(:check_lock).and_return(true)
- # @provider.stub!(:unlock_user).and_return(true)
+ # @provider.stub(:check_lock).and_return(true)
+ # @provider.stub(:unlock_user).and_return(true)
end
it "should unlock the user if it exists and is locked" do
- @provider.stub!(:check_lock).and_return(true)
+ @provider.stub(:check_lock).and_return(true)
@provider.should_receive(:unlock_user).and_return(true)
@provider.action_unlock
@provider.set_updated_status