Ask Your Question

rspec test duplicated class

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

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=""></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


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

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

1 Answer

Sort by ยป oldest newest most voted

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

ffrank gravatar image

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

This is likely caused by multiple declarations like

class { "sudo::useralias": }

or even from mixing this with one or more

include sudo::useralias


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


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

Seen: 351 times

Last updated: Apr 07 '14