Instead of interrupting task evaluation when condition is not met, allow the whole task to be evaluated (including condition and evaluation) so that the interpreter will get all tasks actions (whether condition is met or not) and be able to query the condition. * Modify Interpreter#process_task: test if task condition is met before applying the actions; * Implement condition handling in Task and Task::DSL; * Implement Condition and Condition::DSL (useless as they are, but needed to implement later test keywords as part of the condition DSL.
42 lines
1022 B
Ruby
42 lines
1022 B
Ruby
require 'spec_helper'
|
|
|
|
module Producer::Core
|
|
describe Interpreter do
|
|
subject(:interpreter) { Interpreter.new }
|
|
|
|
describe '#process' do
|
|
it 'processes each task' do
|
|
expect(interpreter).to receive(:process_task).with(:some_task)
|
|
interpreter.process [:some_task]
|
|
end
|
|
end
|
|
|
|
describe '#process_task' do
|
|
let(:action) { double('action') }
|
|
let(:task) { double('task').as_null_object }
|
|
|
|
before do
|
|
allow(task).to receive(:actions) { [action] }
|
|
end
|
|
|
|
context 'when task condition is met' do
|
|
it 'applies the actions' do
|
|
expect(action).to receive(:apply)
|
|
interpreter.process_task(task)
|
|
end
|
|
end
|
|
|
|
context 'when task condition is not met' do
|
|
before do
|
|
allow(task).to receive(:condition_met?) { false }
|
|
end
|
|
|
|
it 'does not apply the actions' do
|
|
expect(action).not_to receive(:apply)
|
|
interpreter.process_task(task)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|