On Jan 16 04:58, Gavin Williams wrote:
> Vamsee 
> 
> Are you able to share how you went about mocking out the ::params class 
> include? 
> 
> As I've got the same pattern that I want to test using rspec-puppet... 
> 

Hi Gavin,

I ended up adding all the params to the define explicity, instead of
including the params class:

define app_setup::app(
  $app_name       = $title,
  $app_host       = $app_setup::params::app_hosts[$title]['url'],
  $app_port       = $app_setup::params::app_hosts[$title]['port'],
  $deploy_user    = $app_setup::params::deploy_user,
  ...
)

The params are accessible in the define without inheriting because I did this 
in the
init.pp file:

class app_setup($deploy_env = 'UNSET')  {
  include app_setup::params
  ...
}

And testing it the usual way:

    let(:params) { {
        :app_host    => 'api.example.net',
        :app_port    => '3009',
        :deploy_user => 'test_user',
        ...
    }}

Hope this helps. I thought this was much cleaner in its contract rather than 
including
the params class. This might or might not appeal to you, though.


Vamsee.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/20140116144637.GA17935%40inara.serenity.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to