Permalink
Browse files

Fix Guard's exit-status codes

  • Loading branch information...
1 parent c01bef5 commit 5cad51e800a3e575cef2ab020327083c78a5ebfe @Maher4Ever committed Jan 3, 2012
Showing with 30 additions and 7 deletions.
  1. +0 −1 lib/guard.rb
  2. +1 −0 lib/guard/cli.rb
  3. +1 −0 lib/guard/interactor.rb
  4. +20 −4 spec/guard/cli_spec.rb
  5. +8 −2 spec/guard/interactor_spec.rb
View
@@ -214,7 +214,6 @@ def stop
interactor.stop if interactor
listener.stop
- abort
end
# Reload all Guards currently enabled.
View
@@ -74,6 +74,7 @@ def start
::Guard.start(options)
rescue Interrupt
::Guard.stop
+ abort
end
desc 'list', 'Lists guards that can be used with init'
View
@@ -123,6 +123,7 @@ def process_input(line)
help
when :stop
::Guard.stop
+ exit
when :pause
::Guard.pause
when :reload
View
@@ -5,11 +5,27 @@
let(:guard) { Guard }
describe '#start' do
- it 'should rescue from an interrupt signal and close nicely' do
- guard.should_receive(:start).and_raise(Interrupt)
- guard.should_receive(:stop)
+ context 'with an interrupt signal' do
+ before do
+ guard.should_receive(:start).and_raise(Interrupt)
+ guard.stub(:stop)
+ end
- subject.start
+ it 'exits nicely' do
+ guard.should_receive(:stop)
+ subject.stub(:abort)
+
+ subject.start
+ end
+
+ it 'exits with failure status code' do
+ begin
+ subject.start
+ raise 'Guard did not abort!'
+ rescue SystemExit => e
+ e.status.should_not eq(0)
+ end
+ end
end
end
@@ -40,10 +40,16 @@
subject.process_input 'help'
end
- it 'stops Guard on stop action' do
+ it 'stops Guard on stop action and exit' do
subject.should_receive(:extract_scopes_and_action).with('stop').and_return [{ }, :stop]
::Guard.should_receive(:stop)
- subject.process_input 'stop'
+
+ begin
+ subject.process_input 'stop'
+ raise 'Guard did not exit!'
+ rescue SystemExit => e
+ e.status.should eq(0)
+ end
end
it 'pauses Guard on pause action' do

0 comments on commit 5cad51e

Please sign in to comment.