Implement target recipe keyword feature
This commit is contained in:
parent
a6e27edfd2
commit
a3bba6d4da
12
features/cli/target.feature
Normal file
12
features/cli/target.feature
Normal file
@ -0,0 +1,12 @@
|
||||
Feature: target recipe keyword
|
||||
|
||||
Scenario: registers the target host on which tasks should be evaluated
|
||||
Given a recipe with:
|
||||
"""
|
||||
target 'some_host.example'
|
||||
|
||||
puts env.target
|
||||
"""
|
||||
When I execute the recipe
|
||||
Then the exit status must be 0
|
||||
And the output must contain exactly "some_host.example\n"
|
@ -2,9 +2,11 @@ module Producer
|
||||
module Core
|
||||
class Env
|
||||
attr_reader :current_recipe
|
||||
attr_accessor :target
|
||||
|
||||
def initialize(recipe)
|
||||
@current_recipe = recipe
|
||||
@target = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,10 +5,25 @@ module Producer::Core
|
||||
let(:recipe) { Recipe.new(proc { nil }) }
|
||||
subject(:env) { Env.new(recipe) }
|
||||
|
||||
describe '#initialize' do
|
||||
it 'has no target' do
|
||||
expect(env.target).not_to be
|
||||
end
|
||||
end
|
||||
|
||||
describe '#current_recipe' do
|
||||
it 'returns the assigned current recipe' do
|
||||
expect(env.current_recipe).to eq recipe
|
||||
end
|
||||
end
|
||||
|
||||
describe '#target' do
|
||||
let(:target) { Object.new }
|
||||
|
||||
it 'returns the defined target' do
|
||||
env.target = target
|
||||
expect(env.target).to eq target
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -87,6 +87,15 @@ module Producer::Core
|
||||
end
|
||||
end
|
||||
|
||||
describe '#target' do
|
||||
let(:code) { proc { target 'some_host.example' } }
|
||||
|
||||
it 'registers the target host in the env' do
|
||||
expect(env).to receive(:target=).with('some_host.example')
|
||||
dsl.evaluate(env)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#tasks' do
|
||||
let(:code) { proc { task(:some_task) } }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user