Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
Commits on Aug 07, 2011
@rodjek Remove quotes from resource refs to match puppetlabs style 3e2b4ce
Commits on Aug 11, 2011
@rodjek Update README to suggest contain_ over create_ d13bee6
@bodepd bodepd Remove Faces API call.
Previously, used the catalog face for
compilation with the :use_node option.

Starting in 2.7.2rc2, all faces options
must be explicit, so the catalog face
no longer supports the use_node option.

This commit changes the call to use
the indirection directly.
@bodepd bodepd Merge branch 'puppetlabs-master' 1cbaf48
@rodjek Merge pull request #11 from puppetlabs/master
fixes 2.7 support
@rodjek Bump to 0.0.6 77307cb
@rodjek Prettify README with some syntax highlighting 20cfb2d
Commits on Aug 29, 2011
@rodjek Add support for testing undefined resource parameters
Closes #13
@rodjek Bump to 0.0.7 c2fd88f
@rodjek munge symbol fact names to strings 26920e9
@rodjek Bump to 0.0.8 6026434
Commits on Aug 31, 2011
@athak athak Add support for additional puppet settings 0820a4f
Commits on Sep 16, 2011
@rodjek default manifest_dir, manifest & template_dir to nil 37906c4
@rodjek automatically set domain fact 1cd3bb9
@rodjek Bump to 0.0.9 cdd0bcb
Commits on Nov 01, 2011
@rodjek Initial function testing mock up 89ac6b8
@rodjek Move manifest matchers into ManifestMatchers module b757ad1
@rodjek WIP 7310eec
@rodjek Document function testing 81257c7
@rodjek Missing an end in an example bb9f233
@rodjek Double plural eb50b75
@rodjek Add new files to gemspec dd259e6
@rodjek Munge libdir to autoload module plugins without pluginsync 7f7e74f
@rodjek Don't hardcode path separator bf2be94
Commits on Nov 03, 2011
@rodjek Better failure messages for the run matcher aefb870
@rodjek Bump to 0.1.0 c73f8ce
Commits on Dec 06, 2011
@jeffmccune jeffmccune Fix rspec dependency
Without this patch, working with rspec-puppet in IRB fails when directly
requiring the library:

    ruby-1.8.7-p334 :001 > require 'rspec-puppet'
    NameError: uninitialized constant RSpec
        from /Users/jeff/.rvm/gems/ruby-1.8.7-p334@puppet/gems/rspec-puppet-0.1.0/lib/rspec-puppet/matchers/create_generic.rb:1
        from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
        from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
        from /Users/jeff/.rvm/gems/ruby-1.8.7-p334@puppet/gems/rspec-puppet-0.1.0/lib/rspec-puppet/matchers.rb:1
        from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
        from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
        from /Users/jeff/.rvm/gems/ruby-1.8.7-p334@puppet/gems/rspec-puppet-0.1.0/lib/rspec-puppet.rb:2
        from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:58:in `gem_original_require'
        from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:58:in `require'
        from (irb):1

This patch fixes the problem by requiring rspec directly from rspec-puppet.rb
Commits on Dec 29, 2011
@jeffmccune jeffmccune Add Regexp support to with_* matchers and improve error messages
Without this patch it is difficult to match portions of long strings
which are attribute values of resource parameters.  For example, the
content parameter of a file resource with a multi-line template.

This patch makes it easier to match portions of the parameter's value by
passing a Regexp instance to the with_ catch all matcher.

The use case looks like:

    describe 'with lsbmajdistrelease available' do
      let(:facts) { @facter_facts.merge({'lsbmajdistrelease' => '6'}) }
      it { should_not contain_file('puppetenterprise.repo').with_content(missing_content) }
      it { should contain_package 'pe-ruby-devel' }
      it do
        should contain_file('puppetenterprise.repo').with_content(/baseurl=http/)
        should contain_file('puppetenterprise.repo').with_content(/pe_base/)
        should contain_file('puppetenterprise.repo').with_content(/pe_updates/)
        should contain_file('puppetenterprise.repo').with_content(/pe_extras/)

This feature allows the same parameter to be matched multiple times using
multiple different regular expressions.

This patch also improves the error message by presenting the actual value in
the catalog when it does not match the expectation.  This change applies to
both String and Regexp expectation matches.

The error output now looks like:

    1) pe_devel on redhat el6 os families with lsbmajdistrelease available
       Failure/Error: should contain_file('puppetenterprise.repo').with_content(/JEFF MCCUNE/)
         expected that the catalogue would contain File[puppetenterprise.repo] with content \
         matching `/JEFF MCCUNE/` but its value of `"# KERMIT FROG\n"` does not

Spec tests have been added to exercise the handling of Regexp instances.

Reviewed-by: Dan Bode
@bodepd bodepd Add Rake task 'spec'
Adds the Rake task 'spec' for consistency
with other Rakefiles in Puppet related projects.
@jeffmccune jeffmccune Merge pull request #17 from jeffmccune/feature/master/improve_matcher…

Add Regexp support to with_* matchers and improve error messages
@jeffmccune jeffmccune Merge pull request #16 from jeffmccune/bug/master/fix_rspec_requirement
Fix rspec dependency
@bodepd bodepd Add with method to generic matcher
This commit adds a method 'with' that can be used
to test mulitple parameters/values with a single
method call


  it do should contain_service('keystone').with(
    'ensure'     => 'running',
    'enable'     => 'true',
    'hasstatus'  => 'true',
    'hasrestart' => 'true'
  ) end

It was created as a more condensed alternative to
chaining methods per parameter to validate.
Commits on Dec 30, 2011
@bodepd bodepd Add 'without' method
Adds a method 'without' which accepts a list of
parameters that should not be defined in the resource.


  it { should contain_service('keystone').without(
    ['restart', 'status']
@jeffmccune jeffmccune Merge pull request #18 from bodepd/with_without_methods
Adds with/without methods
Commits on Jan 20, 2012
@rodjek bump to 0.1.1 d102ebe
Commits on Feb 15, 2012
@rodjek Organise fixtures into modules/ & manifests/ a3fff45
@rodjek Add support for testing the catalogue for a defined host a1b5ebe
Commits on Feb 16, 2012
@nanliu nanliu Add Puppet[:config] as a supported option. cbc3a77
Commits on Mar 12, 2012
@rodjek Add helper script to configure a module for rspec-puppet testing 4300f25
@rodjek Merge pull request #21 from nanliu/tb/config
Add Puppet[:config] as a supported option.
Commits on Apr 05, 2012
@rodjek Friendlier descriptions for contain_ matcher 130aec5
@rodjek Have Travis-ci test rspec-puppet automatically cf7100f
Commits on Apr 06, 2012
@rodjek Have travis build 1.9 398fc77
@rodjek Puppet 2.7 under 1.9.x converts all array members to strings
This hack should keep things working the same under 1.8 and 1.9
@rodjek String#to_a doesn't work under 1.9 eea6dd5
@rodjek Remove a couple of parameterised class tests for 0.25.x 1ef8c26
Commits on Apr 07, 2012
@rodjek Not sure where the second .. came from 1034302
@rodjek I'm not even going to worry about 0.25.x support for now 79afb02
@rodjek Bump to 0.1.3 eed11c7
Commits on Jul 31, 2012
@fungusakafungus fungusakafungus Cache the result of build_catalog 4ae3e45
Commits on Aug 02, 2012
@bodepd bodepd Add support for pre_condition with functions
This commit adds support for using the pre_condition
hook to specify the source code that should be used to
compile a catalog that can be introspected by functions for
testing purposes.

This allows users to test functions that need access to
catalog contents.

This allows the following snippet to test a function that
needs access to the catalog generated by pre_condition:

  describe 'defined_with_params' do
    #describe 'when resource is passed as a string' do
    let :pre_condition do
      'user { "dan": }'
    it { should run.with_params('User[dan]', {}).and_return('true') }
Commits on Aug 03, 2012
@fungusakafungus fungusakafungus fix regression, Puppet[:code] should be part of cache key 0bc21c7
Commits on Aug 08, 2012
@rodjek Merge pull request #36 from bodepd/pre_condition_catalogs_function_te…

Add support for pre_condition with functions
@fungusakafungus fungusakafungus fix tests for rspec-2.11.0 e474433
Commits on Aug 09, 2012
@rodjek Merge branch 'memoize-build-catalog' of…
…c-puppet into Jimdo-memoize-build-catalog
@rodjek Fix bug with optional arrays in the matcher
When a type parameter takes an array with a single value, the compiled version
only has the single value not as an array.
@rodjek Bump to 0.1.4 8d4c964
Commits on Aug 14, 2012
@jeffmccune jeffmccune Use puppetlabs_spec_helper to test parser functions
Without this patch applied rspec-puppet reaches deep inside of Puppet
and uses an unsupported and private interface to obtain functions and
scope instances.  This is a problem because Puppet Labs considers
internal classes such as Puppet::Parser::Scope as private and internal.

We change these classes without warning and this is a maintenance issue
for third party testing tools.

This patch fixes this maintenance problem by using the compatibility
layer implemented in the puppetlabs_spec_helper.  When we change the
internal behavior of private classes such as Puppet::Parser::Scope,
we'll update the spec helper module methods to provide a version
agnostic way to get instances of these internal objects.

As an example, a supported way to get a scope instance is:


Instead of the private and unsupported method of:

This patch introduces a Gem dependency onto the puppetlabs_spec_helper
Commits on Aug 15, 2012
@jeffmccune jeffmccune Merge pull request #39 from jeffmccune/fix/master/clean_function_testing
Use puppetlabs_spec_helper to test parser functions
Commits on Sep 04, 2012
@maxlinc maxlinc obj_name is a symbol c3c62f1
Commits on Sep 05, 2012
Byron Appelt parameterize confdir 9a40d5d
Commits on Oct 02, 2012
@rodjek Preliminary Puppet 3.0 support 60ec4ae
@rodjek Merge pull request #55 from rodjek/3.0
Preliminary Puppet 3.0 support
@rodjek Fix function testing tests under < 3.0 17054d4
@rodjek Update Puppet versions to test against c80924c
@rodjek expand_path e699141
Commits on Oct 03, 2012
@rodjek Update travis config 48dd151
@rodjek 0.1.5 release 695b9a4
Commits on Oct 04, 2012
Byron Appelt Merge remote branch 'upstream/master' into parameterize_confdir b274047
Commits on Nov 16, 2012
@agx agx Allow to set up pre conditions from an array
This improves readability on complex pre conditions and makes sure we
don't forget any newlines that cause weird and hard to debug syntax
errors (#62).
Commits on Nov 17, 2012
@rodjek Merge pull request #63 from agx/issue/62
Allow to set up pre conditions from an array
@rodjek Merge pull request #53 from maxlinc/master
failure_message_for_should - object name is a symbol
Commits on Dec 14, 2012
Sven Mueller Add a new matcher to check that all relationship can be fulfilled. In
other words: That any resource referenced to by a require, subscribe,
before or notify is defined somewhere in the catalogue.
Commits on Jan 18, 2013
@dcarley dcarley (#57) Support values for without_
Parity to `with_` rather than always assuming undefined.
Commits on Jan 20, 2013
@willaerk willaerk Add trivial puppet module and tests to verify param escaping 01e315b
@willaerk willaerk Add escaping for $ to class and define examples 573598c
Commits on Jan 24, 2013
@rodjek Fix for Puppet > 3 && < 3.1
From @jmslagle's PR #61
@rodjek Add puppetlabs_spec_helper as a dependency
Closes #56
@rodjek Stub out facts properly
Closes #28
@rodjek Noope d042310
@rodjek 0.1.6 a086d05
Commits on Jan 29, 2013
@willaerk willaerk Add tests to assert number of classes and resources 68fdb6b
@willaerk willaerk Generic class for counting resources and classes 4110bfd
@willaerk willaerk Factor out dynamic matchers and include count matchers fda613f
@willaerk willaerk Update gemspec 32f9c47
@willaerk willaerk Update README with new matchers 5f6e140
@willaerk willaerk Update gemspec 8061e69
Commits on Jan 30, 2013
@willaerk willaerk Different handling of .to_s method in ruby 1.9 for one-element array dd64761
Commits on Feb 08, 2013
Jeremy Norris function fixes: implement @expected_error and fix double invocation f…
…or unexpected returns.
Commits on Feb 11, 2013
@willaerk willaerk Add some tests to assert an exact set of resource parameters f22e412
@willaerk willaerk Extend 'with' chain to check the number of resource parameters d2c2d81
@willaerk willaerk Update README with extra matchers 5b867aa
Commits on Feb 23, 2013
@rodjek Make manifest matchers available to function tests 2fe7de1
@rodjek Merge branch 'limit_parameters' of…
…puppet into willaerk-limit_parameters
@rodjek Merge branch 'master' of
…into jeremynorris-master
@rodjek Merge pull request #75 from willaerk/have_resource_count
Asserting an exact number of classes or resources
@agx agx Allow to pass procs to with_ / without_
This allows for more complex checks on the resources content. E.g.  to
make sure the generated content doesn't contain string representations
of 'undef' or 'nil' or validates correctly against an XML schema.
@rodjek Fix up the formatting of the Proc error message 40ae655
Commits on Feb 24, 2013
@rodjek Support and_return(false) in the run matcher
Thanks to @jeffersongirao for the original patch (#64)
@rodjek Merge pull request #47 from bappelt/parameterize_confdir
parameterize confdir
@rodjek Merge pull request #70 from incase/include_all_deps
Add a new matcher to check that all relationship can be fulfilled.
@rodjek Merge pull request #72 from dcarley/without_values
(#57) Support values for without_
@rodjek Merge pull request #73 from willaerk/escape_special_chars
Escape dollar signs in parameter values
@rodjek Fix docs and specs for calling functions directly
When using to test functions, the arguments need to be passed
as a single Array.

Closes #27
@rodjek Remove the old create_resource(type, title) matcher 1d6ad04
@willaerk willaerk Typo's in the documentation for the resource_count matchers cc25710
@rodjek Merge pull request #82 from willaerk/master
Documentation fixes for the README
@rodjek Remove test that uses the create_resources matcher 220a798
@rodjek Refactor the includes_all_deps matcher a bit 6504f94
@rodjek Update Puppet build versions abaf61a
Commits on Feb 25, 2013
@rodjek Add "compile" matcher that checks for dep cycles
/cc #74 #30
@rodjek Have travis start building against 3.1.0 84bfa8a
Commits on Feb 26, 2013
@rodjek Boom 1f3b716
@rodjek Improved rake file for rspec-puppet-init
Closes #66
@rodjek Don't break on empty pre_condition
Closes #26
@rodjek Fix dependency cycle check for 2.6.x fd67e50
Commits on Apr 04, 2013
@rodjek Clean up bundler setup 5f3d2c5
@rodjek Remove dependency on puppetlabs_spec_helper
Over time dependencies on the puppetlabs_spec_helper gem have appeared in the
code. This normally wouldn't be much of an issue except for the fact that
puppetlabs_spec_helper also depends on rspec-puppet and this circular
dependency wreaks havoc on package managers.

I've extracted some useful logic from puppetlabs_spec_helper (like using
Puppet::Test::TestHelper where available) and refactored the function example
group to no longer need methods provided by it.

This commit leaves the code in a bit of a messy state, but general cleanup is
soon to come.

re #56
@rodjek Build all branches 0757fa8
@rodjek Merge branch 'master' into remove-puppetlabs-spec-helper 61cd2b6