webmock 3.7.0 → 3.7.5

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: e385b4f3b881b29e228d1b6517f4f7a119fbde52757c0076a1be4ad97fb7c860
4
- data.tar.gz: ed890699362b956dd2f3e8707d33377069064183355015a6bc7d4fdfbc1d94b9
3
+ metadata.gz: 27c0b6ee25eb2a1a31df70a1725d3fcda71aec62460d79b3ba7e05109d602fc1
4
+ data.tar.gz: 07a3ae5f5d93e5c5b86ddae8ab4f351c48777d98a80d4f997faa062b5ca3619a
5
5
  SHA512:
6
- metadata.gz: 93519997dde799f24eb9f64412b5c49ff2b1444fe0158ead76cbf9d340d0273f63aa6790e3acaf5b621df08df621d85d7b3c6a50b55f0d82494869fdac5e491a
7
- data.tar.gz: 8668e895d819594f52963336a376c3b0a6b857eccc557d42f5d0d71757ed64af02efd10275c494b2c64b577b81e7f454017ecd5a5b50f4946e817979162521ef
6
+ metadata.gz: 13c2debfa3694d911cb44abb89be6f205427dc952fa3e3680d5a0035807c5443f2dace34fe2135f5ecd53bf6da6e206b90f7ee9231f6a8251d8ac79d4ce00e1a
7
+ data.tar.gz: 7bdd1a5b5df68f92eb75ef2686a95cf0a40423d603177470e2940c0317f87e3b73aba8d92547eaad34d3a5225d8627ac026e964a09280d7259c5b272321619c0
@@ -1,5 +1,47 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.7.5
4
+
5
+ * Suppress Excon warning generated by extra key
6
+
7
+ Thanks to [Marco Costa](https://github.com/marcotc)
8
+
9
+ ## 3.7.4
10
+
11
+ * Resetting memoized response fields in Curb adapter.
12
+
13
+ Thanks to [Andrei Sidorov](https://github.com/heretge)
14
+
15
+ ## 3.7.3
16
+
17
+ * Fix for http.rb. Allow passing an output buffer to HTTP::Response::Body#readpartial
18
+
19
+ Thanks to [George Claghorn](https://github.com/georgeclaghorn)
20
+
21
+ * Fixed Manticore adapter to invoke Manticore failure handler on stubbed timeout
22
+
23
+ Thanks to [Alex Junger](https://github.com/alexJunger)
24
+
25
+ * Added project metadata to the gemspec
26
+
27
+ Thanks to [Orien Madgwick](https://github.com/orien)
28
+
29
+ ## 3.7.2
30
+
31
+ * Fixed handling of non UTF-8 encoded urls
32
+
33
+ Thanks to [Rafael França](https://github.com/rafaelfranca)
34
+
35
+ * Fixed "shadowing outer local variable" warning
36
+
37
+ Thanks to [y-yagi](https://github.com/y-yagi)
38
+
39
+ ## 3.7.1
40
+
41
+ * Fixed Async::HTTP::Client adapter code to not cause Ruby warning
42
+
43
+ Thanks to [y-yagi](https://github.com/y-yagi)
44
+
3
45
  ## 3.7.0
4
46
 
5
47
  * Support for Async::HTTP::Client
data/README.md CHANGED
@@ -1107,7 +1107,13 @@ People who submitted patches and new features or suggested improvements. Many th
1107
1107
  * Frederick Cheung
1108
1108
  * Fábio D. Batista
1109
1109
  * Andriy Yanko
1110
-
1110
+ * y-yagi
1111
+ * Rafael França
1112
+ * George Claghorn
1113
+ * Alex Junger
1114
+ * Orien Madgwick
1115
+ * Andrei Sidorov
1116
+ * Marco Costa
1111
1117
 
1112
1118
  For a full list of contributors you can visit the
1113
1119
  [contributors](https://github.com/bblimke/webmock/contributors) page.
@@ -195,8 +195,8 @@ if defined?(Async::HTTP)
195
195
  end
196
196
 
197
197
  def build_response(webmock_response)
198
- headers = (webmock_response.headers || {}).each_with_object([]) do |(k, v), o|
199
- Array(v).each do |v|
198
+ headers = (webmock_response.headers || {}).each_with_object([]) do |(k, value), o|
199
+ Array(value).each do |v|
200
200
  o.push [k, v]
201
201
  end
202
202
  end
@@ -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
@@ -107,7 +107,7 @@ if defined?(EventMachine::HttpClient)
107
107
  @uri ||= nil
108
108
  EM.next_tick {
109
109
  setup(make_raw_response(stubbed_webmock_response), @uri,
110
- stubbed_webmock_response.should_timeout ? "WebMock timeout error" : nil)
110
+ stubbed_webmock_response.should_timeout ? Errno::ETIMEDOUT : nil)
111
111
  }
112
112
  self
113
113
  elsif WebMock.net_connect_allowed?(request_signature.uri)
@@ -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)
@@ -86,20 +86,21 @@ module WebMock
86
86
 
87
87
  def self.uris_encoded_and_unencoded(uris)
88
88
  uris.map do |uri|
89
- [ uri.to_s, Addressable::URI.unencode(uri, String).freeze ]
89
+ [
90
+ uri.to_s.force_encoding(Encoding::ASCII_8BIT),
91
+ Addressable::URI.unencode(uri, String).force_encoding(Encoding::ASCII_8BIT).freeze
92
+ ]
90
93
  end.flatten
91
94
  end
92
95
 
93
96
  def self.uris_with_scheme_and_without(uris)
94
97
  uris.map { |uri|
95
- uri = uri.dup.force_encoding(Encoding::ASCII_8BIT) if uri.respond_to?(:force_encoding)
96
98
  [ uri, uri.gsub(%r{^https?://},"").freeze ]
97
99
  }.flatten
98
100
  end
99
101
 
100
102
  def self.uris_with_trailing_slash_and_without(uris)
101
- uris = uris.map { |uri|
102
- uri = uri.dup.force_encoding(Encoding::ASCII_8BIT) if uri.respond_to?(:force_encoding)
103
+ uris.map { |uri|
103
104
  [ uri, uri.omit(:path).freeze ]
104
105
  }.flatten
105
106
  end
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '3.7.0' unless defined?(::WebMock::VERSION)
2
+ VERSION = '3.7.5' 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
@@ -50,7 +50,7 @@ module EMHttpRequestSpecHelper
50
50
  end
51
51
 
52
52
  def client_timeout_exception_class
53
- "WebMock timeout error"
53
+ 'Errno::ETIMEDOUT'
54
54
  end
55
55
 
56
56
  def connection_refused_exception_class
@@ -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
@@ -177,6 +177,16 @@ describe WebMock::Util::URI do
177
177
  end
178
178
  end
179
179
 
180
+ it "should find all variations of uris with https, basic auth, a non-standard port and a path" do
181
+ uri = "https://~%8A:pass@www.example.com:9000/foo"
182
+ variations = [
183
+ "https://~%8A:pass@www.example.com:9000/foo",
184
+ "https://~\x8A:pass@www.example.com:9000/foo".force_encoding(Encoding::ASCII_8BIT)
185
+ ]
186
+
187
+ expect(WebMock::Util::URI.variations_of_uri_as_strings(uri)).to eq(variations)
188
+ end
189
+
180
190
  end
181
191
 
182
192
  describe "normalized uri equality" do
@@ -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.0
4
+ version: 3.7.5
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-08-27 00:00:00.000000000 Z
11
+ date: 2019-09-17 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.5/CHANGELOG.md
411
+ documentation_uri: https://www.rubydoc.info/gems/webmock/3.7.5
412
+ source_code_uri: https://github.com/bblimke/webmock/tree/v3.7.5
413
+ wiki_uri: https://github.com/bblimke/webmock/wiki
409
414
  post_install_message:
410
415
  rdoc_options: []
411
416
  require_paths: