Remove error handling for evaluation errors

This commit is contained in:
Thibault Jouan
2013-08-13 00:11:53 +00:00
parent 0904fa1fc9
commit a5d9ca26f4
12 changed files with 1 additions and 146 deletions

View File

@@ -37,44 +37,6 @@ module Producer::Core
expect(cli.worker).to receive(:process).with([:some_task])
cli.run!
end
context 'when recipe evaluation fails' do
let(:recipe_file) { fixture_path_for('recipes/invalid.rb') }
let(:stdout) { StringIO.new }
subject(:cli) { CLI.new(arguments, stdout) }
context 'when error is known' do
it 'exits with a return status of 70' do
expect { cli.run! }
.to raise_error(SystemExit) { |e|
expect(e.status).to eq 70
}
end
it 'prints the specific error' do
trap_exit { cli.run! }
expect(stdout.string).to match(/
\A
#{recipe_file}:4:
.+
invalid\srecipe\skeyword\s`invalid_keyword'
/x)
end
it 'excludes producer own source code from the error backtrace' do
trap_exit { cli.run! }
expect(stdout.string).to_not match /\/producer-core\//
end
end
context 'when error is unknown (unexpected)' do
it 'lets the error be' do
UnexpectedError = Class.new(StandardError)
allow(cli.recipe).to receive(:evaluate).and_raise(UnexpectedError)
expect { cli.run! }.to raise_error(UnexpectedError)
end
end
end
end
describe '#check_arguments!' do

View File

@@ -4,10 +4,6 @@ module Producer::Core
describe Recipe::DSL do
include FixturesHelpers
# Specific error thrown in the error fixture recipe, we can't define it in
# the recipe, rspec wouldn't know about it.
SomeErrorInRecipe = Class.new(RuntimeError)
let(:code) { proc { } }
let(:env) { double('env').as_null_object }
subject(:dsl) { Recipe::DSL.new &code }
@@ -48,24 +44,6 @@ module Producer::Core
it 'returns itself' do
expect(dsl.evaluate(env)).to eq dsl
end
context 'when recipe is invalid' do
let(:filepath) { fixture_path_for 'recipes/error.rb' }
let(:recipe) { Recipe.from_file(filepath) }
subject(:dsl) { Recipe::DSL.new File.read(filepath) }
it 'reports the recipe file path in the error' do
allow(env).to receive(:current_recipe) { recipe }
expect { dsl.evaluate(env) }.to raise_error(SomeErrorInRecipe) { |e|
expect(e.backtrace.first).to match /\A#{filepath}/
}
end
it 'raises a RecipeEvaluationError on NameError' do
dsl = Recipe::DSL.new { invalid_keyword }
expect { dsl.evaluate(env) }.to raise_error(RecipeEvaluationError)
end
end
end
context 'DSL specific methods' do
@@ -88,16 +66,6 @@ module Producer::Core
it 'sources the recipe given as argument' do
expect { dsl.evaluate(env) }.to throw_symbol :recipe_code
end
context 'when sourced recipe is invalid' do
let(:filepath) { fixture_path_for 'recipes/error' }
it 'reports its file path in the error' do
expect { dsl.evaluate(env) }.to raise_error(SomeErrorInRecipe) { |e|
expect(e.backtrace.first).to match /\A#{filepath}/
}
end
end
end
describe '#target' do

View File

@@ -57,14 +57,6 @@ module Producer::Core
expect(dsl.actions.first.env).to eq env
end
end
context 'when given block is invalid' do
it 'raises a TaskEvaluationError on NameError' do
dsl = Task::DSL.new { invalid_action }
expect { dsl.evaluate(env) }
.to raise_error(TaskEvaluationError)
end
end
end
describe '#condition' do