0

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

JoeNyland
  • 280
  • 2
  • 22

1 Answers1

1

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.

Alex Harvey
  • 14,494
  • 5
  • 61
  • 97
  • He could also use puppet-check, which does this automatically and is being introduced at major companies and used by power users as a replacement for puppetlabs_spec_helper. Disclosure: I am the author. – Matthew Schuchard Jun 11 '16 at 12:28
  • It was my understanding that this was satisfied by the symlink here: https://github.com/MasterRoot24/puppet-cloudwatch/blob/develop/spec/fixtures/modules/cloudwatch/manifests Am I wrong? Is the code snippet ready to be copied verbatim, or do I need to change `source_dir` to something? – JoeNyland Jun 11 '16 at 13:16
  • I've just tried your suggestion and it still doesn't work - please see the update at the end of my question – JoeNyland Jun 11 '16 at 13:22
  • @MasterRoot24 I actually tested your code, so apparently your symlink didn't work. I'll send in a pull request. – Alex Harvey Jun 11 '16 at 14:02
  • I just raised a PR after fixing the tests. A few other changes were also required. – Alex Harvey Jun 11 '16 at 14:21
  • @AlexHarvey Thanks for the PR, I've just got round to looking at it and it all seems to make sense. Thanks for your help! – JoeNyland Jun 17 '16 at 11:28