From 1d38c59200e5c93fb6d997228542335c5d894229 Mon Sep 17 00:00:00 2001 From: monocle Date: Thu, 14 Apr 2011 13:53:53 -0700 Subject: [PATCH] Fix preexisting tests after adding default hooks --- lib/guard.rb | 3 ++- lib/guard/guard.rb | 2 ++ spec/guard_spec.rb | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/guard.rb b/lib/guard.rb index 56bdf5c..29e235f 100644 --- a/lib/guard.rb +++ b/lib/guard.rb @@ -62,8 +62,9 @@ module Guard # fire it if his work leads to a system failure def supervised_task(guard, task_to_supervise, *args) guard.hook "#{task_to_supervise.to_s}_begin" - guard.send(task_to_supervise, *args) + result = guard.send(task_to_supervise, *args) guard.hook "#{task_to_supervise.to_s}_end" + result rescue Exception UI.error("#{guard.class.name} guard failed to achieve its <#{task_to_supervise.to_s}> command: #{$!}") ::Guard.guards.delete guard diff --git a/lib/guard/guard.rb b/lib/guard/guard.rb index a6b546c..e952fe3 100644 --- a/lib/guard/guard.rb +++ b/lib/guard/guard.rb @@ -1,5 +1,7 @@ module Guard class Guard + include Hook + attr_accessor :watchers, :options def initialize(watchers = [], options = {}) diff --git a/spec/guard_spec.rb b/spec/guard_spec.rb index dbd1c14..e1ec612 100644 --- a/spec/guard_spec.rb +++ b/spec/guard_spec.rb @@ -54,7 +54,7 @@ describe Guard do describe ".supervised_task" do subject { ::Guard.setup } before(:each) do - @g = mock(Guard::Guard) + @g = mock(Guard::Guard).as_null_object subject.guards.push(@g) end @@ -92,6 +92,8 @@ describe Guard do failing_result.message.should == 'I break your system' end end + + it "calls the default hooks" end end