Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
Merge pull request #84 from tansengming/master
Browse files Browse the repository at this point in the history
fixed the CLI to exit with a non-zero status whenever deployment fails
  • Loading branch information
Gabe Berke-Williams committed Mar 2, 2012
2 parents 50b8102 + 7e37d61 commit 779d67c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/kumade/cli.rb
Expand Up @@ -34,6 +34,7 @@ def self.swapping_stdout_for(io, print_output = false)
rescue Kumade::DeploymentError
io.rewind
real_stdout.print(io.read)
exit 1
ensure
$stdout = real_stdout
end
Expand Down
15 changes: 10 additions & 5 deletions spec/kumade/cli_spec.rb
Expand Up @@ -89,13 +89,18 @@
output.read.should == "Hello, you can't see me.\n"
end

it 'dumps the output stash to real stdout when an error happens' do
Kumade::CLI.swapping_stdout_for(output) do
$stdout.puts "Hello, you can see me!"
raise Kumade::DeploymentError.new("error")
context 'when print_output is false' do
subject do
Kumade::CLI.swapping_stdout_for(output) do
$stdout.puts "Hello, you can see me!"
raise Kumade::DeploymentError.new("error")
end
end

stdout.should have_received(:print).with("Hello, you can see me!\n")
it 'dumps the output stash to real stdout when an error happens, exits with non-zero status' do
expect { subject }.should raise_error SystemExit
stdout.should have_received(:print).with("Hello, you can see me!\n")
end
end

context "in print output mode" do
Expand Down

0 comments on commit 779d67c

Please sign in to comment.