Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 6104

How to write rspec-test for a class that uses 'create_resources' function

$
0
0
Can't figure out how to write a puppet-Rspec test for the class, that takes parameters and calls 'create_resources' for defined type, passing resources to that function. **Update**: Looks like that I need to test only a httpd::vhost_template, but don't know how. Here is the class I stuck with: class httpd::vhosts($vhosts_config) { if $vhosts_config[use_templates] { notice 'use templates!' create_resources(httpd::vhost_template, $vhosts_config[vhosts]) } } Here is the **httpd::vhost_template** resource definition define httpd::vhost_template ($vhost_name, $vhost_url, $vhost_order) { $basepath = '/vagrant/httpd2_test' validate_string($vhost_name) validate_string($vhost_url) validate_string($vhost_order) $file_name = "${vhost_order}_${vhost_name}.conf" file { "${basepath}/conf.d/${file_name}": ensure => file, content => template('httpd/0x_www.template.xx.conf.erb'), } } Any hints?

Viewing all articles
Browse latest Browse all 6104

Trending Articles