Ensure env cleanup always happen in CLI#run

This commit is contained in:
Thibault Jouan 2014-11-18 19:21:42 +00:00
parent cacfa7e342
commit 7e3d753d5c
2 changed files with 10 additions and 0 deletions

View File

@ -45,6 +45,7 @@ module Producer
def run(worker: Worker.new(@env))
evaluate_recipes.each { |recipe| worker.process recipe.tasks }
ensure
@env.cleanup
end

View File

@ -152,6 +152,15 @@ module Producer::Core
expect(cli.env).to receive :cleanup
cli.run
end
context 'on error' do
let(:recipe_file) { fixture_path_for 'recipes/raise.rb' }
it 'cleans up the env' do
expect(cli.env).to receive :cleanup
cli.run rescue nil
end
end
end
describe '#evaluate_recipes' do