Refactor and simplify recipe DSL evaluation usages:

Remove most of recipe evaluation code in Recipe class, and rely on
Recipe::DSL to get evaluated recipes.

* Remove Recipe#evaluate call from CLI, rely on
  Recipe.evaluate_from_file to get the evaluated recipe;
* Implement Recipe.evaluate_from_file(filepath, env);
* Implement Recipe::DSL.evaluate(code, env);
* Remove code and filepath accessor on Recipe;
* Remove Recipe.from_file and Recipe#evaluate methods;
* Move task evaluations in Recipe::DSL#evaluate;
* Modify Recipe constructor so that it accepts tasks as argument.
This commit is contained in:
Thibault Jouan
2013-08-10 15:36:27 +00:00
parent 7c5d5b0417
commit f0e144cebd
6 changed files with 77 additions and 85 deletions

View File

@@ -27,11 +27,6 @@ module Producer::Core
cli.run!
end
it 'evaluates the recipe with the environment' do
expect(cli.recipe).to receive(:evaluate).with(cli.env)
cli.run!
end
it 'processes the tasks with the worker' do
allow(cli.recipe).to receive(:tasks) { [:some_task] }
expect(cli.worker).to receive(:process).with([:some_task])
@@ -80,12 +75,12 @@ module Producer::Core
describe '#recipe' do
it 'builds a recipe' do
expect(Recipe)
.to receive(:from_file).with(recipe_file)
.to receive(:evaluate_from_file).with(recipe_file, cli.env)
cli.recipe
end
it 'returns the recipe' do
recipe = double('recipe')
recipe = double('recipe').as_null_object
allow(Recipe).to receive(:new) { recipe }
expect(cli.recipe).to be recipe
end