WebMock is a library for stubbing and setting expectations on HTTP requests in Ruby.
WebMock solves the problem of testing code that makes HTTP calls by intercepting requests at the HTTP client library level and allowing developers to stub responses and verify that requests were made as expected. Rather than making real network calls during tests, the tool intercepts requests before they reach the network, enabling fast, isolated test execution. It supports matching requests by method, URI, headers, and body, with intelligent matching that handles different representations of the same URI or headers, such as encoded versus non-encoded forms.
The tool suits any Ruby project that makes HTTP requests and needs to test that code without hitting real endpoints. It works with multiple testing frameworks including RSpec, MiniTest, Test::Unit, and Cucumber, and integrates with numerous HTTP client libraries ranging from the standard library Net::HTTP to specialized clients like Typhoeus, Excon, and HTTPClient. Developers can switch between HTTP libraries without rewriting tests, since WebMock stubs at a low level beneath the client library abstraction. The README does not name alternative libraries for comparison.
The project maintains broad compatibility across Ruby versions and interpreters. Development activity shows ongoing support for emerging Ruby releases and continued integration with new HTTP client libraries as they appear in the ecosystem.