diff options
author | tyler-ball <tyleraball@gmail.com> | 2014-10-31 07:05:21 -0700 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2014-12-17 18:47:25 -0800 |
commit | 390b858f2cfb130817573813294cb77b84f71874 (patch) | |
tree | e6e1f56bf2911bc7b40516b21cc5df88442f776f /spec/unit/exceptions_spec.rb | |
parent | 66665a7f699a592b77249a31af229f1412d90458 (diff) | |
download | chef-390b858f2cfb130817573813294cb77b84f71874.tar.gz |
Adding error handling so saving node doesn't prevent us from running audit mode - decouples converge phase and audit phase more
Diffstat (limited to 'spec/unit/exceptions_spec.rb')
-rw-r--r-- | spec/unit/exceptions_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/unit/exceptions_spec.rb b/spec/unit/exceptions_spec.rb index 6318ec9227..165c11446b 100644 --- a/spec/unit/exceptions_spec.rb +++ b/spec/unit/exceptions_spec.rb @@ -81,4 +81,50 @@ describe Chef::Exceptions do end end end + + describe Chef::Exceptions::RunFailedWrappingError do + shared_examples "RunFailedWrappingError expectations" do + it "should initialize with a default message" do + expect(e.message).to eq("Found #{num_errors} errors, they are stored in the backtrace\n") + end + + it "should provide a modified backtrace when requested" do + e.fill_backtrace + expect(e.backtrace).to eq(backtrace) + end + end + + context "initialized with nothing" do + let(:e) { Chef::Exceptions::RunFailedWrappingError.new } + let(:num_errors) { 0 } + let(:backtrace) { [] } + + include_examples "RunFailedWrappingError expectations" + end + + context "initialized with nil" do + let(:e) { Chef::Exceptions::RunFailedWrappingError.new(nil, nil) } + let(:num_errors) { 0 } + let(:backtrace) { [] } + + include_examples "RunFailedWrappingError expectations" + end + + context "initialized with 1 error and nil" do + let(:e) { Chef::Exceptions::RunFailedWrappingError.new(RuntimeError.new("foo"), nil) } + let(:num_errors) { 1 } + let(:backtrace) { ["1) RuntimeError - foo", ""] } + + include_examples "RunFailedWrappingError expectations" + end + + context "initialized with 2 errors" do + let(:e) { Chef::Exceptions::RunFailedWrappingError.new(RuntimeError.new("foo"), RuntimeError.new("bar")) } + let(:num_errors) { 2 } + let(:backtrace) { ["1) RuntimeError - foo", "", "2) RuntimeError - bar", ""] } + + include_examples "RunFailedWrappingError expectations" + end + + end end |