diff --git a/lib/guard.rb b/lib/guard.rb index 87b692b..d9ed364 100644 --- a/lib/guard.rb +++ b/lib/guard.rb @@ -25,7 +25,7 @@ module Guard Dsl.evaluate_guardfile if guards.empty? - UI.error "No guards found in Guardfile, please add it at least one." + UI.error "No guards found in Guardfile, please add at least one." else Interactor.init_signal_traps @@ -63,14 +63,12 @@ module Guard # Let a guard execute his task but # fire it if his work lead to system failure def supervised_task(guard, task_to_supervise, *args) - begin - guard.send(task_to_supervise, *args) - rescue Exception - UI.error("#{guard.class.name} guard failed to achieve its <#{task_to_supervise.to_s}> command: #{$!}") - ::Guard.guards.delete guard - UI.info("Guard #{guard.class.name} has just been fired") - return $! - end + guard.send(task_to_supervise, *args) + rescue Exception + UI.error("#{guard.class.name} guard failed to achieve its <#{task_to_supervise.to_s}> command: #{$!}") + ::Guard.guards.delete guard + UI.info("Guard #{guard.class.name} has just been fired") + return $! end def locate_guard(name) diff --git a/spec/guard_spec.rb b/spec/guard_spec.rb index f6a3f5b..7e34d57 100644 --- a/spec/guard_spec.rb +++ b/spec/guard_spec.rb @@ -38,25 +38,25 @@ describe Guard do subject { ::Guard.init } it "Should retrieve itself for chaining" do - subject.should be_kind_of Module + subject.should be_kind_of(Module) end it "Should init guards array" do - ::Guard.guards.should be_kind_of Array + ::Guard.guards.should be_kind_of(Array) end it "Should init options" do opts = {:my_opts => true} - ::Guard.init(opts).options.should be_include :my_opts + ::Guard.init(opts).options.should be_include(:my_opts) end it "Should init listeners" do - ::Guard.listener.should be_kind_of Guard::Listener + ::Guard.listener.should be_kind_of(Guard::Listener) end end describe "supervised_task" do - subject {::Guard.init} + subject { ::Guard.init } before :each do @g = mock(Guard::Guard) @@ -68,28 +68,28 @@ describe Guard do end it "should let it go when nothing special occurs" do - subject.guards.should be_include @g + subject.guards.should be_include(@g) subject.supervised_task(@g, :regular).should be_true - subject.guards.should be_include @g + subject.guards.should be_include(@g) end it "should let it work with some tools" do - subject.guards.should be_include @g + subject.guards.should be_include(@g) subject.supervised_task(@g, :regular).should be_true - subject.guards.should be_include @g + subject.guards.should be_include(@g) end it "should fire the guard on spy act discovery" do - subject.guards.should be_include @g - ::Guard.supervised_task(@g, :spy).should be_kind_of Exception - subject.guards.should_not be_include @g + subject.guards.should be_include(@g) + ::Guard.supervised_task(@g, :spy).should be_kind_of(Exception) + subject.guards.should_not be_include(@g) ::Guard.supervised_task(@g, :spy).message.should == 'I break your system' end it "should fire the guard on pirate act discovery" do - subject.guards.should be_include @g - ::Guard.supervised_task(@g, :regular_arg, "given_path").should be_kind_of String - subject.guards.should be_include @g + subject.guards.should be_include(@g) + ::Guard.supervised_task(@g, :regular_arg, "given_path").should be_kind_of(String) + subject.guards.should be_include(@g) ::Guard.supervised_task(@g, :regular_arg, "given_path").should == "given_path" end end