Question

I am trying to test a custom_type using rspec-puppet.

Puppet Code

class vim::ubuntu::config {
  custom_multiple_files { 'line_numbers':
    ensure     => 'present',
    parent_dir => '/home',
    file_name  => '.vimrc',
    line       => 'set number';
  }
}

Rspec-puppet code

require 'spec_helper'

describe "vim::ubuntu::config" do
  it do
    should contain_custom_multiple_files('line_numbers').with({
      'ensure'     => 'present',
      'parent_dir' => '/home',
      'file_name'  => '.vimrc',
      'line'       => 'set number',
    })
  end
end

Result

2) vim::ubuntu::config
Failure/Error: })
Puppet::Error:
Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource
type custom_multiple_files at /etc/puppet/modules/vim/spec/fixtures/modules
/vim/manifests/ubuntu/config.pp:7 on node ...
# ./spec/classes/ubuntu_config_spec.rb:10

Puppet Version

puppet --version
3.4.3

Custom Module at Eclipse

enter image description here

Outcome

Rspec-puppet cannot find the custom type custom_multiple_files, while puppet is able to find and execute the custom type during a puppet run.

Was it helpful?

Solution

You'll need to have a copy of your module in your spec/fixtures/module folder. You can also use a symlink to add a reference from spec/fixtures/module to your custom_type_module.

Reference: https://github.com/rodjek/rspec-puppet/issues/84

OTHER TIPS

An example .fixtures.yml file inside the module's root directory:

---
fixtures:
  repositories:
    concat:
      repo: 'git://github.com/puppetlabs/puppetlabs-concat.git'
      ref:  '1.0.0'
    stdlib:
      repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
      ref:  '3.2.0'

  symlinks:
    keepalived: "#{source_dir}"

Be sure to include "require 'puppetlabs_spec_helper/rake_tasks'" in your Rakefile and adjust aforementioned paths/repos/module names.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top