Commit Graph

18 Commits

Author SHA1 Message Date
Ilya Margolin e474433342 fix tests for rspec-2.11.0 2012-08-09 09:51:47 +10:00
Tim Sharpe 79afb02139 I'm not even going to worry about 0.25.x support for now 2012-04-07 12:54:30 -07:00
Tim Sharpe 1ef8c26388 Remove a couple of parameterised class tests for 0.25.x 2012-04-06 15:05:49 -07:00
Tim Sharpe a1b5ebe25d Add support for testing the catalogue for a defined host 2012-02-15 16:33:48 +11:00
Tim Sharpe a3fff45164 Organise fixtures into modules/ & manifests/ 2012-02-15 16:27:46 +11:00
Jeff McCune 782520d601 Merge pull request #18 from bodepd/with_without_methods
Adds with/without methods
2011-12-30 13:33:59 -08:00
Dan Bode 4588a91049 Add 'without' method
Adds a method 'without' which accepts a list of
parameters that should not be defined in the resource.

Example:

  it { should contain_service('keystone').without(
    ['restart', 'status']
  )}
2011-12-29 19:51:33 -08:00
Dan Bode 4184c54118 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

Example:

  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.
2011-12-29 15:37:24 -08:00
Jeff McCune 3b34a50f3b 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/)
      end
    end

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
2011-12-29 14:55:40 -08:00
Tim Sharpe 81257c7f4e Document function testing 2011-11-01 21:03:35 +13:00
Tim Sharpe 7310eecb76 WIP 2011-11-01 15:51:03 +11:00
Tim Sharpe ac695d6043 Add support for testing undefined resource parameters
Closes #13
2011-08-29 14:18:22 +12:00
Dan Bode 0888e0e4f4 Support non-string types as param values
Previously boolean, hash, and array param
values were not supported for defined or classes.

Now, we are using inspect instead of to_s so they
will be returned as the correct reprentation of
their type to Puppet.

Reviewed-by: Matthaus Litteken <matthaus@puppetlabs.com>
Signed-off-by: Dan Bode <dan@puppetlabs.com>
2011-08-03 08:54:37 -07:00
Matthaus Litteken 7d46c1e999 Quote class name
In case it contains non-alpha-numerics.

Previously, you could not specify classes with
namespaces like: foo::bar

Reviewed-by: Dan Bode <dan@puppetlabs.com>
Signed-off-by: Matthaus Litteken <matthaus@puppetlabs.com>
2011-08-03 08:54:37 -07:00
Matthaus Litteken 7a8c7e9c24 Add pre_condition
Allows you to specify external dependencies
for classes/defines.

Reviewed-by: Dan Bode <dan@puppetlabs.com>
Signed-off-by: Matthaus Litteken <matthaus@puppetlabs.com>
2011-08-02 17:42:11 -07:00
Tim Sharpe df94c1b7b6 Allow contain_<type> along with create_<type> 2011-07-21 07:23:44 +10:00
Tim Sharpe ae27b394a6 Plurals are good 2011-07-19 12:19:09 +10:00
Tim Sharpe 5704939cd3 Add some real basic test cases 2011-07-19 09:54:17 +10:00