Attach our env to the worker from the CLI
This commit is contained in:
@@ -44,10 +44,16 @@ module Producer::Core
|
||||
end
|
||||
|
||||
describe '#initialize' do
|
||||
subject(:cli) { CLI.new(arguments) }
|
||||
it 'assigns the env with CLI output' do
|
||||
expect(cli.env.output).to be stdout
|
||||
end
|
||||
|
||||
it 'assigns $stdout as the default standard output' do
|
||||
expect(cli.stdout).to be $stdout
|
||||
context 'without options' do
|
||||
subject(:cli) { CLI.new(arguments) }
|
||||
|
||||
it 'assigns $stdout as the default standard output' do
|
||||
expect(cli.stdout).to be $stdout
|
||||
end
|
||||
end
|
||||
|
||||
context 'without arguments' do
|
||||
@@ -84,10 +90,16 @@ module Producer::Core
|
||||
end
|
||||
end
|
||||
|
||||
describe '#env' do
|
||||
it 'returns an env' do
|
||||
expect(cli.env).to be_an Env
|
||||
end
|
||||
end
|
||||
|
||||
describe '#load_recipe' do
|
||||
it 'evaluates the recipe file with an env' do
|
||||
it 'evaluates the recipe file with the CLI env' do
|
||||
expect(Recipe)
|
||||
.to receive(:evaluate_from_file).with(recipe_file, kind_of(Env))
|
||||
.to receive(:evaluate_from_file).with(recipe_file, cli.env)
|
||||
cli.load_recipe
|
||||
end
|
||||
|
||||
@@ -96,5 +108,15 @@ module Producer::Core
|
||||
expect(cli.recipe.tasks.count).to be 2
|
||||
end
|
||||
end
|
||||
|
||||
describe '#build_worker' do
|
||||
it 'returns a worker' do
|
||||
expect(cli.build_worker).to be_a Worker
|
||||
end
|
||||
|
||||
it 'assigns the CLI env' do
|
||||
expect(cli.build_worker.env).to eq cli.env
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,8 @@ require 'spec_helper'
|
||||
|
||||
module Producer::Core
|
||||
describe Worker do
|
||||
subject(:worker) { described_class.new }
|
||||
let(:env) { Env.new }
|
||||
subject(:worker) { described_class.new(env) }
|
||||
|
||||
describe '#process' do
|
||||
it 'processes each task' do
|
||||
@@ -31,5 +32,11 @@ module Producer::Core
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#env' do
|
||||
it 'returns the assigned env' do
|
||||
expect(worker.env).to be env
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user