Allow `target' recipe keyword to return target
This commit is contained in:
parent
eba719941d
commit
b11d0b6950
@ -10,4 +10,14 @@ Feature: `target' recipe keyword
|
||||
end
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain exactly "some_host.example\n"
|
||||
Then the output must contain "some_host.example"
|
||||
|
||||
Scenario: returns current target when no arguments are provided
|
||||
Given a recipe with:
|
||||
"""
|
||||
target 'some_host.example'
|
||||
|
||||
env.output.puts target
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "some_host.example"
|
||||
|
@ -26,8 +26,8 @@ module Producer
|
||||
instance_eval File.read("./#{filepath}.rb"), "#{filepath}.rb"
|
||||
end
|
||||
|
||||
def target(hostname)
|
||||
env.target ||= hostname
|
||||
def target(hostname = nil)
|
||||
if hostname then env.target ||= hostname else env.target end
|
||||
end
|
||||
|
||||
def task(name, *args, &block)
|
||||
|
@ -38,6 +38,13 @@ module Producer::Core
|
||||
expect { recipe.target host }.not_to change { env.target }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when no arguments are provided' do
|
||||
it 'returns current target' do
|
||||
recipe.target host
|
||||
expect(recipe.target).to eq host
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#task' do
|
||||
|
Loading…
x
Reference in New Issue
Block a user