webmock 3.42.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bff4bef02b737edabff51c5a68f52b06ad2ee9b5280f11fd0b97ed93b85d13d
4
- data.tar.gz: c9e3641f5610080b0c8968e2d8169b25ff0f78df0880e5ea07355fbc96012add
3
+ metadata.gz: 4919cd5204cf89c2d30230526f0dd658326182c16ea82174c88bfb0adce3748e
4
+ data.tar.gz: aaddb1abbddaf3f9c6fff1ee15a30c4eddf0bd4eafe6a370b1dc2ec7509b4339
5
5
  SHA512:
6
- metadata.gz: 511313f001e32b777eacaf1666b51775f0690c63fc61551f12835dc55c3be54490c8111f21eaa3a4f772a3b26fed1a2f349bd39f352b6014d5509511c25681f5
7
- data.tar.gz: a3623cc22f1c9719739fd3a804546acc619ef2a04624f343d162fbcb1ba49db5a3399a619fb5c6e0ae2842ab6f52e1d4e1a5affe366fa7ffa42149403bbf7063
6
+ metadata.gz: cd641f8e94aac2eb9fb0e5305a1f375c871e78138c33f711a508bd07016571adb4b112e4d05c193524d0081d459273aca4153a47b1396ff9b53a6b7197d43b0d
7
+ data.tar.gz: 94816f0976ab5d05b283b081b77734c566ea5b4f42ac221893493a0012a0bcafcfa0c9493220f319ff305079df352a9bced0efd9d3347c5d34e73d2b26c690eb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,74 @@
1
1
  # Changelog
2
2
 
3
+ # 4.1.0
4
+
5
+ * Match request headers with `hash_including` and `hash_excluding` (#942)
6
+
7
+ `with(headers: hash_including("Authorization"))` now matches any request with an Authorization header. Use `hash_excluding("Authorization")` to match requests without that header. Both WebMock's and RSpec's matchers work here. Previously, using either matcher raised `NoMethodError`.
8
+
9
+ Header names follow the same rules as in a plain header hash. Ordinary values such as strings and numbers compare as text. You can also match a value with a regexp, for example `hash_including("Authorization" => /^Bearer /)`, or with another matcher that implements `===`.
10
+
11
+ For repeated headers, supply an array of strings. Combining a header matcher with `basic_auth` raises `ArgumentError`. To match basic authentication, include the expected Authorization header value in `hash_including`.
12
+
13
+ * Match raw multipart request bodies (#623)
14
+
15
+ You can now match an uploaded filename with `with(body: /filename="report\.pdf"/)`, even when the file contains binary data. A regexp can match part of the raw multipart body. A string matches the entire body byte for byte. A lambda receives the raw body.
16
+
17
+ WebMock still doesn't parse multipart form fields, so using a hash, an array, `hash_including` or `hash_excluding` as a multipart body pattern raises `ArgumentError`.
18
+
19
+ Net::HTTP forms sent with `set_form` are recorded without a body, so any body pattern raises `ArgumentError` for those requests. Typhoeus and Curb pass WebMock the form fields, so patterns that expect the raw multipart body won't match.
20
+
21
+ # 4.0.0
22
+
23
+ 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_json` still matches `with(body: {id: 1})`, and VCR records and replays as before.
24
+
25
+ ## Breaking change
26
+
27
+ * **Ruby 3.0 or later, and crack 0.4.6 or later.** On Ruby 2.6 and 2.7, Bundler keeps installing WebMock 3.x. On JRuby, 4.0 needs JRuby 9.4 or later. If your Gemfile pins crack below 0.4.6, loosen the pin.
28
+
29
+ ## Fixes that can fail a spec
30
+
31
+ * **Stubs that didn't do what they said now fail where they are declared.** A bare `to_return` crashed on the first matching request, `to_raise(:timeout)` returned a 200 instead of raising, and `to_return(status: 404) { ... }` dropped the status. These now raise `ArgumentError`.
32
+
33
+ * **Request bodies that aren't valid JSON no longer match a hash pattern.** A request that sent `{a: 1}` as JSON matched `with(body: {a: 1})`, although a real server would reject it. JSON from `to_json` isn't affected. Before upgrading, run your specs on 3.42.0 and fix any JSON body warnings it prints.
34
+
35
+ * **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 `request` now gets the response while Net::HTTP reads it, instead of after WebMock has read all of it.
36
+
37
+ Statuses such as `:ok` still print the deprecation warning added in 3.39.0, rather than raising. Use a number, such as `200`.
38
+
39
+ ## If a spec fails
40
+
41
+ ### Stub declarations
42
+
43
+ * For an empty 200 response, leave off a bare `to_return`, or give it a response, such as `to_return(status: 200)`. `to_return` and `to_return_json` with no arguments, an empty list or empty `**options` raise `ArgumentError`, and so does a `nil` response, which raised `NoMethodError` before.
44
+ * Give `to_raise` an exception class, an exception or a message, such as `to_raise(StandardError)`. Use `to_timeout` for a timeout.
45
+ * Give `to_return` either responses or a block, such as `to_return { |request| {status: 404, body: "x"} }`.
46
+
47
+ The same checks apply to `and_return`, `and_return_json` and `and_raise`.
48
+
49
+ Thanks to [Daniel Pepper](https://github.com/dpep)
50
+
51
+ ### JSON request bodies (#432)
52
+
53
+ 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_including` or `hash_excluding` no longer matches:
54
+
55
+ * a request body that isn't valid JSON, such as `{a: 1}` or `{'a': 1}`. Send `{a: 1}.to_json` instead.
56
+ * a value the old parser read differently. The body `{"amount":1e+20}` matches `{amount: 1e20}`, not `{amount: "1e+20"}`.
57
+
58
+ A lambda or matcher in a body pattern now gets only the value `JSON.parse` returns, such as the Float `1.0e+20`. One that calls a String method on it, such as `start_with?`, raises `NoMethodError`, which fails the request even when another stub would match. 3.42.0 warns about such a lambda only when the old reading matched.
59
+
60
+ 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!`.
61
+
62
+ ### Real Net::HTTP requests (#742)
63
+
64
+ Previously, with real requests allowed, WebMock read the whole response before calling the block given to `request`. So `response.read_body { |chunk| ... }` got the body in one piece, and `response.decode_content = true` in the block left a gzip body compressed. Now the block gets the response while Net::HTTP reads it, as without WebMock, unless an `after_request` callback for Net::HTTP, such as VCR's, needs the whole body first. A callback registered with `except: [:net_http]` doesn't.
65
+
66
+ Code that relied on WebMock reading the body first can now fail, as it does without WebMock:
67
+
68
+ * Another request on the same connection, sent inside the block or after breaking out of it before the body is read, can fail. Send it after the block returns, or on another connection.
69
+ * `read_body` with a block, called after a request made with a block has returned, raises `IOError`. Call it inside the block.
70
+ * When the connection drops while the body is read, the net-http versions in Ruby 3.4 and later raise instead of retrying. That includes `http.get` without a block of your own, since it passes one to `request`. The net-http versions in Ruby 3.3 and earlier retry a GET and run the block again, even when the block raised `IOError`.
71
+
3
72
  # 3.42.0
4
73
 
5
74
  * Fix VCR failing to replay responses recorded with the `auto_inflate` feature of the `http` gem (#1154)
@@ -44,7 +113,7 @@ WebMock now parses JSON request bodies with Ruby's `JSON.parse`, instead of its
44
113
 
45
114
  * Name a future major version in the deprecation warning for statuses such as `:ok`
46
115
 
47
- The deprecation warning for a status such as `:ok`, added in 3.38.0, said that WebMock 4.0 would raise `ArgumentError` for it. 4.0 changes how JSON request bodies are read and doesn't change statuses yet, so the warning now names a future major version.
116
+ The deprecation warning for a status such as `:ok`, added in 3.39.0, said that WebMock 4.0 would raise `ArgumentError` for it. 4.0 changes how JSON request bodies are read and doesn't change statuses yet, so the warning now names a future major version.
48
117
 
49
118
  # 3.40.0
50
119
 
data/README.md CHANGED
@@ -38,15 +38,13 @@ Supported HTTP libraries
38
38
 
39
39
  Supported Ruby Interpreters
40
40
  ---------------------------
41
- * MRI 2.6
42
- * MRI 2.7
43
41
  * MRI 3.0
44
42
  * MRI 3.1
45
43
  * MRI 3.2
46
44
  * MRI 3.3
47
45
  * MRI 3.4
48
46
  * MRI 4.0
49
- * JRuby
47
+ * JRuby 9.4 or later
50
48
 
51
49
  ## Installation
52
50
 
@@ -277,6 +275,18 @@ req.add_field('Accept', 'image/jpeg')
277
275
  Net::HTTP.start("www.example.com") {|http| http.request(req) } # ===> Success
278
276
  ```
279
277
 
278
+ ### Matching headers with hash_including or hash_excluding
279
+
280
+ A header given without a value matches any value.
281
+
282
+ ```ruby
283
+ stub_request(:get, "www.example.com").
284
+ with(headers: hash_including("Authorization"))
285
+
286
+ stub_request(:get, "www.example.com").
287
+ with(headers: hash_excluding("Authorization")) # requests without an Authorization header
288
+ ```
289
+
280
290
  ### Matching requests against provided block
281
291
 
282
292
  ```ruby
@@ -1160,6 +1170,10 @@ WebMock.after_request(except: [:patron],
1160
1170
  end
1161
1171
  ```
1162
1172
 
1173
+ #### Callbacks and Net::HTTP streaming
1174
+
1175
+ A callback that runs for real Net::HTTP requests makes WebMock read the whole response body before it calls the block given to `request`, so the callback gets all of it. Without such a callback, the block gets the response while Net::HTTP reads it, as without WebMock, so it can read the body in chunks. WebMock decides this when the request is sent, so a callback registered while a request with a block is in flight doesn't get that response. Callbacks stay registered across tests, so one added in an earlier test turns streaming off in later tests too. To keep a callback away from Net::HTTP, register it with `except: [:net_http]`.
1176
+
1163
1177
  #### Removing callbacks
1164
1178
 
1165
1179
  Callbacks stay registered after `WebMock.reset!`, so a callback added in one test keeps running in later ones. To remove all callbacks, call:
@@ -15,16 +15,23 @@ module WebMock
15
15
  def self.invoke_callbacks(options, request_signature, response)
16
16
  return if @@callbacks.empty?
17
17
  CallbackRegistry.callbacks.each do |callback|
18
- except = callback[:options][:except]
19
- real_only = callback[:options][:real_requests_only]
20
- unless except && except.include?(options[:lib])
21
- if !real_only || options[:real_request]
22
- callback[:block].call(request_signature, response)
23
- end
24
- end
18
+ callback[:block].call(request_signature, response) if runs_for?(callback, options)
25
19
  end
26
20
  end
27
21
 
22
+ # Whether invoke_callbacks would run any callback for a request with
23
+ # these options, given each callback's except and real_requests_only.
24
+ def self.any_callbacks_for?(options)
25
+ @@callbacks.any? { |callback| runs_for?(callback, options) }
26
+ end
27
+
28
+ def self.runs_for?(callback, options)
29
+ except = callback[:options][:except]
30
+ real_only = callback[:options][:real_requests_only]
31
+ !(except && except.include?(options[:lib])) && (!real_only || options[:real_request])
32
+ end
33
+ private_class_method :runs_for?
34
+
28
35
  def self.reset
29
36
  @@callbacks = []
30
37
  end
@@ -7,13 +7,7 @@ rescue LoadError
7
7
  end
8
8
 
9
9
  if defined?(Curl)
10
- unsupported_curb_versions = ['0.8.7']
11
-
12
- # Curl::Easy#perform raises "cannot define finalizer for TrueClass" on Ruby 2.6
13
- # in curb 1.3.0 through 1.3.5. Fixed in curb 1.3.6. See https://github.com/taf2/curb/issues/478
14
- unsupported_curb_versions += %w[1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5] if RUBY_VERSION < '2.7'
15
-
16
- WebMock::VersionChecker.new('Curb', Curl::CURB_VERSION, '0.7.16', nil, unsupported_curb_versions).check_version!
10
+ WebMock::VersionChecker.new('Curb', Curl::CURB_VERSION, '0.7.16', nil, ['0.8.7']).check_version!
17
11
 
18
12
  module WebMock
19
13
  module HttpLibAdapters
@@ -111,11 +111,21 @@ module WebMock
111
111
  build_net_http_response(webmock_response, request.uri, &block)
112
112
  elsif WebMock.net_connect_allowed?(request_signature.uri)
113
113
  check_right_http_connection
114
+ callback_options = {lib: :net_http, real_request: true}
115
+ # Without callbacks for this request, nothing needs the body
116
+ # before the block, so the block gets the response while
117
+ # Net::HTTP reads it, as without WebMock, and can stream the
118
+ # body or set decode_content. With callbacks, such as VCR's,
119
+ # the body is read first, so they get all of it.
120
+ stream = block && !WebMock::CallbackRegistry.any_callbacks_for?(callback_options)
114
121
  after_request = lambda do |response|
115
- if WebMock::CallbackRegistry.any_callbacks?
122
+ # Checked again, so that callbacks registered while the
123
+ # request was made get the response too, as before. A request
124
+ # that streams to its block doesn't come here, so callbacks
125
+ # registered after it was sent don't get its response.
126
+ if WebMock::CallbackRegistry.any_callbacks_for?(callback_options)
116
127
  webmock_response = build_webmock_response(response)
117
- WebMock::CallbackRegistry.invoke_callbacks(
118
- {lib: :net_http, real_request: true}, request_signature, webmock_response)
128
+ WebMock::CallbackRegistry.invoke_callbacks(callback_options, request_signature, webmock_response)
119
129
  end
120
130
  response.extend Net::WebMockHTTPResponse
121
131
  # Net::HTTP has read the body and applied its encoding already
@@ -123,16 +133,17 @@ module WebMock
123
133
  block.call response if block
124
134
  response
125
135
  end
126
- super_with_after_request = lambda {
127
- response = super(request, nil, &nil)
128
- after_request.call(response)
136
+ real_request = lambda {
137
+ next super(request, nil, &block) if stream
138
+
139
+ after_request.call(super(request, nil, &nil))
129
140
  }
130
141
  if started?
131
142
  ensure_actual_connection
132
- super_with_after_request.call
143
+ real_request.call
133
144
  else
134
145
  start_with_connect {
135
- super_with_after_request.call
146
+ real_request.call
136
147
  }
137
148
  end
138
149
  else
@@ -3,10 +3,21 @@
3
3
  require "json"
4
4
 
5
5
  module WebMock
6
+ # Hints in failure messages about JSON request bodies.
7
+ #
6
8
  # A body declared as a string must match the request body exactly, which for
7
9
  # JSON includes key order and whitespace. When a request fails to match only
8
10
  # because of that, failure messages suggest declaring the body as a hash.
9
11
  # See #485.
12
+ #
13
+ # A body declared as a hash, an array, hash_including or hash_excluding is
14
+ # matched against the body as JSON.parse reads it, unless it matches any
15
+ # body, as {} does, while WebMock 3.x also read some invalid JSON, such as
16
+ # {a: 1}. When a request fails to match only because its body isn't valid
17
+ # JSON, failure messages say so.
18
+ #
19
+ # A hint is extra, so an error while working one out, for example from a
20
+ # header pattern, means no hint rather than a broken failure message.
10
21
  module JsonBodyHint
11
22
  ADVICE = "A body declared as a string must match exactly. To match it as JSON, " \
12
23
  "declare it as a hash, for example with(body: JSON.parse(json_string))."
@@ -17,6 +28,20 @@ module WebMock
17
28
  EXPECTATION_HINT = "Hint: a request was made with the same JSON body as expected, " \
18
29
  "but formatted differently, for example with keys in another order. #{ADVICE}"
19
30
 
31
+ INVALID_JSON_ADVICE = "WebMock 4.0 and later read JSON request bodies only with JSON.parse, " \
32
+ "while earlier versions also matched some bodies that aren't valid JSON, such as {a: 1}."
33
+
34
+ BYTE_ORDER_MARK = [0xEF, 0xBB, 0xBF].pack("C*").freeze
35
+ private_constant :BYTE_ORDER_MARK
36
+
37
+ # %s is the parser's error.
38
+ INVALID_JSON_HINTS = {
39
+ stub: "Hint: the request body isn't valid JSON (%s), so a stub above with a body declared as " \
40
+ "a hash, an array, hash_including or hash_excluding can't match it. #{INVALID_JSON_ADVICE}",
41
+ expectation: "Hint: a request was made with a body that isn't valid JSON (%s), " \
42
+ "so it can't match the expected body. #{INVALID_JSON_ADVICE}"
43
+ }.freeze
44
+
20
45
  # True when one of the patterns declares its body as a JSON object or array
21
46
  # string, the request has a JSON content type and a body that parses to the
22
47
  # same JSON but is written differently, and the method, URI and headers of
@@ -31,14 +56,46 @@ module WebMock
31
56
  # The body is checked first, since that runs no user code, so URI and
32
57
  # header matchers are only evaluated when a hint is otherwise possible.
33
58
  def self.applies?(request_pattern, request_signature)
34
- patterns = parts_of(request_pattern)
35
- return false unless patterns.all? { |pattern| pattern.is_a?(RequestPattern) && pattern.with_block.nil? }
36
-
37
- with_body = patterns.select(&:body_pattern)
38
- return false unless with_body.size == 1
39
- return false unless body_differs_only_in_formatting?(with_body.first.body_pattern, request_signature)
59
+ patterns, body_pattern = body_pattern_of(request_pattern)
60
+ return false unless body_pattern && body_differs_only_in_formatting?(body_pattern, request_signature)
40
61
 
41
62
  patterns.all? { |pattern| matches_except_body?(pattern, request_signature) }
63
+ rescue StandardError
64
+ false
65
+ end
66
+
67
+ # The hint for an expected request that didn't match: that the JSON is
68
+ # formatted differently, or that the body isn't valid JSON. At most one of
69
+ # them fits, since one needs a body declared as a string and the other a
70
+ # hash, an array, hash_including or hash_excluding.
71
+ def self.expectation_hint(request_pattern, request_signature)
72
+ return EXPECTATION_HINT if applies?(request_pattern, request_signature)
73
+
74
+ invalid_json_hint([request_pattern], request_signature, :expectation)
75
+ end
76
+
77
+ # The hint, for kind :stub or :expectation, when the request body isn't
78
+ # valid JSON and that is the only reason one of the patterns doesn't
79
+ # match: it declares its body as a hash, an array, hash_including or
80
+ # hash_excluding, which doesn't match a body that doesn't parse, and the
81
+ # method, URI and headers of all of its parts match the request. The
82
+ # body is parsed at most once, and only when a pattern could get the hint.
83
+ def self.invalid_json_hint(request_patterns, request_signature, kind)
84
+ candidates = request_patterns.filter_map { |request_pattern| body_pattern_of(request_pattern) }
85
+ # Method patterns run no user code, so they can rule out patterns
86
+ # before the body is parsed.
87
+ candidates.select! do |patterns, body_pattern|
88
+ body_pattern.parses_body? && patterns.all? { |pattern| pattern.method_pattern.matches?(request_signature.method) }
89
+ end
90
+ return if candidates.empty? || !request_signature.json_headers?
91
+
92
+ # The body that a hash or array pattern reads, as in BodyPattern#matches?.
93
+ error = parse_error(request_signature.serialized_body || request_signature.body)
94
+ return unless error && candidates.any? { |patterns, body_pattern| fails_only_on_body?(patterns, body_pattern, request_signature) }
95
+
96
+ format(INVALID_JSON_HINTS.fetch(kind), short_error(error))
97
+ rescue StandardError
98
+ nil
42
99
  end
43
100
 
44
101
  # A pattern made of parts that must all match, such as an RSpec expectation
@@ -48,6 +105,17 @@ module WebMock
48
105
  parts.map { |part| part.is_a?(RequestStub) ? part.request_pattern : part }
49
106
  end
50
107
 
108
+ # The parts of the pattern and the body pattern of the only part that
109
+ # declares a body, or nil when none or several do, or when a part has a
110
+ # block given to with.
111
+ def self.body_pattern_of(request_pattern)
112
+ patterns = parts_of(request_pattern)
113
+ return unless patterns.all? { |pattern| pattern.is_a?(RequestPattern) && pattern.with_block.nil? }
114
+
115
+ with_body = patterns.select(&:body_pattern)
116
+ [patterns, with_body.first.body_pattern] if with_body.size == 1
117
+ end
118
+
51
119
  def self.body_differs_only_in_formatting?(body_pattern, request_signature)
52
120
  expected = body_pattern.pattern
53
121
  actual = request_signature.body
@@ -64,6 +132,41 @@ module WebMock
64
132
  expected_json.eql?(parse_json { WebMock::Util::Parsers::JSON.parse(actual) })
65
133
  end
66
134
 
135
+ # A body that doesn't parse reaches the body pattern as no body, so it is
136
+ # given none here: the body isn't parsed again, and no user code runs, as
137
+ # the pattern has nothing to compare its values with. Some patterns, such
138
+ # as hash_including({}), match any body, so they get no hint. A pattern
139
+ # that raises, for example a header regexp in an encoding that doesn't
140
+ # fit the request header, gets no hint, while the others still can.
141
+ def self.fails_only_on_body?(patterns, body_pattern, request_signature)
142
+ !body_pattern.matches?(nil, request_signature.content_type) &&
143
+ patterns.all? { |pattern| matches_except_body?(pattern, request_signature) }
144
+ rescue StandardError
145
+ false
146
+ end
147
+
148
+ # The parser's error, or nil when the body parses, is blank after a byte
149
+ # order mark, which the parser drops, or is nested deeper than WebMock
150
+ # reads. None of those is what the hint is about.
151
+ def self.parse_error(body)
152
+ return unless body.is_a?(String) && !body.b.delete_prefix(BYTE_ORDER_MARK).match?(/\A[ \t\r\n]*\z/)
153
+
154
+ WebMock::Util::Parsers::JSON.parse(body)
155
+ nil
156
+ rescue WebMock::Util::Parsers::ParseError => error
157
+ error.message unless error.cause.is_a?(::JSON::NestingError)
158
+ end
159
+
160
+ # Older json versions quote the rest of the body, json 2.5 starts with a
161
+ # line of its C source, such as "809: ", and json 2.8 and 2.9 cut the
162
+ # quote at 32 bytes, which can leave part of a character at the end.
163
+ def self.short_error(message)
164
+ message = message.delete_prefix(WebMock::Util::Parsers::JSON::ERROR_PREFIX)
165
+ cut = message.length > 1000
166
+ message = WebMock::Util::MessageString.utf8(message[0, 1000].scrub("")).gsub(/\s+/, " ").sub(/\A\d+: /, "").strip
167
+ cut || message.length > 100 ? "#{message[0, 100]}..." : message
168
+ end
169
+
67
170
  def self.matches_except_body?(request_pattern, request_signature)
68
171
  request_pattern.method_pattern.matches?(request_signature.method) &&
69
172
  request_pattern.uri_pattern.matches?(request_signature.uri) &&
@@ -75,6 +178,7 @@ module WebMock
75
178
  rescue ::JSON::JSONError, EncodingError, WebMock::Util::Parsers::ParseError
76
179
  nil
77
180
  end
78
- private_class_method :parts_of, :body_differs_only_in_formatting?, :matches_except_body?, :parse_json
181
+ private_class_method :parts_of, :body_pattern_of, :body_differs_only_in_formatting?, :fails_only_on_body?,
182
+ :parse_error, :short_error, :matches_except_body?, :parse_json
79
183
  end
80
184
  end
@@ -61,14 +61,16 @@ module WebMock
61
61
  end
62
62
 
63
63
  # Only when too few requests matched: with too many, declaring the body
64
- # as a hash would match even more of them.
64
+ # as a hash would match even more of them, and a request whose body isn't
65
+ # valid JSON isn't why there are too many.
65
66
  def json_body_hint
66
67
  return "" unless WebMock.show_body_diff? && too_few_requests_executed?
67
68
 
68
- requests = RequestRegistry.instance.requested_signatures.select do |request_signature, _|
69
- JsonBodyHint.applies?(request_pattern, request_signature)
69
+ RequestRegistry.instance.requested_signatures.each do |request_signature, _|
70
+ hint = JsonBodyHint.expectation_hint(request_pattern, request_signature)
71
+ return "\n\n#{hint}" if hint
70
72
  end
71
- requests.empty? ? "" : "\n\n#{JsonBodyHint::EXPECTATION_HINT}"
73
+ ""
72
74
  end
73
75
 
74
76
  # Only when too few requests matched, as for json_body_hint.
@@ -25,6 +25,11 @@ module WebMock
25
25
  rspec_argument_matcher_name(matcher) =~ /R?Spec::Mocks::ArgumentMatchers::Array(In|Ex)cludingMatcher/
26
26
  end
27
27
 
28
+ # WebMock's anything or RSpec's.
29
+ def any_arg_matcher?(matcher)
30
+ WebMock::Matchers::AnyArgMatcher === matcher || rSpecAnyArgMatcher?(matcher)
31
+ end
32
+
28
33
  # The class name of a possible RSpec matcher, or nil for values that
29
34
  # can't be one, which are most values in a pattern. A custom matcher can
30
35
  # be a BasicObject, which has no #class.
@@ -114,8 +119,12 @@ module WebMock
114
119
  def set_basic_auth_as_headers!(options)
115
120
  if basic_auth = options.delete('basic_auth')
116
121
  validate_basic_auth!(basic_auth)
117
- options['headers'] ||= {}
118
- options['headers']['Authorization'] = WebMock::Util::Headers.basic_auth_header(basic_auth[0],basic_auth[1])
122
+ headers = (options['headers'] ||= {})
123
+ if WebMock::Matchers::HashArgumentMatcher === headers || RSpecMatcherDetector.rSpecHashMatcher?(headers)
124
+ raise ArgumentError, "basic_auth can't be combined with headers given as hash_including or " \
125
+ "hash_excluding. With hash_including, put the Authorization header in it instead."
126
+ end
127
+ headers['Authorization'] = WebMock::Util::Headers.basic_auth_header(basic_auth[0],basic_auth[1])
119
128
  end
120
129
  end
121
130
 
@@ -423,11 +432,14 @@ module WebMock
423
432
  @pattern = pattern.is_a?(Hash) ? normalize_hash(pattern) : webmock_hash_matcher(pattern)
424
433
  end
425
434
 
426
- def matches?(body, content_type = "", serialized_body = nil)
427
- # Checked on the raw value, so body patterns used with mixed case
428
- # multipart content types keep working as in earlier versions.
429
- assert_non_multipart_body(content_type)
435
+ # True for a hash, an array, hash_including or hash_excluding, which
436
+ # match the body as parsed for its content type, such as JSON, unless
437
+ # they match any body, as {} does.
438
+ def parses_body?
439
+ @pattern.is_a?(Hash) || @pattern.is_a?(Array) || @pattern.is_a?(WebMock::Matchers::HashArgumentMatcher)
440
+ end
430
441
 
442
+ def matches?(body, content_type = "", serialized_body = nil)
431
443
  if serialized_body
432
444
  case @pattern
433
445
  when String, Regexp, Hash, Array, WebMock::Matchers::HashArgumentMatcher, nil
@@ -435,17 +447,24 @@ module WebMock
435
447
  end
436
448
  end
437
449
 
450
+ # WebMock can't parse a multipart body yet, or match one recorded
451
+ # without its content, as Net::HTTP's set_form is. Other patterns get
452
+ # the raw body. The check is on the raw content type, so hash patterns
453
+ # still match mixed case multipart content types, as before.
454
+ assert_non_multipart_body(content_type) if parses_body? || NilClass === body
455
+
438
456
  if (@pattern).is_a?(Hash)
439
457
  return true if @pattern.empty?
440
- matching_parsed_body?(body, content_type) { |parsed| matching_body_hashes?(parsed, @pattern, content_type) }
458
+ matching_body_hashes?(body_as_hash(body, content_type), @pattern, content_type)
441
459
  elsif (@pattern).is_a?(Array)
442
- matching_parsed_body?(body, content_type) { |parsed| matching_body_array?(parsed, @pattern, content_type) }
460
+ matching_body_array?(body_as_hash(body, content_type), @pattern, content_type)
443
461
  elsif (@pattern).is_a?(WebMock::Matchers::HashArgumentMatcher)
444
- matching_parsed_body?(body, content_type) { |parsed| @pattern == parsed }
462
+ @pattern == body_as_hash(body, content_type)
445
463
  else
446
464
  empty_string?(@pattern) && empty_string?(body) ||
447
465
  @pattern == body ||
448
- @pattern === body
466
+ multipart_bytes_equal?(body, content_type) ||
467
+ pattern_matches?(body)
449
468
  end
450
469
  end
451
470
 
@@ -455,66 +474,32 @@ module WebMock
455
474
 
456
475
  private
457
476
 
458
- WARNED_LEGACY_JSON = {}
459
- private_constant :WARNED_LEGACY_JSON
460
-
461
- # WebMock 3.40.0 and earlier read JSON bodies with a YAML based parser,
462
- # which reads some bodies that aren't valid JSON and some values
463
- # differently from the json gem. When the pattern doesn't match the json
464
- # gem's reading and the old parser reads the body differently, the old
465
- # reading decides, as in 3.40.0, with a warning once for each pattern
466
- # when it matches.
467
- def matching_parsed_body?(body, content_type)
468
- parsed = body_as_hash(body, content_type)
477
+ # A multipart body can hold a binary file, and its encoding can differ
478
+ # from the pattern's, so a string is compared with it as bytes. Multipart
479
+ # bodies didn't match any pattern before, so other bodies are compared
480
+ # as they were.
481
+ def multipart_bytes_equal?(body, content_type)
482
+ String === @pattern && String === body && multipart?(content_type) && @pattern.b == body.b
483
+ end
484
+
485
+ # Ruby can't match a regexp against a body that isn't valid in its
486
+ # encoding, or a regexp with non ASCII text against binary bytes, as in
487
+ # a multipart upload of a binary file. Such a body is matched as bytes
488
+ # by a regexp for bytes, and otherwise as UTF-8 text with the invalid
489
+ # bytes replaced, which keeps the text around them, such as a filename.
490
+ def pattern_matches?(body)
491
+ @pattern === body
492
+ rescue ArgumentError, Encoding::CompatibilityError
493
+ raise unless Regexp === @pattern && String === body &&
494
+ (!body.valid_encoding? || body.encoding == Encoding::BINARY)
495
+
496
+ text = body.b
497
+ text = text.force_encoding(Encoding::UTF_8).scrub unless @pattern.encoding == Encoding::BINARY
469
498
  begin
470
- return true if yield(parsed)
471
- rescue SignalException, SystemExit
472
- raise
473
- rescue Exception => error
474
- # A value in the pattern, such as a lambda or an RSpec expectation,
475
- # may expect what the old parser reads, so the old reading decides.
476
- end
477
-
478
- json = body && WebMock::Util::ContentType.body_format(content_type) == :json
479
- legacy = legacy_json(body) if json
480
- if !json || legacy.eql?(parsed)
481
- raise error if error
482
- return false
499
+ @pattern === text
500
+ rescue Encoding::CompatibilityError
501
+ false
483
502
  end
484
-
485
- # As in 3.40.0, including an error the pattern raises for it.
486
- matched = yield(legacy)
487
- warn_legacy_json(body, parsed) if matched
488
- matched
489
- end
490
-
491
- def legacy_json(body)
492
- WebMock::Util::Parsers::JSON.parse_legacy(body)
493
- rescue WebMock::Util::Parsers::ParseError
494
- nil
495
- end
496
-
497
- def warn_legacy_json(body, parsed)
498
- pattern = to_s
499
- # Without object addresses, so equal patterns, such as ones with a
500
- # lambda built in each example, warn once.
501
- key = pattern.gsub(/#<([\w:]+?):0x\h+/, '#<\\1').hash
502
- return if WARNED_LEGACY_JSON[key]
503
- WARNED_LEGACY_JSON[key] = true
504
- advice =
505
- if parsed.nil?
506
- "Send valid JSON, for example from to_json, and write the pattern for what JSON.parse returns."
507
- else
508
- "Write the pattern for what JSON.parse returns: #{shorten(parsed.inspect)}."
509
- end
510
- WebMock::Deprecation.warning(
511
- "the body pattern #{shorten(pattern)} matched the request body #{shorten(body).inspect} " \
512
- "only as WebMock's old JSON parser reads it. WebMock 4.0 drops that parser, so it won't match. #{advice}"
513
- )
514
- end
515
-
516
- def shorten(text)
517
- text.length > 100 ? "#{text[0, 100]}..." : text
518
503
  end
519
504
 
520
505
  def body_as_hash(body, content_type)
@@ -535,8 +520,14 @@ module WebMock
535
520
  nil
536
521
  end
537
522
 
523
+ # Checked on the raw value, as in earlier versions, so mixed case
524
+ # content types aren't multipart here.
525
+ def multipart?(content_type)
526
+ content_type =~ %r{^multipart/form-data}
527
+ end
528
+
538
529
  def assert_non_multipart_body(content_type)
539
- if content_type =~ %r{^multipart/form-data}
530
+ if multipart?(content_type)
540
531
  raise ArgumentError.new("WebMock does not support matching body for multipart/form-data requests yet :(")
541
532
  end
542
533
  end
@@ -604,11 +595,23 @@ module WebMock
604
595
  end
605
596
 
606
597
  class HeadersPattern
598
+ include RSpecMatcherDetector
599
+
600
+ PLAIN_VALUES = [String, Symbol, Numeric, NilClass, TrueClass, FalseClass].freeze
601
+ private_constant :PLAIN_VALUES
602
+
607
603
  def initialize(pattern)
608
- @pattern = WebMock::Util::Headers.normalize_headers(pattern) || {}
604
+ matcher = webmock_hash_matcher(pattern)
605
+ @pattern = if WebMock::Matchers::HashArgumentMatcher === matcher
606
+ matcher.class.new(normalize_matcher_headers(matcher))
607
+ else
608
+ WebMock::Util::Headers.normalize_headers(pattern) || {}
609
+ end
609
610
  end
610
611
 
611
612
  def matches?(headers)
613
+ return @pattern == (headers || {}) if hash_matcher?
614
+
612
615
  if empty_headers?(@pattern)
613
616
  empty_headers?(headers)
614
617
  else
@@ -621,15 +624,87 @@ module WebMock
621
624
  end
622
625
 
623
626
  def to_s
627
+ return matcher_to_s if hash_matcher?
628
+
624
629
  WebMock::Util::Headers.sorted_headers_string(@pattern)
625
630
  end
626
631
 
627
632
  def pp_to_s
633
+ return matcher_to_s if hash_matcher?
634
+
628
635
  WebMock::Util::Headers.pp_headers_string(@pattern)
629
636
  end
630
637
 
631
638
  private
632
639
 
640
+ def hash_matcher?
641
+ WebMock::Matchers::HashArgumentMatcher === @pattern
642
+ end
643
+
644
+ def expected_headers(matcher)
645
+ matcher.instance_variable_get(:@expected)
646
+ end
647
+
648
+ # The expected headers of hash_including or hash_excluding, with names
649
+ # normalized as for a plain hash, so they compare with the request's
650
+ # headers. Values compared as text are normalized as in a plain hash.
651
+ def normalize_matcher_headers(matcher)
652
+ expected_headers(matcher).each_with_object({}) do |(name, value), headers|
653
+ if Array === value && !value.all? { |element| text_value?(element) }
654
+ raise ArgumentError, "Headers given as hash_including or hash_excluding can't have " \
655
+ "matchers in an array of values, as given for #{name}"
656
+ elsif Array === value || text_value?(value)
657
+ headers.update(WebMock::Util::Headers.normalize_headers(name => value))
658
+ else
659
+ headers[WebMock::Util::Headers.normalize_name(name)] = value
660
+ end
661
+ end
662
+ end
663
+
664
+ # Strings, symbols and numbers are compared as text, as in a plain hash,
665
+ # and so is any value that doesn't define its own ===, such as a URI or
666
+ # a Time. A regexp, a class, a range, a lambda or a matcher, which
667
+ # define ===, are compared with ===. A BasicObject can only be a custom
668
+ # matcher.
669
+ def text_value?(value)
670
+ return false unless ::Kernel === value
671
+ return true if PLAIN_VALUES.any? { |type| type === value }
672
+ return false if any_arg_matcher?(value)
673
+
674
+ ::Kernel.instance_method(:method).bind_call(value, :===).owner == ::Kernel
675
+ end
676
+
677
+ # A header given without a value is listed by name, as hash_including
678
+ # takes it. A matcher is shown by its description, or by inspect only
679
+ # for types whose inspect shows no state, since a matcher's inspect can
680
+ # include a value it saw in an earlier request, such as an
681
+ # Authorization header.
682
+ def matcher_to_s
683
+ name = WebMock::Matchers::HashIncludingMatcher === @pattern ? "hash_including" : "hash_excluding"
684
+ without_value, with_value = expected_headers(@pattern).partition { |_header, value| any_arg_matcher?(value) }
685
+ arguments = without_value.map { |header, _value| header.inspect }
686
+ if with_value.any? || without_value.empty?
687
+ arguments << "{#{with_value.map { |header, value| "#{header.inspect} => #{value_to_s(value)}" }.join(", ")}}"
688
+ end
689
+ "#{name}(#{arguments.join(", ")})"
690
+ end
691
+
692
+ def value_to_s(value)
693
+ return "a custom matcher" unless ::Kernel === value
694
+
695
+ described = begin
696
+ value.description if value.respond_to?(:description)
697
+ rescue StandardError, NotImplementedError
698
+ nil
699
+ end
700
+ return described if String === described
701
+
702
+ case value
703
+ when String, Array, Regexp, Module, Range, Proc then value.inspect
704
+ else "#<#{value.class.name || "custom matcher"}>"
705
+ end
706
+ end
707
+
633
708
  def empty_headers?(headers)
634
709
  headers.nil? || headers == {}
635
710
  end
@@ -24,10 +24,11 @@ module WebMock
24
24
  end
25
25
 
26
26
  def request_stubs
27
- return if WebMock::StubRegistry.instance.request_stubs.empty?
27
+ stubs = WebMock::StubRegistry.instance.request_stubs
28
+ return if stubs.empty?
28
29
 
29
30
  text = "registered request stubs:\n".dup
30
- WebMock::StubRegistry.instance.request_stubs.each do |stub|
31
+ stubs.each do |stub|
31
32
  text << "\n#{WebMock::Util::MessageString.utf8(WebMock::StubRequestSnippet.new(stub).to_s(false))}"
32
33
  if WebMock.show_body_diff?
33
34
  add_body_diff(stub, text)
@@ -35,6 +36,7 @@ module WebMock
35
36
  end
36
37
  add_trailing_slash_hint(stub, text)
37
38
  end
39
+ add_invalid_json_hint(stubs, text) if WebMock.show_body_diff?
38
40
  text
39
41
  end
40
42
 
@@ -62,6 +64,12 @@ module WebMock
62
64
  text << "\n\n#{JsonBodyHint::STUB_HINT}\n"
63
65
  end
64
66
 
67
+ # Once after the stubs, since it is about the request rather than a stub.
68
+ def add_invalid_json_hint(stubs, text)
69
+ hint = JsonBodyHint.invalid_json_hint(stubs, request_signature, :stub)
70
+ text << "\n\n#{hint}\n" if hint
71
+ end
72
+
65
73
  def add_trailing_slash_hint(stub, text)
66
74
  difference = TrailingSlashHint.difference(stub.request_pattern, request_signature)
67
75
  text << "\n\n#{TrailingSlashHint::STUB_HINTS[difference]}\n" if difference
@@ -18,9 +18,14 @@ module WebMock
18
18
 
19
19
  def to_return(*response_hashes, &block)
20
20
  if block
21
+ raise ArgumentError, '#to_return does not accept both responses and a block' unless response_hashes.empty?
22
+
21
23
  @responses_sequences << ResponsesSequence.new([ResponseFactory.response_for(block)])
22
24
  else
23
- @responses_sequences << ResponsesSequence.new([*response_hashes].flatten.map {|r| ResponseFactory.response_for(r)})
25
+ response_hashes = [*response_hashes].flatten
26
+ require_args!(response_hashes, :to_return, 'response')
27
+
28
+ @responses_sequences << ResponsesSequence.new(response_hashes.map {|r| ResponseFactory.response_for(r)})
24
29
  end
25
30
  self
26
31
  end
@@ -29,7 +34,10 @@ module WebMock
29
34
  def to_return_json(*response_hashes)
30
35
  raise ArgumentError, '#to_return_json does not support passing a block' if block_given?
31
36
 
32
- json_response_hashes = [*response_hashes].flatten.map do |resp_h|
37
+ response_hashes = [*response_hashes].flatten
38
+ require_args!(response_hashes, :to_return_json, 'response')
39
+
40
+ json_response_hashes = response_hashes.map do |resp_h|
33
41
  headers, body = resp_h.values_at(:headers, :body)
34
42
 
35
43
  json_body = if body.respond_to?(:call)
@@ -60,7 +68,15 @@ module WebMock
60
68
  end
61
69
 
62
70
  def to_raise(*exceptions)
63
- @responses_sequences << ResponsesSequence.new([*exceptions].flatten.map {|e|
71
+ exceptions = [*exceptions].flatten
72
+ require_args!(exceptions, :to_raise, 'exception')
73
+ exceptions.each do |exception|
74
+ next if exception.is_a?(String) || exception.is_a?(Exception) || (exception.is_a?(Class) && exception <= Exception)
75
+
76
+ raise ArgumentError, "#{exception.inspect} is not a valid exception for #to_raise"
77
+ end
78
+
79
+ @responses_sequences << ResponsesSequence.new(exceptions.map {|e|
64
80
  ResponseFactory.response_for(exception: e)
65
81
  })
66
82
  self
@@ -134,6 +150,11 @@ module WebMock
134
150
 
135
151
  private
136
152
 
153
+ def require_args!(values, method, noun)
154
+ raise ArgumentError, "##{method} requires at least one #{noun}" if values.empty?
155
+ raise ArgumentError, "nil is not a valid #{noun} for ##{method}" if values.any?(&:nil?)
156
+ end
157
+
137
158
  def json_response_body(body)
138
159
  case body
139
160
  when String, IO, Pathname
@@ -1,12 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # parse_legacy is a copy of https://github.com/jnunemaker/crack/blob/master/lib/crack/json.rb
4
- # with date parsing removed
5
- # Copyright (c) 2004-2008 David Heinemeier Hansson
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
- # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
-
10
3
  require "json"
11
4
  require_relative "parse_error"
12
5
 
@@ -18,23 +11,15 @@ module WebMock
18
11
  # gem version to parse in a thread's stack.
19
12
  MAX_NESTING = 1000
20
13
 
14
+ # Starts the message of every ParseError raised here.
15
+ ERROR_PREFIX = "Invalid JSON string: "
16
+
21
17
  def self.parse(json)
22
18
  # JSON texts may start with a byte order mark, which parsers may ignore.
23
19
  json = to_utf8(json).delete_prefix("\uFEFF")
24
20
  ::JSON.parse(json, allow_duplicate_key: true, max_nesting: MAX_NESTING)
25
21
  rescue ::JSON::JSONError, EncodingError => e
26
- raise ParseError, "Invalid JSON string: #{e.message}"
27
- end
28
-
29
- # The YAML based parser WebMock used up to 3.40.0. It reads some
30
- # bodies that aren't valid JSON, such as {a: 1}, and some values
31
- # differently from the json gem, such as 1e+20 as a String.
32
- # WebMock 4.0 drops it.
33
- def self.parse_legacy(json)
34
- yaml = unescape(convert_json_to_yaml(json))
35
- YAML.load(yaml)
36
- rescue ArgumentError, EncodingError, Psych::Exception => e
37
- raise ParseError, "Invalid JSON string: #{yaml}, Error: #{e.inspect}"
22
+ raise ParseError, "#{ERROR_PREFIX}#{e.message}"
38
23
  end
39
24
 
40
25
  # The json gem reads bytes that aren't valid in their encoding, so
@@ -45,59 +30,12 @@ module WebMock
45
30
  if json.encoding == Encoding::BINARY || json.encoding == Encoding::US_ASCII
46
31
  json = json.dup.force_encoding(Encoding::UTF_8)
47
32
  end
48
- raise ParseError, "Invalid JSON string: it isn't valid #{json.encoding}" unless json.valid_encoding?
33
+ raise ParseError, "#{ERROR_PREFIX}it isn't valid #{json.encoding}" unless json.valid_encoding?
49
34
 
50
35
  json.encoding == Encoding::UTF_8 ? json : json.encode(Encoding::UTF_8)
51
36
  end
52
37
  private_class_method :to_utf8
53
-
54
- protected
55
-
56
- def self.unescape(str)
57
- str.gsub(/\\u([0-9a-f]{4})/) { [$1.hex].pack("U") }
58
- end
59
-
60
- # Ensure that ":" and "," are always followed by a space
61
- def self.convert_json_to_yaml(json) #:nodoc:
62
- scanner, quoting, marks, times = StringScanner.new(json), false, [], []
63
- while scanner.scan_until(/(\\['"]|['":,\\]|\\.)/)
64
- case char = scanner[1]
65
- when '"', "'"
66
- if !quoting
67
- quoting = char
68
- elsif quoting == char
69
- quoting = false
70
- end
71
- when ":",","
72
- marks << scanner.pos - 1 unless quoting
73
- when "\\"
74
- scanner.skip(/\\/)
75
- end
76
- end
77
-
78
- if marks.empty?
79
- json.gsub(/\\\//, '/')
80
- else
81
- left_pos = [-1].push(*marks)
82
- right_pos = marks << json.bytesize
83
- output = []
84
-
85
- left_pos.each_with_index do |left, i|
86
- if json.respond_to?(:byteslice)
87
- output << json.byteslice(left.succ..right_pos[i])
88
- else
89
- output << json[left.succ..right_pos[i]]
90
- end
91
- end
92
-
93
- output = output * " "
94
-
95
- times.each { |i| output[i-1] = ' ' }
96
- output.gsub!(/\\\//, '/')
97
- output
98
- end
99
- end
100
38
  end
101
39
  end
102
40
  end
103
- end
41
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WebMock
4
- VERSION = '3.42.0' unless defined?(::WebMock::VERSION)
4
+ VERSION = '4.1.0' unless defined?(::WebMock::VERSION)
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.42.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartosz Blimke
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.3.2
32
+ version: 0.4.6
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 0.3.2
39
+ version: 0.4.6
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: hashdiff
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -363,9 +363,9 @@ licenses:
363
363
  - MIT
364
364
  metadata:
365
365
  bug_tracker_uri: https://github.com/bblimke/webmock/issues
366
- changelog_uri: https://github.com/bblimke/webmock/blob/v3.42.0/CHANGELOG.md
367
- documentation_uri: https://www.rubydoc.info/gems/webmock/3.42.0
368
- source_code_uri: https://github.com/bblimke/webmock/tree/v3.42.0
366
+ changelog_uri: https://github.com/bblimke/webmock/blob/v4.1.0/CHANGELOG.md
367
+ documentation_uri: https://www.rubydoc.info/gems/webmock/4.1.0
368
+ source_code_uri: https://github.com/bblimke/webmock/tree/v4.1.0
369
369
  wiki_uri: https://github.com/bblimke/webmock/wiki
370
370
  rdoc_options: []
371
371
  require_paths:
@@ -374,7 +374,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
374
374
  requirements:
375
375
  - - ">="
376
376
  - !ruby/object:Gem::Version
377
- version: '2.6'
377
+ version: '3.0'
378
378
  required_rubygems_version: !ruby/object:Gem::Requirement
379
379
  requirements:
380
380
  - - ">="