Ask Your Question

how to test customize type use rspec-puppet

asked 2013-10-15 11:53:29 -0600

Andy Lu gravatar image

I want to know how to test customize type use rspec-puppet

such as I have this type "anchor" in init.pp

anchor { 'ntp::begin': before => Class[$ntp_classes] }

How could I test it? It always says Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type anchor.

And I also google this problem already it said this was a bug of puppet version 3.0 , but now I am in 3.3.1 it should fixed this bug already. Why I still have this problem...what should I do?

Anyone can help me?

edit retag flag offensive close merge delete


The same error message occurs when the manifest you want to test rely on types defines by external modules. I have the same issue for a personal module that is ...(more)

doc75 gravatar imagedoc75 ( 2013-10-20 15:42:38 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-10-15 14:05:05 -0600

GregLarkin gravatar image

updated 2013-10-15 18:22:25 -0600

I researched this more thoroughly again, due to lavaman's input (Thx!). I believe this issue describes the bug you are encountering:

There is a code diff in the comments ( or below) that you could try patching into your installation to see if that fixes the problem for you. Please report back here with further status when you can.

edit flag offensive delete link more


That link is just about getting types and providers available for use. There is a different mechanism to include other puppet modules for rspec testing that I'm not clear on either.

lavaman gravatar imagelavaman ( 2013-10-15 16:11:38 -0600 )edit

answered 2013-10-20 16:45:21 -0600

doc75 gravatar image

updated 2013-10-20 16:47:50 -0600

Here is the solution that solves my problem (cf. above comment).

Launch the following commands:

  • gem install puppetlabs_spec_helper (or better, use a Gemfile and bundler to manage automatically all dependancies)
  • rspec-puppet-init

Then create the file .fixtures.yml in the root directory of your module with the following content (not tested and replace mymodule with your module name):

    stdlib: ""
    mymodule: "#{source_dir}"

Then create the file Rakefile in the root directory of your module with the following content:

require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint'

At this point, when you run rake spec, it will ... (more)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-10-15 11:53:29 -0600

Seen: 1,195 times

Last updated: Oct 20 '13