Skip to content

Commit

Permalink
Fixes tests
Browse files Browse the repository at this point in the history
Several tests broke when making the pidfile tracking more robust.
  • Loading branch information
Zachery Moneypenny committed Mar 15, 2015
1 parent a0b5b03 commit 0436dfd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/guard/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def start
end

def stop
if @started
if redis_started?
shutdown_redis
true
else
Expand All @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion spec/guard/redis/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0436dfd

Please # to comment.