Extract task DSL code and spec

This commit is contained in:
Thibault Jouan
2013-07-30 19:33:59 +00:00
parent 2939123574
commit b1c99dbeeb
5 changed files with 58 additions and 50 deletions

View File

@@ -0,0 +1,39 @@
require 'spec_helper'
module Producer::Core
describe Task::DSL do
subject(:dsl) { Task::DSL.new &block }
describe '#initialize' do
let(:block) { Proc.new { raise 'error from task' } }
it 'evaluates its block' do
expect { dsl }.to raise_error(RuntimeError, 'error from task')
end
end
describe '#condition' do
context 'condition is met (block evals to true)' do
let(:block) { Proc.new {
condition { true }
raise 'error after condition'
} }
it 'evaluates all the block' do
expect { dsl }.to raise_error(RuntimeError, 'error after condition')
end
end
context 'condition is not met (block evals to false)' do
let(:block) { Proc.new {
condition { false }
raise
} }
it 'stops block evaluation' do
expect { dsl }.not_to raise_error
end
end
end
end
end