Permalink
Browse files

FileNotifier uses new available? options to determine if a path was g…

…iven
  • Loading branch information...
1 parent 20ff426 commit abcb4e20afa63a99ec4affb900358de3b77a0445 @amiel amiel committed Mar 28, 2013
Showing with 12 additions and 3 deletions.
  1. +2 −0 .gitignore
  2. +3 −1 lib/guard/notifiers/file_notifier.rb
  3. +7 −2 spec/guard/notifiers/file_notifier_spec.rb
View
@@ -15,6 +15,8 @@ Gemfile.lock
bin/fsevent_watch_guard
Makefile
+.guard_result
+
## MAC OS
.DS_Store
.Trashes
@@ -24,7 +24,7 @@ module FileNotifier
# @return [Boolean] the availability status
#
def available?(silent = false, options = {})
- true
+ options.has_key?(:path)
end
# Write the notification to a file. By default it writes type, tytle, and
@@ -43,6 +43,8 @@ def notify(type, title, message, image, options = { })
format = options.fetch(:format, DEFAULTS[:format])
write(options[:path], format % [type, title, message])
+ else
+ ::Guard::UI.error ':file notifier requires a :path option'
end
end
@@ -4,8 +4,12 @@
describe Guard::Notifier::FileNotifier do
describe '.available?' do
- it 'is always true' do
- subject.should be_available
+ it 'is true if there is a file in options' do
+ subject.should be_available(true, :path => '.guard_result')
+ end
+
+ it 'is false if there is no path in options' do
+ subject.should_not be_available
end
end
@@ -26,6 +30,7 @@
# specified. So, we just don't do anything in .notify if there's no path.
it 'does not write to a file if no path is specified' do
subject.should_not_receive(:write)
+ ::Guard::UI.should_receive(:error).with ":file notifier requires a :path option"
subject.notify('success', 'any title', 'any message', 'any image', { })
end

0 comments on commit abcb4e2

Please sign in to comment.