2010-10-03 21:00:33 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Guard::Notifier do
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2011-05-30 14:04:02 +00:00
|
|
|
describe ".turn_off" do
|
|
|
|
before do
|
|
|
|
ENV["GUARD_NOTIFY"] = 'true'
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.turn_off
|
2011-05-30 14:04:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "disables the notifications" do
|
|
|
|
ENV["GUARD_NOTIFY"].should eql 'false'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe ".turn_on" do
|
|
|
|
context "on Mac OS" do
|
2011-05-30 15:20:39 +00:00
|
|
|
before do
|
2011-06-16 11:14:51 +00:00
|
|
|
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'darwin'
|
2011-05-30 15:20:39 +00:00
|
|
|
end
|
|
|
|
|
2011-06-28 20:15:14 +00:00
|
|
|
context "with the GrowlNotify library available" do
|
|
|
|
before do
|
2011-10-05 05:10:48 +00:00
|
|
|
class ::GrowlNotify
|
|
|
|
class GrowlNotFound < Exception; end
|
2011-06-28 20:15:14 +00:00
|
|
|
def self.config ; end
|
|
|
|
end
|
|
|
|
end
|
2011-10-12 18:54:57 +00:00
|
|
|
|
|
|
|
it "loads the library and enables the notifications" do
|
|
|
|
described_class.should_receive(:require).with('growl_notify').and_return true
|
|
|
|
GrowlNotify.should_receive(:application_name).and_return ''
|
|
|
|
described_class.turn_on
|
|
|
|
described_class.should be_enabled
|
|
|
|
end
|
|
|
|
|
2011-10-05 05:10:48 +00:00
|
|
|
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
|
2011-10-12 18:54:57 +00:00
|
|
|
described_class.growl_library.should eql :growl_notify
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
Object.send(:remove_const, :GrowlNotify)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with the GNTP library available" do
|
|
|
|
before do
|
|
|
|
class ::GNTP
|
2011-10-12 19:03:59 +00:00
|
|
|
def initialize(app); end
|
2011-10-12 18:54:57 +00:00
|
|
|
def register(config) ; end
|
|
|
|
end
|
2011-10-05 05:10:48 +00:00
|
|
|
end
|
2011-06-28 20:15:14 +00:00
|
|
|
|
2011-05-30 15:20:39 +00:00
|
|
|
it "loads the library and enables the notifications" do
|
2011-10-12 18:54:57 +00:00
|
|
|
described_class.should_receive(:require).with('growl_notify').and_raise LoadError
|
|
|
|
described_class.should_receive(:require).with('ruby_gntp').and_return true
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.turn_on
|
|
|
|
described_class.should be_enabled
|
2011-10-12 18:54:57 +00:00
|
|
|
described_class.growl_library.should eql :ruby_gntp
|
2011-05-30 15:20:39 +00:00
|
|
|
end
|
2011-06-28 20:15:14 +00:00
|
|
|
|
|
|
|
after do
|
2011-10-12 18:54:57 +00:00
|
|
|
Object.send(:remove_const, :GNTP)
|
2011-06-28 20:15:14 +00:00
|
|
|
end
|
2011-05-30 15:20:39 +00:00
|
|
|
end
|
2011-05-30 14:04:02 +00:00
|
|
|
|
2011-08-17 12:27:40 +00:00
|
|
|
context "with the Growl library available" do
|
|
|
|
it "loads the library and enables the notifications" do
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.should_receive(:require).with('growl_notify').and_raise LoadError
|
2011-10-12 18:54:57 +00:00
|
|
|
described_class.should_receive(:require).with('ruby_gntp').and_raise LoadError
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.should_receive(:require).with('growl').and_return true
|
|
|
|
described_class.turn_on
|
|
|
|
described_class.should be_enabled
|
2011-10-12 18:54:57 +00:00
|
|
|
described_class.growl_library.should eql :growl
|
2011-08-17 12:27:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-12 18:54:57 +00:00
|
|
|
context "without a Growl library available" do
|
2011-05-30 15:20:39 +00:00
|
|
|
it "disables the notifications" do
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.should_receive(:require).with('growl_notify').and_raise LoadError
|
2011-10-12 18:54:57 +00:00
|
|
|
described_class.should_receive(:require).with('ruby_gntp').and_raise LoadError
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.should_receive(:require).with('growl').and_raise LoadError
|
|
|
|
described_class.turn_on
|
|
|
|
described_class.should_not be_enabled
|
2011-10-12 18:54:57 +00:00
|
|
|
described_class.growl_library.should be nil
|
2011-05-30 15:20:39 +00:00
|
|
|
end
|
2010-10-17 19:42:40 +00:00
|
|
|
end
|
2010-10-03 21:00:33 +00:00
|
|
|
end
|
2011-05-30 14:04:02 +00:00
|
|
|
|
|
|
|
context "on Linux" do
|
2011-05-30 15:20:39 +00:00
|
|
|
before do
|
2011-06-16 11:14:51 +00:00
|
|
|
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'linux'
|
2011-05-30 15:20:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context "with the Libnotify library available" do
|
|
|
|
it "loads the library and enables the notifications" do
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.should_receive(:require).with('libnotify').and_return true
|
|
|
|
described_class.turn_on
|
|
|
|
described_class.should be_enabled
|
2011-05-30 15:20:39 +00:00
|
|
|
end
|
|
|
|
end
|
2011-05-30 14:04:02 +00:00
|
|
|
|
2011-05-30 15:20:39 +00:00
|
|
|
context "without the Libnotify library available" do
|
|
|
|
it "disables the notifications" do
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.should_receive(:require).with('libnotify').and_raise LoadError
|
|
|
|
described_class.turn_on
|
|
|
|
described_class.should_not be_enabled
|
2011-05-30 15:20:39 +00:00
|
|
|
end
|
2011-05-20 23:19:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-05-30 14:04:02 +00:00
|
|
|
context "on Windows" do
|
2011-05-30 15:20:39 +00:00
|
|
|
before do
|
2011-06-16 11:14:51 +00:00
|
|
|
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'mswin'
|
2011-05-30 15:20:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context "with the rb-notifu library available" do
|
|
|
|
it "loads the library and enables the notifications" do
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.should_receive(:require).with('rb-notifu').and_return true
|
|
|
|
described_class.turn_on
|
|
|
|
described_class.should be_enabled
|
2011-05-30 15:20:39 +00:00
|
|
|
end
|
|
|
|
end
|
2011-05-30 14:04:02 +00:00
|
|
|
|
2011-05-30 15:20:39 +00:00
|
|
|
context "without the rb-notify library available" do
|
|
|
|
it "disables the notifications" do
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.should_receive(:require).with('rb-notifu').and_raise LoadError
|
|
|
|
described_class.turn_on
|
|
|
|
described_class.should_not be_enabled
|
2011-05-30 15:20:39 +00:00
|
|
|
end
|
2011-05-30 14:04:02 +00:00
|
|
|
end
|
|
|
|
end
|
2011-05-06 21:19:31 +00:00
|
|
|
end
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2011-04-16 21:13:29 +00:00
|
|
|
describe ".notify" do
|
2011-09-22 22:22:44 +00:00
|
|
|
before { described_class.stub(:enabled?).and_return(true) }
|
2011-05-30 14:04:02 +00:00
|
|
|
|
|
|
|
context "on Mac OS" do
|
|
|
|
before do
|
2011-10-12 18:54:57 +00:00
|
|
|
RbConfig::CONFIG.stub(:[]).and_return 'darwin'
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.stub(:require_growl)
|
2011-05-30 14:04:02 +00:00
|
|
|
end
|
|
|
|
|
2011-08-17 12:27:40 +00:00
|
|
|
context 'with growl gem' do
|
|
|
|
before do
|
|
|
|
Object.send(:remove_const, :Growl) if defined?(Growl)
|
|
|
|
Growl = Object.new
|
2011-10-12 18:54:57 +00:00
|
|
|
described_class.growl_library = :growl
|
2011-08-17 12:27:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
Object.send(:remove_const, :Growl)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "passes the notification to Growl" do
|
|
|
|
Growl.should_receive(:notify).with("great",
|
|
|
|
:title => "Guard",
|
|
|
|
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
|
|
|
:name => "Guard"
|
|
|
|
)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard'
|
2011-08-17 12:27:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "don't passes the notification to Growl if library is not available" do
|
|
|
|
Growl.should_not_receive(:notify)
|
2011-10-12 18:54:57 +00:00
|
|
|
described_class.growl_library = nil
|
|
|
|
described_class.should_receive(:enabled?).and_return(false)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard'
|
2011-08-17 12:27:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "allows additional notification options" do
|
|
|
|
Growl.should_receive(:notify).with("great",
|
|
|
|
:title => "Guard",
|
|
|
|
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
|
|
|
:name => "Guard",
|
|
|
|
:priority => 1
|
|
|
|
)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard', :priority => 1
|
2011-08-17 12:27:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "allows to overwrite a default notification option" do
|
|
|
|
Growl.should_receive(:notify).with("great",
|
|
|
|
:title => "Guard",
|
|
|
|
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
|
|
|
:name => "Guard-Cucumber"
|
|
|
|
)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard', :name => "Guard-Cucumber"
|
2011-08-17 12:27:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-06-28 20:15:14 +00:00
|
|
|
context 'with growl_notify gem' do
|
|
|
|
before do
|
|
|
|
Object.send(:remove_const, :GrowlNotify) if defined?(GrowlNotify)
|
|
|
|
GrowlNotify = Object.new
|
2011-10-12 18:54:57 +00:00
|
|
|
described_class.growl_library = :growl_notify
|
2011-06-28 20:15:14 +00:00
|
|
|
end
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2011-06-28 20:15:14 +00:00
|
|
|
after do
|
|
|
|
Object.send(:remove_const, :GrowlNotify)
|
|
|
|
end
|
2011-05-30 14:45:15 +00:00
|
|
|
|
2011-06-28 20:15:14 +00:00
|
|
|
it "passes the notification to Growl" do
|
|
|
|
GrowlNotify.should_receive(:send_notification).with(
|
|
|
|
:title => "Guard",
|
|
|
|
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
|
|
|
:application_name => "Guard",
|
|
|
|
:description => 'great'
|
|
|
|
)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard'
|
2011-06-28 20:15:14 +00:00
|
|
|
end
|
2011-06-07 15:58:02 +00:00
|
|
|
|
2011-06-28 20:15:14 +00:00
|
|
|
it "don't passes the notification to Growl if library is not available" do
|
|
|
|
GrowlNotify.should_not_receive(:send_notification)
|
2011-10-12 18:54:57 +00:00
|
|
|
described_class.growl_library = nil
|
|
|
|
described_class.should_receive(:enabled?).and_return(false)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard'
|
2011-06-28 20:15:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "allows additional notification options" do
|
|
|
|
GrowlNotify.should_receive(:send_notification).with(
|
|
|
|
:title => "Guard",
|
|
|
|
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
|
|
|
:application_name => "Guard",
|
|
|
|
:description => 'great',
|
|
|
|
:priority => 1
|
|
|
|
)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard', :priority => 1
|
2011-06-28 20:15:14 +00:00
|
|
|
end
|
2011-05-30 14:45:15 +00:00
|
|
|
|
2011-07-01 15:52:24 +00:00
|
|
|
it "throws out the application name since Guard should only use one Growl App Name while running" do
|
2011-06-28 20:15:14 +00:00
|
|
|
GrowlNotify.should_receive(:send_notification).with(
|
|
|
|
:title => "Guard",
|
|
|
|
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
2011-07-01 15:52:24 +00:00
|
|
|
:application_name => "Guard",
|
2011-06-28 20:15:14 +00:00
|
|
|
:description => 'great'
|
|
|
|
)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard', :name => "Guard-Cucumber"
|
2011-06-28 20:15:14 +00:00
|
|
|
end
|
2011-05-30 14:45:15 +00:00
|
|
|
end
|
2011-10-12 18:54:57 +00:00
|
|
|
|
|
|
|
context 'with ruby_gntp gem' do
|
|
|
|
before do
|
|
|
|
described_class.growl_library = :ruby_gntp
|
2011-10-12 19:03:59 +00:00
|
|
|
described_class.gntp = Object.new
|
2011-10-12 18:54:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "passes a success notification to Ruby GNTP" do
|
|
|
|
described_class.gntp.should_receive(:notify).with(
|
|
|
|
:name => "success",
|
|
|
|
:text => 'great',
|
|
|
|
:title => "Guard",
|
|
|
|
:icon => 'file://' + Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s
|
|
|
|
)
|
|
|
|
described_class.notify 'great', :title => 'Guard'
|
|
|
|
end
|
|
|
|
|
|
|
|
it "passes a pending notification to Ruby GNTP" do
|
|
|
|
described_class.gntp.should_receive(:notify).with(
|
|
|
|
:name => "pending",
|
|
|
|
:text => 'great',
|
|
|
|
:title => "Guard",
|
|
|
|
:icon => 'file://' + Pathname.new(File.dirname(__FILE__)).join('../../images/pending.png').to_s
|
|
|
|
)
|
|
|
|
described_class.notify 'great', :title => 'Guard', :image => :pending
|
|
|
|
end
|
|
|
|
|
|
|
|
it "passes a failure notification to Ruby GNTP" do
|
|
|
|
described_class.gntp.should_receive(:notify).with(
|
|
|
|
:name => "failed",
|
|
|
|
:text => 'great',
|
|
|
|
:title => "Guard",
|
|
|
|
:icon => 'file://' + Pathname.new(File.dirname(__FILE__)).join('../../images/failed.png').to_s
|
|
|
|
)
|
|
|
|
described_class.notify 'great', :title => 'Guard', :image => :failed
|
|
|
|
end
|
|
|
|
|
|
|
|
it "passes a general notification to Ruby GNTP" do
|
|
|
|
described_class.gntp.should_receive(:notify).with(
|
|
|
|
:name => "notify",
|
|
|
|
:text => 'great',
|
|
|
|
:title => "Guard",
|
|
|
|
:icon => 'file:///path/to/custom.png'
|
|
|
|
)
|
|
|
|
described_class.notify 'great', :title => 'Guard', :image => '/path/to/custom.png'
|
|
|
|
end
|
|
|
|
|
|
|
|
it "don't passes the notification to Ruby GNTP if library is not available" do
|
|
|
|
described_class.gntp.should_not_receive(:notify)
|
|
|
|
described_class.growl_library = nil
|
|
|
|
described_class.should_receive(:enabled?).and_return(false)
|
|
|
|
described_class.notify 'great', :title => 'Guard'
|
|
|
|
end
|
|
|
|
|
|
|
|
it "allows additional notification options" do
|
|
|
|
described_class.gntp.should_receive(:notify).with(
|
|
|
|
:name => "success",
|
|
|
|
:text => 'great',
|
|
|
|
:title => "Guard",
|
|
|
|
:icon => 'file://' + Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
|
|
|
:sticky => true
|
|
|
|
)
|
|
|
|
described_class.notify 'great', :title => 'Guard', :sticky => true
|
|
|
|
end
|
|
|
|
end
|
2011-05-30 14:04:02 +00:00
|
|
|
end
|
2011-09-22 22:22:44 +00:00
|
|
|
|
2011-05-30 14:04:02 +00:00
|
|
|
context "on Linux" do
|
|
|
|
before do
|
2011-10-12 18:54:57 +00:00
|
|
|
RbConfig::CONFIG.stub(:[]).and_return 'linux'
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.stub(:require_libnotify)
|
2011-06-07 15:35:49 +00:00
|
|
|
Object.send(:remove_const, :Libnotify) if defined?(Libnotify)
|
2011-05-30 14:04:02 +00:00
|
|
|
Libnotify = Object.new
|
|
|
|
end
|
|
|
|
|
2011-06-07 15:35:49 +00:00
|
|
|
after do
|
|
|
|
Object.send(:remove_const, :Libnotify)
|
|
|
|
end
|
2011-05-30 14:45:15 +00:00
|
|
|
|
2011-05-30 14:04:02 +00:00
|
|
|
it "passes the notification to Libnotify" do
|
|
|
|
Libnotify.should_receive(:show).with(
|
|
|
|
:body => "great",
|
|
|
|
:summary => 'Guard',
|
2011-08-11 10:09:24 +00:00
|
|
|
:icon_path => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
|
|
|
:transient => true
|
2010-10-17 19:42:40 +00:00
|
|
|
)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard'
|
2010-10-17 19:42:40 +00:00
|
|
|
end
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2011-06-07 15:58:02 +00:00
|
|
|
it "don't passes the notification to Libnotify if library is not available" do
|
|
|
|
Libnotify.should_not_receive(:show)
|
2011-10-12 18:54:57 +00:00
|
|
|
described_class.should_receive(:enabled?).and_return(false)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard'
|
2011-06-07 15:58:02 +00:00
|
|
|
end
|
|
|
|
|
2011-05-30 14:45:15 +00:00
|
|
|
it "allows additional notification options" do
|
2010-10-17 19:42:40 +00:00
|
|
|
Libnotify.should_receive(:show).with(
|
|
|
|
:body => "great",
|
|
|
|
:summary => 'Guard',
|
2011-05-30 14:45:15 +00:00
|
|
|
:icon_path => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
2011-08-11 10:09:24 +00:00
|
|
|
:transient => true,
|
2011-05-30 14:45:15 +00:00
|
|
|
:urgency => :critical
|
2010-10-17 19:42:40 +00:00
|
|
|
)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard', :urgency => :critical
|
2011-05-30 14:45:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "allows to overwrite a default notification option" do
|
|
|
|
Libnotify.should_receive(:show).with(
|
|
|
|
:body => "great",
|
|
|
|
:summary => 'Guard',
|
2011-08-11 10:09:24 +00:00
|
|
|
:icon_path => '~/.guard/success.png',
|
|
|
|
:transient => true
|
2011-05-30 14:45:15 +00:00
|
|
|
)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard', :icon_path => '~/.guard/success.png'
|
2010-10-17 19:42:40 +00:00
|
|
|
end
|
|
|
|
end
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2011-05-30 14:04:02 +00:00
|
|
|
context "on Windows" do
|
|
|
|
before do
|
2011-10-12 18:54:57 +00:00
|
|
|
RbConfig::CONFIG.stub(:[]).and_return 'mswin'
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.stub(:require_rbnotifu)
|
2011-06-07 15:35:49 +00:00
|
|
|
Object.send(:remove_const, :Notifu) if defined?(Notifu)
|
2011-05-30 14:04:02 +00:00
|
|
|
Notifu = Object.new
|
|
|
|
end
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2011-06-07 15:35:49 +00:00
|
|
|
after do
|
|
|
|
Object.send(:remove_const, :Notifu)
|
|
|
|
end
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2011-05-30 14:04:02 +00:00
|
|
|
it "passes the notification to rb-notifu" do
|
|
|
|
Notifu.should_receive(:show).with(
|
|
|
|
:message => "great",
|
|
|
|
:title => 'Guard',
|
|
|
|
:type => :info,
|
|
|
|
:time => 3
|
|
|
|
)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard'
|
2011-05-30 14:04:02 +00:00
|
|
|
end
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2011-06-07 15:58:02 +00:00
|
|
|
it "don't passes the notification to rb-notifu if library is not available" do
|
|
|
|
Notifu.should_not_receive(:show)
|
2011-10-12 18:54:57 +00:00
|
|
|
described_class.should_receive(:enabled?).and_return(false)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard'
|
2011-04-10 20:32:29 +00:00
|
|
|
end
|
|
|
|
|
2011-05-30 14:45:15 +00:00
|
|
|
it "allows additional notification options" do
|
|
|
|
Notifu.should_receive(:show).with(
|
|
|
|
:message => "great",
|
|
|
|
:title => 'Guard',
|
|
|
|
:type => :info,
|
|
|
|
:time => 3,
|
|
|
|
:nosound => true
|
|
|
|
)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard', :nosound => true
|
2011-04-10 20:32:29 +00:00
|
|
|
end
|
|
|
|
|
2011-05-30 14:45:15 +00:00
|
|
|
it "allows to overwrite a default notification option" do
|
|
|
|
Notifu.should_receive(:show).with(
|
|
|
|
:message => "great",
|
|
|
|
:title => 'Guard',
|
|
|
|
:type => :info,
|
|
|
|
:time => 10
|
|
|
|
)
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.notify 'great', :title => 'Guard', :time => 10
|
2011-05-30 14:45:15 +00:00
|
|
|
end
|
2011-05-30 14:04:02 +00:00
|
|
|
end
|
2010-10-03 21:00:33 +00:00
|
|
|
end
|
2011-04-10 20:32:29 +00:00
|
|
|
|
2011-05-30 14:04:02 +00:00
|
|
|
describe ".enabled?" do
|
|
|
|
context "when enabled" do
|
|
|
|
before { ENV["GUARD_NOTIFY"] = 'true' }
|
|
|
|
|
|
|
|
it { should be_enabled }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when disabled" do
|
|
|
|
before { ENV["GUARD_NOTIFY"] = 'false' }
|
|
|
|
|
|
|
|
it { should_not be_enabled }
|
|
|
|
end
|
|
|
|
end
|
2011-09-22 22:22:44 +00:00
|
|
|
|
2011-04-16 21:13:29 +00:00
|
|
|
end
|