webmock 3.7.2 → 3.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +4 -0
- data/lib/webmock/http_lib_adapters/http_rb/streamer.rb +2 -2
- data/lib/webmock/http_lib_adapters/manticore_adapter.rb +16 -8
- data/lib/webmock/version.rb +1 -1
- data/spec/acceptance/http_rb/http_rb_spec.rb +11 -0
- data/spec/acceptance/manticore/manticore_spec.rb +19 -0
- data/webmock.gemspec +8 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6023ac450eb0fc7d307ffd764f811e9d409e28fdfabdb215bec15d4e4ea7a363
|
4
|
+
data.tar.gz: 2417fb3aecf50a9b48dc84ee1eb55da9493cff52c68c8a292e0d9215f1c52379
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a83cdbc53a9c75e6d4db3f01e727cc2cb27fb8097dfbad2cd36b39e263bfdc570f60b1c2b924845f81bff2c89dbd91758061c830293c86d0f3a2ba2bb01d619a
|
7
|
+
data.tar.gz: 07cc56e80c126f76ecd53a00b218e80c0a07760d478b1d8354d85f7057828256f4dcc2e857312c83a2bfadbdbcfda0bb20c82510949cabdb24fd3f50657fffbb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.7.3
|
4
|
+
|
5
|
+
* Fix for http.rb. Allow passing an output buffer to HTTP::Response::Body#readpartial
|
6
|
+
|
7
|
+
Thanks to [George Claghorn](https://github.com/georgeclaghorn)
|
8
|
+
|
9
|
+
* Fixed Manticore adapter to invoke Manticore failure handler on stubbed timeout
|
10
|
+
|
11
|
+
Thanks to [Alex Junger](https://github.com/alexJunger)
|
12
|
+
|
13
|
+
* Added project metadata to the gemspec
|
14
|
+
|
15
|
+
Thanks to [Orien Madgwick](https://github.com/orien)
|
16
|
+
|
3
17
|
## 3.7.2
|
4
18
|
|
5
19
|
* Fixed handling of non UTF-8 encoded urls
|
data/README.md
CHANGED
@@ -1109,6 +1109,10 @@ People who submitted patches and new features or suggested improvements. Many th
|
|
1109
1109
|
* Andriy Yanko
|
1110
1110
|
* y-yagi
|
1111
1111
|
* Rafael França
|
1112
|
+
* George Claghorn
|
1113
|
+
* Alex Junger
|
1114
|
+
* Orien Madgwick
|
1115
|
+
|
1112
1116
|
|
1113
1117
|
|
1114
1118
|
For a full list of contributors you can visit the
|
@@ -5,7 +5,7 @@ module HTTP
|
|
5
5
|
@io = StringIO.new str
|
6
6
|
end
|
7
7
|
|
8
|
-
def readpartial(size = nil)
|
8
|
+
def readpartial(size = nil, outbuf = nil)
|
9
9
|
unless size
|
10
10
|
if defined?(HTTP::Client::BUFFER_SIZE)
|
11
11
|
size = HTTP::Client::BUFFER_SIZE
|
@@ -14,7 +14,7 @@ module HTTP
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
@io.read size
|
17
|
+
@io.read size, outbuf
|
18
18
|
end
|
19
19
|
|
20
20
|
def close
|
@@ -24,6 +24,12 @@ if defined?(Manticore)
|
|
24
24
|
Manticore.instance_variable_set(:@manticore_facade, OriginalManticoreClient.new)
|
25
25
|
end
|
26
26
|
|
27
|
+
class StubbedTimeoutResponse < Manticore::StubbedResponse
|
28
|
+
def call
|
29
|
+
@handlers[:failure].call(Manticore::ConnectTimeout.new("Too slow (mocked timeout)"))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
27
33
|
class WebMockManticoreClient < Manticore::Client
|
28
34
|
def request(klass, url, options={}, &block)
|
29
35
|
super(klass, WebMock::Util::URI.normalize_uri(url).to_s, format_options(options))
|
@@ -106,14 +112,16 @@ if defined?(Manticore)
|
|
106
112
|
end
|
107
113
|
|
108
114
|
def generate_manticore_response(webmock_response)
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
115
|
+
if webmock_response.should_timeout
|
116
|
+
StubbedTimeoutResponse.new
|
117
|
+
else
|
118
|
+
Manticore::StubbedResponse.stub(
|
119
|
+
code: webmock_response.status[0],
|
120
|
+
body: webmock_response.body,
|
121
|
+
headers: webmock_response.headers,
|
122
|
+
cookies: {}
|
123
|
+
)
|
124
|
+
end
|
117
125
|
end
|
118
126
|
|
119
127
|
def generate_webmock_response(manticore_response)
|
data/lib/webmock/version.rb
CHANGED
@@ -72,6 +72,17 @@ describe "HTTP.rb" do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
context "streamer" do
|
75
|
+
it "can be read to a provided buffer" do
|
76
|
+
stub_request(:get, "example.com/foo")
|
77
|
+
.to_return(status: 200, body: "Hello world!")
|
78
|
+
response = HTTP.get "http://example.com/foo"
|
79
|
+
|
80
|
+
buffer = ""
|
81
|
+
response.body.readpartial(1024, buffer)
|
82
|
+
|
83
|
+
expect(buffer).to eq "Hello world!"
|
84
|
+
end
|
85
|
+
|
75
86
|
it "can be closed" do
|
76
87
|
stub_request :get, "example.com/foo"
|
77
88
|
response = HTTP.get "http://example.com/foo"
|
@@ -51,6 +51,25 @@ if RUBY_PLATFORM =~ /java/
|
|
51
51
|
response = Manticore.head("http://example-foo.com")
|
52
52
|
expect(response.code).to eq(204)
|
53
53
|
end
|
54
|
+
|
55
|
+
context "when a custom failure handler is defined" do
|
56
|
+
let(:failure_handler) { proc {} }
|
57
|
+
|
58
|
+
before do
|
59
|
+
allow(failure_handler).to receive(:call).with(kind_of(Manticore::Timeout)) do |ex|
|
60
|
+
raise ex
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it "handles timeouts by invoking the failure handler" do
|
65
|
+
stub_request(:get, "http://example-foo.com").to_timeout
|
66
|
+
request = Manticore.get("http://example-foo.com").tap do |req|
|
67
|
+
req.on_failure(&failure_handler)
|
68
|
+
end
|
69
|
+
expect { request.call }.to raise_error(Manticore::Timeout)
|
70
|
+
expect(failure_handler).to have_received(:call)
|
71
|
+
end
|
72
|
+
end
|
54
73
|
end
|
55
74
|
end
|
56
75
|
end
|
data/webmock.gemspec
CHANGED
@@ -13,6 +13,14 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.description = %q{WebMock allows stubbing HTTP requests and setting expectations on HTTP requests.}
|
14
14
|
s.license = "MIT"
|
15
15
|
|
16
|
+
s.metadata = {
|
17
|
+
'bug_tracker_uri' => 'https://github.com/bblimke/webmock/issues',
|
18
|
+
'changelog_uri' => "https://github.com/bblimke/webmock/blob/v#{s.version}/CHANGELOG.md",
|
19
|
+
'documentation_uri' => "https://www.rubydoc.info/gems/webmock/#{s.version}",
|
20
|
+
'source_code_uri' => "https://github.com/bblimke/webmock/tree/v#{s.version}",
|
21
|
+
'wiki_uri' => 'https://github.com/bblimke/webmock/wiki'
|
22
|
+
}
|
23
|
+
|
16
24
|
s.required_ruby_version = '>= 2.0'
|
17
25
|
|
18
26
|
s.add_dependency 'addressable', '>= 2.3.6'
|
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.
|
4
|
+
version: 3.7.3
|
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-
|
11
|
+
date: 2019-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -405,7 +405,12 @@ files:
|
|
405
405
|
homepage: http://github.com/bblimke/webmock
|
406
406
|
licenses:
|
407
407
|
- MIT
|
408
|
-
metadata:
|
408
|
+
metadata:
|
409
|
+
bug_tracker_uri: https://github.com/bblimke/webmock/issues
|
410
|
+
changelog_uri: https://github.com/bblimke/webmock/blob/v3.7.3/CHANGELOG.md
|
411
|
+
documentation_uri: https://www.rubydoc.info/gems/webmock/3.7.3
|
412
|
+
source_code_uri: https://github.com/bblimke/webmock/tree/v3.7.3
|
413
|
+
wiki_uri: https://github.com/bblimke/webmock/wiki
|
409
414
|
post_install_message:
|
410
415
|
rdoc_options: []
|
411
416
|
require_paths:
|