2010-10-03 21:00:33 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Guard::Notifier do
|
|
|
|
subject { Guard::Notifier }
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2011-04-16 21:13:29 +00:00
|
|
|
describe ".notify" do
|
|
|
|
before(:each) do
|
|
|
|
@saved_guard_env = ENV["GUARD_ENV"]
|
|
|
|
ENV["GUARD_ENV"] = 'dont_mute_notify'
|
|
|
|
end
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2010-10-17 19:42:40 +00:00
|
|
|
if mac?
|
2010-10-19 19:49:17 +00:00
|
|
|
require 'growl'
|
2011-04-16 21:13:29 +00:00
|
|
|
it "uses Growl on Mac OS X" do
|
2010-10-17 19:42:40 +00:00
|
|
|
Growl.should_receive(:notify).with("great",
|
|
|
|
:title => "Guard",
|
|
|
|
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
|
|
|
:name => "Guard"
|
|
|
|
)
|
|
|
|
subject.notify 'great', :title => 'Guard'
|
|
|
|
end
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2011-04-29 22:40:12 +00:00
|
|
|
elsif linux?
|
2010-10-21 08:27:31 +00:00
|
|
|
require 'libnotify'
|
2011-04-16 21:13:29 +00:00
|
|
|
it "uses Libnotify on Linux" do
|
2010-10-17 19:42:40 +00:00
|
|
|
Libnotify.should_receive(:show).with(
|
|
|
|
:body => "great",
|
|
|
|
:summary => 'Guard',
|
2010-10-21 08:27:31 +00:00
|
|
|
:icon_path => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s
|
2010-10-17 19:42:40 +00:00
|
|
|
)
|
2010-10-21 08:27:31 +00:00
|
|
|
subject.notify 'great', :title => 'Guard'
|
2010-10-17 19:42:40 +00:00
|
|
|
end
|
|
|
|
end
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2011-04-16 21:13:29 +00:00
|
|
|
describe ".turn_off" do
|
2011-04-10 20:32:29 +00:00
|
|
|
before(:each) { subject.turn_off }
|
|
|
|
|
|
|
|
if mac?
|
|
|
|
require 'growl'
|
2011-04-16 21:13:29 +00:00
|
|
|
it "does nothing" do
|
2011-04-10 20:32:29 +00:00
|
|
|
Growl.should_not_receive(:notify)
|
|
|
|
subject.notify 'great', :title => 'Guard'
|
|
|
|
end
|
|
|
|
|
2011-04-29 22:40:12 +00:00
|
|
|
elsif linux?
|
2011-04-10 20:32:29 +00:00
|
|
|
require 'libnotify'
|
2011-04-16 21:13:29 +00:00
|
|
|
it "does nothing" do
|
2011-04-10 20:32:29 +00:00
|
|
|
Libnotify.should_not_receive(:show)
|
|
|
|
subject.notify 'great', :title => 'Guard'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-04-16 21:13:29 +00:00
|
|
|
after(:each) { ENV["GUARD_ENV"] = @saved_guard_env }
|
2010-10-03 21:00:33 +00:00
|
|
|
end
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2011-04-16 21:13:29 +00:00
|
|
|
end
|