summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Shpakov <igorshp@gmail.com>2015-04-09 15:42:03 +0100
committerIgor Shpakov <igorshp@gmail.com>2015-04-09 15:42:03 +0100
commitcd21b8c4f46678e01beb13100b1413a813f87d26 (patch)
tree317be70127fe70829d824a4bf058310cd8d9d76f
parent8f971a1c5e7a1095798aee6874aecc42047d37ab (diff)
downloadchef-cd21b8c4f46678e01beb13100b1413a813f87d26.tar.gz
added rspec test
testing early fail inside 'run#begin' block.
-rw-r--r--spec/unit/client_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb
index fa8317744c..cef8f970bc 100644
--- a/spec/unit/client_spec.rb
+++ b/spec/unit/client_spec.rb
@@ -819,4 +819,24 @@ describe Chef::Client do
end
end
+
+ describe "should always attempt to run handlers" do
+ let(:e) { NoMethodError }
+ subject { client }
+ before do
+ # fail on the first thing in begin block
+ allow_any_instance_of(Chef::RunLock).to receive(:save_pid).and_raise(e)
+ end
+
+ it "should run exception handlers on early fail" do
+ expect(subject).to receive(:run_failed)
+ exception = nil
+ begin
+ subject.run
+ rescue e => ex
+ exception = ex
+ end
+ expect(exception).to be_instance_of(e)
+ end
+ end
end