Skip to content


Fix puppet 3 issue with multiple classes and functions by moving re-initing puppet each catalog compile #61

wants to merge 1 commit into from

3 participants


This fixes the issue described in #60 and #58 for me. It passes tests on puppet 3 also.

I'm positive there is a better way to re-initialize the puppet engine, however, I tried calling various clear methods before settling on this with no positive results.


This doesn't work for me, because Puppet includes a check that raises an exception if this is called more than once:


What version of puppet? I've been using the version here for some time locally with no issues. 3.0.1 here.


@jmslagle Look at the related issues (#60 and #58), which are caused by a known Puppet bug. You can work around by making 1 spec per class or something like that. That is how I am getting around it.

But I just wanted to note that this pull request could just never work.


Oh sorry, thought you were someone different. If you look at the source code of Puppet no matter what it hits that line and raises an exception. I have no idea how yours is working.

@jmslagle jmslagle closed this

The fix to puppet seems to address this, however it raises the multiple init thing reported above. rspec-puppet will need modified to no longer init.

@rodjek rodjek referenced this pull request from a commit
@rodjek Fix for Puppet > 3 && < 3.1
From @jmslagle's PR #61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 16, 2012
  1. @jmslagle
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 4 deletions.
  1. +0 −4 lib/rspec-puppet.rb
  2. +4 −0 lib/rspec-puppet/support.rb
4 lib/rspec-puppet.rb
@@ -6,10 +6,6 @@
require 'rspec-puppet/example'
require 'rspec-puppet/setup'
-if Integer(Puppet.version.split('.').first) >= 3
- Puppet.initialize_settings
RSpec.configure do |c|
c.add_setting :module_path, :default => '/etc/puppet/modules'
c.add_setting :manifest_dir, :default => nil
4 lib/rspec-puppet/support.rb
@@ -5,6 +5,10 @@ module Support
def build_catalog_without_cache(nodename, facts_val, code)
+ if Integer(Puppet.version.split('.').first) >= 3
+ Puppet.initialize_settings
+ end
Puppet[:code] = code
node_obj =
Something went wrong with that request. Please try again.