Implement `get' task keyword, fetch from registry
This commit is contained in:
parent
f92ad8128d
commit
456ed17724
13
features/tasks/registry.feature
Normal file
13
features/tasks/registry.feature
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Feature: access to registry from task DSL
|
||||||
|
|
||||||
|
Scenario: `get' keyword fetches a value from the registry
|
||||||
|
Given a recipe with:
|
||||||
|
"""
|
||||||
|
set :some_key, 'some_value'
|
||||||
|
|
||||||
|
task :output_some_key do
|
||||||
|
echo get :some_key
|
||||||
|
end
|
||||||
|
"""
|
||||||
|
When I successfully execute the recipe
|
||||||
|
Then the output must contain "some_value"
|
@ -37,6 +37,10 @@ module Producer
|
|||||||
def ask(question, choices, prompter: Prompter)
|
def ask(question, choices, prompter: Prompter)
|
||||||
prompter.new(env.input, env.output).prompt(question, choices)
|
prompter.new(env.input, env.output).prompt(question, choices)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get(key)
|
||||||
|
env[key]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -102,5 +102,13 @@ module Producer::Core
|
|||||||
expect(ask).to eq :choice
|
expect(ask).to eq :choice
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#get' do
|
||||||
|
let(:env) { Env.new(registry: { some_key: :some_value }) }
|
||||||
|
|
||||||
|
it 'fetches a value from the registry at given index' do
|
||||||
|
expect(dsl.get :some_key).to eq :some_value
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user