diff --git a/spec/producer/core/recipe_spec.rb b/spec/producer/core/recipe_spec.rb index d4e2d08..9763359 100644 --- a/spec/producer/core/recipe_spec.rb +++ b/spec/producer/core/recipe_spec.rb @@ -7,35 +7,13 @@ module Producer::Core subject(:recipe) { Recipe.new } describe '.evaluate_from_file' do - let(:env) { double 'env' } - let(:filepath) { fixture_path_for 'recipes/empty.rb' } - let(:code) { File.read(filepath) } + let(:env) { double 'env' } + let(:filepath) { fixture_path_for 'recipes/some_recipe.rb' } + subject(:recipe) { Recipe.evaluate_from_file(filepath, env) } - it 'builds a new DSL sandbox with code read from given file path' do - expect(Recipe::DSL).to receive(:new).with(code).and_call_original - Recipe.evaluate_from_file(filepath, env) + it 'returns an evaluated recipe' do + expect(recipe.tasks.map(&:name)).to eq [:some_task, :another_task] end - - it 'evaluates the DSL sandbox code with given environment' do - dsl = double('dsl').as_null_object - allow(Recipe::DSL).to receive(:new) { dsl } - expect(dsl).to receive(:evaluate).with(env) - Recipe.evaluate_from_file(filepath, env) - end - - it 'builds a recipe with evaluated tasks' do - dsl = Recipe::DSL.new { task(:some_task) { } } - allow(Recipe::DSL).to receive(:new) { dsl } - expect(Recipe).to receive(:new).with(dsl.tasks) - Recipe.evaluate_from_file(filepath, env) - end - - it 'returns the recipe' do - recipe = double('recipe').as_null_object - allow(Recipe).to receive(:new) { recipe } - expect(Recipe.evaluate_from_file(filepath, env)).to be recipe - end - end describe '#initialize' do @@ -46,8 +24,8 @@ module Producer::Core end context 'when tasks are given as argument' do - let(:tasks) { [Task.new(:some_task)] } - let(:recipe) { Recipe.new(tasks) } + let(:tasks) { [double('task')] } + subject(:recipe) { Recipe.new(tasks) } it 'assigns the tasks' do expect(recipe.tasks).to eq tasks