Accept a default value for `get' registry keyword
This commit is contained in:
parent
2d3975d47f
commit
1465b98f18
@ -46,3 +46,13 @@ Feature: key/value registry
|
||||
When I execute the recipe
|
||||
Then the output must not contain "after_fail"
|
||||
And the output must match /\A\w+Error:\s+:no_key/
|
||||
|
||||
Scenario: `get' keyword accepts a default value
|
||||
Given a recipe with:
|
||||
"""
|
||||
task :registry_testing do
|
||||
echo get(:some_key, 'some_value')
|
||||
end
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "some_value"
|
||||
|
@ -20,10 +20,10 @@ module Producer
|
||||
@remote ||= Remote.new(target)
|
||||
end
|
||||
|
||||
def [](key)
|
||||
@registry.fetch key
|
||||
def [](*args)
|
||||
@registry.fetch *args
|
||||
rescue KeyError
|
||||
fail RegistryKeyError, key.inspect
|
||||
fail RegistryKeyError, args.first.inspect
|
||||
end
|
||||
alias get []
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user