-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
render_file will select delete_file resources out of the resource collection and ignore template_create resources that would otherwise match #858
Comments
Please include your recipe and spec code as well. |
@coderanger It's at https://github.com/aogail/chefspec-template-or-delete. Do you mean I should include it somewhere else? |
@aogail In general it's best to include it in the issue itself since external repos 1) have a ton of extra files in them and 2) can change under the hood. |
Does it work if you use a single resource instead? template '/etc/config.conf' do
variables(
:setting => node['chefspec-render-file']['setting']
)
source 'config.conf.erb'
action node['chefspec-render-file']['setting'] ? :create : :delete
end Guessing something might be getting overwritten in the internal tracking? |
Good idea, I'll give that a try. |
the render_file matcher finds the chefspec/lib/chefspec/matchers/render_file_matcher.rb Lines 85 to 87 in b402602
|
as far as i can see the node attribute control has nothing to do with this bug... |
In one of my cookbooks, I'm using a node attribute to control whether a config file is laid down or deleted during the chef run. The node attribute's default value is nil, in which case the config file is deleted. If the node attribute is set to another value, the config file is created based on a template from the cookbook.
I discovered that in this scenario, the
render_file
matcher does not correctly match the latter case.create_template
does correctly match, though. I distilled a minimal cookbook to exhibit the issue and posted it on Github: https://github.com/aogail/chefspec-template-or-deleteRecipe:
Chefspec tests:
Chefspec failure output:
The text was updated successfully, but these errors were encountered: