Fix NameError from removed rspec-expectations diff class (#13)#31
Open
tas50 wants to merge 1 commit into
Open
Conversation
tas50
force-pushed
the
fix/issue-13-rspec-expectations-diff
branch
from
June 28, 2026 05:19
ce9333c to
9202d2d
Compare
rspec-expectations renamed its private diff helper from ExpectedsForMultipleDiffs to MultiMatcherDiff in 3.12.4 and changed its signature (actual moved from message_with_diff into the from factory). A prior change removed the version pin and the broken require but left the call site referencing the old class, turning the original LoadError into a latent NameError that fires whenever a resource-parameter assertion renders a diff. Add a diff_for helper that detects which class is available and uses the matching API, so chefspec works across the full rspec ~> 3.0 range. Also drop the now-stale gemspec comment describing a pin that no longer exists, and replace the pending resource_matcher spec with a test covering the diff-rendering failure path. Signed-off-by: Tim Smith <tsmith84@proton.me>
tas50
force-pushed
the
fix/issue-13-rspec-expectations-diff
branch
from
June 28, 2026 05:19
9202d2d to
5c70b7c
Compare
This was referenced Jun 28, 2026
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.
Summary
Resolves #13.
rspec-expectations renamed its private diff helper class from
ExpectedsForMultipleDiffstoMultiMatcherDiffin 3.12.4 and changed its signature (actualmoved frommessage_with_diffinto thefromfactory). The originally reported error was aLoadErroronrequire "rspec/matchers/expecteds_for_multiple_diffs".A prior change (#19) addressed the
LoadErrorby removing therspec-expectations <= 3.12.3pin and commenting out the brokenrequire— but it left the call site inResourceMatcher#failure_messagestill referencing the removed::RSpec::Matchers::ExpectedsForMultipleDiffsclass. That turned the loudLoadErrorinto a latentNameErrorthat only fires when a resource-parameter assertion fails and chefspec tries to render a diff.Changes
lib/chefspec/matchers/resource_matcher.rb: Remove the stale commented-outrequire; extract adiff_forhelper that detects which private rspec class is available and calls the matching API. This keeps chefspec working across the fullrspec ~> 3.0range (old and new rspec-expectations).chefspec.gemspec: Drop the dangling "temporary restriction" comment that described a version pin already removed.spec/unit/matchers/resource_matcher_spec.rb: Replace thependingstub with a real test covering the diff-rendering failure path (regression test for this issue).Testing
NameErrorwith a failing test first, then confirmed the fix (green) against rspec-expectations 3.13.5.163 examples, 0 failures.cookstyle --chefstyle -c .rubocop.yml→ no offenses.