Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replace kill_orphan_sporks by reevaluate

reevaluate also relaunch_sporks after a Guard reevaluation
  • Loading branch information...
commit 659e67b38ebf758bb5782f6ecdd9ced6fbcdd38e 1 parent d38ddff
Thibaud Guillaume-Gentil authored
View
2  lib/guard/spork.rb
@@ -15,7 +15,7 @@ def initialize(watchers=[], options={})
# This class will be reinitialized by Guard when the Guardfile
# is reevaluated, so we must always begin by trying to clean
# up after any hypothetical predecessor
- runner.kill_orphan_sporks
+ runner.reevaluate
end
def start
View
3  lib/guard/spork/runner.rb
@@ -42,10 +42,11 @@ def kill_global_sporks!
kill_pids ps_spork_pids
end
- def kill_orphan_sporks
+ def reevaluate
if ENV['SPORK_PIDS']
kill_pids(ENV['SPORK_PIDS'].split(',').map(&:to_i))
ENV.delete('SPORK_PIDS')
+ launch_sporks("reload")
end
end
View
18 spec/guard/spork/runner_spec.rb
@@ -356,7 +356,11 @@ def inspect() to_s end
end
end
- describe "#kill_orphan_sporks" do
+ describe "#reevaluate" do
+ before(:each) do
+ runner.stub(:launch_sporks)
+ end
+
around(:each) do |example|
ENV['SPORK_PIDS'] = '666,999'
Process.stub(:kill)
@@ -369,17 +373,23 @@ def inspect() to_s end
Process.should_receive(:kill).with('KILL', 666)
Process.should_receive(:kill).with('KILL', 999)
- runner.kill_orphan_sporks
+ runner.reevaluate
end
it "clears the SPORK_PIDS environment variable" do
- expect { runner.kill_orphan_sporks }.to change { ENV['SPORK_PIDS'] }.to(nil)
+ expect { runner.reevaluate }.to change { ENV['SPORK_PIDS'] }.to(nil)
end
it "works when the environment variable is unset" do
ENV['SPORK_PIDS'] = nil
Process.should_not_receive(:kill)
- runner.kill_orphan_sporks
+ runner.reevaluate
+ end
+
+ it "reloads sporks" do
+ runner.should_receive(:launch_sporks)
+ runner.reevaluate
end
end
+
end
View
4 spec/guard/spork_spec.rb
@@ -5,7 +5,7 @@
let(:runner) { subject.runner }
describe '#initialize' do
- let(:runner) { double('runner instance', :kill_orphan_sporks => nil) }
+ let(:runner) { double('runner instance', :reevaluate => nil) }
before(:each) { Guard::Spork::Runner.stub(:new => runner) }
it "instantiates Runner with the given options" do
@@ -14,7 +14,7 @@
end
it "kills any orphan spork instances" do
- runner.should_receive(:kill_orphan_sporks)
+ runner.should_receive(:reevaluate)
Guard::Spork.new []
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.