# bblimke/webmock

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/bblimke-webmock).**

4,050 stars · 577 forks · Ruby · MIT

## Links

- GitHub: https://github.com/bblimke/webmock
- awesome-repositories: https://awesome-repositories.com/repository/bblimke-webmock.md

## Description

WebMock is a Ruby library for HTTP request stubbing, response simulation, and network interception. It serves as a test assertion framework for verifying outgoing HTTP traffic and a network interception layer that blocks external connections to prevent accidental requests during testing.

The project provides capabilities for dynamic response generation and the sequencing of different return values for repeated requests to the same endpoint. It supports simulating network failures, such as timeouts or exceptions, and allows for response replays using raw HTTP data loaded from local files.

The library covers a broad range of API simulation and network control functions, including request matching based on URIs and headers, request signature recording, and outbound traffic filtering. It also includes monitoring utilities to intercept and log network events via custom callbacks.

## Tags

### Testing & Quality Assurance

- [HTTP Stubbing Frameworks](https://awesome-repositories.com/f/testing-quality-assurance/http-request-clients/api-request-clients/request-testing/stub-registries/http-stubbing-frameworks.md) — Implements a comprehensive framework for stubbing HTTP requests and returning predefined status codes and bodies. ([source](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md))
- [Ruby](https://awesome-repositories.com/f/testing-quality-assurance/node-js-test-automation/http-mocking/ruby.md) — Simulates HTTP server responses to isolate application logic from external network dependencies in Ruby projects.
- [API Expectation Frameworks](https://awesome-repositories.com/f/testing-quality-assurance/api-expectation-frameworks.md) — Provides tools to verify that specific API calls were made with the expected parameters and headers. ([source](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md))
- [External API Call Assertions](https://awesome-repositories.com/f/testing-quality-assurance/external-api-call-assertions.md) — Verifies that an application made expected outgoing HTTP requests to external services.
- [Custom Mock Response Overrides](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/network-api-mocking/api-response-modifiers/local-api-response-mocking/custom-mock-response-overrides.md) — Enables the configuration of custom status codes, headers, and bodies to override default mock responses. ([source](https://github.com/bblimke/webmock/blob/master/README.md))
- [Request Verification](https://awesome-repositories.com/f/testing-quality-assurance/http-request-clients/request-verification.md) — Asserts that outgoing requests were made, skipped, or executed a specific number of times. ([source](https://github.com/bblimke/webmock#readme))
- [Network Connection Blockers](https://awesome-repositories.com/f/testing-quality-assurance/network-connection-blockers.md) — Blocks all external network connections by default to prevent accidental requests during testing.
- [Response Simulators](https://awesome-repositories.com/f/testing-quality-assurance/network-resilience-simulators/response-simulators.md) — Generates custom status codes, artificial delays, and specific content types to test application resilience.
- [Network Failure Simulations](https://awesome-repositories.com/f/testing-quality-assurance/network-resilience-simulators/response-simulators/network-failure-simulations.md) — Provides simulations of network-level errors such as connection timeouts and service outages to verify application resilience. ([source](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md))
- [Regex Request Matching](https://awesome-repositories.com/f/testing-quality-assurance/regex-request-matching.md) — Allows matching API requests using regular expressions and flexible patterns in URIs and headers. ([source](https://github.com/bblimke/webmock#readme))
- [Network Request Assertions](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/assertions-and-validation/assertion-validation-utilities/assertion-libraries/execution-assertions/network-request-assertions.md) — Provides assertions for verifying that specific network requests were executed with expected parameters.
- [File-Based Response Serving](https://awesome-repositories.com/f/testing-quality-assurance/file-based-response-serving.md) — Serves the raw contents of local files as mock API response bodies.
- [Dynamic Response Callbacks](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/network-api-mocking/api-response-modifiers/dynamic-response-filters/dynamic-response-callbacks.md) — Provides custom callback functions to generate mock responses dynamically based on incoming request data. ([source](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md))
- [Response Sequencing](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/network-api-mocking/api-response-modifiers/dynamic-response-filters/dynamic-response-callbacks/per-request-response-assignments/response-sequencing.md) — Returns a sequence of different responses for repeated requests to the same endpoint. ([source](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md))
- [Local API Response Mocking](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/network-api-mocking/api-response-modifiers/local-api-response-mocking.md) — Loads raw HTTP responses from local files to serve as stubbed return values. ([source](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md))
- [Mock State Resetting](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/test-data-management/test-mock-management-tools/mock-state-resetting.md) — Includes utilities to reset request history and clear active stubs between individual test cases. ([source](https://github.com/bblimke/webmock/blob/master/README.md))
- [Network Connectivity Controls](https://awesome-repositories.com/f/testing-quality-assurance/network-connectivity-controls.md) — Restricts or permits network access to specific hosts during test execution to ensure isolation. ([source](https://github.com/bblimke/webmock/blob/master/README.md))

### Development Tools & Productivity

- [Request Body Matchers](https://awesome-repositories.com/f/development-tools-productivity/regular-expressions/route-pattern-matching/request-body-matchers.md) — Validates request payloads using regular expressions, partial data structures, or custom logic blocks. ([source](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md))

### Networking & Communication

- [Application-Level Traffic Interception](https://awesome-repositories.com/f/networking-communication/application-level-traffic-interception.md) — Hooks into Ruby HTTP client libraries to divert outgoing traffic into a custom stub handler.
- [Request History Logs](https://awesome-repositories.com/f/networking-communication/http-request-customization/request-execution/post-request-executions/request-history-logs.md) — Captures and stores a history of all intercepted requests to enable post-execution assertions.
- [HTTP Client Interception](https://awesome-repositories.com/f/networking-communication/local-packet-captures/application-layer-interceptions/http-client-interception.md) — Intercepts outgoing network traffic to block external connections and prevent accidental requests during tests.

### Programming Languages & Runtimes

- [Ruby HTTP Mocking Libraries](https://awesome-repositories.com/f/programming-languages-runtimes/node-js-network-libraries/ruby-http-mocking-libraries.md) — Provides utilities to intercept and simulate HTTP traffic within Ruby applications during testing.

### Part of an Awesome List

- [Network Request Filters](https://awesome-repositories.com/f/awesome-lists/data/regular-expressions/regular-expression-filtering/network-request-filters.md) — Uses regular expressions and custom logic to block or allow specific network requests based on URL patterns. ([source](https://github.com/bblimke/webmock#readme))
- [Testing](https://awesome-repositories.com/f/awesome-lists/devtools/testing.md) — HTTP request stubbing.
