Skip to content

feat(matchers): emit match_or/match_and as pact_ffi integration JSON - #3

Draft
YOU54F wants to merge 5 commits into
base/pr-420-or-composite-matcherfrom
feat/or-matcher-integration-json
Draft

YOU54F wants to merge 5 commits into
base/pr-420-or-composite-matcherfrom
feat/or-matcher-integration-json

Conversation

@YOU54F

@YOU54F YOU54F commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

Stacked on pact-foundation/pact-ruby#420 (this PR's base, base/pr-420-or-composite-matcher, is that PR's head).

  • match_or / match_and are emitted as pact_ffi integration JSON with "pact:matcher:combine". Previously pact-ruby resolved them itself, so the FFI path now handles them.
  • match_null and *_or_nil helpers, with docs in the README.
  • Fix: release the mock server when an interaction has mismatches.
  • Specs: matcher serialisation, and OR in the body, headers and query against the mock server (http_client_spec.rb).

Testing

http_client_spec (7 examples) and the matcher specs passed locally against a pact_ffi build with #601. The port 9001 failures elsewhere are pre-existing.

Depends on

Warning

The last commit (test: consume pact_ffi 0.5.13-or.1 … (revert before merge)) points this repo at the fork prerelease so CI can test it end to end. Revert it and bump to the released pact_ffi before merging upstream.

CI: the pin commit installs pact_ffi 0.5.13-or.1 via YOU54F/pact-ruby-ffi feat/or-matcher and fails unless that version is loaded.

🤖 Generated with Claude Code

YOU54F and others added 5 commits November 9, 2026 17:31
Combined matchers now serialise inline, like every other matcher:

  {"pact:matcher:type":[<each matcher without its value>],
   "pact:matcher:combine":"OR"|"AND","value":<sample>}

This needs a pact_ffi with `pact:matcher:combine` support
(pact-foundation/pact-reference#601), which writes the usual
`{"combine":"OR","matchers":[...]}` rule list to the pact file.

- Combined is now a Pact::Matchers::Base, so it is serialised wherever
  matchers are (request/response bodies, headers, query, message
  contents) and can be nested in a hash/array or inside another
  matcher's sample.
- Matchers nested in an object sample keep their own rules, so
  null-or-object works.
- Drop the separate PactFfi.with_matching_rules call, the path tracking
  in InteractionContents and Base#as_matching_rule.
- A Combined cannot be an alternative of another Combined, and is
  rejected in plugin (matching(...)) contents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ches

HttpInteractionBuilder#execute raised InteractionMismatchesError before
cleaning up, so the mock server kept its port and the pact handle was
not reset; the next interaction on the same port then failed with
"Address already in use". It also raised NoMethodError, hiding the real
error, when the mock server failed to start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he mock server

Proves each alternative matches, a value matching none fails, nested
rules in a null-or-object sample still apply, and the written pact
contains `"combine": "OR"` rule lists. Uses a separate consumer name and
a temp pact dir so the provider verification does not replay it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…evert before merge)

CI clones the YOU54F/pact-ruby-ffi PR branch, whose download script fetches
the rc, and points pact-ffi at it with DEBUG_TARGET. The pact-ffi gem
cannot come from git: its native libraries are not committed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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