There are two ways to solve your problem.
First, you can use the create_template match. This will only match the resources of the "template" in the execution context:
expect(chef_run).to create_template('my_file')
This connector can also be connected, so you can approve the attributes:
expect(chef_run).to create_template('my_file') .with_path('my_path') .with_owner('root')
However, this template will not display the template. Thus, you cannot verify that you have configured the file specification correctly.
There may also be a top-level match for any type of βfileβ ( file , cookbook_file and template ) that actually displays the contents in memory:
expect(chef_run).to render_file('my_file').with_content(/^match me$/)
Further information on render_file can be found in README .
source share