webmock 3.11.1 → 3.11.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc97c874689b792ce7a6a84750b324c2cb610fd667c0fbc341dccaf14cc26fc1
4
- data.tar.gz: 05c2e55ba9554c1066f6631c5b5beabfafc05904ce811aef7ceb944b99d5367d
3
+ metadata.gz: 6784322094783787fdf1a995a18c703ef70e0dccf59cbc8ad69cf086b11feb7b
4
+ data.tar.gz: e2e0fc45a8e44efdcfbfd777a733790b6d1762311f62762065e602c281daff09
5
5
  SHA512:
6
- metadata.gz: 27824be10a455582f88966a60539c2f2af49fca630e7ef5f9c49ef342c22d1f28e4abd3fe52a4882cdeb756bb04853798d24f43a4a64575f9e070f287d1cb905
7
- data.tar.gz: 37cbd35aabaff9f013a5305163ef1420dd00b4d3635e1c70bedb246e44e152c189cff4cca9ff561a89220b68e876d80cdfa31aeffdcd7841a36105fa96be2904
6
+ metadata.gz: 277b355a34e07d6bf1c97692fe3c64c54518b16705fc9a6135b1b2000d0cd9e72256e88858e4b4c345cac9cda5d8edf2163f94e69ace05bbc6e75986eae0794d
7
+ data.tar.gz: ba7f43ee30745e58fa57d7030bce1bde7c334b719707642eadcce8963c0e52b88932913ed2a3115b59b6e3477830c87f9646961b7c5bdd95a95086ff733833c8
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ # 3.11.2
4
+
5
+ * Fix for Manticore streaming mode
6
+
7
+ Thanks to [Oleksiy Kovyrin](https://github.com/kovyrin)
8
+
3
9
  # 3.11.1
4
10
 
5
11
  * Compatibility with async-http 0.54+
data/README.md CHANGED
@@ -1153,6 +1153,7 @@ People who submitted patches and new features or suggested improvements. Many th
1153
1153
  * Marek Kasztelnik
1154
1154
  * ce07c3
1155
1155
  * Jun Jiang
1156
+ * Oleksiy Kovyrin
1156
1157
 
1157
1158
  For a full list of contributors you can visit the
1158
1159
  [contributors](https://github.com/bblimke/webmock/contributors) page.
@@ -127,8 +127,15 @@ if defined?(Manticore)
127
127
  def generate_webmock_response(manticore_response)
128
128
  webmock_response = WebMock::Response.new
129
129
  webmock_response.status = [manticore_response.code, manticore_response.message]
130
- webmock_response.body = manticore_response.body
131
130
  webmock_response.headers = manticore_response.headers
131
+
132
+ # The attempt to read the body could fail if manticore is used in a streaming mode
133
+ webmock_response.body = begin
134
+ manticore_response.body
135
+ rescue ::Manticore::StreamClosedException
136
+ nil
137
+ end
138
+
132
139
  webmock_response
133
140
  end
134
141
  end
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '3.11.1' unless defined?(::WebMock::VERSION)
2
+ VERSION = '3.11.2' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -70,6 +70,38 @@ if RUBY_PLATFORM =~ /java/
70
70
  expect(failure_handler).to have_received(:call)
71
71
  end
72
72
  end
73
+
74
+ context 'when used in a streaming mode' do
75
+ let(:webmock_server_url) {"http://#{WebMockServer.instance.host_with_port}/"}
76
+ let(:result_chunks) { [] }
77
+
78
+ def manticore_streaming_get
79
+ Manticore.get(webmock_server_url).tap do |req|
80
+ req.on_success do |response|
81
+ response.body do |chunk|
82
+ result_chunks << chunk
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ context 'when connections are allowed' do
89
+ it 'works' do
90
+ WebMock.allow_net_connect!
91
+ expect { manticore_streaming_get.call }.to_not raise_error
92
+ expect(result_chunks).to_not be_empty
93
+ end
94
+ end
95
+
96
+ context 'when stubbed' do
97
+ it 'works' do
98
+ stub_body = 'hello!'
99
+ stub_request(:get, webmock_server_url).to_return(body: stub_body)
100
+ expect { manticore_streaming_get.call }.to_not raise_error
101
+ expect(result_chunks).to eq [stub_body]
102
+ end
103
+ end
104
+ end
73
105
  end
74
106
  end
75
107
  end
@@ -45,6 +45,7 @@ Gem::Specification.new do |s|
45
45
  s.add_development_dependency 'minitest', '>= 5.0.0'
46
46
  s.add_development_dependency 'test-unit', '>= 3.0.0'
47
47
  s.add_development_dependency 'rdoc', '> 3.5.0'
48
+ s.add_development_dependency 'webrick'
48
49
 
49
50
  s.files = `git ls-files`.split("\n")
50
51
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
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.11.1
4
+ version: 3.11.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: 2021-01-13 00:00:00.000000000 Z
11
+ date: 2021-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -254,6 +254,20 @@ dependencies:
254
254
  - - ">"
255
255
  - !ruby/object:Gem::Version
256
256
  version: 3.5.0
257
+ - !ruby/object:Gem::Dependency
258
+ name: webrick
259
+ requirement: !ruby/object:Gem::Requirement
260
+ requirements:
261
+ - - ">="
262
+ - !ruby/object:Gem::Version
263
+ version: '0'
264
+ type: :development
265
+ prerelease: false
266
+ version_requirements: !ruby/object:Gem::Requirement
267
+ requirements:
268
+ - - ">="
269
+ - !ruby/object:Gem::Version
270
+ version: '0'
257
271
  description: WebMock allows stubbing HTTP requests and setting expectations on HTTP
258
272
  requests.
259
273
  email:
@@ -407,9 +421,9 @@ licenses:
407
421
  - MIT
408
422
  metadata:
409
423
  bug_tracker_uri: https://github.com/bblimke/webmock/issues
410
- changelog_uri: https://github.com/bblimke/webmock/blob/v3.11.1/CHANGELOG.md
411
- documentation_uri: https://www.rubydoc.info/gems/webmock/3.11.1
412
- source_code_uri: https://github.com/bblimke/webmock/tree/v3.11.1
424
+ changelog_uri: https://github.com/bblimke/webmock/blob/v3.11.2/CHANGELOG.md
425
+ documentation_uri: https://www.rubydoc.info/gems/webmock/3.11.2
426
+ source_code_uri: https://github.com/bblimke/webmock/tree/v3.11.2
413
427
  wiki_uri: https://github.com/bblimke/webmock/wiki
414
428
  post_install_message:
415
429
  rdoc_options: []