Fix exit-status codes for Guard #216

Merged
merged 3 commits into from Jan 5, 2012
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