Implement nested tasks
This commit is contained in:
@@ -126,6 +126,15 @@ module Producer::Core
|
||||
end
|
||||
end
|
||||
|
||||
describe '#task' do
|
||||
before { described_class.define_action(:some_action, SomeAction) }
|
||||
|
||||
it 'registers a nested task as an action' do
|
||||
task.task(:nested_task) { some_action }
|
||||
expect(task.actions).to match [an_instance_of(Task)]
|
||||
end
|
||||
end
|
||||
|
||||
describe '#ask' do
|
||||
let(:question) { 'Which letter?' }
|
||||
let(:choices) { [[:a, ?A], [:b, ?B]] }
|
||||
|
@@ -25,9 +25,9 @@ module Producer::Core
|
||||
end
|
||||
|
||||
describe '#process_task' do
|
||||
let(:env) { instance_spy Env, dry_run?: false }
|
||||
let(:action) { double('action', to_s: 'echo').as_null_object }
|
||||
let(:task) { Task.new(env, :some_task, [action]) }
|
||||
let(:env) { instance_spy Env, dry_run?: false }
|
||||
let(:action) { double('action', to_s: 'echo').as_null_object }
|
||||
let(:task) { Task.new(env, :some_task, [action]) }
|
||||
|
||||
it 'logs task info' do
|
||||
expect(env).to receive(:log).with /\ATask: `some_task'/
|
||||
@@ -68,11 +68,21 @@ module Producer::Core
|
||||
worker.process_task task
|
||||
end
|
||||
|
||||
it 'logs the task as beeing skipped' do
|
||||
it 'logs the task as being skipped' do
|
||||
expect(env).to receive(:log).with /some_task.+skipped\z/
|
||||
worker.process_task task
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a task contains nested tasks' do
|
||||
let(:inner_task) { Task.new(env, :inner, [action]) }
|
||||
let(:outer_task) { Task.new(env, :outer, [inner_task]) }
|
||||
|
||||
it 'processes nested tasks' do
|
||||
expect(action).to receive :apply
|
||||
worker.process [outer_task]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user