Search code examples
puppetrspec-puppet

Why does rspec-puppet not find my class?


I've created a Puppet module to install AWS Cloudwatch monitoring scripts and set them up. The Puppet module is available here.

When I run rake spec, my test suite fails with:

rspec ./spec/classes/init_spec.rb:4 # cloudwatch with default values for all parameters should contain Class[cloudwatch]

I cannot for the life of me work out why this test is failing. How do I fix it?

I've tried creating a .fixtures/yml in the root of the repo with the following content:

fixtures:
  symlinks:
    cloudwatch: "../../../../manifests"

fixtures:
  symlinks:
    cloudwatch: "#{source_dir}"

But no dice.

I've also tried using a symlink to link to the manifests directory: https://github.com/MasterRoot24/puppet-cloudwatch/commit/932970aab085984f2cda44fba841c3bde20f7a2b


Solution

  • Your initial problem is you're missing the .fixtures.yml file, which needs the following content:

    fixtures:
      symlinks:
        cloudwatch: "#{source_dir}"
    

    as documented in the puppetlabs_spec_helper README.

    Additional changes were required to get the test to pass as can be seen in the PR I just raised here.

    Responding to your edited question, which discusses a fixtures file that wasn't in the code you linked, I don't think your fixtures is syntactically valid; I don't believe you can specify more than one fixtures block. Anyway, have a look at my PR.