# WebMock

> Library for stubbing and setting expectations on HTTP requests in Ruby.

Source: https://talira.ai/catalog/webmock-ey6nmggt
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [developer tools / testing / http mocking](https://talira.ai/categories/developer-tools/testing/http-mocking), [languages / ruby](https://talira.ai/categories/languages/ruby)
- Platforms: cli
- Licence: MIT
- Pricing: Free and open source
- Free tier: yes
- Self-hostable: yes
- Creator: Bartosz Blimke

WebMock stubs HTTP requests in Ruby tests at the level of the HTTP client libraries, so tests keep working when you change HTTP library. It matches requests by method, URI, headers and body (treating equivalent encodings of a URI or header as the same), lets you set expectations that a request was made, and by default blocks real network connections in tests. It works with [RSpec](https://talira.ai/catalog/rspec-87n8pes2.md), Minitest and Test::Unit and supports Net::HTTP (and libraries built on it such as HTTParty), HTTPClient, Excon, Curb, Typhoeus, http.rb, httpx, Patron, Manticore and Async::HTTP. [VCR](https://talira.ai/catalog/vcr-5q5vt0wn.md) can use it to record and replay requests.

## Links

- GitHub: https://github.com/bblimke/webmock

## Problems it solves

- my Ruby tests make real HTTP calls to third-party APIs and are slow and flaky
- fake the response from Stripe or GitHub's API in an RSpec test
- make sure a test fails if any code tries to hit the real network
- assert that my code sent a POST with the right JSON body
- simulate a timeout or a 500 from an external API in tests

## Features

- stubs at the HTTP client library level
- request matching on method, URI, headers and body
- request expectations
- blocks real connections by default
- RSpec, Minitest and Test::Unit support

## Capabilities

- Has official SDKs: plan not known

## Trust

Overall: 0.61 out of 1.
Signals: maintenance 0.85, adoption 0.72, momentum 0.40, community 1.00, backing 0.20, extensibility 0.00.

- last commit 40 days ago
- 81 commits in the last 90 days
- latest release v3.34.0 40 days ago
- 4.0k GitHub stars
- 308 contributors
- created by Bartosz Blimke

## Alternatives

- [VCR](https://talira.ai/catalog/vcr-5q5vt0wn.md): Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.
