Mastodon Mastodon - Loathing RSpec and Puppet
 logo
  • Home 
  • Tags 
  • Blog posts 
  1. Home
  2. Blog posts
  3. Loathing RSpec and Puppet

Loathing RSpec and Puppet

Posted on June 28, 2016  (Last modified on July 11, 2024) • 1 min read • 135 words
Puppet   Solved   Testing  
Puppet   Solved   Testing  
Share via

On this page
    • $MODULE/Rakefile
    • $MODULE/.fixtures.yml
    • $MODULE/spec/spec_helper.rb
    • $MODULE/spec/classes/$MODULE_spec.rb
    • Final note

There are words for how much I hate RSpec (especially RSpec-Puppet), but they would be too harsh to write down.

So now that I don’t have to google the same shit over and over again, here’s what you have to do to get basic puppet module testing up and running (replace $MODULE with your module name, of course):

$MODULE/Rakefile  

require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'

$MODULE/.fixtures.yml  

fixtures:
  repositories:
    concat: git://github.com/puppetlabs/puppetlabs-concat.git
    # alternate method, for specifying refs
    stdlib:
      repo: git://github.com/puppetlabs/puppetlabs-stdlib.git
      ref:  1.0.0
  symlinks:
    # do _not_ forget this
    $MODULE: "#{source_dir}"

$MODULE/spec/spec_helper.rb  

require 'rubygems'
require 'puppetlabs_spec_helper/module_spec_helper'

$MODULE/spec/classes/$MODULE_spec.rb  

# see also http://rspec-puppet.com/
require 'spec_helper'

describe '$MODULE' do
  context 'default' do
    it {
      should contain_file('/etc/haproxy/haproxy.conf')
    }

    # or ...
    it do
      is_expected.to contain_file('/this/syntax/is/even/more/retarded')
    end
  end
end

Final note  

It’s “rake spec”, not “rake test”. Of course.

 Testing logstash configs with Docker
TeamCity LDAP authentication with JumpCloud 
On this page:
    • $MODULE/Rakefile
    • $MODULE/.fixtures.yml
    • $MODULE/spec/spec_helper.rb
    • $MODULE/spec/classes/$MODULE_spec.rb
    • Final note
In case you want to follow me

Here are some links. The further to the right, the less active.

           
(c) Axel Bock | Powered by Hinode.
Link copied to clipboard
Code copied to clipboard