Repository navigation
-
Add
executed_requeststo inspect the requests made (#1069)WebMock.executed_requestsreturns every request made since the last reset, in order, including repeated ones. You can assert on each one's body or headers, for exampleJSON.parse(WebMock.executed_requests.last.body).Previously, this needed WebMock internals such as
WebMock::RequestRegistry.instance.requested_signatures.hash.keys, which list each distinct request only once.Thanks to John Gallagher for the idea, which we started pairing on at EuRuKo 2024 in Sarajevo.
-
Fix stub matching for consecutive Curb PUT requests on the same handle
After
curl.http_put("first"), WebMock could match a subsequentcurl.http_putagainst the previous body. It now matches the second request with an empty body. -
Run HTTPClient request filters once per attempt on real requests
Previously, WebMock could run a filter twice, so a filter that generated a request ID could send a different ID to the server than the one WebMock recorded.
-
Fix async HTTPClient requests hanging when an
after_requestcallback is registeredPreviously, with real connections allowed, WebMock read the response body for the callback from the same stream as your code, so reading part of a
get_asyncresponse before callingjoincould hang. -
Match file and stream uploads by their content
Previously, a body pattern such as
with(body: "abc")never matched a Curb, Patron or em-http-request request that uploaded a file or stream, because WebMock compared the pattern with the file object. Stubs now compare it with the uploaded bytes for Curb and Patron, andassert_requesteddoes so for all three.Blocks given to
stub_request(...).withstill receive the original file or stream. -
Count em-http-request requests blocked by
disable_net_connect!Previously, WebMock did not record them, so
assert_requesteddid not count them. They are now counted, as with other HTTP clients.