Honor the globally configured platform in example groups - #53
Open
tas50 wants to merge 1 commit into
Open
Conversation
The platform can be set globally with RSpec.configure rather than per example group, which is how many existing cookbooks configure it from spec_helper.rb. The runner already fell back to the global setting, but the example group helpers did not: chefspec_platform defaulted to nil, so the preload and the Chef.node stub were both skipped. Custom resources were then never registered and referencing one from a recipe block raised NoMethodError, while built in resources kept working, which made the failure look like a problem with the resource. Default the platform and version lets to the global configuration. Fixes chefspec#953 Signed-off-by: Tim Smith <tsmith84@proton.me>
tas50
force-pushed
the
fix/global-platform-config
branch
from
August 22, 2026 00:09
4db50e1 to
978a36d
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#953
Problem
The platform can be set globally instead of per example group, which is how a lot of existing cookbooks configure it from
spec_helper.rb:SoloRunner#with_default_optionsalready falls back to that setting, but the example group helpers did not:Both the preload and the
Chef.nodestub are gated onchefspec_platform:So with only the global setting, custom resources are never registered and referencing one from a
recipeblock raises:Built in resources keep working, which is what makes this hard to diagnose. Adding
platform 'ubuntu'to the describe block fixes it, and several people in the issue report losing hours to it.Fix
Default the platform and version lets to the global configuration, so the example group helpers agree with the runner.
Testing
Adds a
spec_global_platformacceptance example: a custom resource, a globalRSpec.configureplatform, and no per example groupplatform.2 examples, 0 failures2 examples, 2 failures(NoMethodError)197 examples, 0 failuresspec_platform, which covers the no-platform warning pathThis does not address the related wrinkle in the issue thread where a global
versioncombines with a per example groupplatform(ubuntu/7.8). That is a separate bug.