Skip to content
Browse files

Task does not process if passed a failed report (halt processing chain)

* Raise HaltedChainError if passed a failed report
* task still passes report to next task so all of them have a chance to report
  • Loading branch information...
1 parent 44a9bf8 commit d679ed3ad4df3a01a581e620209f98ff2aa17c22 @ismasan committed May 8, 2009
Showing with 20 additions and 0 deletions.
  1. +7 −0 lib/proto_processor/task.rb
  2. +13 −0 spec/base_task_spec.rb
View
7 lib/proto_processor/task.rb
@@ -24,8 +24,15 @@ def initialize(args)
@error = nil
end
+ class HaltedChainError < StandardError
+ def message
+ "Task not run because previous task failed"
+ end
+ end
+
def run
begin
+ raise HaltedChainError if report[:status] == 'FAILURE'
validate!
before_process
process
View
13 spec/base_task_spec.rb
@@ -83,6 +83,19 @@ def valid?
end
+ describe 'task receiving failed report' do
+ before do
+ @task = FooTask.new([@input, @options, {:status => 'FAILURE'}])
+ end
+
+ it "should halt processing" do
+ @task.should_not_receive(:process)
+ @task.run
+ @task.should_not be_successful
+ @task.report[:status].should == 'FAILURE'
+ end
+ end
+
describe "running" do
it "should invoke :process" do

0 comments on commit d679ed3

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