Implement task evaluation feature
This commit is contained in:
@@ -54,6 +54,23 @@ module Producer::Core
|
||||
expect { dsl }.to raise_error(RuntimeError, 'error from recipe')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#tasks' do
|
||||
let(:code) { Proc.new { task(:some_task) } }
|
||||
|
||||
it 'returns registered tasks' do
|
||||
expect(dsl.tasks[0].name).to eq :some_task
|
||||
end
|
||||
end
|
||||
|
||||
describe '#task' do
|
||||
let(:code) { Proc.new { task(:one); task(:two) } }
|
||||
|
||||
it 'registers tasks in declaration order' do
|
||||
expect(dsl.tasks[0].name).to eq :one
|
||||
expect(dsl.tasks[1].name).to eq :two
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
23
spec/producer/core/task_spec.rb
Normal file
23
spec/producer/core/task_spec.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
require 'spec_helper'
|
||||
|
||||
module Producer::Core
|
||||
describe Task do
|
||||
let(:name) { :some_task }
|
||||
let(:block) { }
|
||||
subject(:task) { Task.new(name, &block) }
|
||||
|
||||
describe '#name' do
|
||||
it 'returns its name' do
|
||||
expect(task.name).to eq name
|
||||
end
|
||||
end
|
||||
|
||||
describe 'evaluate' do
|
||||
let(:block) { Proc.new { raise 'error from task' } }
|
||||
|
||||
it 'evaluates its block' do
|
||||
expect { task.evaluate }.to raise_error(RuntimeError, 'error from task')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user