Permalink
Browse files

Merge pull request #414 from aspiers/master

misc fixes
  • Loading branch information...
2 parents 8f8f01e + ed1bb0f commit 0248bbc9f40b14f3c442e6d3ec77dfad955cdac8 @thibaudgg thibaudgg committed Apr 4, 2013
Showing with 29 additions and 17 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 Gemfile
  3. +19 −10 lib/guard/notifiers/tmux.rb
  4. +2 −4 lib/guard/runner.rb
  5. +5 −2 spec/guard/runner_spec.rb
  6. +1 −1 spec/guard_spec.rb
View
@@ -16,6 +16,7 @@ bin/fsevent_watch_guard
Makefile
.guard_result
+coverage/
## MAC OS
.DS_Store
View
@@ -43,5 +43,6 @@ end
#
group :test do
gem 'rspec'
+ gem 'guard-rspec' # this is required by guard_spec.rb
gem 'coveralls', :require => false
end
@@ -65,7 +65,7 @@ def notify(type, title, message, image, options = { })
color = tmux_color(type, options)
color_location = options[:color_location] || DEFAULTS[:color_location]
- system("#{ DEFAULTS[:client] } set #{ color_location } #{ color }")
+ run_client "set #{ color_location } #{ color }"
show_message = options[:display_message] || DEFAULTS[:display_message]
display_message(type, title, message, options) if show_message
@@ -98,10 +98,10 @@ def display_message(type, title, message, options = { })
formatted_message = message.split("\n").join(separator)
display_message = message_format % [title, formatted_message]
- system("#{ DEFAULTS[:client] } set display-time #{ display_time * 1000 }")
- system("#{ DEFAULTS[:client] } set message-fg #{ message_color }")
- system("#{ DEFAULTS[:client] } set message-bg #{ color }")
- system("#{ DEFAULTS[:client] } display-message '#{ display_message }'")
+ run_client "set display-time #{ display_time * 1000 }"
+ run_client "set message-fg #{ message_color }"
+ run_client "set message-bg #{ color }"
+ run_client "display-message '#{ display_message }'"
end
# Get the Tmux color for the notification type.
@@ -138,31 +138,40 @@ def turn_on(options = { })
@options_stored = true
end
- system("#{ DEFAULTS[:client] } set quiet on")
+ run_client "set quiet on"
end
# Notification stopping. Restore the previous Tmux state
# if available (existing options are restored, new options
- # are unset) and unquite the Tmux output.
+ # are unset) and unquiet the Tmux output.
#
def turn_off(options = { })
if @options_stored
@options_store.each do |key, value|
if value
- system("#{ DEFAULTS[:client] } set #{ key } #{ value }")
+ run_client "set #{ key } #{ value }"
else
- system("#{ DEFAULTS[:client] } set -u #{ key }")
+ run_client "set -u #{ key }"
end
end
reset_options_store
end
- system("#{ DEFAULTS[:client] } set quiet off")
+ run_client 'set quiet off'
end
private
+ def system(args)
+ args += " >/dev/null 2>&1" if ENV['GUARD_ENV'] == 'test'
+ super
+ end
+
+ def run_client(args)
+ system("#{ DEFAULTS[:client] } #{args}")
+ end
+
# Reset the internal Tmux options store defaults.
#
def reset_options_store
View
@@ -50,8 +50,8 @@ def deprecation_warning
#
def run(task, scopes = {})
Lumberjack.unit_of_work do
- scoped_guards(scopes) do |guard|
- run_supervised_task(guard, task)
+ scoped_guards(scopes) do |guard|
+ run_supervised_task(guard, task) if guard.respond_to?(task)
end
end
end
@@ -101,8 +101,6 @@ def run_supervised_task(guard, task, *args)
result
end
- rescue NoMethodError
- # Do nothing
rescue Exception => ex
::Guard::UI.error("#{ guard.class.name } failed to achieve its <#{ task.to_s }>, exception was:" +
"\n#{ ex.class }: #{ ex.message }\n#{ ex.backtrace.join("\n") }")
@@ -68,8 +68,9 @@
describe '#run' do
let(:scopes) { { :group => foo_group } }
- it 'executes a supervised task on all registered guards' do
- [foo_guard, bar1_guard, bar2_guard].each do |g|
+ it 'executes a supervised task on all registered guards implementing that task' do
+ [foo_guard, bar1_guard].each do |g|
+ g.stub(:my_task)
subject.should_receive(:run_supervised_task).with(g, :my_task)
end
subject.run(:my_task)
@@ -94,6 +95,7 @@
let(:scopes) { { :plugins => [bar1_guard] } }
it 'executes the supervised task on the specified guard only' do
+ bar1_guard.stub(:my_task)
subject.should_receive(:run_supervised_task).with(bar1_guard, :my_task)
subject.should_not_receive(:run_supervised_task).with(foo_guard, :my_task)
@@ -107,6 +109,7 @@
let(:scopes) { { :groups => [foo_group] } }
it 'executes the task on each guard in the specified group only' do
+ foo_guard.stub(:my_task)
subject.should_receive(:run_supervised_task).with(foo_guard, :my_task)
subject.should_not_receive(:run_supervised_task).with(bar1_guard, :my_task)
View
@@ -135,7 +135,7 @@
end
end
- describe ".setup_signal_traps" do
+ describe ".setup_signal_traps", :speed => 'slow' do
before { ::Guard::Dsl.stub(:evaluate_guardfile) }
unless windows? || defined?(JRUBY_VERSION)

0 comments on commit 0248bbc

Please sign in to comment.