don't use system notification library if could not be required
This commit is contained in:
parent
e2b13d2dc5
commit
d41e9fe7fe
@ -46,19 +46,19 @@ module Guard
|
||||
def self.notify_mac(title, message, image, options)
|
||||
require_growl # need for guard-rspec formatter that is called out of guard scope
|
||||
default_options = { :title => title, :icon => image_path(image), :name => "Guard" }
|
||||
Growl.notify message, default_options.merge(options)
|
||||
Growl.notify message, default_options.merge(options) if enabled?
|
||||
end
|
||||
|
||||
def self.notify_linux(title, message, image, options)
|
||||
require_libnotify # need for guard-rspec formatter that is called out of guard scope
|
||||
default_options = { :body => message, :summary => title, :icon_path => image_path(image) }
|
||||
Libnotify.show default_options.merge(options)
|
||||
Libnotify.show default_options.merge(options) if enabled?
|
||||
end
|
||||
|
||||
def self.notify_windows(title, message, image, options)
|
||||
require_rbnotifu # need for guard-rspec formatter that is called out of guard scope
|
||||
default_options = { :message => message, :title => title, :type => image_level(image), :time => 3 }
|
||||
Notifu.show default_options.merge(options)
|
||||
Notifu.show default_options.merge(options) if enabled?
|
||||
end
|
||||
|
||||
def self.image_path(image)
|
||||
|
@ -107,6 +107,12 @@ describe Guard::Notifier do
|
||||
subject.notify 'great', :title => 'Guard'
|
||||
end
|
||||
|
||||
it "don't passes the notification to Growl if library is not available" do
|
||||
Growl.should_not_receive(:notify)
|
||||
subject.should_receive(:enabled?).and_return(true, false)
|
||||
subject.notify 'great', :title => 'Guard'
|
||||
end
|
||||
|
||||
it "allows additional notification options" do
|
||||
Growl.should_receive(:notify).with("great",
|
||||
:title => "Guard",
|
||||
@ -148,6 +154,12 @@ describe Guard::Notifier do
|
||||
subject.notify 'great', :title => 'Guard'
|
||||
end
|
||||
|
||||
it "don't passes the notification to Libnotify if library is not available" do
|
||||
Libnotify.should_not_receive(:show)
|
||||
subject.should_receive(:enabled?).and_return(true, false)
|
||||
subject.notify 'great', :title => 'Guard'
|
||||
end
|
||||
|
||||
it "allows additional notification options" do
|
||||
Libnotify.should_receive(:show).with(
|
||||
:body => "great",
|
||||
@ -190,6 +202,12 @@ describe Guard::Notifier do
|
||||
subject.notify 'great', :title => 'Guard'
|
||||
end
|
||||
|
||||
it "don't passes the notification to rb-notifu if library is not available" do
|
||||
Notifu.should_not_receive(:show)
|
||||
subject.should_receive(:enabled?).and_return(true, false)
|
||||
subject.notify 'great', :title => 'Guard'
|
||||
end
|
||||
|
||||
it "allows additional notification options" do
|
||||
Notifu.should_receive(:show).with(
|
||||
:message => "great",
|
||||
|
Loading…
Reference in New Issue
Block a user