Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make the notifier spec more robust on notification library loading.

I really love travis-ci, it makes my life easier AND harder.
  • Loading branch information...
commit 1bcfdfd3ad06c1860e38442b6863a42395f924a6 1 parent 320706e
@netzpirat netzpirat authored
Showing with 51 additions and 21 deletions.
  1. +51 −21 spec/guard/notifier_spec.rb
View
72 spec/guard/notifier_spec.rb
@@ -15,39 +15,69 @@
end
describe ".turn_on" do
- before do
- ENV["GUARD_NOTIFY"] = 'false'
- end
-
- it "enables the notifications" do
- subject.turn_on
- ENV["GUARD_NOTIFY"].should eql 'true'
- end
-
context "on Mac OS" do
- before { Config::CONFIG.should_receive(:[]).with('target_os').and_return 'darwin' }
+ before do
+ Config::CONFIG.should_receive(:[]).with('target_os').and_return 'darwin'
+ end
+
+ context "with the Growl library available" do
+ it "loads the library and enables the notifications" do
+ subject.should_receive(:require).with('growl').and_return true
+ subject.turn_on
+ subject.should be_enabled
+ end
+ end
- it "tries to load Growl" do
- subject.should_receive(:require_growl)
- subject.turn_on
+ context "without the Growl library available" do
+ it "disables the notifications" do
+ subject.should_receive(:require).with('growl').and_raise LoadError
+ subject.turn_on
+ subject.should_not be_enabled
+ end
end
end
context "on Linux" do
- before { Config::CONFIG.should_receive(:[]).with('target_os').and_return 'linux' }
+ before do
+ Config::CONFIG.should_receive(:[]).with('target_os').and_return 'linux'
+ end
+
+ context "with the Libnotify library available" do
+ it "loads the library and enables the notifications" do
+ subject.should_receive(:require).with('libnotify').and_return true
+ subject.turn_on
+ subject.should be_enabled
+ end
+ end
- it "tries to load Libnotify" do
- subject.should_receive(:require_libnotify)
- subject.turn_on
+ context "without the Libnotify library available" do
+ it "disables the notifications" do
+ subject.should_receive(:require).with('libnotify').and_raise LoadError
+ subject.turn_on
+ subject.should_not be_enabled
+ end
end
end
context "on Windows" do
- before { Config::CONFIG.should_receive(:[]).with('target_os').and_return 'mswin' }
+ before do
+ Config::CONFIG.should_receive(:[]).with('target_os').and_return 'mswin'
+ end
+
+ context "with the rb-notifu library available" do
+ it "loads the library and enables the notifications" do
+ subject.should_receive(:require).with('rb-notifu').and_return true
+ subject.turn_on
+ subject.should be_enabled
+ end
+ end
- it "tries to load rb-notifu" do
- subject.should_receive(:require_rbnotifu)
- subject.turn_on
+ context "without the rb-notify library available" do
+ it "disables the notifications" do
+ subject.should_receive(:require).with('rb-notifu').and_raise LoadError
+ subject.turn_on
+ subject.should_not be_enabled
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.