Skip to content

[ruby] Update webmock 3.26.4 → 3.34.0 (minor) - #931

Open
depfu[bot] wants to merge 1 commit into
mainfrom
depfu/update/webmock-3.34.0
Open

depfu[bot] wants to merge 1 commit into
mainfrom
depfu/update/webmock-3.34.0

Conversation

@depfu

@depfu depfu Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Here is everything you need to know about this update. Please take a good look at what changed and the test results before merging this pull request.

What changed?

✳️ webmock (3.26.4 → 3.34.0) · Repo · Changelog

Release Notes

3.34.0

  • Allow with(query: :any) to match any query string (#1099)

    stub_request(:get, "www.example.com").with(query: :any) matches requests with any query string, or none. RSpec's anything works the same way. Previously, this raised NoMethodError, and you had to write with(query: hash_including({})).

    Use a URL without query parameters when passing query: :any. Otherwise, WebMock raises ArgumentError.

    Thanks to nightpool

  • Raise a clear ArgumentError for an unsupported query option

    Previously, a value such as with(query: :all) raised NoMethodError (undefined method split). The new error lists the supported values.

  • Show anything for keys given without a value to hash_including or hash_excluding outside RSpec

    Previously, with Minitest or Test::Unit, messages showed #<WebMock::Matchers::AnyArgMatcher:0x...>, for example for with(query: hash_including(:a)). RSpec's own matchers already showed anything.

  • Provide HTTP_HOST to to_rack apps when the client has not supplied a Host header (#1084)

    Previously, requests from some HTTP clients reached the Rack app without HTTP_HOST. This caused host checks such as Sinatra's HostAuthorization to see an empty host.

    WebMock now fills in the host from the request URL, including the port when it is not the default. An explicit Host header is preserved.

    Thanks to Benoit Tigeot

  • Fix Rack compatibility for to_rack apps

    The request environment now passes Rack::Lint.

    SERVER_PORT and CONTENT_LENGTH are now strings. If your app or tests read them directly, use string comparisons, such as env['SERVER_PORT'] == "80". The environment also includes SERVER_PROTOCOL.

    CONTENT_TYPE is omitted when the request has no content type. The Content-Length header is passed only as CONTENT_LENGTH, without an extra HTTP_CONTENT_LENGTH entry. Transfer-Encoding is removed because the body has already been decoded.

    Repeated header values are joined into one string. Header values and the body read from rack.input now use binary (ASCII-8BIT) strings.

3.33.0

  • Return effective_url as a String for stubbed Typhoeus responses (#869)

    Previously, this was an Addressable::URI. If your code calls methods such as effective_url.host, parse the returned string into a URI first.

    The URL keeps the request's port, query order and encoding. It follows curl's formatting: for example, http://example.com:80 becomes http://example.com:80/. Stubbed timeouts now provide an effective_url too.

    Thanks to Tom Brammar

  • Fix incorrect removal of default ports from displayed URLs

    WebMock could accidentally remove :80 or :443 from a URL's path or query. For example, an error message could show /foo/bar instead of /foo:80/bar.

    Only the host's default port is now removed. This also works when the port is immediately followed by a query string, as in http://example.com:80?a=b.

  • Set return_code to :ok for completed stubbed Typhoeus requests (#736)

    return_code is now :ok and return_message is now "No error"; both were previously nil. This includes HTTP error responses such as 404: :ok means the transfer completed. Stubbed timeouts still return :operation_timedout.

    Thanks to Michael Spiz

  • Fix the raw headers returned by stubbed Typhoeus responses

    The response_headers string now uses the stubbed HTTP status. For example, a 404 stub no longer reports HTTP/1.1 200 OK.

    Stubs without headers now return an empty headers hash ({}) instead of nil. Their response_headers contains the status line instead of being nil.

    The raw headers use binary string encoding, matching real responses. For timeouts, response_headers is now an empty string.

3.32.0

  • Make a Net::HTTP object created while WebMock was enabled behave like any other Net::HTTP object after WebMock.disable! (#1067)

    Such an object, like a connection cached by net-http-persistent or by Capybara with Selenium, used to raise ArgumentError on start or a stubbed request, and WebMock::NetConnectNotAllowedError on any other request, after WebMock was disabled. It now sends real requests until WebMock is enabled again.

    Thanks to Mike Taylor and James Rodovich

  • Connect again when a request is retried on a Net::HTTP object that WebMock started without connecting and whose first real connection failed

    Such a retry used to raise NoMethodError (undefined method closed? for nil). It now tries to connect again, and raises the connection error if that fails too.

  • Drop the Transfer-Encoding header from stubbed async-http responses, as WebMock already does with Content-Length (#1044)

    A stub with a Transfer-Encoding header, such as chunked, used to fail with "Message contains both transfer encoding and content length". async-http sets both headers itself from the body, and its responses from real servers don't include them either.

    Thanks to Tim Mertens

  • Record requests made with curb's http_patch as PATCH requests with their body (#1112)

    curb has http_patch since 1.0.8. WebMock recorded such a request as a GET, or as a POST after post_body=, so a PATCH stub never matched it.

    Thanks to Andy Williams

  • Record a curb request sent without a body as having none, even after an earlier http_post or http_patch call with a body on the same Curl::Easy object

    For example, after c.http_post("a=1"), c.reset and c.http(:POST), the second request was recorded with the body a=1, so a stub for that body matched it.

3.31.0

  • Return the contents of a File or Pathname body given to to_return_json, or returned by its body lambda, instead of encoding the object as a JSON string (#1119)

    The file is read and closed as it is for to_return: when the stub is declared, or on each request when it comes from a lambda.

    Thanks to Alex

  • Match HTTP methods given as a string or in upper case, as in stub_request("get", ...), a_request("GET", ...) or assert_requested("post", ...) (#821)

    Before, such a method never matched, so the stub never applied and negative expectations like assert_not_requested("get", ...) always passed. A test that passed only because of this can now fail.

    The method of a request is now always a lower case Symbol too. A request made with an upper case method, as Typhoeus does with method: :POST, now matches a :post stub, and callbacks and with blocks see :post.

    Thanks to Euisan Kim

3.30.0

  • Allow narrowing an RSpec expectation on a stub with with, as in expect(stub).to have_been_requested.once.with(body: "abc") (#1128)

    The expectation counts only the requests that match both the stub and the conditions given to with. The stub itself does not change.

    Thanks to Sébastien S.

  • Show the JSON body hint for expectations narrowed with with too, and no longer show it when a block is given to the stub or expectation, since checking would mean calling the block

  • Allow a full URL with a path in disable_net_connect!(allow: ...), as in allow: "https://github.com/mozilla/geckodriver/releases/latest" (#977)

    URLs are compared the same way as in stubs, so the default port, letter case in the host, and the order and encoding of query parameters don't matter. A URL without a path or query allows every path on that scheme, host and port; a trailing slash restricts requests to / with no query string. Credentials in either URL are ignored.

    Thanks to Henry Blyth

3.29.0

  • Show a body diff for JSON requests whose content type has a +json suffix, such as application/vnd.api+json, and for the other content types WebMock already matches as JSON (#734)

    Thanks to Olivier Brisse

  • Ignore the case of JSON, XML and url-encoded content types when matching request bodies, and match bodies of any +json or +xml media type, such as image/svg+xml, as JSON or XML

  • Suggest declaring a JSON body as a hash when a request fails to match only because the JSON is formatted differently (#649)

    A body declared as a string must match the request body exactly, including key order and whitespace. When that is the only difference, the error for an unregistered request and the failure message of a request expectation now say so, and suggest with(body: JSON.parse(json_string)). Matching JSON strings regardless of key order by default is planned for the next major version (#485).

3.28.0

  • Fix to_rack apps receiving a rack.session they did not set up (#985)

    WebMock used to add a session hash to the Rack env, shared by every request to the same stub. This confused apps that check whether a session is present, such as Rails API-only apps, and carried session data over between requests. WebMock now leaves rack.session and rack.session.options unset, as a real server does. If your app needs a session, include session middleware in the app you pass to to_rack. RackResponse#session and RackResponse#session_options have been removed.

    Thanks to Jan Graichen

  • Fix crash when matching a hash body pattern against a JSON or XML request that has no body

    Thanks to Chris

  • No longer warn about curb versions newer than the last one tested

  • Document regexp values in hash_including

    Thanks to Christian Bruckmayer

  • Remove unused RequestSignatureSnippet#request_params

    Thanks to Daniel Pepper

3.27.0

  • Fix crash in async-http adapter when a request header has a nil value

    Thanks to hikmetba-bit

  • The async-http adapter now matches stubs against raw request header values instead of values parsed by protocol-http, consistent with the other adapters

  • Add RSpec hash_excluding support to body matching

    Thanks to Chris Gunther

  • Fix hash_excluding ignoring keys given without a value and regexp values, in both query and body matching

  • Fix crash when matching a request that has more than one Content-Type header

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by 72 commits:


Depfu Status

Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with @depfu rebase.

All Depfu comment commands
@​depfu rebase
Rebases against your default branch and redoes this update
@​depfu recreate
Recreates this PR, overwriting any edits that you've made to it
@​depfu merge
Merges this PR once your tests are passing and conflicts are resolved
@​depfu cancel merge
Cancels automatic merging of this PR
@​depfu close
Closes this PR and deletes the branch
@​depfu reopen
Restores the branch and reopens this PR (if it's closed)
@​depfu pause
Ignores all future updates for this dependency and closes this PR
@​depfu pause [minor|major]
Ignores all future minor/major updates for this dependency and closes this PR
@​depfu resume
Future versions of this dependency will create PRs again (leaves this PR as is)

@depfu depfu Bot added the depfu label Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants