bblimke/webmock
67.6
Adequate · 28 September 2026
4.4k
lines of production code
Ruby
primary language
2
measurements over time
What this system is
WebMock is a Ruby library that intercepts and mocks HTTP requests to facilitate isolated testing across a wide variety of HTTP client libraries. It provides a registry of adapters for major HTTP gems, allowing tests to stub responses and verify request patterns without making real network calls. The system supports flexible request matching, including partial hash comparisons and execution count assertions, and integrates with RSpec, Minitest, and Test::Unit for expressive test expectations.
How it got here
2009 — Initial project structure and core refactoring
8 changes.
This period established the foundational project structure, including documentation, licensing, and the core WebMock library initialization with an adapter registry. It involved significant refactoring of the API and request matching logic, alongside the addition of new HTTP library adapters and thread-safe utility classes. The work also expanded test coverage for code quality and assertion methods while updating dependency constraints for modern Ruby versions.
2010–2011 — RSpec integration and test infrastructure expansion
12 changes.
This period focused on enhancing WebMock's testing capabilities by introducing new RSpec matchers with flexible execution counts and improved failure descriptions. The team significantly expanded test coverage by adding acceptance tests for multiple HTTP adapters (Async::HTTP, Curb, HTTPClient, Typhoeus) and establishing robust unit and shared test suites to ensure reliability across different environments.
2012–2024 — HTTP adapter expansion and matcher flexibility
5 changes.
This period focused on expanding WebMock's compatibility by adding support for the Excon and HTTP.rb HTTP libraries, including comprehensive acceptance and unit tests for each. It also introduced flexible request matching capabilities through new hash\_including and hash\_excluding matchers, alongside improved robustness in JSON parsing utilities.
Features
Added hash\_including and hash\_excluding matchers for request matching
WebMock now supports partial hash matching for request bodies and query parameters via new \hash\_including\ and \hash\_excluding\ matchers. This allows users to verify that a request contains specific key-value pairs without requiring an exact match of the entire hash structure, aligning with RSpec's argument matching behavior. The implementation includes dedicated matcher classes (\HashIncludingMatcher\, \HashExcludingMatcher\, \HashArgumentMatcher\, and \AnyArgMatcher\) to handle these flexible comparison rules.
lib/webmock/matchers · high confidence
Initial project structure and documentation setup
This change establishes the foundational project structure by adding the \.gitignore\ file to exclude build artifacts and IDE files, the \.rspec-tm\ configuration for TextMate integration, the \LICENSE\ (MIT), and the \README.md\ documentation which details supported HTTP libraries (such as Net::HTTP, Typhoeus, and HTTPClient) and Ruby versions. It also includes the \Rakefile\ for running specs and tests, and the \CHANGELOG.md\ recording version history up to 3.26.4. The legacy \README\ file is renamed to \.gemtest\.
(repo-wide) · high confidence
New HTTP library adapters for Async::HTTP, HTTP.rb, and em-http-request
WebMock now supports stubbing requests made via the Async::HTTP, HTTP.rb, and em-http-request libraries. This adds new adapter files (async\_http\_client\_adapter.rb, http\_rb\_adapter.rb, em\_http\_request\_adapter.rb) that integrate with WebMock's existing request registry and stubbing mechanisms, allowing tests to intercept and mock network calls from these specific HTTP clients.
_lib/webmock/http\_lib\adapters · high confidence
New HTTP.rb adapter for WebMock
Added a new adapter for the \http-rb\ gem, enabling WebMock to intercept and mock HTTP requests made via this library. The implementation supports multiple versions of the \http-rb\ gem (including 1.x, 2.x, 3.x, 5.x, and 6.x) by handling version-specific API changes in request signing, response construction, and body streaming. It allows users to stub responses, preserve body encoding, and stream real responses when WebMock is not active, ensuring compatibility with the library's evolving interface across major releases.
_lib/webmock/http\_lib\_adapters/http\rb · high confidence
New RSpec matchers for verifying HTTP requests
A new RSpec matcher module has been added to WebMock, providing DSL methods such as \have\_been\_made\, \have\_been\_requested\, \have\_not\_been\_made\, \have\_requested\, and \have\_not\_requested\. These matchers allow users to write expressive expectations directly in their RSpec tests to verify that specific HTTP requests were made or not made during test execution.
lib/webmock/rspec · high confidence
Behavioural changes
Refactored utility classes for thread safety, header normalization, and query parsing
The \lib/webmock/util\ module has been restructured into dedicated classes to improve reliability and behavior. \HashCounter\ is now thread-safe, using a Mutex to synchronize access to request counts, which prevents race conditions in multi-threaded environments. \Headers\ now normalizes header names (e.g., converting underscores to hyphens) and sorts them in 'unexpected request' messages for consistent reporting. \QueryMapper\ provides a robust replacement for Addressable's query handling, supporting multiple notations (subscript, dot, flat) and correctly handling nested arrays and special characters like \+\ in query parameters. \URI\ normalization now ensures query parameters are sorted and handles localhost detection including IPv6 \\[::1\]\. Additionally, \HashValidator\ and \HashKeysStringifier\ provide utilities for validating stub options and converting symbol keys to strings.
lib/webmock/util · high confidence
Updated RSpec matchers with flexible execution counts and improved descriptions
The RSpec matchers in lib/webmock/rspec/matchers have been updated to support RSpec 3's matcher protocol and now include new methods for specifying flexible request execution expectations. Users can now use at\_least\_times and at\_most\_times (alongside at\_least\_once/twice and at\_most\_once/twice) to assert that a request was made within a specific range of times, rather than only exact counts. Additionally, the matchers now provide a description method, which improves the readability of test failure messages by clearly stating what was expected.
lib/webmock/rspec/matchers · high confidence
WebMock 3.26.4: Refactored API and Request Matching
WebMock has been refactored to move instance methods into the WebMock::API module, requiring users to include WebMock::API explicitly rather than relying on automatic inclusion in RSpec or Test::Unit adapters. The library now supports matching request headers against regular expressions and allows the :allow option in disable\_net\_connect! to accept hosts with ports. Additionally, response objects are now passed to after\_request callbacks for stubbed requests, and the assert\_requested and assert\_not\_requested methods support at\_least\_times and at\_most\_times matchers for more flexible request verification.
lib/webmock · high confidence
WebMock library initialization and adapter registry
The lib/webmock.rb entry point now explicitly requires the core WebMock components, including the API module, request pattern matching logic, and a comprehensive registry of HTTP library adapters (such as Net::HTTP, HTTP.rb, HTTPClient, Patron, Curb, Typhoeus, Excon, and Async::HTTP). This establishes the foundational structure for the library, ensuring all necessary utilities, matchers, and adapter implementations are loaded upon initialization.
lib · high confidence
Test coverage
Add acceptance tests for the HTTPClient adapter; Added Minitest integration tests for WebMock; Added Test::Unit test suite for WebMock assertions; Added acceptance test suites for core WebMock behaviors; Added acceptance tests for Typhoeus Hydra integration; Added acceptance tests for the Async::HTTP::Client adapter; Added acceptance tests for the Curb HTTP adapter; Added acceptance tests for the Excon HTTP library adapter; Added test suite for code quality, test configuration, and adapter registry; Added test support infrastructure for Rack and WebMock specs; Added unit tests for API matchers, error messages, and request verification; Added unit tests for JSON parsing utility; Added unit tests for WebMock utility modules; Added unit tests for hash matching matchers; Reorganized acceptance test structure with retry logic and shared examples.
Dependencies
Updated dependency constraints and Ruby version requirements
WebMock now requires Ruby 2.6 or later and has updated its runtime dependencies to Addressable \>= 2.8.0, Crack \>= 0.3.2, and Hashdiff \>= 0.4.0. Development dependencies have also been refreshed, including Curb \>= 0.7.16, Typhoeus \>= 0.5.0, and Excon \>= 0.27.5, to ensure compatibility with modern versions of these HTTP libraries.
(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
Score
- CAI 67 → 68 (+0.5)
- Rubric changed (rubric-2026.09.8 → rubric-2026.09.16) — scores are not directly comparable.
Lenses
- Code Health 99 → 99 (+0.0)
- Architecture 100 → 99 (-1.4)
- Maturity 54 → 54 (+0.0)
- Readiness 67 → 67 (+0.0)
- Security 84 → 88 (+3.9)
Resolved (3)
- Documentation: no installation or build instructions (README.md)
- Documentation: no usage examples (README.md)
- Off-boarding risk: anonymized user #1
New (4)
- Ambiguous naming/overlap: stub_request is the primary public API for creating stubs. globally_stub_request exists on the WebMock module but has a different signature (requires order and block) and likely serves a specific internal or legacy purpose. It creates confusion about which method to use for global stubs.
- Confusingly similar names: a_request and stub_request are very similar in name and likely accept similar arguments. In many mocking libraries, a_request is used for assertions (checking if a request was made) while stub_request is for setting up expectations. However, the naming a_request is non-standard and easily confused with stub_request.
- Duplicate intent: Both methods appear to reset the WebMock state. Having two public methods with slightly different names for the same action is confusing.
- Off-boarding risk: anonymized user #1
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
bblimke/webmock 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 28 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 0fdbad0846d044af30f4b46f5e1f2be1a29ab8ec — the exact code this score is about.
- Scored under rubric-2026.09.16 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-2d9048c36d26.