webmock 3.7.2 → 3.8.0

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: 95babf82ad860e3ab49c323e66fcc785820dfecf100c03aa2fc126329e35c64a
4
- data.tar.gz: 36d86569a52f5a999d9d2093a05a09fde833aaa669d94b94325ca11f03479027
3
+ metadata.gz: c7f69433e4cc2a3e16c2ba55df62db7f99585200c9bc9bc1d1e9f53df9fc8bb6
4
+ data.tar.gz: ffa4936d1432c8256bcd244db949cd75342170d60c9920707846ae6d12540434
5
5
  SHA512:
6
- metadata.gz: 34a48904414979c39edd9ee796172ea6a2018392b9a3a6e9ef28fc47b550e542f83c247382206e0d13fe51df8becd008f6b4e135976f7f08b3088fe13f680670
7
- data.tar.gz: bb1a6e478680c68f109a0937f7b372a08e3f2a0385fa79386acae1ed5db35b679224376b62258472dcf55b66386166a8dcbf9c1580beb16938e439816f475873
6
+ metadata.gz: 272c6a7bab37739d29fe8412264227325c4ceda06d17a6df13ba6ed317bda6770865063ef99b215c7880029f4a4dca1114e88fb5c0c017efeddee3a67f68cdf9
7
+ data.tar.gz: b86032f68e0e058d99c2ab61b1d360756d9bf4611cf383588feaad866a1d33964b4150a7819f5c1b0c64651539aed99499de7f8e1efbac476f99769f76abcfd4
@@ -1,11 +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
8
+ - 2.7.0
9
9
  - rbx-2
10
10
  - ruby-head
11
11
  - jruby-9.1.17.0
@@ -1,5 +1,47 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.8.0
4
+
5
+ * Fixed options handling when initialising Async::HTTP::Client
6
+
7
+ Thanks to [Samuel Williams](https://github.com/ioquatix)
8
+
9
+ * Ruby 2.7 support.
10
+
11
+ Thanks to [Ryan Davis](https://github.com/zenspider) and [Brandur](https://github.com/brandur)
12
+
13
+ ## 3.7.6
14
+
15
+ * Suppressed keyword argument warnings in Ruby 2.7 in async-http adapter.
16
+
17
+ Thanks to [Koichi ITO](https://github.com/koic)
18
+
19
+ ## 3.7.5
20
+
21
+ * Suppress Excon warning generated by extra key
22
+
23
+ Thanks to [Marco Costa](https://github.com/marcotc)
24
+
25
+ ## 3.7.4
26
+
27
+ * Resetting memoized response fields in Curb adapter.
28
+
29
+ Thanks to [Andrei Sidorov](https://github.com/heretge)
30
+
31
+ ## 3.7.3
32
+
33
+ * Fix for http.rb. Allow passing an output buffer to HTTP::Response::Body#readpartial
34
+
35
+ Thanks to [George Claghorn](https://github.com/georgeclaghorn)
36
+
37
+ * Fixed Manticore adapter to invoke Manticore failure handler on stubbed timeout
38
+
39
+ Thanks to [Alex Junger](https://github.com/alexJunger)
40
+
41
+ * Added project metadata to the gemspec
42
+
43
+ Thanks to [Orien Madgwick](https://github.com/orien)
44
+
3
45
  ## 3.7.2
4
46
 
5
47
  * Fixed handling of non UTF-8 encoded urls
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
 
@@ -1109,7 +1110,14 @@ People who submitted patches and new features or suggested improvements. Many th
1109
1110
  * Andriy Yanko
1110
1111
  * y-yagi
1111
1112
  * Rafael França
1112
-
1113
+ * George Claghorn
1114
+ * Alex Junger
1115
+ * Orien Madgwick
1116
+ * Andrei Sidorov
1117
+ * Marco Costa
1118
+ * Ryan Davis
1119
+ * Brandur
1120
+ * Samuel Williams
1113
1121
 
1114
1122
  For a full list of contributors you can visit the
1115
1123
  [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
@@ -159,4 +159,7 @@ if defined?(Excon)
159
159
  end
160
160
  end
161
161
  end
162
+
163
+ # Suppresses Excon connection argument validation warning
164
+ Excon::VALID_CONNECTION_KEYS << :__construction_args
162
165
  end
@@ -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
- raise Manticore::ConnectTimeout if webmock_response.should_timeout
110
-
111
- Manticore::StubbedResponse.stub(
112
- code: webmock_response.status[0],
113
- body: webmock_response.body,
114
- headers: webmock_response.headers,
115
- cookies: {}
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)
@@ -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,7 +268,14 @@ 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'
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '3.7.2' unless defined?(::WebMock::VERSION)
2
+ VERSION = '3.8.0' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -474,18 +474,25 @@ unless RUBY_PLATFORM =~ /java/
474
474
  include CurbSpecHelper::ClassPerform
475
475
  end
476
476
 
477
- describe "using .reset" do
477
+ describe "using #reset" do
478
478
  before do
479
479
  @curl = Curl::Easy.new
480
480
  @curl.url = "http://example.com"
481
- body = "on_success fired"
482
- stub_request(:any, "example.com").to_return(body: body)
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 the body_str" do
487
+ it "should clear all memoized response fields" do
487
488
  @curl.reset
488
- expect(@curl.body_str).to eq(nil)
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
@@ -28,6 +28,8 @@ module ExconSpecHelper
28
28
  res
29
29
  end
30
30
 
31
+ Excon.set_raise_on_warnings!(true)
32
+
31
33
  OpenStruct.new \
32
34
  body: response.body,
33
35
  headers: headers,
@@ -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
@@ -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.2
4
+ version: 3.8.0
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-04 00:00:00.000000000 Z
11
+ date: 2020-01-14 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.8.0/CHANGELOG.md
411
+ documentation_uri: https://www.rubydoc.info/gems/webmock/3.8.0
412
+ source_code_uri: https://github.com/bblimke/webmock/tree/v3.8.0
413
+ wiki_uri: https://github.com/bblimke/webmock/wiki
409
414
  post_install_message:
410
415
  rdoc_options: []
411
416
  require_paths: