diff options
author | Jeff McCune <jeff@puppetlabs.com> | 2013-01-14 18:37:16 -0800 |
---|---|---|
committer | Jeff McCune <jeff@puppetlabs.com> | 2013-01-14 18:38:27 -0800 |
commit | 2a28ece233262e2c94f8f608bf900b7801c06c9a (patch) | |
tree | 92eeadaba1b6c07ec56efd42789446e287368a64 | |
parent | 9dfc58327bcf0d54a74d0425bf62fa593ae10829 (diff) | |
download | puppet-stdlib-2a28ece233262e2c94f8f608bf900b7801c06c9a.tar.gz puppet-stdlib-2a28ece233262e2c94f8f608bf900b7801c06c9a.tar.bz2 |
(maint) Fix getparam() spec failure on MRI 1.8
Without this patch applied we're getting the following spec failure, but
only in the MRI 1.8 matrix cells.
Failures:
1) getparam when compared against a resource with params
Failure/Error: should run.with_params('User[dan]', '').and_return('')
ArgumentError:
interning empty string
# ./vendor/ruby/1.8/gems/puppet-3.0.2/lib/puppet/parser/resource.rb:42:in `intern'
# ./vendor/ruby/1.8/gems/puppet-3.0.2/lib/puppet/parser/resource.rb:42:in `[]'
# ./lib/puppet/parser/functions/getparam.rb:29:in `real_function_getparam'
# ./vendor/ruby/1.8/gems/puppet-3.0.2/lib/puppet/parser/functions.rb:63:in `send'
# ./vendor/ruby/1.8/gems/puppet-3.0.2/lib/puppet/parser/functions.rb:63:in `function_getparam'
# ./vendor/ruby/1.8/gems/rspec-puppet-0.1.5/lib/rspec-puppet/matchers/run.rb:8:in `call'
# ./vendor/ruby/1.8/gems/rspec-puppet-0.1.5/lib/rspec-puppet/matchers/run.rb:8
# ./vendor/ruby/1.8/gems/rspec-puppet-0.1.5/lib/rspec-puppet/matchers/run.rb:24:in `call'
# ./vendor/ruby/1.8/gems/rspec-puppet-0.1.5/lib/rspec-puppet/matchers/run.rb:24
# ./vendor/ruby/1.8/gems/rspec-expectations-2.11.3/lib/rspec/matchers/extensions/instance_eval_with_args.rb:11:in `instance_exec'
# ./vendor/ruby/1.8/gems/rspec-expectations-2.11.3/lib/rspec/matchers/extensions/instance_eval_with_args.rb:11:in `instance_eval_with_args'
# ./vendor/ruby/1.8/gems/rspec-expectations-2.11.3/lib/rspec/matchers/matcher.rb:60:in `matches?'
# ./vendor/ruby/1.8/gems/rspec-expectations-2.11.3/lib/rspec/expectations/handler.rb:9:in `handle_matcher'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/subject.rb:64:in `should'
# ./spec/functions/getparam_spec.rb:29
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:113:in `instance_eval'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:113:in `run'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:253:in `with_around_each_hooks'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:110:in `run'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:378:in `run_examples'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:374:in `map'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:374:in `run_examples'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:360:in `run'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `run'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `map'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `run'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `run'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `map'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `run'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/reporter.rb:34:in `report'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:25:in `run'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
# ./vendor/ruby/1.8/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `autorun'
# ./vendor/ruby/1.8/bin/rspec:23
This patch addresses the problem by explicitly returning an empty string if the
string itself is empty. This avoids trying to convert an empty string to a
symbol which is the root cause of the problem.
-rw-r--r-- | lib/puppet/parser/functions/getparam.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/getparam.rb b/lib/puppet/parser/functions/getparam.rb index 0962656..6d51006 100644 --- a/lib/puppet/parser/functions/getparam.rb +++ b/lib/puppet/parser/functions/getparam.rb @@ -25,6 +25,8 @@ ENDOFDOC raise(ArgumentError, 'Must specify a reference') unless reference raise(ArgumentError, 'Must specify name of a parameter') unless param and param.instance_of? String + return '' if param.empty? + if resource = findresource(reference.to_s) return resource[param] if resource[param] end |