webmock 3.24.0 → 3.26.2

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: 9283efd8ecb49795fe14fc5903295b0d143fbdd17f5cc1611e89d918f917c33f
4
- data.tar.gz: ea556e59d242667816568c75f7c42be613e09f688c3ada07c65f0c9de0e3d05d
3
+ metadata.gz: d61b9a1ba2457ef06a173ec71523bedaaecdac935b59611abeff105679da7cb3
4
+ data.tar.gz: 1d78e1c3b493bd1fc2af0961a6bebae5a273e1937b6cad6aaa7ef501e4b70778
5
5
  SHA512:
6
- metadata.gz: bcd310894ba47584609ffafcd332cbd824d3921ec938a7ca63e84e983436188dbf7f44a13137e407b3c5798fd9a02ced95e5797ac9ee3e923adf588cf04c4015
7
- data.tar.gz: 617bcf11b564bf6cc2faf4a973e9882dbb9639e685ed989fe6bc11b65c1ea7e66d12a106484e2e641ff4fda4c8c7336fe83509852b2a858f94fe0a657b5aae6c
6
+ metadata.gz: 4e56c8868b81ac1465e6b28b96041f9ea0a3cda7ef3728d0bc6715215d84baa44af5b5e1f4ba48597f34e6fd2e6f00f86cb5d61c194fb2eebd0a58caf92f615b
7
+ data.tar.gz: ea6072e9d1dbba86925558f31e10df790c5979f470806b92be7cfa483d47b1158ba55b1453981d696751ca2b2c98a1847f50cb635779a7eef7e7a377598777b4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # Changelog
2
2
 
3
+ # 3.26.2
4
+
5
+ * Add support to parse http/2 request on curb adapter
6
+
7
+ Thanks to [Christoph Rieß](https://github.com/criess)
8
+
9
+ * CurbAdapter alias `code` from `response_code`
10
+
11
+ Thanks to [Christoph Rieß](https://github.com/criess)
12
+
13
+ * Add HTTP.rb v6.0.0 compatibility to http_rb adapter
14
+
15
+ Thanks to [Erik Berlin](https://github.com/sferik)
16
+
17
+ # 3.26.1
18
+
19
+ * Fix compatibility with recent async-http versions
20
+
21
+ Thanks to [Mikhail Doronin](https://github.com/misdoro)
22
+
23
+ # 3.26.0
24
+
25
+ * Support Addressable::URI in request patterns
26
+
27
+ Thanks to [Alexey Zapparov](https://github.com/ixti)
28
+
29
+ # 3.25.2
30
+
31
+ * Return support for `em_http_request`
32
+
33
+ Thanks to [Oleg](https://github.com/Koilanetroc)
34
+
35
+ # 3.25.1
36
+
37
+ * Fix FrozenError in Typhoeus streaming response body
38
+
39
+ Thanks to [Patrick Jaberg](https://github.com/patrickjaberg)
40
+
41
+ # 3.25.0
42
+
43
+ * Resolve net-http adapter deprecation Ruby 3.4
44
+
45
+ Thanks to [Earlopain](https://github.com/Earlopain)
46
+
3
47
  # 3.24.0
4
48
 
5
49
  * Ignore parsing errors when parsing invalid JSON or XML body to match against body pattern #1066
data/README.md CHANGED
@@ -44,6 +44,8 @@ Supported Ruby Interpreters
44
44
  * MRI 3.1
45
45
  * MRI 3.2
46
46
  * MRI 3.3
47
+ * MRI 3.4
48
+ * MRI 4.0
47
49
  * JRuby
48
50
 
49
51
  ## Installation
@@ -1206,6 +1208,11 @@ People who submitted patches and new features or suggested improvements. Many th
1206
1208
  * Jacob Frautschi
1207
1209
  * Christian Schmidt
1208
1210
  * Rodrigo Argumedo
1211
+ * Patrick Jaberg
1212
+ * Oleg
1213
+ * Mikhail Doronin
1214
+ * Christoph Rieß
1215
+ * Erik Berlin
1209
1216
 
1210
1217
  For a full list of contributors you can visit the
1211
1218
  [contributors](https://github.com/bblimke/webmock/contributors) page.
@@ -211,7 +211,7 @@ if defined?(Async::HTTP)
211
211
  def build_response(webmock_response)
212
212
  headers = (webmock_response.headers || {}).each_with_object([]) do |(k, value), o|
213
213
  Array(value).each do |v|
214
- o.push [k, v]
214
+ o.push [k, v] unless k.downcase == 'content-length' # async-http appends the exact content-length automatically
215
215
  end
216
216
  end
217
217
 
@@ -7,7 +7,7 @@ rescue LoadError
7
7
  end
8
8
 
9
9
  if defined?(Curl)
10
- WebMock::VersionChecker.new('Curb', Curl::CURB_VERSION, '0.7.16', '1.0.1', ['0.8.7']).check_version!
10
+ WebMock::VersionChecker.new('Curb', Curl::CURB_VERSION, '0.7.16', '1.2.2', ['0.8.7']).check_version!
11
11
 
12
12
  module WebMock
13
13
  module HttpLibAdapters
@@ -32,8 +32,8 @@ if defined?(Curl)
32
32
  status, headers = nil, {}
33
33
 
34
34
  header_string.split(/\r\n/).each do |header|
35
- if header =~ %r|^HTTP/1.[01] \d\d\d (.*)|
36
- status = $1
35
+ if header =~ %r{\AHTTP/(1\.[01]|2) (\d{3})\s*(.*)}
36
+ status = $3
37
37
  else
38
38
  parts = header.split(':', 2)
39
39
  unless parts.empty?
@@ -313,6 +313,7 @@ if defined?(Curl)
313
313
  def response_code
314
314
  @response_code ||= super
315
315
  end
316
+ alias code response_code
316
317
 
317
318
  def header_str
318
319
  @header_str ||= super
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- return if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4.0')
4
-
5
3
  begin
6
4
  require 'em-http-request'
7
5
  rescue LoadError
@@ -28,9 +28,6 @@ module HTTP
28
28
  headers = webmock_response.headers || {}
29
29
  uri = normalize_uri(request_signature && request_signature.uri)
30
30
 
31
- # HTTP.rb 3.0+ uses a keyword argument to pass the encoding, but 1.x
32
- # and 2.x use a positional argument, and 0.x don't support supplying
33
- # the encoding.
34
31
  body = build_http_rb_response_body_from_webmock_response(webmock_response)
35
32
 
36
33
  return new(status, "1.1", headers, body, uri) if HTTP::VERSION < "1.0.0"
@@ -46,6 +43,17 @@ module HTTP
46
43
  })
47
44
  end
48
45
 
46
+ # 6.0.0 changed Response.new from a positional hash to keyword arguments.
47
+ if HTTP::VERSION >= '6.0.0'
48
+ return new(
49
+ status: status,
50
+ version: "1.1",
51
+ headers: headers,
52
+ body: body,
53
+ request: request,
54
+ )
55
+ end
56
+
49
57
  new({
50
58
  status: status,
51
59
  version: "1.1",
@@ -10,15 +10,22 @@ module HTTP
10
10
 
11
11
  def readpartial(size = nil, outbuf = nil)
12
12
  unless size
13
- if defined?(HTTP::Client::BUFFER_SIZE)
14
- size = HTTP::Client::BUFFER_SIZE
15
- elsif defined?(HTTP::Connection::BUFFER_SIZE)
13
+ if defined?(HTTP::Connection::BUFFER_SIZE)
16
14
  size = HTTP::Connection::BUFFER_SIZE
15
+ elsif defined?(HTTP::Client::BUFFER_SIZE)
16
+ size = HTTP::Client::BUFFER_SIZE
17
17
  end
18
18
  end
19
19
 
20
- chunk = @io.read size, outbuf
21
- chunk.force_encoding(@encoding) if chunk
20
+ chunk = @io.read(size, outbuf)
21
+
22
+ # HTTP.rb 6.0+ expects EOFError at end-of-stream instead of nil
23
+ if chunk.nil?
24
+ raise EOFError if HTTP::VERSION >= "6.0.0"
25
+ return nil
26
+ end
27
+
28
+ chunk.force_encoding(@encoding)
22
29
  end
23
30
 
24
31
  def close
@@ -43,7 +43,10 @@ module HTTP
43
43
  invoke_callbacks(webmock_response, real_request: false)
44
44
  response = ::HTTP::Response.from_webmock @request, webmock_response, request_signature
45
45
 
46
- @options.features.each { |_name, feature| response = feature.wrap_response(response) }
46
+ # HTTP.rb 6.0+ wraps responses in reverse feature order
47
+ features = @options.features.values
48
+ features = features.reverse if HTTP::VERSION >= "6.0.0"
49
+ features.each { |feature| response = feature.wrap_response(response) }
47
50
  response
48
51
  end
49
52
 
@@ -12,19 +12,25 @@ module WebMock
12
12
  adapter_for :net_http
13
13
 
14
14
  OriginalNetHTTP = Net::HTTP unless const_defined?(:OriginalNetHTTP)
15
+ # This will be removed in Ruby 3.5. In Ruby 3.4, const_remove will warn.
16
+ HAS_LEGACY_CONSTANT = Net.const_defined?(:HTTPSession)
15
17
 
16
18
  def self.enable!
17
19
  Net.send(:remove_const, :HTTP)
18
- Net.send(:remove_const, :HTTPSession)
19
20
  Net.send(:const_set, :HTTP, @webMockNetHTTP)
20
- Net.send(:const_set, :HTTPSession, @webMockNetHTTP)
21
+ if HAS_LEGACY_CONSTANT
22
+ remove_silently(Net, :HTTPSession)
23
+ Net.send(:const_set, :HTTPSession, @webMockNetHTTP)
24
+ end
21
25
  end
22
26
 
23
27
  def self.disable!
24
28
  Net.send(:remove_const, :HTTP)
25
- Net.send(:remove_const, :HTTPSession)
26
29
  Net.send(:const_set, :HTTP, OriginalNetHTTP)
27
- Net.send(:const_set, :HTTPSession, OriginalNetHTTP)
30
+ if HAS_LEGACY_CONSTANT
31
+ remove_silently(Net, :HTTPSession)
32
+ Net.send(:const_set, :HTTPSession, OriginalNetHTTP)
33
+ end
28
34
 
29
35
  #copy all constants from @webMockNetHTTP to original Net::HTTP
30
36
  #in case any constants were added to @webMockNetHTTP instead of Net::HTTP
@@ -37,6 +43,14 @@ module WebMock
37
43
  end
38
44
  end
39
45
 
46
+ def self.remove_silently(mod, const) #:nodoc:
47
+ # Don't warn on removing the deprecated constant
48
+ verbose, $VERBOSE = $VERBOSE, nil
49
+ mod.send(:remove_const, const)
50
+ ensure
51
+ $VERBOSE = verbose
52
+ end
53
+
40
54
  @webMockNetHTTP = Class.new(Net::HTTP) do
41
55
  class << self
42
56
  def socket_type
@@ -186,9 +200,9 @@ module WebMock
186
200
 
187
201
 
188
202
  def check_right_http_connection
189
- unless @@alredy_checked_for_right_http_connection ||= false
203
+ unless @@already_checked_for_right_http_connection ||= false
190
204
  WebMock::NetHTTPUtility.puts_warning_for_right_http_if_needed
191
- @@alredy_checked_for_right_http_connection = true
205
+ @@already_checked_for_right_http_connection = true
192
206
  end
193
207
  end
194
208
  end
@@ -172,7 +172,7 @@ if defined?(Typhoeus)
172
172
  request.execute_headers_callbacks(response)
173
173
  end
174
174
  if request.respond_to?(:streaming?) && request.streaming?
175
- response.options[:response_body] = ""
175
+ response.options[:response_body] = "".dup
176
176
  request.on_body.each { |callback| callback.call(webmock_response.body, response) }
177
177
  end
178
178
  request.finish(response)
@@ -86,10 +86,10 @@ module WebMock
86
86
  URICallablePattern.new(uri)
87
87
  elsif uri.is_a?(::URI::Generic)
88
88
  URIStringPattern.new(uri.to_s)
89
- elsif uri.is_a?(String)
90
- URIStringPattern.new(uri)
89
+ elsif uri.respond_to?(:to_str)
90
+ URIStringPattern.new(uri.to_str)
91
91
  else
92
- raise ArgumentError.new("URI should be a String, Regexp, Addressable::Template or a callable object. Got: #{uri.class}")
92
+ raise ArgumentError.new("URI should be a String, Regexp, Addressable::Template, a callable object, or respond to #to_str. Got: #{uri.class}")
93
93
  end
94
94
  end
95
95
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WebMock
4
- VERSION = '3.24.0' unless defined?(::WebMock::VERSION)
4
+ VERSION = '3.26.2' unless defined?(::WebMock::VERSION)
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.24.0
4
+ version: 3.26.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartosz Blimke
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-09-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: addressable
@@ -198,20 +197,6 @@ dependencies:
198
197
  - - ">="
199
198
  - !ruby/object:Gem::Version
200
199
  version: 2.2.4
201
- - !ruby/object:Gem::Dependency
202
- name: mutex_m
203
- requirement: !ruby/object:Gem::Requirement
204
- requirements:
205
- - - ">="
206
- - !ruby/object:Gem::Version
207
- version: '0'
208
- type: :development
209
- prerelease: false
210
- version_requirements: !ruby/object:Gem::Requirement
211
- requirements:
212
- - - ">="
213
- - !ruby/object:Gem::Version
214
- version: '0'
215
200
  - !ruby/object:Gem::Dependency
216
201
  name: excon
217
202
  requirement: !ruby/object:Gem::Requirement
@@ -373,11 +358,10 @@ licenses:
373
358
  - MIT
374
359
  metadata:
375
360
  bug_tracker_uri: https://github.com/bblimke/webmock/issues
376
- changelog_uri: https://github.com/bblimke/webmock/blob/v3.24.0/CHANGELOG.md
377
- documentation_uri: https://www.rubydoc.info/gems/webmock/3.24.0
378
- source_code_uri: https://github.com/bblimke/webmock/tree/v3.24.0
361
+ changelog_uri: https://github.com/bblimke/webmock/blob/v3.26.2/CHANGELOG.md
362
+ documentation_uri: https://www.rubydoc.info/gems/webmock/3.26.2
363
+ source_code_uri: https://github.com/bblimke/webmock/tree/v3.26.2
379
364
  wiki_uri: https://github.com/bblimke/webmock/wiki
380
- post_install_message:
381
365
  rdoc_options: []
382
366
  require_paths:
383
367
  - lib
@@ -385,15 +369,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
385
369
  requirements:
386
370
  - - ">="
387
371
  - !ruby/object:Gem::Version
388
- version: '2.5'
372
+ version: '2.6'
389
373
  required_rubygems_version: !ruby/object:Gem::Requirement
390
374
  requirements:
391
375
  - - ">="
392
376
  - !ruby/object:Gem::Version
393
377
  version: '0'
394
378
  requirements: []
395
- rubygems_version: 3.5.16
396
- signing_key:
379
+ rubygems_version: 4.1.0.dev
397
380
  specification_version: 4
398
381
  summary: Library for stubbing HTTP requests in Ruby.
399
382
  test_files: []