diff options
author | Ho-Sheng Hsiao <hosheng.hsiao@gmail.com> | 2012-03-23 11:16:02 -0400 |
---|---|---|
committer | Ho-Sheng Hsiao <hosheng.hsiao@gmail.com> | 2012-03-23 11:16:02 -0400 |
commit | 16ec134c9e766b98d6d9e98aeb1b8dd0641dd4f0 (patch) | |
tree | a2191adcb8a6cf13ed373f10568f9be5f2e67506 /spec | |
parent | 037b74cfb5bb0a79b8bdb64eee91e90893392f01 (diff) | |
download | mixlib-shellout-16ec134c9e766b98d6d9e98aeb1b8dd0641dd4f0.tar.gz |
[RSPEC] Refactored spec for checking error message format
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mixlib/shellout/shellout_spec.rb | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/spec/mixlib/shellout/shellout_spec.rb b/spec/mixlib/shellout/shellout_spec.rb index 9e6deca..78273c1 100644 --- a/spec/mixlib/shellout/shellout_spec.rb +++ b/spec/mixlib/shellout/shellout_spec.rb @@ -433,10 +433,19 @@ describe Mixlib::ShellOut do context 'with nonzero exit status' do let(:exit_code) { 2 } + let(:exception_message_format) { Regexp.escape(executed_cmd.format_for_exception) } it "should raise InvalidCommandResult" do lambda { executed_cmd.error! }.should raise_error(Mixlib::ShellOut::ShellCommandFailed) end + + it "includes output with exceptions from #error!" do + begin + executed_cmd.error! + rescue Mixlib::ShellOut::ShellCommandFailed => e + e.message.should match(exception_message_format) + end + end end context 'with valid exit codes' do @@ -470,16 +479,6 @@ describe Mixlib::ShellOut do end end - it "includes output with exceptions from #error!" do - cmd = Mixlib::ShellOut.new('ruby -e "exit 2"') - cmd.run_command - begin - cmd.error! - rescue Mixlib::ShellOut::ShellCommandFailed => e - e.message.should match(Regexp.escape(cmd.format_for_exception)) - end - end - it "errors out when told the result is invalid" do cmd = Mixlib::ShellOut.new('ruby -e "exit 0"') cmd.run_command |