Ask Your Question
1

how to test customize type use rspec-puppet

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

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

Comments

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 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
0

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

doc75 gravatar image

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

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):

fixtures:
  repositories:
    stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
  symlinks:
    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
0

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

GregLarkin gravatar image

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

I researched this more thoroughly again, due to lavaman's input (Thx!). I believe this issue describes the bug you are encountering: http://projects.puppetlabs.com/issues/17543

There is a code diff in the comments ( http://projects.puppetlabs.com/issues/17543#note-3 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

Comments

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 -0500 )edit

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

Stats

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

Seen: 1,008 times

Last updated: Oct 20 '13