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

fixed the CLI to exit with a non-zero status whenever deployment fails #84

Merged
merged 3 commits into from
Mar 2, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/kumade/cli.rb
Original file line number Diff line number Diff line change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid. I like this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Mike. Scratched an itch that I had with Kumade.

ensure
$stdout = real_stdout
end
Expand Down
15 changes: 10 additions & 5 deletions spec/kumade/cli_spec.rb
Original file line number Diff line number Diff line change
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