Render the creating resource when a path has several resources - #49
Open
tas50 wants to merge 1 commit into
Open
Conversation
The render_file matcher looked up the resource for a path by trying cookbook_file, then file, then template, and stopped at the first match regardless of the action that resource performed. A recipe that renders a config file with a template and removes it with a guarded file resource therefore matched the file[:delete] resource and reported the file as unrendered, even though create_template matched and the template really was rendered. Prefer whichever candidate resource actually performs a create-like action and fall back to the first match so failure messages are unchanged when nothing creates the file. Fixes chefspec#858 Signed-off-by: Tim Smith <tsmith84@proton.me>
tas50
force-pushed
the
fix/render-file-resource-selection
branch
from
August 22, 2026 00:09
ce335f4 to
1bb0f9b
Compare
Author
|
CI on this PR is red for an unrelated reason: main's bundle cannot be installed on Linux, which breaks every job before any test runs. That is fixed separately in #56, which is green across Ruby 3.1 to 3.4. This PR should go green once #56 lands and this branch is rebased. Locally, against a working bundle, this branch passes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes chefspec#858
Problem
render_fileresolved the resource for a path like this:It stops at the first match and never considers the action. A recipe that renders a config file with a template and removes it with a guarded
fileresource declares two resources for the same path, so thefile[:delete]resource wins andrender_filereports the file as unrendered.The confusing part is that
create_templatematches correctly at the same time, which makes this look like a rendering bug rather than a lookup bug.Fix
Collect all candidate resources for the path and prefer whichever one performs a create-like action, falling back to the first match so failure messages are unchanged when nothing creates the file.
Testing
Adds a template plus
file[:delete]pair for the same path to therender_fileacceptance example.55 examples, 0 failures55 examples, 2 failures197 examples, 0 failures