Ask Your Question
0

rspec test duplicated class

asked 2013-08-22 06:59:04 -0500

Jon gravatar image

I have the main init.pp class, which takes a list of parameters and then makes calls to other classes from within it.

When writing rspec tests, i get errors saying i have duplicated class:

  Duplicate declaration: Class[Sudo::User_alias] is already declared; cannot redeclare at /etc/puppetlabs/puppet/modules/sudo/manifests/init.pp:46 on node <a href="http://pb2svpoc01v.europe.nyx.com">pb2svpoc01v.europe.nyx.com</a>
 # ./sudo/spec/classes/user__alias_spec.rb:13:in `block (2 levels) in <top (required)>'

It seems to see the class { 'sudo::useralias': } call in init.pp as a duplicated class to ... (more)

edit retag flag offensive close merge delete

Comments

Can you post any of the manifest and rspec code here for further review?

GregLarkin gravatar imageGregLarkin ( 2013-08-23 02:03:43 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-04-04 17:43:08 -0500

ffrank gravatar image

updated 2014-04-07 15:51:41 -0500

This is likely caused by multiple declarations like

class { "sudo::useralias": }

or even from mixing this with one or more

include sudo::useralias

declarations.

The latter can coexist with one of the former, but there are parse order issues. Avoid the class { "-name-": } syntax. Prefer include. Try and fill parameters from Hiera as consequently as possible.

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

Stats

Asked: 2013-08-22 06:59:04 -0500

Seen: 319 times

Last updated: Apr 07 '14