Issue #15529 has been updated by Josh Cooper.

Note: if we decide adding a TestHelper.initialize method is what we want, then 
we will also need to update puppet_spec_helper to call it. And 
puppet_spec_helper will need to take into account the initialize method may not 
exist (in 3.0.0/1).
----------------------------------------
Bug #15529: Puppet settings should be initialized prior to running any tests 
and reinitialized before each test
https://projects.puppetlabs.com/issues/15529#change-78824

Author: Dominic Cleal
Status: In Topic Branch Pending Review
Priority: Normal
Assignee: 
Category: 
Target version: 3.1.0
Affected Puppet version: 3.0.0
Keywords: puppetlabs_spec_helper autoload modules
Branch: https://github.com/puppetlabs/puppet/pull/1332


Testing modules with Puppet 3 is broken in two ways:

1. Puppet's settings are not initialized prior to the module's specs start.
1. Puppet's TestHelper clears app_default_settings after each test, but never 
reinitialized prior to running the second, third, etc test.

Whenever app_default settings are not initialized, the Autoloader will not be 
able to load code from the module, such as when a module's type/provider 
requires utility code from the module, or another module.

Users have run into this in a variety of ways:

<https://github.com/rodjek/rspec-puppet/pull/41#issuecomment-8023987><br>
<https://github.com/rodjek/rspec-puppet/pull/61><br>
<https://github.com/rodjek/rspec-puppet/issues/60><br>
<https://github.com/rodjek/rspec-puppet/issues/58><br>

The TestHelper should ensure that settings are in a consistent state so that 
module authors don't need to.

This is true for puppet itself, since attempting to load a face prior to 
settings being initiallized, e.g. executing `Puppet::Interface.faces.each { 
|name| puts name }` as the first and only spec will fail, since settings are 
never initialized.
 
----

Original description: 

I'm trying to create a module (domcleal/augeasproviders) containing a provider 
for a type supplied by a second module (puppetlabs/mount_providers).  When the 
mount_providers module is installed locally via `puppet module`, this isn't 
added into RUBYLIB while running specs.  This causes references to 
Puppet::Type.type(:mounttab) from within the spec to return nil.

It appears that the branch in the autoloader checking 
`Puppet.settings.app_defaults_initialized?` (line 136 in master) is returning 
false and so perhaps some further initialisation of Puppet is required?


-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to