Issue #15756 has been updated by Daniel Pittman.

I still get test failures with the updated code:

<pre>
  1) The require function should add a dependency between the 'required' class 
and our class
     Failure/Error: @scope.function_require("requiredclass")
     ArgumentError:
       custom functions must be called with a single array that contains the 
arguments
     # ./lib/puppet/parser/functions.rb:65:in `block in newfunction'
     # ./spec/integration/parser/functions/require_spec.rb:20:in `block (2 
levels) in <top (required)>'

  2) The require function should queue relationships between the 'required' 
class and our classes
     Failure/Error: @scope.function_require("requiredclass1")
     ArgumentError:
       custom functions must be called with a single array that contains the 
arguments
     # ./lib/puppet/parser/functions.rb:65:in `block in newfunction'
     # ./spec/integration/parser/functions/require_spec.rb:31:in `block (2 
levels) in <top (required)>'

  3) Puppet::Parser::Functions#hiera_array should raise a useful error when nil 
is returned
     Failure/Error: expect { scope.function_hiera_array("badkey") }.to 
raise_error(Puppet::ParseError, /Could not find data item badkey/ )
       expected Puppet::ParseError with message matching /Could not find data 
item badkey/, got #<ArgumentError: custom functions must be called with a 
single array that contains the arguments>
     # ./spec/unit/parser/functions/hiera_array_spec.rb:16:in `block (2 levels) 
in <top (required)>'

  4) Puppet::Parser::Functions#hiera_hash should raise a useful error when nil 
is returned
     Failure/Error: expect { scope.function_hiera_hash("badkey") }.to 
raise_error(Puppet::ParseError, /Could not find data item badkey/ )
       expected Puppet::ParseError with message matching /Could not find data 
item badkey/, got #<ArgumentError: custom functions must be called with a 
single array that contains the arguments>
     # ./spec/unit/parser/functions/hiera_hash_spec.rb:12:in `block (2 levels) 
in <top (required)>'

  5) Puppet::Parser::Functions#hiera_include should raise a useful error when 
nil is returned
     Failure/Error: expect { scope.function_hiera_include("badkey") }.to 
raise_error(Puppet::ParseError, /Could not find data item badkey/ )
       expected Puppet::ParseError with message matching /Could not find data 
item badkey/, got #<ArgumentError: custom functions must be called with a 
single array that contains the arguments>
     # ./spec/unit/parser/functions/hiera_include_spec.rb:12:in `block (2 
levels) in <top (required)>'

  6) Puppet::Parser::Functions#hiera should raise a useful error when nil is 
returned
     Failure/Error: expect { scope.function_hiera("badkey") }.to 
raise_error(Puppet::ParseError, /Could not find data item badkey/ )
       expected Puppet::ParseError with message matching /Could not find data 
item badkey/, got #<ArgumentError: custom functions must be called with a 
single array that contains the arguments>
     # ./spec/unit/parser/functions/hiera_spec.rb:14:in `block (2 levels) in 
<top (required)>'

  7) Puppet::Parser::Functions when calling newfunction should create the 
function in the environment module
     Failure/Error: Puppet::Parser::Functions.newfunction("name", :type => 
:rvalue)
     Mocha::ExpectationError:
       unexpected invocation: 
#<Module:0x7f850bcc6c98>.define_method('real_function_name')
       unsatisfied expectations:
       - expected exactly once, not yet invoked: 
#<Module:0x7f850bcc6c98>.define_method()
       satisfied expectations:
       - allowed any number of times, not yet invoked: 
Signal.trap(any_parameters)
       - allowed any number of times, invoked once: 
Puppet::Parser::Functions.environment_module(any_parameters)
     # ./lib/puppet/parser/functions.rb:58:in `newfunction'
     # ./spec/unit/parser/functions_spec.rb:27:in `block (3 levels) in <top 
(required)>'

  8) Puppet::Parser::Functions when calling newfunction should warn if the 
function already exists
     Failure/Error: Puppet::Parser::Functions.newfunction("name", :type => 
:rvalue)
     Mocha::ExpectationError:
       unexpected invocation: 
#<Module:0x7f850de7a470>.define_method('real_function_name')
       unsatisfied expectations:
       - expected exactly twice, not yet invoked: 
#<Module:0x7f850de7a470>.define_method()
       satisfied expectations:
       - allowed any number of times, not yet invoked: 
Signal.trap(any_parameters)
       - allowed any number of times, invoked once: 
Puppet::Parser::Functions.environment_module(any_parameters)
     # ./lib/puppet/parser/functions.rb:58:in `newfunction'
     # ./spec/unit/parser/functions_spec.rb:32:in `block (3 levels) in <top 
(required)>'

  9) Puppet::Parser::Functions when calling function to test function existance 
should return its name if the function exists
     Failure/Error: Puppet::Parser::Functions.newfunction("name", :type => 
:rvalue)
     Mocha::ExpectationError:
       unexpected invocation: 
#<Module:0x7f850eb85ed0>.define_method('real_function_name')
       unsatisfied expectations:
       - expected exactly once, not yet invoked: 
#<Module:0x7f850eb85ed0>.define_method()
       satisfied expectations:
       - allowed any number of times, not yet invoked: 
Signal.trap(any_parameters)
       - allowed any number of times, invoked once: 
Puppet::Parser::Functions.environment_module(any_parameters)
     # ./lib/puppet/parser/functions.rb:58:in `newfunction'
     # ./spec/unit/parser/functions_spec.rb:59:in `block (3 levels) in <top 
(required)>'
</pre>

----------------------------------------
Bug #15756: scope.function_template with a single String parameter fails in 
Ruby 1.9
https://projects.puppetlabs.com/issues/15756#change-70834

Author: Roger Que
Status: In Topic Branch Pending Review
Priority: Normal
Assignee: Andrew  Parker
Category: templates
Target version: 3.0.0
Affected Puppet version: 2.7.18
Keywords: ruby19 functions
Branch: https://github.com/puppetlabs/puppet/pull/1105


The Puppet documentation mentions [using `scope.function_template` with a 
String 
parameter](http://docs.puppetlabs.com/guides/templating.html#access-to-variables-and-puppet-functions-with-the-scope-object)
 in order to render an ERB template inside another template:

    <%= scope.function_template('referenced_template.erb') %>

This works in Ruby 1.8, but fails with the following error when the Puppet 
master is running 1.9:

    err: Could not retrieve catalog from remote server: Error 400 on SERVER: 
Failed to parse template [xxx].erb:
      Filepath: /usr/share/ruby/vendor_ruby/puppet/parser/functions/template.rb
      Line: 10
      Detail: undefined method `collect' for "referenced_template.erb":String
     at /etc/puppet/modules/[yyy].pp:164 on node [zzz.example]

It looks like the `template` function is invoking `collect` on its argument 
regardless of whether it's a String or Array, which works in Ruby 1.8 
(`'abc'.collect` behaves like `['abc'].collect`) but not in 1.9. Passing an 
Array works with both versions.

This is on Fedora 17, Ruby 1.9.3p194, with Puppet 2.7.18.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to puppet-bugs@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-bugs+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to