webmock 3.7.6 → 3.8.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: 337947555c0257e2a9eb31d5af91db7a2540ad489fd27dc31ad3409e14a9b028
4
- data.tar.gz: bd7cde5d8e0c7226e1c9a38303dee583ac2e974658373215b7c11396579adef2
3
+ metadata.gz: e810298e20d5299b4db93de105d6bfd2928db868ed70d6113e1e308091130f7c
4
+ data.tar.gz: d35d0053907cb949df0a891e9b9e6e4f2c62143651fc2b19a2d02192fb1d6f91
5
5
  SHA512:
6
- metadata.gz: e94e7cd1f009c514204c4642ce13df9eb338fcd0cadea61347f02550606680c1605ea00b03c6453d34c89b407987b02d1b3a01c6ae9bc26ec56aec8103726999
7
- data.tar.gz: 0fc2817995308a59726a703c3ab221e9aa7ee10b35909a637dfe9620c5c185d06ea5327f86234e6578568d94e7ca566df112601eb27f762d258c183b10c67dbc
6
+ metadata.gz: f42ea1b65f3203df24d0dc5cf39204274c30339eb8831bc95570da25cc497cb51bb9cc696636a437b941aea050940574d01c6632dbe9db29bd67f67eab2e15d9
7
+ data.tar.gz: 902b36dd0712ecafe4e26eca7416e6444638ea2687a86b434382428a6158c6b7a9155b17b62c30755712cc5cf51985482b6d7c386461d11ed5ade0afa069b45c
@@ -1,13 +1,11 @@
1
1
  before_install:
2
- - gem update --system
3
- - gem update bundler
2
+ - gem update --system -N
4
3
  rvm:
5
4
  - 2.3.8
6
5
  - 2.4.6
7
6
  - 2.5.5
8
7
  - 2.6.3
9
- - 2.6.3
10
- - 2.7.0-preview1
8
+ - 2.7.0
11
9
  - rbx-2
12
10
  - ruby-head
13
11
  - jruby-9.1.17.0
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.8.2
4
+
5
+ * Support correct encoding parameter for HTTP.rb 2.x and earlier
6
+
7
+ Thanks to [Alex Coomans](https://github.com/drcapulet)
8
+
9
+ ## 3.8.1
10
+
11
+ * Added support for mocking non-ASCII bodies when making requests with HTTP.rb
12
+
13
+ Thanks to [Patrik Ragnarsson](https://github.com/dentarg)
14
+
15
+ ## 3.8.0
16
+
17
+ * Fixed options handling when initialising Async::HTTP::Client
18
+
19
+ Thanks to [Samuel Williams](https://github.com/ioquatix)
20
+
21
+ * Ruby 2.7 support.
22
+
23
+ Thanks to [Ryan Davis](https://github.com/zenspider) and [Brandur](https://github.com/brandur)
24
+
3
25
  ## 3.7.6
4
26
 
5
27
  * Suppressed keyword argument warnings in Ruby 2.7 in async-http adapter.
data/README.md CHANGED
@@ -1115,6 +1115,11 @@ People who submitted patches and new features or suggested improvements. Many th
1115
1115
  * Orien Madgwick
1116
1116
  * Andrei Sidorov
1117
1117
  * Marco Costa
1118
+ * Ryan Davis
1119
+ * Brandur
1120
+ * Samuel Williams
1121
+ * Patrik Ragnarsson
1122
+ * Alex Coomans
1118
1123
 
1119
1124
  For a full list of contributors you can visit the
1120
1125
  [contributors](https://github.com/bblimke/webmock/contributors) page.
@@ -36,7 +36,7 @@ if defined?(Async::HTTP)
36
36
  protocol = endpoint.protocol,
37
37
  scheme = endpoint.scheme,
38
38
  authority = endpoint.authority,
39
- options = {}
39
+ **options
40
40
  )
41
41
  webmock_endpoint = WebMockEndpoint.new(scheme, authority, protocol)
42
42
 
@@ -14,9 +14,19 @@ module HTTP
14
14
  def from_webmock(webmock_response, request_signature = nil)
15
15
  status = Status.new(webmock_response.status.first)
16
16
  headers = webmock_response.headers || {}
17
- body = Body.new Streamer.new webmock_response.body
18
17
  uri = normalize_uri(request_signature && request_signature.uri)
19
18
 
19
+ # HTTP.rb 3.0+ uses a keyword argument to pass the encoding, but 1.x
20
+ # and 2.x use a positional argument, and 0.x don't support supplying
21
+ # the encoding.
22
+ body = if HTTP::VERSION < "1.0.0"
23
+ Body.new(Streamer.new(webmock_response.body))
24
+ elsif HTTP::VERSION < "3.0.0"
25
+ Body.new(Streamer.new(webmock_response.body), webmock_response.body.encoding)
26
+ else
27
+ Body.new(Streamer.new(webmock_response.body), encoding: webmock_response.body.encoding)
28
+ end
29
+
20
30
  return new(status, "1.1", headers, body, uri) if HTTP::VERSION < "1.0.0"
21
31
 
22
32
  new({
@@ -228,9 +228,9 @@ class PatchedStringIO < StringIO #:nodoc:
228
228
 
229
229
  alias_method :orig_read_nonblock, :read_nonblock
230
230
 
231
- def read_nonblock(size, *args)
231
+ def read_nonblock(size, *args, **kwargs)
232
232
  args.reject! {|arg| !arg.is_a?(Hash)}
233
- orig_read_nonblock(size, *args)
233
+ orig_read_nonblock(size, *args, **kwargs)
234
234
  end
235
235
 
236
236
  end
@@ -257,7 +257,7 @@ end
257
257
  module Net #:nodoc: all
258
258
 
259
259
  class WebMockNetBufferedIO < BufferedIO
260
- def initialize(io, *args)
260
+ def initialize(io, *args, **kwargs)
261
261
  io = case io
262
262
  when Socket, OpenSSL::SSL::SSLSocket, IO
263
263
  io
@@ -268,23 +268,33 @@ module Net #:nodoc: all
268
268
  end
269
269
  raise "Unable to create local socket" unless io
270
270
 
271
- super
271
+ # Prior to 2.4.0 `BufferedIO` only takes a single argument (`io`) with no
272
+ # options. Here we pass through our full set of arguments only if we're
273
+ # on 2.4.0 or later, and use a simplified invocation otherwise.
274
+ if RUBY_VERSION >= '2.4.0'
275
+ super
276
+ else
277
+ super(io)
278
+ end
272
279
  end
273
280
 
274
281
  if RUBY_VERSION >= '2.6.0'
282
+ # https://github.com/ruby/ruby/blob/7d02441f0d6e5c9d0a73a024519eba4f69e36dce/lib/net/protocol.rb#L208
283
+ # Modified version of method from ruby, so that nil is always passed into orig_read_nonblock to avoid timeout
275
284
  def rbuf_fill
276
- current_thread_id = Thread.current.object_id
277
-
278
- trace = TracePoint.trace(:line) do |tp|
279
- next unless Thread.current.object_id == current_thread_id
280
- if tp.binding.local_variable_defined?(:tmp)
281
- tp.binding.local_variable_set(:tmp, nil)
282
- end
283
- end
284
-
285
- super
286
- ensure
287
- trace.disable
285
+ case rv = @io.read_nonblock(BUFSIZE, nil, exception: false)
286
+ when String
287
+ return if rv.nil?
288
+ @rbuf << rv
289
+ rv.clear
290
+ return
291
+ when :wait_readable
292
+ @io.to_io.wait_readable(@read_timeout) or raise Net::ReadTimeout
293
+ when :wait_writable
294
+ @io.to_io.wait_writable(@read_timeout) or raise Net::ReadTimeout
295
+ when nil
296
+ raise EOFError, 'end of file reached'
297
+ end while true
288
298
  end
289
299
  end
290
300
  end
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '3.7.6' unless defined?(::WebMock::VERSION)
2
+ VERSION = '3.8.2' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -74,13 +74,13 @@ describe "HTTP.rb" do
74
74
  context "streamer" do
75
75
  it "can be read to a provided buffer" do
76
76
  stub_request(:get, "example.com/foo")
77
- .to_return(status: 200, body: "Hello world!")
77
+ .to_return(status: 200, body: "Hello world!")
78
78
  response = HTTP.get "http://example.com/foo"
79
79
 
80
80
  buffer = ""
81
81
  response.body.readpartial(1024, buffer)
82
82
 
83
- expect(buffer).to eq "Hello world!"
83
+ expect(buffer).to eq "Hello world!"
84
84
  end
85
85
 
86
86
  it "can be closed" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.6
4
+ version: 3.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartosz Blimke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-29 00:00:00.000000000 Z
11
+ date: 2020-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -407,9 +407,9 @@ licenses:
407
407
  - MIT
408
408
  metadata:
409
409
  bug_tracker_uri: https://github.com/bblimke/webmock/issues
410
- changelog_uri: https://github.com/bblimke/webmock/blob/v3.7.6/CHANGELOG.md
411
- documentation_uri: https://www.rubydoc.info/gems/webmock/3.7.6
412
- source_code_uri: https://github.com/bblimke/webmock/tree/v3.7.6
410
+ changelog_uri: https://github.com/bblimke/webmock/blob/v3.8.2/CHANGELOG.md
411
+ documentation_uri: https://www.rubydoc.info/gems/webmock/3.8.2
412
+ source_code_uri: https://github.com/bblimke/webmock/tree/v3.8.2
413
413
  wiki_uri: https://github.com/bblimke/webmock/wiki
414
414
  post_install_message:
415
415
  rdoc_options: []
@@ -426,7 +426,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
426
426
  - !ruby/object:Gem::Version
427
427
  version: '0'
428
428
  requirements: []
429
- rubygems_version: 3.0.3
429
+ rubygems_version: 3.1.2
430
430
  signing_key:
431
431
  specification_version: 4
432
432
  summary: Library for stubbing HTTP requests in Ruby.