Repository navigation
chore(deps): update dependency webmock to v4 - #46
Open
renovate[bot] wants to merge 1 commit into
Open
renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #46 +/- ##
=======================================
Coverage 71.79% 71.79%
=======================================
Files 1 1
Lines 78 78
=======================================
Hits 56 56
Misses 22 22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
'~> 3.0'→'~> 4.0'Release Notes
bblimke/webmock (webmock)
v4.0.0Compare Source
4.0 requires Ruby 3.0 or later. Its other changes fix behaviour that was wrong in 3.x, so a spec fails only if it passed because of one of them. A typical test suite needs no changes: a stub such as
stub_request(:get, url).to_return(body: "ok")works as before, a request that sends{id: 1}.to_jsonstill matcheswith(body: {id: 1}), and VCR records and replays as before.Breaking change
Fixes that can fail a spec
Stubs that didn't do what they said now fail where they are declared. A bare
to_returncrashed on the first matching request,to_raise(:timeout)returned a 200 instead of raising, andto_return(status: 404) { ... }dropped the status. These now raiseArgumentError.Request bodies that aren't valid JSON no longer match a hash pattern. A request that sent
{a: 1}as JSON matchedwith(body: {a: 1}), although a real server would reject it. JSON fromto_jsonisn't affected. Before upgrading, run your specs on 3.42.0 and fix any JSON body warnings it prints.Real Net::HTTP requests behave as without WebMock. This only matters if your specs make real requests through Net::HTTP that aren't stubbed or recorded with VCR. The block given to
requestnow gets the response while Net::HTTP reads it, instead of after WebMock has read all of it.Statuses such as
:okstill print the deprecation warning added in 3.39.0, rather than raising. Use a number, such as200.If a spec fails
Stub declarations
to_return, or give it a response, such asto_return(status: 200).to_returnandto_return_jsonwith no arguments, an empty list or empty**optionsraiseArgumentError, and so does anilresponse, which raisedNoMethodErrorbefore.to_raisean exception class, an exception or a message, such asto_raise(StandardError). Useto_timeoutfor a timeout.to_returneither responses or a block, such asto_return { |request| {status: 404, body: "x"} }.The same checks apply to
and_return,and_return_jsonandand_raise.Thanks to Daniel Pepper
JSON request bodies (#432)
3.41.0 started reading JSON request bodies with
JSON.parse, and fell back to WebMock's old JSON parser with a deprecation warning. 4.0 drops the old parser, so a body declared as a hash, an array,hash_includingorhash_excludingno longer matches:{a: 1}or{'a': 1}. Send{a: 1}.to_jsoninstead.{"amount":1e+20}matches{amount: 1e20}, not{amount: "1e+20"}.A lambda or matcher in a body pattern now gets only the value
JSON.parsereturns, such as the Float1.0e+20. One that calls a String method on it, such asstart_with?, raisesNoMethodError, which fails the request even when another stub would match. 3.42.0 warns about such a lambda only when the old reading matched.When the only reason a stub doesn't match is that the request body isn't valid JSON, the failure message now says so and quotes the parser's error, unless body diffs are hidden with
WebMock.hide_body_diff!.Real Net::HTTP requests (#742)
Previously, with real requests allowed, WebMock read the whole response before calling the block given to
request. Soresponse.read_body { |chunk| ... }got the body in one piece, andresponse.decode_content = truein the block left a gzip body compressed. Now the block gets the response while Net::HTTP reads it, as without WebMock, unless anafter_requestcallback for Net::HTTP, such as VCR's, needs the whole body first. A callback registered withexcept: [:net_http]doesn't.Code that relied on WebMock reading the body first can now fail, as it does without WebMock:
read_bodywith a block, called after a request made with a block has returned, raisesIOError. Call it inside the block.http.getwithout a block of your own, since it passes one torequest. The net-http versions in Ruby 3.3 and earlier retry a GET and run the block again, even when the block raisedIOError.Configuration
📅 Schedule: (UTC)
* 0-3 * * 1)🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.