Implement set' and
get' recipe keywords:
`set' registers a value at given index in env registry, `get' retrieves a value at given index.
This commit is contained in:
parent
154ee8d534
commit
f92ad8128d
21
features/recipes/registry.feature
Normal file
21
features/recipes/registry.feature
Normal file
@ -0,0 +1,21 @@
|
||||
Feature: key/value registry
|
||||
|
||||
Scenario: `set' keyword registers a value in the registry
|
||||
Given a recipe with:
|
||||
"""
|
||||
set :some_key, 'some_value'
|
||||
|
||||
puts env.registry[:some_key]
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "some_value"
|
||||
|
||||
Scenario: `get' keyword fetches a value from the registry
|
||||
Given a recipe with:
|
||||
"""
|
||||
set :some_key, 'some_value'
|
||||
|
||||
puts get :some_key
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "some_value"
|
@ -37,6 +37,14 @@ module Producer
|
||||
task("#{name}", *args, &block)
|
||||
end
|
||||
end
|
||||
|
||||
def set(key, value)
|
||||
env[key] = value
|
||||
end
|
||||
|
||||
def get(key)
|
||||
env[key]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -100,5 +100,19 @@ module Producer::Core
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#set' do
|
||||
it 'registers a key/value pair in env registry' do
|
||||
dsl.set :some_key, :some_value
|
||||
expect(env[:some_key]).to eq :some_value
|
||||
end
|
||||
end
|
||||
|
||||
describe '#get' do
|
||||
it 'fetches a value from the registry at given index' do
|
||||
dsl.set :some_key, :some_value
|
||||
expect(dsl.get :some_key).to eq :some_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user