Skip to content

Add respond_to_missing? to ResourceMatcher#42

Open
tas50 wants to merge 1 commit into
chef:mainfrom
tas50:cleanup/resource-matcher-respond-to-missing
Open

Add respond_to_missing? to ResourceMatcher#42
tas50 wants to merge 1 commit into
chef:mainfrom
tas50:cleanup/resource-matcher-respond-to-missing

Conversation

@tas50

@tas50 tas50 commented Jun 28, 2026

Copy link
Copy Markdown

Summary

ResourceMatcher#method_missing provides the dynamic with_*(value) matcher sugar, but there was no corresponding respond_to_missing?. As a result matcher.respond_to?(:with_owner) returned false even though the call works — the object lied about its own interface, which trips up respond_to?-based introspection and serialization libraries.

This adds respond_to_missing? mirroring the method_missing regex, the same pattern already used in SoloRunner#respond_to_missing? (solo_runner.rb).

Testing

  • Added a unit spec (TDD — verified it failed first) covering both that the matcher reports responding to with_* methods and that it does not claim unrelated methods.
  • bundle exec rspec spec/unit/163 examples, 0 failures.
  • cookstyle --chefstyle -c .rubocop.yml → no offenses.

Note

This touches spec/unit/matchers/resource_matcher_spec.rb, which is also rewritten by #31 (the rspec-expectations fix replaced its pending stub). Whichever merges first, the other needs a trivial merge of the two example groups.

ResourceMatcher#method_missing implements the dynamic `with_*` matcher
sugar but had no matching respond_to_missing?, so `respond_to?(:with_x)`
returned false and the object misrepresented its interface to
introspection and serialization. Add respond_to_missing? mirroring the
method_missing pattern, following the same approach already used in
SoloRunner.

Signed-off-by: Tim Smith <tsmith84@proton.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant