webmock 3.7.3 → 3.8.1
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 +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +34 -0
- data/README.md +7 -2
- data/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +3 -3
- data/lib/webmock/http_lib_adapters/curb_adapter.rb +4 -0
- data/lib/webmock/http_lib_adapters/excon_adapter.rb +3 -0
- data/lib/webmock/http_lib_adapters/http_rb/response.rb +1 -1
- data/lib/webmock/http_lib_adapters/net_http.rb +26 -16
- data/lib/webmock/version.rb +1 -1
- data/spec/acceptance/curb/curb_spec.rb +12 -5
- data/spec/acceptance/excon/excon_spec_helper.rb +2 -0
- data/spec/acceptance/http_rb/http_rb_spec.rb +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4eb1f45308b980dfaa6f5e292efad872723d4f4d5d51a2edc07fac71f58ff79
|
4
|
+
data.tar.gz: b26aea6c4f2823a534274984ddf7a1d77bf69b0f9eb41e62dea9341c13efa028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d914ab7d87674019a2f2ffe195a296ff488067b2971caf588f221ff6810fdbc7b646f529c680d7b0aefd09eb98a6db7b66fa1c8767f0fe6ee244df32e5ac583a
|
7
|
+
data.tar.gz: af18127a0082d5b74b400af4406909393de802ffc775ed5ecae25305ea0d06dbd571ed92d042d064c0aefad4e07b5ff32a660037fc63467143a4e0a71be3309b
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,39 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.8.1
|
4
|
+
|
5
|
+
* Added support for mocking non-ASCII bodies when making requests with HTTP.rb
|
6
|
+
|
7
|
+
Thanks to [Patrik Ragnarsson](https://github.com/dentarg)
|
8
|
+
|
9
|
+
## 3.8.0
|
10
|
+
|
11
|
+
* Fixed options handling when initialising Async::HTTP::Client
|
12
|
+
|
13
|
+
Thanks to [Samuel Williams](https://github.com/ioquatix)
|
14
|
+
|
15
|
+
* Ruby 2.7 support.
|
16
|
+
|
17
|
+
Thanks to [Ryan Davis](https://github.com/zenspider) and [Brandur](https://github.com/brandur)
|
18
|
+
|
19
|
+
## 3.7.6
|
20
|
+
|
21
|
+
* Suppressed keyword argument warnings in Ruby 2.7 in async-http adapter.
|
22
|
+
|
23
|
+
Thanks to [Koichi ITO](https://github.com/koic)
|
24
|
+
|
25
|
+
## 3.7.5
|
26
|
+
|
27
|
+
* Suppress Excon warning generated by extra key
|
28
|
+
|
29
|
+
Thanks to [Marco Costa](https://github.com/marcotc)
|
30
|
+
|
31
|
+
## 3.7.4
|
32
|
+
|
33
|
+
* Resetting memoized response fields in Curb adapter.
|
34
|
+
|
35
|
+
Thanks to [Andrei Sidorov](https://github.com/heretge)
|
36
|
+
|
3
37
|
## 3.7.3
|
4
38
|
|
5
39
|
* Fix for http.rb. Allow passing an output buffer to HTTP::Response::Body#readpartial
|
data/README.md
CHANGED
@@ -43,6 +43,7 @@ Supported Ruby Interpreters
|
|
43
43
|
* MRI 2.4
|
44
44
|
* MRI 2.5
|
45
45
|
* MRI 2.6
|
46
|
+
* MRI 2.7
|
46
47
|
* JRuby
|
47
48
|
* Rubinius
|
48
49
|
|
@@ -1112,8 +1113,12 @@ People who submitted patches and new features or suggested improvements. Many th
|
|
1112
1113
|
* George Claghorn
|
1113
1114
|
* Alex Junger
|
1114
1115
|
* Orien Madgwick
|
1115
|
-
|
1116
|
-
|
1116
|
+
* Andrei Sidorov
|
1117
|
+
* Marco Costa
|
1118
|
+
* Ryan Davis
|
1119
|
+
* Brandur
|
1120
|
+
* Samuel Williams
|
1121
|
+
* Patrik Ragnarsson
|
1117
1122
|
|
1118
1123
|
For a full list of contributors you can visit the
|
1119
1124
|
[contributors](https://github.com/bblimke/webmock/contributors) page.
|
@@ -36,12 +36,12 @@ 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
|
|
43
|
-
@network_client = WebMockClient.new(endpoint, protocol, scheme, authority, options)
|
44
|
-
@webmock_client = WebMockClient.new(webmock_endpoint, protocol, scheme, authority, options)
|
43
|
+
@network_client = WebMockClient.new(endpoint, protocol, scheme, authority, **options)
|
44
|
+
@webmock_client = WebMockClient.new(webmock_endpoint, protocol, scheme, authority, **options)
|
45
45
|
|
46
46
|
@scheme = scheme
|
47
47
|
@authority = authority
|
@@ -340,6 +340,10 @@ if defined?(Curl)
|
|
340
340
|
|
341
341
|
def reset
|
342
342
|
instance_variable_set(:@body_str, nil)
|
343
|
+
instance_variable_set(:@content_type, nil)
|
344
|
+
instance_variable_set(:@header_str, nil)
|
345
|
+
instance_variable_set(:@last_effective_url, nil)
|
346
|
+
instance_variable_set(:@response_code, nil)
|
343
347
|
super
|
344
348
|
end
|
345
349
|
end
|
@@ -14,7 +14,7 @@ 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
|
17
|
+
body = Body.new(Streamer.new(webmock_response.body), encoding: webmock_response.body.encoding)
|
18
18
|
uri = normalize_uri(request_signature && request_signature.uri)
|
19
19
|
|
20
20
|
return new(status, "1.1", headers, body, uri) if HTTP::VERSION < "1.0.0"
|
@@ -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
|
-
|
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
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
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
|
data/lib/webmock/version.rb
CHANGED
@@ -474,18 +474,25 @@ unless RUBY_PLATFORM =~ /java/
|
|
474
474
|
include CurbSpecHelper::ClassPerform
|
475
475
|
end
|
476
476
|
|
477
|
-
describe "using
|
477
|
+
describe "using #reset" do
|
478
478
|
before do
|
479
479
|
@curl = Curl::Easy.new
|
480
480
|
@curl.url = "http://example.com"
|
481
|
-
|
482
|
-
|
481
|
+
stub_request(:any, "example.com").
|
482
|
+
to_return(body: "abc",
|
483
|
+
headers: { "Content-Type" => "application/json" })
|
483
484
|
@curl.http_get
|
484
485
|
end
|
485
486
|
|
486
|
-
it "should clear
|
487
|
+
it "should clear all memoized response fields" do
|
487
488
|
@curl.reset
|
488
|
-
expect(@curl
|
489
|
+
expect(@curl).to have_attributes(
|
490
|
+
body_str: nil,
|
491
|
+
content_type: nil,
|
492
|
+
header_str: nil,
|
493
|
+
last_effective_url: nil,
|
494
|
+
response_code: 0,
|
495
|
+
)
|
489
496
|
end
|
490
497
|
end
|
491
498
|
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.
|
4
|
+
version: 3.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartosz Blimke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-05 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.
|
411
|
-
documentation_uri: https://www.rubydoc.info/gems/webmock/3.
|
412
|
-
source_code_uri: https://github.com/bblimke/webmock/tree/v3.
|
410
|
+
changelog_uri: https://github.com/bblimke/webmock/blob/v3.8.1/CHANGELOG.md
|
411
|
+
documentation_uri: https://www.rubydoc.info/gems/webmock/3.8.1
|
412
|
+
source_code_uri: https://github.com/bblimke/webmock/tree/v3.8.1
|
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.
|
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.
|