All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
- Fixed a bug that prevented the platform pretending/stubbing logic from being temporarily disabled when loading Ruby code.
- Official Puppet 6 support added.
- When testing resource parameter values, the values received from Puppet are now reencoded before testing to ensure that the line endings (if present) match the platform being tested.
basemodulepathsettings (introduced in Puppet 6) are now configurable in rspec-puppet.
- Added a Puppet 6.x adapter so that rspec-puppet does not try to set removed
Puppet settings (specifically
trusted_server_facts) when running tests against the upcoming Puppet 6.0.0 release.
- If present,
Win32::Dirwill be used to managed the fixtures directory junction on Windows as the builtin
Filemodule does not have complete support for directory junctions on Ruby <= 2.1.
- Resource coverage results are now exposed to the configured RSpec reporter rather than only being printed to STDOUT.
- If running with parallel_tests, resource coverage data is stored in per-process temp files and merged at the end of the final rspec process, allowing for a complete coverage report to be generated when splitting a test suite across multiple rspec processes.
- rspec-puppet no longer attempts to set the
trusted_server_factsPuppet setting on Puppet 4.0.0, as the setting was only introduced in Puppet 4.1.0.
Selinuxstubbing introduced in 2.6.12 no longer assumes the use of rspec-mocks. If rspec-mocks is not available, it will fall back to mocha and finally fall back to doing nothing if neither is available.
Win32::TaskSchedulerstubs to match the latest release of
osstructured fact is now correctly treated as a Hash when determining the platform that rspec-puppet pretends to be.
- The default resources that Puppet adds to the catalogue (
Class[Settings], etc) are now filtered out of the catalogue when using the
have_resource_countmatcher, rather than simply subtracted from the resource count. This allows the
have_resource_countmatcher to be used on subsects of the catalogue (
- When running on Windows, rspec-puppet will now convert Puppet configuration
NUL, preventing Puppet from automatically creating directories like
C:\devwhen running tests on Windows as an Administrator.
- When overriding fact values, rspec-puppet will now assign the stub facts a weight of 1000 to ensure that they override the generated fact values from Facter 3.x.
Selinux.is_selinux_enabledis now automatically stubbed to return 0 to disable any SELinux related apply-time validation of resources.
- When testing against Puppet 3.x, rspec-puppet will now honour the
RSpec.configuration.parservalue when determining the module name to set up the fixture symlink.
- When testing for the absence of a parameter using
only_with(:parameter_name => nil), this will no longer incorrectly affect the expected parameter count.
server_factshash is now only built if
true. Previously, this was always built but only used when enabled.
- Replaced deprecated
File.exist?, which behaves much more reliably in respect to symlinks.
- Stubbed out
Puppet::Util::Windows::Security.supports_acl?when compiling the catalogue as this check only make sense when applying the resources to a host and prevents testing Windows File resources on non-Windows hosts.
- The cached default provider for native types is now reset before compiling a new catalogue.
- Resource titles that contain single quotes are now rendered correctly, allowing them to be tested.
- When pretending to be a different platform, the methods in
Puppet::Util::Platformare now stubbed after the catalogue has been compiled, allowing path related logic in custom facts to behave as expected.
- A mock version of
Win32::TaskSchedulerhas been added to rspec-puppet. This will be loaded when running rspec-puppet on a non-Windows host in order to allow testing of catalogues containing Scheduled_task resources.
- Stubbed out the
Puppet::Type::File::ProviderWindowsas this can only be evaluated at apply time and prevents testing Windows File resources that manage symlinks on non-Windows hosts.
- Fixed unhandled exception when testing resource parameters where the expected value is an Array or a Hash and the actual value is a different data type.
- A mock version of
Win32::Registryhas been added to rspec-puppet. This will be loaded when running rspec-puppet on a non-Windows host in order to allow testing of catalogues that contain Exec resources that use the
powershellprovider from the
- Fixed a case where the order in which tests are run can cause a resource that is being tested to be falsely reported as untested in the coverage report.
- The tests for the
compilematcher have been updated to support the new error message format introduced in Puppet 5.3.4.
- The builtin
$server_factshash is now populated on versions of Puppet that support it (Puppet >= 4.3). This is not currently enabled by default, but can be enabled by setting
$facts['os']['name']are now checked when determining if rspec-puppet needs to pretend to be running on a different platform (previously only
- Initialise Hiera 3 before loading any monkey patches to ensure that the correct code is loaded for the actual platform running the tests.
- Performance regression with Puppet < 4.0.0 due to overly agressive cache invalidation.
- Clarified rspec-puppet-init output when run inside a directory that does not
- An issue where the optional minimum resource coverage check would throw an exception when the coverage wasn't 100%.
- Fixed an issue caused by
Puppet::Util.get_envwhen pretending to be a Windows host.
derive_node_facts_from_nodenamesetting added to disable the overriding of
domainfacts with values derived from the node name specified with
trusted_factshash now accepts symbol keys, matching the behaviour of the
- The modifications made to Puppet internals are now contained to rspec-puppet examples, preventing them from bleeding out into other examples in the same RSpec process (like Ruby unit tests).
- rspec-puppet no longer attempts to configure settings for Puppet 3.x releases that they do not support.
- A regression that prevented environment names to be specified as a symbol.
- A regression that prevented the
environmentpathsetting from taking effect.
- Stubbed out the automatic confines created by resource providers on their specified commands, which was preventing the correct provider from being assigned to a resource when performing cross-platform testing.
- Facts derived from the node name now only get merged on top of the facts
let(:facts)if the node name has been manually specified with
- Puppet 5.0.x added to the CI test matrices.
- The automatic setup code now checks for the presence of
metadata.jsonin the working directory. If not present, it assumes that rspec-puppet is running from inside a control repo instead of a module and skips creating the
spec/fixturesdirectory structure and link.
- A new configuration option has been added
RSpec.configuration.setup_fixtures) that controls whether rspec-puppet will manage the
- A race condition when running rspec-puppet under parallel_tests causing
errors when creating the
- The contents of the
networkingfact hash is no longer cleared when merging in the facts derived from the node name.
- 2.6.0 introduced a change to how resource titles are rendered in the test
manifest which caused them to get rendered as double quoted strings. This
caused a failure for tests of defined types that contained
$characters as Puppet would try and interpolate the values in the title as variable(s).
The Windows parity release. rspec-puppet now officially supports Windows. A lot of work has been put in to support cross-platform tests, so that you can now test your Windows manifests on *nix, and your *nix manifests on Windows.
- Puppet settings are now applied as application overrides, allowing users to
Puppet.settingsdirectly to make changes to settings without them getting clobbered by rspec-puppet.
- Improved support for setting up the
spec/fixtures/moduleslink on Windows by using directory junctions instead of symlinks, removing the need for Administrator access.
- When testing for the absence of a parameter on a resource, the error message now contains the value(s) of the parameter(s) that should be undefined.
- When testing a defined type, the defined type being tested is no longer part of the coverage report.
- The cached catalogue will now be invalidated when hiera-puppet-helper users
- Multiple instances of a defined type can now be tested at once by providing
an array of strings with
- Explicitly specifying the type of an example group (
:type => :class) now takes precedence over the type inferred from the spec file's location.
- The manifest specified in
site.ppfor Puppet < 4.x) is now imported if specified on Puppet >= 4.x.
- Puppet functions called when testing a Puppet function now get executed in the same scope as parent function.
- The module is now automatically linked into
spec/fixtures/modulesat the start of the rspec-puppet run.
- CI testing of PRs on Windows via Appveyor.
- Support for setting node parameters (mocking the behaviour of an ENC or
Puppet Enterprise Console) using
- Support for injecting Puppet code at the end of the test code using
- Resource coverage reports for
- Puppet functions that take a lambda as a parameter can now be tested by
- Facts and trusted facts are now available when testing Puppet functions.
- Hiera configuration can now be specified when testing Puppet functions using
- Trusted facts (
$trusted) can now be specified in
:defaultis now a supported parameter value when passed in by
- Support for testing Puppet data type aliases.
- Facts generated from the node name (as set by
let(:node)) now take precedence over the values specified in
- Only fact names will now be converted to lowercase, not the fact values.
- Matchers now support resources where the namevar has a different value to the title.
- Resources created outside of the module being tested by functions like
ensure_packageare no longer present in the coverage report from Puppet 4.6 onwards.
- Guards have been put in place to prevent the possibility of rspec-puppet getting stuck in an infinite recursion when testing the relationships between resources.
- A full
spec/spec_helper.rbfile is now written out by
rspec-puppet-initto fix the
fixture_pathissue on new modules.
- The namevar of a resources is no longer taken into account when testing the
exact parameters of the resource with
- Minimum resource coverage check for RSpec <= 3.2.
- Resource parameters that take a hash as their value will no longer have that hash converted into an array.
- Testing the value of a parameter with a Proc that returns
nilnow works as expected.
- When testing Puppet functions, the function name is no longer automatically coverted to lowercase.
- The value of
$::environmentis now forced to be a string as expected for Puppet 4.0 - 4.3.
- app_management is no longer enabled by rspec-puppet for Puppet >= 5.0 as it is already enabled by default.
- Failing to provide parameters when testing an application now raises the
correct exception (
- Ruby symbols in nested hashes or arrays are now converted into strings when
passed in by
- Namespaced resources are now correctly capitalised when being added to the resource coverage filter.
Headline features are app management, nested hashes in params, and testing for "internal" functions.
Thanks to everyone who contributed: Leo Arnold, Matt Schuchard, and Si Wilkins
- Updates to the README
- Improve Gemfile to work with older rubies
- Add support for app management testing
- Enable nested hashes in params
- After refactoring the function test code, puppet 4 "internal" functions can now be tested too
- Link functions and types on setup
- Increased test coverage
This release now supports testing exported resources in the same way that normal resources in the catalog are tested. Access them in your examples using
exported_resources. See "Testing Exported Resources" in the README for examples.
- This release pulls out much of the version-specific code into separate classes to reduce complexity and enable easier maintenance going forward.
- Support colon-separated module_path and environmentpath values.
- Support a threshold for the code coverage test, that can fail the whole run.
- Ensure a consistent environment for all examples by adding a forced initialization of puppet before each.
Thanks to Adrien Thebo, Arthur Gautier, Brett Gray, and Nicholas Hinds, as well as all the folks helping out on github for their contributions to this release.
Properly fix yesterday's issue by unsharing the cache key before passing the data to puppet. This also contains a new test matrix to avoid missing a half-baked fix like yesterday.
A quick workaround to re-enable testing with the recently released puppet 3.8.5 and the soon to be released puppet 4.3.2. See PUP-5743 for the gritty details. Upgrade to this version if you hit the "undefined method `resource' for nil:NilClass" error.
Rspec-puppet now supports testing custom types,
:undef values in params, structured facts, and checks resource dependencies recursively.
The settings in
manifest are now respected throughout the code base. The former default for
'/etc/puppet/modules') was dropped to avoid accidentally poisoning the test environment with unrelated code.
To reduce the maintenance overhead of boilerplate code, rspec-puppet now provides some of the code that rspec-puppet-init deployed in helper files that you can just
This release also reduces memory usage on bigger testsuites drastically by reducing the caching of compiled catalogs.
- Limit the catalogue cache to 16 entries. Significant memory savings and reduced runtime were observed in testing this.
- Prevent Puppet 3's _timestamp fact from invalidating cache.
- Extracted catalog cache from RSpec::Puppet::Support.
- Updated README to use the rspec 3 syntax, and additional explanations.
contain_file(...).with_content(...)will now only show the diff and not the full contents of the file.
- Custom type testing example group and matcher.
- before/require/subscribe/notify checking now searches recursively through all dependencies.
File[a] -> File[b] -> File[c]is now matched by
contain_file('a').that_comes_before('File[c]'), whereas earlier versions would have missed that.
:undefto pass a literal undef value through to the subject.
- Support structured facts with keys as symbols or strings (#295).
- rspec-puppet-init now creates smaller files, using rspec-puppet helpers, instead of pasting code into the module.
- Added a list of related projects to the README.
- Fix #276:
compile.and_raise_errornow correctly considers successful compilation an error
modulepathcan now contain multiple entries and rspec-puppet will configure puppet to load code from all of them
- Support running with rspec 2.99 again
- non-class resources are now covered by the coverage code
- Fix #323/MODULES-2374: autorequires checking doesn't abort on "undefined method `' for nil:NilClass"
- improved documentation for hiera integration, added example spec
- document the
Thanks to Adrien Thebo, Alex Harvey, Brian, Dan Bode, Dominic Cleal, Javier Palacios, Jeff McCune, Jordan Moldow, Peter van Zetten, Raphaël Pinson, Simon Kohlmeyer, and Tristan Colgate for their contributions to this release.
-- David Schmitt
- Settings for ordering, strict_variables, stringify_facts, and trusted_node_data
- Expose the scope in function example groups
- rspec-puppet-init now works with Puppet 4
- Several fixes and enhancements for the
- Recompile the catalog when the hiera config changes
2.1.0 - 2015-04-21
- Puppet 4 support
- Ability to set
environmentin a let block
- Better function failure messages
- Filter fixtures from coverage reports
- Fix functions accidentally modifying rspec function arguments
- Restructured TravisCI matrix (NB: Puppet 2.6 is no longer tested)
2.0.1 - 2015-03-12
- Allow RSpec 2 to still be used
2.0.0 - 2014-12-02
subjectis now a lambda to enable catching compilation failures.
- Ability to use RSpec 3
- Hiera integration
- Coverage reports
- Ability to test on the future parser
- Function tests now have a catalogue
- Add array of references support to Relationship matchers
- Better error messaging and handling for parameters (
niland friends) and dependency cycles
1.0.1 and earlier
For changelog of versions 1.0.1 and earlier, see http://rspec-puppet.com/changelog/