diff options
author | Claire McQuin <claire@getchef.com> | 2014-10-29 15:14:22 -0700 |
---|---|---|
committer | Claire McQuin <claire@getchef.com> | 2014-10-29 15:59:04 -0700 |
commit | 5fed7a65a2f024d964ecf2de1bcf2911cf8a600c (patch) | |
tree | 14cc6968e4fe4fd2485c0211088b25c645a80a4b /spec/unit/handler_spec.rb | |
parent | b92c309b0f1aa0837f76ab89d6c81c36076ceca9 (diff) | |
download | chef-5fed7a65a2f024d964ecf2de1bcf2911cf8a600c.tar.gz |
Update to RSpec 3.
Diffstat (limited to 'spec/unit/handler_spec.rb')
-rw-r--r-- | spec/unit/handler_spec.rb | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/spec/unit/handler_spec.rb b/spec/unit/handler_spec.rb index 3a7e046dd5..a9aa0e0b50 100644 --- a/spec/unit/handler_spec.rb +++ b/spec/unit/handler_spec.rb @@ -42,54 +42,54 @@ describe Chef::Handler do @run_status.run_context = @run_context @start_time = Time.now @end_time = @start_time + 4.2 - Time.stub(:now).and_return(@start_time, @end_time) + allow(Time).to receive(:now).and_return(@start_time, @end_time) @run_status.start_clock @run_status.stop_clock end it "has a shortcut for the exception" do - @handler.exception.should == @exception + expect(@handler.exception).to eq(@exception) end it "has a shortcut for the backtrace" do - @handler.backtrace.should == @backtrace + expect(@handler.backtrace).to eq(@backtrace) end it "has a shortcut for all resources" do - @handler.all_resources.should == @all_resources + expect(@handler.all_resources).to eq(@all_resources) end it "has a shortcut for just the updated resources" do - @handler.updated_resources.should == [@all_resources.first] + expect(@handler.updated_resources).to eq([@all_resources.first]) end it "has a shortcut for the start time" do - @handler.start_time.should == @start_time + expect(@handler.start_time).to eq(@start_time) end it "has a shortcut for the end time" do - @handler.end_time.should == @end_time + expect(@handler.end_time).to eq(@end_time) end it "has a shortcut for the elapsed time" do - @handler.elapsed_time.should == 4.2 + expect(@handler.elapsed_time).to eq(4.2) end it "has a shortcut for the node" do - @handler.node.should == @node + expect(@handler.node).to eq(@node) end it "has a shortcut for the run context" do - @handler.run_context.should == @run_context + expect(@handler.run_context).to eq(@run_context) end it "has a shortcut for the success? and failed? predicates" do - @handler.success?.should be_false # becuase there's an exception - @handler.failed?.should be_true + expect(@handler.success?).to be_falsey # becuase there's an exception + expect(@handler.failed?).to be_truthy end it "has a shortcut to the hash representation of the run status" do - @handler.data.should == @run_status.to_hash + expect(@handler.data).to eq(@run_status.to_hash) end end @@ -100,16 +100,16 @@ describe Chef::Handler do $report_ran = true raise Exception, "I died the deth" end - lambda {@handler.run_report_safely(@run_status)}.should_not raise_error - $report_ran.should be_true + expect {@handler.run_report_safely(@run_status)}.not_to raise_error + expect($report_ran).to be_truthy end it "does not fail if the report handler does not raise an exception" do $report_ran = false def @handler.report $report_ran = true end - lambda {@handler.run_report_safely(@run_status)}.should_not raise_error - $report_ran.should be_true + expect {@handler.run_report_safely(@run_status)}.not_to raise_error + expect($report_ran).to be_truthy end end @@ -123,46 +123,46 @@ describe Chef::Handler do @run_status.run_context = @run_context @start_time = Time.now @end_time = @start_time + 4.2 - Time.stub(:now).and_return(@start_time, @end_time) + allow(Time).to receive(:now).and_return(@start_time, @end_time) @run_status.start_clock @run_status.stop_clock end it "has a shortcut for all resources" do - @handler.all_resources.should == @all_resources + expect(@handler.all_resources).to eq(@all_resources) end it "has a shortcut for just the updated resources" do - @handler.updated_resources.should == [@all_resources.first] + expect(@handler.updated_resources).to eq([@all_resources.first]) end it "has a shortcut for the start time" do - @handler.start_time.should == @start_time + expect(@handler.start_time).to eq(@start_time) end it "has a shortcut for the end time" do - @handler.end_time.should == @end_time + expect(@handler.end_time).to eq(@end_time) end it "has a shortcut for the elapsed time" do - @handler.elapsed_time.should == 4.2 + expect(@handler.elapsed_time).to eq(4.2) end it "has a shortcut for the node" do - @handler.node.should == @node + expect(@handler.node).to eq(@node) end it "has a shortcut for the run context" do - @handler.run_context.should == @run_context + expect(@handler.run_context).to eq(@run_context) end it "has a shortcut for the success? and failed? predicates" do - @handler.success?.should be_true - @handler.failed?.should be_false + expect(@handler.success?).to be_truthy + expect(@handler.failed?).to be_falsey end it "has a shortcut to the hash representation of the run status" do - @handler.data.should == @run_status.to_hash + expect(@handler.data).to eq(@run_status.to_hash) end end @@ -170,45 +170,45 @@ describe Chef::Handler do describe "when running a start handler" do before do @start_time = Time.now - Time.stub(:now).and_return(@start_time) + allow(Time).to receive(:now).and_return(@start_time) @run_status.start_clock end it "should not have all resources" do - @handler.all_resources.should be_false + expect(@handler.all_resources).to be_falsey end it "should not have updated resources" do - @handler.updated_resources.should be_false + expect(@handler.updated_resources).to be_falsey end it "has a shortcut for the start time" do - @handler.start_time.should == @start_time + expect(@handler.start_time).to eq(@start_time) end it "does not have a shortcut for the end time" do - @handler.end_time.should be_false + expect(@handler.end_time).to be_falsey end it "does not have a shortcut for the elapsed time" do - @handler.elapsed_time.should be_false + expect(@handler.elapsed_time).to be_falsey end it "has a shortcut for the node" do - @handler.node.should == @node + expect(@handler.node).to eq(@node) end it "does not have a shortcut for the run context" do - @handler.run_context.should be_false + expect(@handler.run_context).to be_falsey end it "has a shortcut for the success? and failed? predicates" do - @handler.success?.should be_true # for some reason this is true - @handler.failed?.should be_false + expect(@handler.success?).to be_truthy # for some reason this is true + expect(@handler.failed?).to be_falsey end it "has a shortcut to the hash representation of the run status" do - @handler.data.should == @run_status.to_hash + expect(@handler.data).to eq(@run_status.to_hash) end end |