You're right that my function isn't inside Puppet, Henrik. But the whole point of it is to be able to run Puppet functions without needing to run Puppet itself so they can be live debugged very quickly.
It worked fine with Puppet 2.6, but I guess the upgrades that have been to Puppet made since then prevent it from operating in the same way with Puppet 3. I'll try to stick it into the test framework as you've suggested. Many thanks, Dave On Friday, 2 May 2014 15:18:02 UTC+1, Henrik Lindberg wrote: > > On 2014-01-05 11:18, KomodoDave wrote: > > Thanks for the response, Henrik. > > > > I’ve tried what you suggested already: > > > > |node=Puppet::Node.new('localhost') > > compiler=Puppet::Parser::Compiler.new(node) > > scope=Puppet::Parser::Scope.new(compiler) > > | > > > > ..but the result is: > > > > | > > /usr/lib/ruby/vendor_ruby/puppet/context.rb:43:in `lookup': no > 'environments' in > {:root_environment=>#<Puppet::Node::Environment:0x7f31f0383230 > @modulepath=[], @name=:"*root*", @manifest="path_to_my_script_dir">, > :current_environment=>#<Puppet::Node::Environment:0x7f31f0383230 > @modulepath=[], @name=:"*root*", @manifest="path_to_my_script_dir">} at top > of [] (Puppet::Context::UndefinedBindingError) > > | > > > > ..where |path_to_my_script_dir| is the absolute path of the directory > > containing my ruby script. > > > > Is there a way for me to set up the correct context and/or environments > > mentioned in this error message? > > > > Sorry, your function is obviously not inside puppet itself and needs to > be setup. Look at how tests are done for functions in puppet-stdlib, it > uses rspec-puppet to help with setting up things for the tests. > > https://github.com/puppetlabs/puppetlabs-stdlib/tree/master/spec/functions > > Hope that helps. > > - henrik > -- Notice: This email is confidential and may contain copyright material of Ocado Limited (the "Company"). Opinions and views expressed in this message may not necessarily reflect the opinions and views of the Company. If you are not the intended recipient, please notify us immediately and delete all copies of this message. Please note that it is your responsibility to scan this message for viruses. Company reg. no. 3875000. Ocado Limited Titan Court 3 Bishops Square Hatfield Business Park Hatfield Herts AL10 9NE -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/a764cd4c-7c81-4c4c-859e-289ebf16b46f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.