Allow access to registry from conditions
This commit is contained in:
parent
d335abce57
commit
77582ef843
@ -24,3 +24,13 @@ Feature: key/value registry
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "some_value"
|
||||
|
||||
Scenario: `get' keyword fetches a value from a condition
|
||||
Given a recipe with:
|
||||
"""
|
||||
set :some_key, 'some_value'
|
||||
|
||||
task(:ok) { condition { get :some_key }; echo get :some_key }
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "some_value"
|
||||
|
@ -29,6 +29,9 @@ module Producer
|
||||
end
|
||||
end
|
||||
|
||||
extend Forwardable
|
||||
def_delegators :@env, :get
|
||||
|
||||
define_test :`, Tests::ShellCommandStatus
|
||||
define_test :sh, Tests::ShellCommandStatus
|
||||
define_test :file_contains, Tests::FileContains
|
||||
|
@ -20,6 +20,7 @@ module Producer
|
||||
def [](key)
|
||||
@registry[key]
|
||||
end
|
||||
alias get []
|
||||
|
||||
def []=(key, value)
|
||||
@registry[key] = value
|
||||
|
@ -173,5 +173,14 @@ module Producer::Core
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#get' do
|
||||
let(:env) { Env.new }
|
||||
|
||||
it 'delegates to env registry' do
|
||||
expect(env).to receive(:get).with :some_key
|
||||
described_class.evaluate(env, []) { get :some_key }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user