I am writting a custom puppet <http://mindmajix.com/puppet-training> module which includes an ::apache::vhost resource, and would like to verify in my rspec tests that the directories parameter contains a certain value, without reproducing the entire directories configuration which is mostly hardcoded in the spec test.
class foo::apache { # prepend 'from ' to each element in array of subnets # Change this ugliness to use map once we've upgraded to puppet v4 # open to suggetions on better way to do this too... $subnets = $::foo::subnets $subnets_yaml = inline_template('<%= subnets.map {|s| "from " +s}.to_yaml %>') $allowed_subnets_directives = parseyaml($subnets_yaml) ::apache::vhost { 'foo_vhost': directories => [ -- snip -- ##### How can I check just the path & allow keys of this element? { 'path' => '~^.*$', 'Order' => 'deny,allow', 'allow' => concat(['from localhost'], $allowed_subnets_directives), 'provider' => 'location', }, ] } # foo_vhost } # foo::apache I've removed most of the manifest for brevity. I can test the entire directives parameter with something along the lines of describe 'foo::apache' do it { is_expected.to contain_apache__vhost('foo_vhost').with( 'directories' => [{'path' => '~^.*$', 'allow' => ['from localhost', 'from 10.20.30/24', ],}, ] but the directories parameter is long and static, and I'm keen to avoid that. The rspec include matcher looks like what I need, but I can't work out how to use it to verify the parameter, or the $allowed_subnets_directives variable in puppet <http://tekslate.com/puppet-training>. Help would be appreciable. Thanks in advance. -- 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 puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/b2c4e41d-8f8f-4439-bd68-99ae32e33d96%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.