deps(ruby): bump webmock from 3.34.0 to 3.36.0 in /ruby in the bundler-dependencies group
Bumps the bundler-dependencies group in /ruby with 1 update: webmock.
Updates webmock from 3.34.0 to 3.36.0
Release notes
Sourced from webmock's releases.
3.36.0
Fix matching of indexed arrays nested inside arrays of hashes (#1144)
Previously, WebMock read indexed arrays nested inside an array of hashes, such as
a[][b][0][c]=1, as hashes with"0","1"keys. WebMock writes that form itself, sowith(query: {"a" => [{"b" => [{"c" => "1"}]}]})with a regexp URI did not match?a[][b][][c]=1, and a Typhoeus request with that hash as its body did not match a stub with the same hash.If a stub uses the old shape, such as
{"a" => [{"b" => {"0" => {"c" => "1"}}}]}, for example one copied from WebMock's suggested stub, use arrays instead.Thanks to Hamza Tarar
Fix matching of arrays of hashes that repeat a nested key
Previously, WebMock put a nested key repeated under
[]into the first hash of the array, soitems[][address][city]=X&items[][address][city]=Ywas read as one item with the cityY. A stub listing both items did not match, and a stub forXandYalso matched a request forZandY. Rails and Faraday encode arrays of nested hashes this way.Such keys now go into a new hash, as in Rack. If a stub lists such an array as one item, for example one copied from WebMock's suggested stub, list every item.
Queries that mix a value and nested keys under the same name, such as
a[][b]=1&a[][b][c]=2ora[c]=1&a[c][]=2, no longer raiseIndexErroror join the values into one string.Apply Net::HTTP
response_body_encodingto stubbed response bodies (#1138)Previously, stubbed Net::HTTP responses ignored
Net::HTTP#response_body_encoding=andNet::HTTPResponse#body_encoding=. A body stubbed as binary, for example from a raw response file, stayedASCII-8BITeven withhttp.response_body_encoding = trueand aContent-Typeoftext/plain; charset=utf-8.Stubbed bodies now get the encoding real responses get: with
true, the charset from theContent-Typeheader or an HTML<meta>tag, and otherwise the encoding the setting names. Without the setting, a body keeps the encoding it was stubbed with.Thanks to Yang Bai
Give each stubbed Net::HTTP response its own copy of the body
Previously, a stubbed Net::HTTP response returned the stubbed body string itself. A body stubbed with a frozen string, such as a literal in a file with
# frozen_string_literal: true, maderesponse.body.force_encoding("UTF-8")raiseFrozenError, which a real response never does. Changing the body in place, for example withresponse.body << "!", changed it for later requests to the same stub too.Keep the size of async-http responses to HEAD requests (#1143)
async-http gives the size of a response to a HEAD request as
response.body.length, not as a header. Previously, a response stubbed withstub_request(:head, url).to_return(headers: {"Content-Length" => "42"})ignored theContent-Length: its body wasnilover HTTP/1 and had a length of 0 over HTTP/2. A real response lost its size, with anilbody, when aWebMock.after_requestcallback was registered, for example while VCR was recording, and the recorded response had noContent-Length.A stubbed response now takes its size from the stubbed
Content-Length, or from the stubbed body without one, as before. A real response keeps its size when a callback is registered, and the recorded response has it as itsContent-Length.Thanks to Andrew K. Fader
Keep the URI query of HTTPClient requests that pass a query argument (#1145)
Previously, WebMock dropped the query in the URI when an HTTPClient request also passed the query argument.
HTTPClient.new.get("http://example.com/?a=1", {"b" => "2"})requests/?a=1&b=2, but WebMock saw/?b=2, and with{}as the query argument it saw no query at all. A stub ora_requestexpectation could match a URL that was never requested.If a stub or expectation for such a request leaves out the query in the URI, add it, for example
stub_request(:get, "http://example.com/?a=1&b=2"). Record VCR cassettes with such requests again.Thanks to AmeenKhan12345
3.35.0
Fix
get_filewith Patron 1.1 (#1147)Previously, with Patron 1.1,
get_fileignored stubs: it made a real request and wrote the real response to the file, even when real connections were disabled.
... (truncated)
Changelog
Sourced from webmock's changelog.
3.36.0
Fix matching of indexed arrays nested inside arrays of hashes (#1144)
Previously, WebMock read indexed arrays nested inside an array of hashes, such as
a[][b][0][c]=1, as hashes with"0","1"keys. WebMock writes that form itself, sowith(query: {"a" => [{"b" => [{"c" => "1"}]}]})with a regexp URI did not match?a[][b][][c]=1, and a Typhoeus request with that hash as its body did not match a stub with the same hash.If a stub uses the old shape, such as
{"a" => [{"b" => {"0" => {"c" => "1"}}}]}, for example one copied from WebMock's suggested stub, use arrays instead.Thanks to Hamza Tarar
Fix matching of arrays of hashes that repeat a nested key
Previously, WebMock put a nested key repeated under
[]into the first hash of the array, soitems[][address][city]=X&items[][address][city]=Ywas read as one item with the cityY. A stub listing both items did not match, and a stub forXandYalso matched a request forZandY. Rails and Faraday encode arrays of nested hashes this way.Such keys now go into a new hash, as in Rack. If a stub lists such an array as one item, for example one copied from WebMock's suggested stub, list every item.
Queries that mix a value and nested keys under the same name, such as
a[][b]=1&a[][b][c]=2ora[c]=1&a[c][]=2, no longer raiseIndexErroror join the values into one string.Apply Net::HTTP
response_body_encodingto stubbed response bodies (#1138)Previously, stubbed Net::HTTP responses ignored
Net::HTTP#response_body_encoding=andNet::HTTPResponse#body_encoding=. A body stubbed as binary, for example from a raw response file, stayedASCII-8BITeven withhttp.response_body_encoding = trueand aContent-Typeoftext/plain; charset=utf-8.Stubbed bodies now get the encoding real responses get: with
true, the charset from theContent-Typeheader or an HTML<meta>tag, and otherwise the encoding the setting names. Without the setting, a body keeps the encoding it was stubbed with.Thanks to Yang Bai
Give each stubbed Net::HTTP response its own copy of the body
Previously, a stubbed Net::HTTP response returned the stubbed body string itself. A body stubbed with a frozen string, such as a literal in a file with
# frozen_string_literal: true, maderesponse.body.force_encoding("UTF-8")raiseFrozenError, which a real response never does. Changing the body in place, for example withresponse.body << "!", changed it for later requests to the same stub too.Keep the size of async-http responses to HEAD requests (#1143)
async-http gives the size of a response to a HEAD request as
response.body.length, not as a header. Previously, a response stubbed withstub_request(:head, url).to_return(headers: {"Content-Length" => "42"})ignored theContent-Length: its body wasnilover HTTP/1 and had a length of 0 over HTTP/2. A real response lost its size, with anilbody, when aWebMock.after_requestcallback was registered, for example while VCR was recording, and the recorded response had noContent-Length.A stubbed response now takes its size from the stubbed
Content-Length, or from the stubbed body without one, as before. A real response keeps its size when a callback is registered, and the recorded response has it as itsContent-Length.Thanks to Andrew K. Fader
Keep the URI query of HTTPClient requests that pass a query argument (#1145)
Previously, WebMock dropped the query in the URI when an HTTPClient request also passed the query argument.
HTTPClient.new.get("http://example.com/?a=1", {"b" => "2"})requests/?a=1&b=2, but WebMock saw/?b=2, and with{}as the query argument it saw no query at all. A stub ora_requestexpectation could match a URL that was never requested.If a stub or expectation for such a request leaves out the query in the URI, add it, for example
stub_request(:get, "http://example.com/?a=1&b=2"). Record VCR cassettes with such requests again.Thanks to AmeenKhan12345
3.35.0
- Fix
get_filewith Patron 1.1 (#1147)
... (truncated)
Commits
a9a6fc0Version 3.36.0622fbf0Tidy #1145 and document it4bd2170Merge pull request #1145 from AmeenKhan12345/fix-httpclient-uri-query-dropped18c1092Tidy #1143, keep the size of every real HEAD responsee06de88Merge pull request #1143 from andrewfader/async-http-head-content-length27cd96fTidy #1138, apply the encoding once and copy stubbed bodies14defa9Merge pull request #1138 from ybai08/net-http-response-body-encodingb55c6c8Merge pull request #1146 from sporkmonger/net-http-start-host-name62bf051Start a new hash when a nested key repeats under []d8a27e9Tidy #1144 and document it- Additional commits viewable in compare view
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebasewill rebase this PR@dependabot recreatewill recreate this PR, overwriting any edits that have been made to it@dependabot show <dependency name> ignore conditionswill show all of the ignore conditions of the specified dependency@dependabot ignore <dependency name> major versionwill close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself)@dependabot ignore <dependency name> minor versionwill close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself)@dependabot ignore <dependency name>will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself)@dependabot unignore <dependency name>will remove all of the ignore conditions of the specified dependency@dependabot unignore <dependency name> <ignore condition>will remove the ignore condition of the specified dependency and ignore conditions
Summary by cubic
Bumps webmock from 3.34.0 to 3.36.0 in the Ruby tests along with its transitive dependencies addressable and hashdiff.
This minor update includes several behavior fixes around query and body matching, Net::HTTP response encoding, and HTTPClient URI handling. Most notably:
- Arrays of hashes with repeated nested keys now match as separate items (compatible with Rails/Faraday encoding); stubs that previously matched incorrectly may need to be updated.
Net::HTTP#response_body_encodingis now applied to stubbed response bodies.- Each stubbed Net::HTTP response gets its own copy of the body, preventing mutations from leaking across requests.
- HTTPClient requests that pass a query argument no longer lose the query from the URI.
No changes to our test suite should be required unless stubs relied on the old query or body matching behavior.