Implement `target' condition keyword

This commit is contained in:
Thibault Jouan 2014-09-25 01:34:30 +00:00
parent a7b2c4abea
commit 42e29cc1fe
3 changed files with 27 additions and 1 deletions

View 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"

View File

@ -30,7 +30,7 @@ module Producer
end end
extend Forwardable extend Forwardable
def_delegators :@env, :get def_delegators :@env, :get, :target
define_test :`, Tests::ShellCommandStatus define_test :`, Tests::ShellCommandStatus
define_test :sh, Tests::ShellCommandStatus define_test :sh, Tests::ShellCommandStatus

View File

@ -182,5 +182,16 @@ module Producer::Core
described_class.evaluate(env, []) { get :some_key } described_class.evaluate(env, []) { get :some_key }
end end
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
end end