pact-ruby
2,196
Stars
—
Forks
0
Watchers
—
Open Issues
待补全
许可证
Ruby
语言
—
创建时间
最近更新
项目能做什么
Ruby 契约测试工具,为消费者提供 Mock 和 DSL,并为服务端提供回放验证。
来源:AI 基于仓库事实生成
· 内容以仓库实际 README 为准
使用说明 查看原始 README 原仓库文档
中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# Pact Ruby
`pact-ruby v2+` implements support for the latest versions of Pact specifications:
- It's based on pact-ffi and pact-ruby-ffi
- It provides a convenient DSL, simplifying the writing of contract tests in Ruby/RSpec
- Writing contract tests with HTTP transports
- Writing contract tests with non-HTTP transports (for example, gRPC)
- Writing contract tests for async messages (Kafka, etc.)
- Verifying contract tests for HTTP/non-HTTP/async message transport
- V4 specification supports mixed pact interactions in a single file.
## Architecture

- DSL - implementation of RSpec-DSL for convenient writing of Pact tests
- Matchers - implementation of Pact matchers, which are convenient helpers used in consumer-DSL, encapsulating all the logic for serialization into Pact format
- Mock servers - mock servers that allow for correct execution of provider tests
## Installation
The `pact/v2` namespace was introduced in `pact-ruby` v1.67.0 and moved to `pact` in v2
It introduces a suite of new depedencies, including a reliance on the `pact-ffi` and `ffi` gems.
```rb
gem "pact"
```
`pact-ffi` ships prebuilt binary gems, and does not support platforms outside of the released [pact_ffi](https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_ffi) libraries
| Version | Platform |
|-----------|----------------------|
| 0.5.8.1 | x86_64-darwin |
| 0.5.8.1 | arm64-darwin |
| 0.5.8.1 | x86_64-linux |
| 0.5.8.1 | aarch64-linux |
| 0.5.8.1 | x86_64-linux-musl |
| 0.5.8.1 | aarch64-linux-musl |
| 0.5.8.1 | x64-mingw32 |
| 0.5.8.1 | x64-mingw-ucrt |
If you require a pure ruby gem, you are advised to pin to v1.
## Usage
For each type of interaction (due to their specific features), a separate version of DSL has been implemented. However, the general principles remain the same for each type of interaction.
Place your consumer tests under
`spec/pact/providers/**`
**it's not an error: consumer tests contain `providers` subdirectory (because we're testing against different providers)**
```ruby
# Declaration of a consumer test, always include the :pact tag
# This is used in CI/CD pipelines to separate Pact tests from other RSpec tests
# Pact tests are not run as part of the general RSpec pipeline
RSpec.describe "SomePactConsumerTestForAnyTransport", :pact do
# declaration of the type of interaction - here we determine which consumer and provider interact on which transport
has_http_pact_between "CONSUMER-NAME", "PROVIDER-NAME"
# or
has_grpc_pact_between "CONSUMER-NAME", "PROVIDER-NAME"
# or
has_message_pact_between "CONSUMER-NAME", "PROVIDER-NAME"
# the context for one of the interactions, for example GET /api/v2/stores
context "with GET /api/v2/stores" do
let(:interaction) do
# creating a new interaction - within which we describe the contract
new_interaction
阅读完整原文
项目深度分析 AI 生成
私有化轻量级 Pact Broker 与自动化治理工作台
| 产品构想 | 针对不愿使用 PactFlow SaaS 但原生开源 Pact Broker 部署运维复杂的企业,提供一键部署的轻量化契约管理台与治理工具。 |
| 核心功能 | 一键容器化部署;契约版本比对与差异可视化;基于 Pact Ruby 的 CI/CD 拦截规则配置;服务依赖拓扑图展示。 |
| 目标用户 | 有数据隐私要求的金融、医疗等领域的微服务研发团队及架构师。 |
| 难度/周期 | 高 · 3-6个月 · 成本:服务器/CI资源;多平台(跨架构FFI)测试环境成本。 |
| 收费模式 | 企业许可证买断或按节点/席位年订阅制付费。 |
| 竞争风险 | 需直面官方商业化产品 PactFlow 的激烈竞争;开源社区对免费方案接受度较高。 |
| 依据 | 已验证事实 |
面向 Rails 微服务的契约测试与质量保障顾问服务
| 产品构想 | 为正在向微服务转型或深陷跨服务联调痛点的 Ruby 团队提供契约测试实施落地、架构规范设计及培训支持。 |
| 核心功能 | 现有系统接口评估;Pact-Ruby 规范制定与测试套件搭建;CI/CD 流水线集成与 Provider 验证方案落地;团队专项培训。 |
| 目标用户 | 拥有中大型 Ruby/Rails 复杂技术栈但缺少契约测试经验的团队负责人。 |
| 难度/周期 | 中 · 2-4周(按项目实施) · 成本:人力时间成本为主,极低基础设施成本。 |
| 收费模式 | 咨询费、实施交付外包费、按天或按人头计费的培训费用。 |
| 竞争风险 | 服务交付难以标准化扩张,严重依赖个人技术威信与销售网络。 |
| 依据 | 数据支持的判断 |
基于 RSpec 与 Pact 的 API 契约自动生成工具(SaaS/CLI插件)
| 产品构想 | 开发针对 Rails 应用的开发辅助工具,通过监听测试环境或 RSpec Request Spec 自动反向生成符合 Pact 规范的契约骨架代码。 |
| 核心功能 | RSpec 运行时追踪与参数推断;自动生成带 Matcher 的 Pact-Ruby 测试骨架;支持 HTTP/gRPC 协议的模式转化器。 |
| 目标用户 | 觉得手写 Pact DSL 繁琐、想要快速补齐历史遗留接口契约测试的 Ruby 开发者。 |
| 难度/周期 | 中 · 1-3个月 · 成本:开发与维护成本,少量文档托管与自动化构建资源。 |
| 收费模式 | 核心工具开源,高级高级分析、团队模板共享及批量推导功能采用付费订阅模式(Open-Core)。 |
| 竞争风险 | 自动生成的契约可能过度脆弱或冗余,实际开发维护成本可能高于手写。 |
| 依据 | AI推测 |
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心
竞品与相似项目 GitHub Search 真实检索
| 项目 | 中文简介 | Stars | 语言 |
|---|---|---|---|
| pact-foundation/pact_broker-client | 中文介绍暂未生成 A Ruby and CLI client for the Pact Broker. Publish and retri |
68 | Ruby |
| pact-foundation/roadmap | 中文介绍暂未生成 Developer Relations @ Pact - Your map to the Pact landscape |
45 | - |
| pact-foundation/pact-message-ruby | 中文介绍暂未生成 Create and verify consumer driven contracts for messages |
10 | Ruby |
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。
项目优势与风险
| 技术成熟度 | 创建时间待补全,最近推送 ,发布过 41 个 Release |
| 社区活跃 | Star 2,196 / Fork 0 / Issue 0(数据支持,可自行核实) |
| 许可证 | 未检测到(需人工确认) |
| 主要风险 | 上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价 |
安装与使用
此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。