diff options
Diffstat (limited to 'spec/unit/provider/cron_spec.rb')
-rw-r--r-- | spec/unit/provider/cron_spec.rb | 72 |
1 files changed, 36 insertions, 36 deletions
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") |