Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODULES-1202 - add module_spec_helper support for 3.6 config items #70

Merged
merged 2 commits into from
Jul 9, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,33 @@ NOTE that this is specifically for initializing Puppet's core. If your project
not have any dependencies on puppet and you just want to use the utility classes,
see the next section.

To enable strict-variable or future-parser rspec-puppet failures export the
`STRICT_VARIABLES=yes` and/or `FUTURE_PARSER=yes` environment variables. Eg:

FUTURE_PARSER=yes STRICT_VARIABLES=yes rake spec

A number of the Puppet parser features, controlled via configuration during a
normal puppet run, can be controlled by exporting specific environment
variables for the spec run. These are:

* ``FUTURE_PARSER`` - set to "yes" to enable the [future parser](http://docs.puppetlabs.com/puppet/latest/reference/experiments_future.html),
the equivalent of setting [parser=future](http://docs.puppetlabs.com/references/latest/configuration.html#parser)
in puppet.conf.
* ``STRICT_VARIABLES`` - set to "yes" to enable strict variable checking,
the equivalent of setting [strict_variables](http://docs.puppetlabs.com/references/latest/configuration.html#strictvariables)=true
in puppet.conf.
* ``ORDERING`` - set to the desired ordering method ("title-hash", "manifest", or "random")
to set the order of unrelated resources when applying a catalog. Leave unset for the default
behavior, currently "random". This is equivalent to setting [ordering](http://docs.puppetlabs.com/references/latest/configuration.html#ordering)
in puppet.conf.
* ``STRINGIFY_FACTS`` - set to "no" to enable [structured facts](http://docs.puppetlabs.com/facter/2.0/fact_overview.html#writing-structured-facts),
otherwise leave unset to retain the current default behavior. This is equivalent to setting
[stringify_facts=false](http://docs.puppetlabs.com/references/latest/configuration.html#stringifyfacts)
in puppet.conf.
* ``TRUSTED_NODE_DATA`` - set to "yes" to enable [the $facts hash and trusted node data](http://docs.puppetlabs.com/puppet/latest/reference/lang_facts_and_builtin_vars.html),
which enabled ``$facts`` and ``$trusted`` hashes. This is equivalent to setting
[trusted_node_data=true](http://docs.puppetlabs.com/references/latest/configuration.html#trustednodedata)
in puppet.conf.

As an example, to run spec tests with the future parser, strict variable checking,
and manifest ordering, you would:

FUTURE_PARSER=yes STRICT_VARIABLES=yes ORDERING=manifest rake spec

Using Utility Classes
=====================
Expand Down
6 changes: 6 additions & 0 deletions lib/puppetlabs_spec_helper/module_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ def verify_contents(subject, title, expected_lines)
## These depend on rspec-puppet #209 and #183 being released
#c.parser = 'future' if ENV['FUTURE_PARSER'] == 'yes'
#c.strict_variables = true if ENV['STRICT_VARIABLES'] == 'yes'
#c.stringify_facts = false if ENV['STRINGIFY_FACTS'] == 'no'
#c.trusted_node_data = true if ENV['TRUSTED_NODE_DATA'] == 'yes'
#c.ordering = ENV['ORDERING'] if ENV['ORDERING']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you could create similar PRs to rspec-puppet as #209 and comment here, that would be great. I'd rather maintain as little code in puppetlabs_spec_helper as possible if rspec-puppet makes better sense for it (which is pretty much true of all the code in PSH, but that's the eventual goal).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh hey, I see rodjek/rspec-puppet#212 now :). So if you could just update the comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it looks like our comments crossed in the ajax-y ether...


c.before :each do
Puppet.settings[:strict_variables] = true if ENV['STRICT_VARIABLES'] == 'yes'
Puppet.settings[:parser] = 'future' if ENV['FUTURE_PARSER'] == 'yes'
Puppet.settings[:stringify_facts] = false if ENV['STRINGIFY_FACTS'] == 'no'
Puppet.settings[:trusted_node_data] = true if ENV['TRUSTED_NODE_DATA'] == 'yes'
Puppet.settings[:ordering] = ENV['ORDERING'] if ENV['ORDERING']
end
end