Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert silent discard of NoMethodError from plugins introduced by 95d…

…9cd1 (fixes #413)

Rather than silently discarding all NoMethodErrors, we just check
whether the plugin implements the task and only execute it if it does.
  • Loading branch information...
commit b5a2f01ed49d488a46be3d5ed5425caf539ef6cb 1 parent 2a32757
Adam Spiers authored
Showing with 6 additions and 5 deletions.
  1. +1 −3 lib/guard/runner.rb
  2. +5 −2 spec/guard/runner_spec.rb
View
4 lib/guard/runner.rb
@@ -51,7 +51,7 @@ def deprecation_warning
def run(task, scopes = {})
Lumberjack.unit_of_work do
scoped_guards(scopes) do |guard|
- run_supervised_task(guard, task)
+ 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") }")
View
7 spec/guard/runner_spec.rb
@@ -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)

1 comment on commit b5a2f01

@amiel
Collaborator

:+1:

Please sign in to comment.
Something went wrong with that request. Please try again.