pact-foundation/pact-ruby
75.3
Strong · 19 September 2026
3.8k
lines of production code
Ruby
primary language
1
measurement over time
What this system is
This system is the Pact Ruby library, a tool for consumer-driven contract testing that enables developers to verify interactions between services. It supports HTTP, gRPC, and asynchronous message transports like Kafka, allowing users to define expected behaviors and automatically verify provider implementations against those contracts. The library provides DSLs for writing tests, utilities for generating random data and matching complex structures, and integration helpers for RSpec and Rails environments.
How it got here
2013 — v2 FFI architecture and DSL overhaul
11 changes.
The project underwent a major architectural shift to version 2.0.0, replacing the core implementation with a Pact FFI-based architecture and introducing a new, simplified DSL for multi-transport contract testing. This period focused on stabilizing the new foundation by adopting Zeitwerk for autoloading, restructuring configuration and matchers, and establishing comprehensive test infrastructure and CLI tooling.
2017–2026 — Pact v2 FFI migration and plugin support
10 changes.
This period focused on rewriting the core consumer and provider libraries to utilize the Pact FFI, enabling native support for gRPC, Kafka, and custom protocol plugins. The work included reorganizing the library namespace, introducing new RSpec DSL helpers, and establishing comprehensive test coverage for the new plugin-based architecture and release automation.
Features
Added Alligator model to ZooApp example
The ZooApp example now includes an Alligator model class within the ZooApp::Animals namespace. This new model accepts a name attribute during initialization and implements equality comparison based on the name, providing a concrete example of a domain object for the application.
_example/zoo-app/lib/zoo\app/models · high confidence
Added ZooApp example application with AnimalServiceClient
The example/zoo-app directory now includes a Ruby-based consumer application (ZooApp v1.0.0) that demonstrates Pact best practices. It features an AnimalServiceClient that interacts with an external animal-service.com API to retrieve alligator data, handling JSON parsing and HTTP response validation.
_example/zoo-app/lib/zoo\app · high confidence
Added animal-service example application
The example/animal-service directory now contains a complete, runnable example application. This includes a Sinatra-based API that exposes an endpoint to retrieve alligator data by name, backed by a SQLite database via Sequel, along with the necessary configuration (config.ru), Rake tasks for running Pact verification tests, and the core library code.
example/animal-service · high confidence
Added pact executable entry point
A new executable script named 'pact' has been added to the bin directory, allowing users to launch the Pact CLI directly from the command line by invoking the Pact::CLI.start method.
bin · high confidence
Added release and specification automation tasks
New Rake tasks have been introduced to streamline the development and release workflow. The \tasks/release.rake\ file provides commands to generate changelogs using conventional changelog and to create and push Git tags for releases based on the current version. Additionally, \tasks/spec.rake\ defines specific RSpec tasks to run general specs, Pact provider specs, and Pact consumer verification specs, along with a combined task to execute all test suites.
tasks · high confidence
Introduce FFI-based provider verification with HTTP, gRPC, and async message support
The provider verification logic in lib/pact/provider has been rewritten to use the Pact FFI verifier, replacing the previous implementation. This change introduces dedicated verifiers for HTTP, gRPC, and async message transports, along with a MixedVerifier to coordinate them. It includes a new PactBrokerProxy to fetch pacts from the broker, a ProviderServerRunner to handle provider state setup/teardown and message verification via WEBrick, and configuration classes (PactConfig) for each transport type. The implementation also patches WEBrick to handle bodyless PUT/PATCH/POST requests and ensures compatibility with Rack 1.6+ and 2.x/3.x.
lib/pact/provider · high confidence
Major v2 release with new DSL, FFI-based architecture, and multi-transport support
The library has been upgraded to version 2.0.0, introducing a complete architectural shift to use the Pact FFI (Foreign Function Interface) and pact-ruby-ffi for core functionality. This change brings a new, simplified DSL for writing contract tests that supports HTTP, gRPC, and async message transports (such as Kafka). The namespace has moved from \pact/v2\ to \pact\, and the gem now relies on prebuilt binary gems for \pact-ffi\. Additionally, the project has restructured its documentation by splitting the README into dedicated files (CONTRIBUTING, RELEASING, ROADMAP) and updated the RSpec configuration to use the progress formatter with color.
(repo-wide) · high confidence
New RSpec DSL helpers for Pact consumer, provider, and message testing
This change introduces a new set of RSpec helper modules in lib/pact/rspec/support to streamline Pact contract testing. For consumers, PactConsumerDsl provides class methods like has\_http\_pact\_between and has\_message\_pact\_between to configure pact definitions, along with instance methods for managing interactions and executing HTTP pact verification. For providers, PactProducerDsl offers http\_pact\_provider, grpc\_pact\_provider, and message\_pact\_provider to set up verification contexts, including support for mixed pact providers. Additionally, PactMessageHelpers adds support for Kafka-based message testing via Waterdrop, allowing producers to generate outbox items and consumers to match specific headers. The update also includes WebmockHelpers to safely manage WebMock state during provider verification, ensuring network calls are temporarily allowed and then restored to their previous configuration.
lib/pact/rspec · high confidence
New release automation scripts for gem publishing
Added \script/release.sh\ and \script/trigger-release.sh\ to streamline the release process. The local release script handles version bumping, changelog generation, and git tagging, while the trigger script invokes the GitHub Actions release workflow via the API, requiring a specific access token for authentication.
script · high confidence
Pact library updated to version 2.1.0 with new DSL and configuration structure
The Pact library has been upgraded to version 2.1.0, introducing a new configuration DSL in \lib/pact/configuration.rb\ that allows users to set \before\_provider\_state\_setup\ and \after\_provider\_state\_teardown\ blocks, replacing previous global variable approaches. The update also adds a new \Pact::Generators\ module for creating random data (integers, decimals, strings, UUIDs, dates, etc.) and a \Pact::Matchers\ module providing structured matchers for various data types (strings, integers, UUIDs, dates, etc.) supporting Pact specification versions 1 through 4. Additionally, new modules for \Consumer\, \Provider\, and \Railtie\ have been added, with the Railtie loading Pact Rake tasks for Rails applications. The RSpec integration now filters pact specs from the generic pipeline using metadata flags.
lib/pact · high confidence
Behavioural changes
5 commits (0 fixes) modifying example/animal-service/db
A change to existing behaviour in example/animal-service/db — 5 commits, 1 file.
example/animal-service/db · medium confidence · unverified
Adopts Zeitwerk for library autoloading and introduces FFI error handling
The library now uses Zeitwerk for class autoloading, replacing the previous manual require structure, which improves how classes are loaded and organized. Additionally, a new FFI error class has been added to provide detailed context (reason, status, and message) when underlying FFI operations fail, and core extension polyfills are explicitly loaded before eager loading to ensure compatibility with host applications.
lib · high confidence
Corrected polyfill implementations for blank?, present?, and presence methods
The core\_ext polyfill module has been updated to more closely align with Active Support's behavior for applications not loading the full library. Specifically, the implementations of Object\#blank?, Object\#present?, and the newly added Object\#presence method have been fixed to ensure correct logical evaluation across various object types. This change ensures that methods like presence correctly return the object itself when present, and blank?/present? behave consistently with standard Active Support expectations, improving reliability for users relying on these utilities without the full framework.
lib/pact/support · high confidence
New FFI-based consumer API for HTTP, gRPC, and message interactions
The consumer library has been rewritten to use the Pact FFI directly, introducing new builder classes for HTTP, gRPC, and message interactions. This change enables support for plugin-based content types (such as Protobuf) and allows users to define interaction references. The new API also ensures that the FFI log level is correctly initialized when creating a pact, and provides a unified configuration interface for different transport types.
lib/pact/consumer · high confidence
Pact v2 library reorganized under the Pact namespace
The Pact v2 library has been reorganized to move generators, matchers, and tasks into the main Pact namespace. This change introduces new generator classes for random integers, decimals, hexadecimal strings, UUIDs, and dates, alongside a comprehensive set of matcher classes for v1 through v4 of the Pact specification. Users can now utilize these updated components for more precise contract testing, including support for complex types like semver, content types, and nested structures via each-key and each-value matchers.
lib/pact/generators, lib/pact/matchers, lib/pact/tasks · high confidence
Test coverage
Added Pact contract tests for Zoo App and Animal Service integration; Added Pact v2 integration tests for HTTP, gRPC, Kafka, and MATT plugins; Added RSpec test configuration files for Rails and general specs; Added internal test application scaffolding for Pact verification; Added test coverage for Pact library components.
Dependencies
Updated gem dependencies and metadata for pact-ruby
The pact gem's dependency manifest has been updated to include pact-ffi (\~\> 0.5.8) for Rust Core support, rack-proxy, and webrick (\~\> 1.8) as runtime dependencies, while adding zeitwerk (\~\> 2.3) for code loading. Development dependencies now include appraisal (\~\> 2.5), faraday (\~\>2.0), and various testing and linting tools. The gemspec metadata has been enriched with author details, license (MIT), and documentation links, and example applications (animal-service, zoo-app) have been updated to use pact-ffi.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 75.
Lenses
- Code Health 96
- Architecture 98
- Maturity 76
- Readiness 74
- Security 70
Changes since last survey
- 300 commits — 219 feature/other, 81 fixes
By area
- (root) — 78 commits
- lib/pact — 61 commits
- .github/workflows — 43 commits
- (repo) — 42 commits
- example/animal-service — 41 commits
- example/zoo-app — 11 commits
- spec/lib — 6 commits
- lib/pact.rb — 4 commits
- spec/pact — 3 commits
- documentation/README_V2.md — 2 commits
- script/trigger-release.sh — 2 commits
- spec/support — 2 commits
- example/zoo-app-v2 — 1 commit
- spec/fixtures — 1 commit
- spec/integration — 1 commit
- spec/internal — 1 commit
- tasks/foo-bar.rake — 1 commit
Notable commits
- fix: FIX: HTTP_HOST headers.
- fix: Merge branch 'fix/ConsumerContractBuilder-name-fix' of github.com:marcotc/pact-ruby into marcotc-fix/ConsumerContractBuilder-name-fix
- fix: Merge branch 'karouf-fix-expected-body-when-using-generators'
- fix: Merge branch 'master' into fix-expected-body-when-using-generators
- fix: Merge branch 'master' into snyk-fix-e2e111acad3ffee375a0bdc9b0c67419
- fix: Merge pull request #282 from pact-foundation/snyk-fix-e2e111acad3ffee375a0bdc9b0c67419
- fix: Merge pull request #289 from pact-foundation/snyk-fix-10a9401c1ac6771508527fd7b172ad31
- fix: Merge pull request #295 from pact-foundation/revert-254-bjacobs/replace-term-ansicolor-with-rainbow
- fix: Merge pull request #304 from pact-foundation/snyk-fix-7ad1470a0bf12f0513a757bbd08d0cc5
- fix: Merge pull request #307 from pact-foundation/snyk-fix-6e67950a5b1409e2b470562f9064f681
- fix: Merge pull request #308 from pact-foundation/snyk-fix-dd0fcf2f41999b2e87f51da71f0fa3af
- fix: Merge pull request #310 from pact-foundation/fix/test_rack_2_or_3
- fix: Merge pull request #312 from pact-foundation/snyk-fix-489277ea9526e8286554e979419c6720
- fix: Merge pull request #313 from pact-foundation/marcotc-fix/ConsumerContractBuilder-name-fix
- fix: Merge pull request #323 from pact-foundation/fix/require_ostruct
- fix: Merge pull request #325 from pact-foundation/snyk-fix-dd76f77d0729aadf3330e08d8fd805b3
- fix: Merge pull request #327 from pact-foundation/fix/sinatra_4_1_x
- fix: Merge pull request #331 from pact-foundation/fix/issue_328
- fix: Merge pull request #333 from pact-foundation/cuon-kakimoto-fix/sinatra_4_1_x_host
- fix: Merge pull request #344 from pact-foundation/snyk-fix-d25de6de0640ebe27062fca382a9e18a
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
pact-foundation/pact-ruby was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 00c43cb8330c4fa7080b878c12f9143343f48a6c — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.