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:
Thibault Jouan 2014-01-21 17:11:17 +00:00
parent 154ee8d534
commit f92ad8128d
3 changed files with 43 additions and 0 deletions

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

View File

@ -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

View File

@ -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