diff --git a/lib/guard/notifier.rb b/lib/guard/notifier.rb index 1ee20e5..ede2895 100644 --- a/lib/guard/notifier.rb +++ b/lib/guard/notifier.rb @@ -181,6 +181,9 @@ module Guard end rescue LoadError require 'growl' + rescue ::GrowlNotify::GrowlNotFound + turn_off + UI.info "Please install Growl from http://growl.info" end rescue LoadError turn_off diff --git a/spec/guard/notifier_spec.rb b/spec/guard/notifier_spec.rb index 806e2a0..1c68333 100644 --- a/spec/guard/notifier_spec.rb +++ b/spec/guard/notifier_spec.rb @@ -21,10 +21,20 @@ describe Guard::Notifier do context "with the GrowlNotify library available" do before do - module ::GrowlNotify + class ::GrowlNotify + class GrowlNotFound < Exception; end def self.config ; end end end + + it "should respond properly to a GrowlNotify exception" do + ::GrowlNotify.should_receive(:config).and_raise ::GrowlNotify::GrowlNotFound + ::GrowlNotify.should_receive(:application_name).and_return '' + ::Guard::UI.should_receive(:info) + described_class.should_receive(:require).with('growl_notify').and_return true + described_class.turn_on + described_class.should_not be_enabled + end it "loads the library and enables the notifications" do described_class.should_receive(:require).with('growl_notify').and_return true