Implement `target' condition keyword
This commit is contained in:
parent
a7b2c4abea
commit
42e29cc1fe
15
features/condition_target.feature
Normal file
15
features/condition_target.feature
Normal file
@ -0,0 +1,15 @@
|
||||
Feature: `target' condition keyword
|
||||
|
||||
Scenario: returns the current target
|
||||
Given a recipe with:
|
||||
"""
|
||||
target 'some_host.example'
|
||||
|
||||
task :test_target do
|
||||
condition { target == 'some_host.example' }
|
||||
|
||||
echo 'OK'
|
||||
end
|
||||
"""
|
||||
When I execute the recipe
|
||||
Then the output must contain "OK"
|
@ -30,7 +30,7 @@ module Producer
|
||||
end
|
||||
|
||||
extend Forwardable
|
||||
def_delegators :@env, :get
|
||||
def_delegators :@env, :get, :target
|
||||
|
||||
define_test :`, Tests::ShellCommandStatus
|
||||
define_test :sh, Tests::ShellCommandStatus
|
||||
|
@ -182,5 +182,16 @@ module Producer::Core
|
||||
described_class.evaluate(env, []) { get :some_key }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#target' do
|
||||
let(:env) { Env.new }
|
||||
|
||||
before { env.target = :some_target }
|
||||
|
||||
it 'returns current env target' do
|
||||
condition = described_class.evaluate(env, []) { target == :some_target }
|
||||
expect(condition).to be_met
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user