Ask Your Question

rspec-puppet tests with additional class/resource

asked 2016-04-09 12:19:55 -0600

DarylW gravatar image

I have a question.. Say I have some autorequires functionality built into a class..

if defined( File[$parent_dir]) {
  $require_parent = File[$parent_dir]
exec { '/some/command':
  require => $require_parent,

How would I test that with rspec-puppet? Is there a way that I can create the file resource in a describe/context block for a single test?

I know how to write the actual matcher via the rspec-puppet docs

it { contain_file('foo').that_requires('File[bar]') }

But how do I set up the conditions for that test?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-04-09 12:44:18 -0600

You'd use pre_condition -

let(:pre_condition) { "file { '/parent/dir': }" }
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: 2016-04-09 12:19:55 -0600

Seen: 163 times

Last updated: Apr 09 '16