Skip to content
Snippets Groups Projects
Unverified Commit c9888b4c authored by Rémy Coutable's avatar Rémy Coutable Committed by GitHub
Browse files

Merge pull request #930 from pocke/cleanup-process

Ensure Guard calls `#stop` even if an exception is raised
parents 435ffc3b f0048807
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -47,8 +47,9 @@ module Guard
exitcode = e.status
end
 
stop
exitcode
ensure
stop
end
 
def stop
Loading
Loading
Loading
Loading
@@ -16,7 +16,7 @@ module Guard
end
 
def self.disconnect
@notifier.disconnect
@notifier && @notifier.disconnect
@notifier = nil
end
 
Loading
Loading
Loading
Loading
@@ -82,6 +82,20 @@ RSpec.describe Guard::Commander do
Guard.start
end
end
context "when listener.start raises an error" do
it "calls Commander#stop" do
allow(listener).to receive(:start).and_raise(RuntimeError)
# From stop()
expect(interactor).to receive(:background)
expect(listener).to receive(:stop)
expect(runner).to receive(:run).with(:stop)
expect(Guard::UI).to receive(:info).with("Bye bye...", reset: true)
expect { Guard.start }.to raise_error(RuntimeError)
end
end
end
 
describe ".stop" do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment