Specifying dependencies in rspec-puppet
Posted on 28 June 2012
This doesn’t seem to be specified anywhere in the rspec-puppet documentation, so I thought I’d leave it here for the moment. Suppose you have a puppet type which always depends on another:
define foo () { file { "/etc/${name}": } Bar[$name] -> Foo[$name] }
If you want to write an rspec-puppet unit test for this, it will fail because it can’t find the resource Bar[$name]
, unless you define it as a precondition:
describe 'foo', :type => :define do let(:title) { 'my-foo' } let(:pre_condition) { 'bar { "my-foo" }' } it { should contain_file('/etc/my-foo') } end