diff --git a/features/registry.feature b/features/registry.feature index b11f610..5cc0524 100644 --- a/features/registry.feature +++ b/features/registry.feature @@ -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" diff --git a/lib/producer/core/env.rb b/lib/producer/core/env.rb index 035582b..38f47c6 100644 --- a/lib/producer/core/env.rb +++ b/lib/producer/core/env.rb @@ -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 []