diff options
author | Chris Armstrong <chris.armstrong@socrata.com> | 2013-09-24 14:46:47 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2014-01-21 17:15:22 -0800 |
commit | 6baa0861a364adbac507a447b6cb3cbad4a160b1 (patch) | |
tree | 2a39182337512e17bd5651d0e277f18bc399d02d /spec/mixlib | |
parent | fa0a9c82b50bf941f34b2480f80fb5c88fd241db (diff) | |
download | mixlib-shellout-6baa0861a364adbac507a447b6cb3cbad4a160b1.tar.gz |
Adds error? method to check whether the process exited successfully. This allows the user to use custom error-handling logic. error! now uses error? internally.
Diffstat (limited to 'spec/mixlib')
-rw-r--r-- | spec/mixlib/shellout_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb index 0a6f9b2..3d0a04f 100644 --- a/spec/mixlib/shellout_spec.rb +++ b/spec/mixlib/shellout_spec.rb @@ -750,6 +750,24 @@ describe Mixlib::ShellOut do lambda { executed_cmd.invalid!("I expected this to exit 42, not 0") }.should raise_error(Mixlib::ShellOut::ShellCommandFailed) end end + + describe "#error?" do + context 'when exiting with invalid code' do + let(:exit_code) { 2 } + + it "should return true" do + executed_cmd.error?.should be_true + end + end + + context 'when exiting with valid code' do + let(:exit_code) { 0 } + + it "should return false" do + executed_cmd.error?.should be_false + end + end + end end context "when handling the subprocess" do |