OSS Tanbou

stub Ruby HTTP requests without real network calls and verify expectations against methods, URIs, headers, and bodies

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
4,049
Primary language
Ruby
License
MIT
Repository last updated
Aug 29, 2026
On this page

Overview

WebMock is a Ruby testing library for stubbing HTTP requests and verifying request expectations. It intercepts requests at a low HTTP-client layer, letting tests use a common stubbing model across Net::HTTP and several other Ruby HTTP libraries.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

Stub HTTP responses without connecting to the real network

Tests can define response bodies, statuses, and headers for matching requests and receive deterministic results from application HTTP calls.

Sources: [1]

Match requests by method, URI, headers, body, and more

Request matching can combine methods, URIs, query parameters, headers, bodies, regular expressions, and related conditions.

Sources: [1]

Integrate with RSpec, Minitest, Test::Unit, and multiple HTTP clients

Framework-specific require entrypoints simplify test-suite integration, while adapters cover many commonly used Ruby HTTP client libraries.

Sources: [1]

Best fit

Fits fast and reproducible unit tests around external HTTP integrations

It isolates tests from network latency, rate limits, and service outages while verifying how application code constructs requests and handles responses.

Sources: [1]

Before adoption

Use another test layer to catch drift from real service contracts

Mocked responses cannot detect provider-side schema, status-code, or authentication changes by themselves. Contract or integration tests should verify compatibility with real services separately.

Sources: [1]

Configure network blocking and localhost allowances intentionally

WebMock.disable_net_connect! can prohibit real external requests, with options such as allowing localhost. Make the policy explicit so accidental network calls do not leak into unit tests.

Sources: [1]

Account for client-specific behavior such as Net::HTTP.start timing

The README explains that WebMock delays Net::HTTP connections until a request by default, altering native connection behavior. Tests covering connection lifecycle need the relevant adapter settings and limitations.

Sources: [1][2]

Official sources

  1. [1]WebMock v3.26.4 README(2026-10-03)
  2. [2]WebMock v3.26.4 release(2026-10-03)
  3. [3]WebMock MIT license(2026-10-03)
Supplemental curator note

WebMock makes external-API unit tests fast and deterministic, but stubs can drift away from real service contracts. Keep contract or integration tests in a separate layer rather than treating mocked behavior as proof that the external integration still works.

Try it in 3 steps

  1. 1

    Install WebMock 3.26.4

    Install the pinned stable release into a Ruby environment.

    gem install webmock -v 3.26.4
  2. 2

    Create a minimal stub-only script

    Create a script that replaces the example.com GET request with a stub response and does not call the real network.

    printf '%s\n' 'require "uri"' 'require "net/http"' 'require "webmock"' 'include WebMock::API' 'WebMock.enable!' 'stub_request(:get, "http://example.com/").to_return(body: "stubbed")' 'puts Net::HTTP.get(URI("http://example.com/"))' > webmock_demo.rb
  3. 3

    Verify the stubbed response

    If it prints stubbed, request interception and response stubbing are working.

    ruby webmock_demo.rb
Check the official README

Growth

Growth trends · Last 30 days

4,049 Stars

Trend data is still being collected.

Development activity

Last 90 days · weekly

Commits (last 30 days)
0
Open PRs
27

Development activity is still being collected.

Built with

Categories and tags

GitHub data

GitHub dataView detailed GitHub data
Stars
4,049
Forks
582
Watchers
40
Open issues
153
Contributors
236
Owner type
User
Primary language
Ruby
License
MIT
Repository last updated
Aug 29, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?