From 0436dfd577833a3cf8decfa84d1133d2810e580a Mon Sep 17 00:00:00 2001 From: Zachery Moneypenny Date: Sun, 15 Mar 2015 11:57:56 -0500 Subject: [PATCH] Fixes tests Several tests broke when making the pidfile tracking more robust. --- lib/guard/redis.rb | 6 +++++- spec/guard/redis/redis_spec.rb | 2 +- spec/spec_helper.rb | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/guard/redis.rb b/lib/guard/redis.rb index 3938ca3..d0be875 100644 --- a/lib/guard/redis.rb +++ b/lib/guard/redis.rb @@ -20,7 +20,7 @@ def start end def stop - if @started + if redis_started? shutdown_redis true else @@ -44,6 +44,10 @@ def run_on_change(paths) reload if reload_on_change? end + def redis_started? + @started + end + def shutdown_redis return UI.info "No instance of Redis to stop." unless pid return UI.info "Redis (#{pid}) was already stopped." unless process_running? diff --git a/spec/guard/redis/redis_spec.rb b/spec/guard/redis/redis_spec.rb index eb51be1..c865715 100644 --- a/spec/guard/redis/redis_spec.rb +++ b/spec/guard/redis/redis_spec.rb @@ -25,7 +25,6 @@ server = double(IO.pipe).as_null_object expect(server).to receive(:write) expect(server).to receive(:close_write) - expect(server).to receive(:pid).and_return(9999) allow(IO).to receive(:popen).and_yield(server) guard.start end @@ -34,6 +33,7 @@ describe "#stop" do it "kills the process if a pid file is found" do pid = 5 + allow(guard).to receive(:redis_started?).and_return(true) allow(guard).to receive(:pid).and_return(pid) allow(guard).to receive(:process_running?).and_return(true) expect(Process).to receive(:kill).with("TERM", pid) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8e0c378..401fc65 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,5 +5,6 @@ RSpec.configure do |config| config.before(:each) do allow(Guard::UI).to receive(:info) + allow(Guard::UI).to receive(:error) end end