webmock 3.6.0 → 3.6.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: 137bc694f0b4f457b84a5fc6f93a7b2227ff19bcb6e8bd1525244649df56898c
4
- data.tar.gz: f998d2cd340cffd2637bcc3cf8cfe322c85de1055d07b51c7e193acde549d340
3
+ metadata.gz: 9d54455d6752d60f630b108721f21ad51f4d2e648cf1fe492f72cce5d0e3bd66
4
+ data.tar.gz: 937d29ecd33fe244fe5f9749140d94c4ea68134b8afdcdd44a4ec41d5562df10
5
5
  SHA512:
6
- metadata.gz: 9b36a8ce4d2b4b779e89f5e7db1ed1c8e17817f1088fcd9d92e8f2154373a254292240dffc0d7f376fb86c1230f0371aefa6a56163710cc2ed86301915270b52
7
- data.tar.gz: 54d26c28e44ebec703628a4473f4bc1547f7c6fad2eeefbffea77398fed62759f131f94bd7fceb78275a8be70d30c94586383ecb43c1f16882a8dfe4e89dcf53
6
+ metadata.gz: 46ffed006b40f5d04d66ca5c3997f5874801e55d50a6580c1f3686a1c06a2fd4f69b4ab23c07f4828bdf01ace8749a0a7874a92db04780e621333a731bf89baf
7
+ data.tar.gz: 3d265897b59b5adcf8cf1954c5656160eb8bfeeb583d3abdcf9883b61b88b1b09ed050da8f45f582a190a86beb8d1bb809d55b39d89ac9ab4ed1681bc05ebeaa
@@ -5,12 +5,13 @@ rvm:
5
5
  - 2.3.8
6
6
  - 2.4.6
7
7
  - 2.5.5
8
- - 2.6.2
8
+ - 2.6.3
9
9
  - rbx-2
10
10
  - ruby-head
11
11
  - jruby-9.1.17.0
12
- - jruby-9.2.6.0
12
+ - jruby-9.2.7.0
13
13
  - jruby-head
14
+ jdk: openjdk8
14
15
  matrix:
15
16
  allow_failures:
16
17
  - rvm: jruby-head
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.6.2
4
+
5
+ * Fixed Patron adapter to handle HTTP/2 status line.
6
+
7
+ Thanks to [Fábio D. Batista](https://github.com/fabiob)
8
+
9
+ ## 3.6.1
10
+
11
+ * Fixed issue with matching Addressable::Template without a period in the domain
12
+
13
+ Thanks to [Eike Send](https://github.com/eikes)
14
+
15
+ * Support for `write_timeout` in Net::HTTP
16
+
17
+ Thanks to [Claudio Poli](https://github.com/masterkain)
18
+
19
+ * Fixed issue with handling urls with ":80" or ":443" in the path.
20
+
21
+ Thanks to [Csaba Apagyi](https://github.com/thisismydesign) for reporting and to [Frederick Cheung](https://github.com/fcheung) for fixing the issue.
22
+
3
23
  ## 3.6.0
4
24
 
5
25
  * Compatibility with the latest version of hashdiff gem, with constant changed from HashDiff to Hashdiff
data/README.md CHANGED
@@ -878,6 +878,10 @@ end
878
878
 
879
879
  Please submit them here [http://github.com/bblimke/webmock/issues](http://github.com/bblimke/webmock/issues)
880
880
 
881
+ ## Issue triage [![Open Source Helpers](https://www.codetriage.com/bblimke/webmock/badges/users.svg)](https://www.codetriage.com/bblimke/webmock)
882
+
883
+ You can contribute by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to webmock on CodeTriage](https://www.codetriage.com/bblimke/webmock).
884
+
881
885
  ## Suggestions
882
886
 
883
887
  If you have any suggestions on how to improve WebMock please send an email to the mailing list [groups.google.com/group/webmock-users](http://groups.google.com/group/webmock-users)
@@ -1096,6 +1100,14 @@ People who submitted patches and new features or suggested improvements. Many th
1096
1100
  * Pavel Valena
1097
1101
  * Adam Sokolnicki
1098
1102
  * Jeff Felchner
1103
+ * Eike Send
1104
+ * Claudio Poli
1105
+ * Csaba Apagyi
1106
+ * Frederick Cheung
1107
+ * Fábio D. Batista
1108
+
1109
+
1110
+
1099
1111
 
1100
1112
  For a full list of contributors you can visit the
1101
1113
  [contributors](https://github.com/bblimke/webmock/contributors) page.
@@ -50,19 +50,22 @@ if defined?(Manticore)
50
50
 
51
51
  if webmock_response = registered_response_for(request_signature)
52
52
  webmock_response.raise_error_if_any
53
- manticore_response = generate_manticore_response(webmock_response).call
54
- real_request = false
53
+ manticore_response = generate_manticore_response(webmock_response)
54
+ manticore_response.on_success do
55
+ WebMock::CallbackRegistry.invoke_callbacks({lib: :manticore, real_request: false}, request_signature, webmock_response)
56
+ end
55
57
 
56
58
  elsif real_request_allowed?(request_signature.uri)
57
- manticore_response = Manticore::Response.new(self, request, context, &block).call
58
- webmock_response = generate_webmock_response(manticore_response)
59
- real_request = true
59
+ manticore_response = Manticore::Response.new(self, request, context, &block)
60
+ manticore_response.on_complete do |completed_response|
61
+ webmock_response = generate_webmock_response(completed_response)
62
+ WebMock::CallbackRegistry.invoke_callbacks({lib: :manticore, real_request: true}, request_signature, webmock_response)
63
+ end
60
64
 
61
65
  else
62
66
  raise WebMock::NetConnectNotAllowedError.new(request_signature)
63
67
  end
64
68
 
65
- WebMock::CallbackRegistry.invoke_callbacks({lib: :manticore, real_request: real_request}, request_signature, webmock_response)
66
69
  manticore_response
67
70
  end
68
71
 
@@ -229,14 +229,15 @@ class PatchedStringIO < StringIO #:nodoc:
229
229
  alias_method :orig_read_nonblock, :read_nonblock
230
230
 
231
231
  def read_nonblock(size, *args)
232
- orig_read_nonblock(size)
232
+ args.reject! {|arg| !arg.is_a?(Hash)}
233
+ orig_read_nonblock(size, *args)
233
234
  end
234
235
 
235
236
  end
236
237
 
237
238
  class StubSocket #:nodoc:
238
239
 
239
- attr_accessor :read_timeout, :continue_timeout
240
+ attr_accessor :read_timeout, :continue_timeout, :write_timeout
240
241
 
241
242
  def initialize(*args)
242
243
  end
@@ -118,7 +118,7 @@ if defined?(::Patron)
118
118
  def self.build_webmock_response(patron_response)
119
119
  webmock_response = WebMock::Response.new
120
120
  reason = patron_response.status_line.
121
- scan(%r(\AHTTP/(\d+\.\d+)\s+(\d\d\d)\s*([^\r\n]+)?))[0][2]
121
+ scan(%r(\AHTTP/(\d+(?:\.\d+)?)\s+(\d\d\d)\s*([^\r\n]+)?))[0][2]
122
122
  webmock_response.status = [patron_response.status, reason]
123
123
  webmock_response.body = patron_response.body
124
124
  webmock_response.headers = patron_response.headers
@@ -183,8 +183,7 @@ module WebMock
183
183
  def matches_with_variations?(uri)
184
184
  normalized_template = Addressable::Template.new(WebMock::Util::URI.heuristic_parse(@pattern.pattern))
185
185
 
186
- WebMock::Util::URI.variations_of_uri_as_strings(uri, only_with_scheme: true)
187
- .any? { |u| normalized_template.match(u) }
186
+ WebMock::Util::URI.variations_of_uri_as_strings(uri).any? { |u| normalized_template.match(u) }
188
187
  end
189
188
  end
190
189
 
@@ -41,12 +41,12 @@ module WebMock
41
41
  uris = uris_with_trailing_slash_and_without(uris)
42
42
  end
43
43
 
44
- uris = uris_encoded_and_unencoded(uris)
45
-
46
44
  if normalized_uri.port == Addressable::URI.port_mapping[normalized_uri.scheme]
47
45
  uris = uris_with_inferred_port_and_without(uris)
48
46
  end
49
47
 
48
+ uris = uris_encoded_and_unencoded(uris)
49
+
50
50
  if normalized_uri.scheme == "http" && !only_with_scheme
51
51
  uris = uris_with_scheme_and_without(uris)
52
52
  end
@@ -80,8 +80,7 @@ module WebMock
80
80
 
81
81
  def self.uris_with_inferred_port_and_without(uris)
82
82
  uris.map { |uri|
83
- uri = uri.dup.force_encoding(Encoding::ASCII_8BIT) if uri.respond_to?(:force_encoding)
84
- [ uri, uri.gsub(%r{(:80)|(:443)}, "").freeze ]
83
+ [ uri, uri.omit(:port)]
85
84
  }.flatten
86
85
  end
87
86
 
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '3.6.0' unless defined?(::WebMock::VERSION)
2
+ VERSION = '3.6.2' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -36,6 +36,7 @@ class WebMockServer
36
36
  end
37
37
  end
38
38
  server.start do |socket|
39
+ socket.read(1)
39
40
  socket.puts <<-EOT.gsub(/^\s+\|/, '')
40
41
  |HTTP/1.1 200 OK\r
41
42
  |Date: Fri, 31 Dec 1999 23:59:59 GMT\r
@@ -121,6 +121,11 @@ describe WebMock::RequestPattern do
121
121
  to match(WebMock::RequestSignature.new(:get, "www.example.com"))
122
122
  end
123
123
 
124
+ it "should match if uri Addressable::Template pattern matches request uri without TLD" do
125
+ expect(WebMock::RequestPattern.new(:get, Addressable::Template.new("localhost"))).
126
+ to match(WebMock::RequestSignature.new(:get, "localhost"))
127
+ end
128
+
124
129
  it "should match if Addressable::Template pattern that has ip address host matches request uri" do
125
130
  signature = WebMock::RequestSignature.new(:get, "127.0.0.1:3000/1234")
126
131
  uri = Addressable::Template.new("127.0.0.1:3000/{id}")
@@ -1,6 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
-
4
3
  URIS_WITHOUT_PATH_OR_PARAMS =
5
4
  [
6
5
  "www.example.com",
@@ -65,7 +64,6 @@ URIS_WITH_DIFFERENT_PORT =
65
64
  "http://www.example.com:88/"
66
65
  ].sort
67
66
 
68
-
69
67
  URIS_FOR_HTTPS =
70
68
  [
71
69
  "https://www.example.com",
@@ -74,6 +72,49 @@ URIS_FOR_HTTPS =
74
72
  "https://www.example.com:443/"
75
73
  ].sort
76
74
 
75
+ URIS_FOR_LOCALHOST =
76
+ [
77
+ "localhost",
78
+ "localhost/",
79
+ "localhost:80",
80
+ "localhost:80/",
81
+ "http://localhost",
82
+ "http://localhost/",
83
+ "http://localhost:80",
84
+ "http://localhost:80/"
85
+ ].sort
86
+
87
+ URIS_WITH_SCHEME =
88
+ [
89
+ "http://www.example.com",
90
+ "http://www.example.com/",
91
+ "http://www.example.com:80",
92
+ "http://www.example.com:80/"
93
+ ].sort
94
+
95
+ URIS_WITH_COLON_IN_PATH =
96
+ [
97
+ [
98
+ "https://example.com/a/b:80",
99
+ "https://example.com:443/a/b:80",
100
+ ].sort,
101
+ [
102
+ "https://example.com:443/a/b:443",
103
+ "https://example.com/a/b:443",
104
+ ].sort,
105
+ [
106
+ "http://example.com/a/b:443",
107
+ "example.com/a/b:443",
108
+ "http://example.com:80/a/b:443",
109
+ "example.com:80/a/b:443",
110
+ ].sort,
111
+ [
112
+ "http://example.com/a/b:80",
113
+ "example.com/a/b:80",
114
+ "http://example.com:80/a/b:80",
115
+ "example.com:80/a/b:80",
116
+ ].sort
117
+ ]
77
118
 
78
119
  describe WebMock::Util::URI do
79
120
 
@@ -115,6 +156,27 @@ describe WebMock::Util::URI do
115
156
  end
116
157
  end
117
158
 
159
+ it "should find all variations of the same uri for all variations of host names uris without a period" do
160
+ URIS_FOR_LOCALHOST.each do |uri|
161
+ expect(WebMock::Util::URI.variations_of_uri_as_strings(uri).sort).to eq(URIS_FOR_LOCALHOST)
162
+ end
163
+ end
164
+
165
+ it "should find all variations of the same uri with scheme for all variations when only_with_scheme is true" do
166
+ URIS_WITHOUT_PATH_OR_PARAMS.each do |uri|
167
+ variations_of_uri_with_scheme = WebMock::Util::URI.variations_of_uri_as_strings(uri, only_with_scheme: true)
168
+ expect(variations_of_uri_with_scheme.sort).to eq(URIS_WITH_SCHEME)
169
+ end
170
+ end
171
+
172
+ it "should not replace :80 or :443 in path" do
173
+ URIS_WITH_COLON_IN_PATH.each do |uris|
174
+ uris.each do |uri|
175
+ expect(WebMock::Util::URI.variations_of_uri_as_strings(uri).sort).to eq(uris)
176
+ end
177
+ end
178
+ end
179
+
118
180
  end
119
181
 
120
182
  describe "normalized uri equality" do
@@ -13,8 +13,6 @@ 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.rubyforge_project = 'webmock'
17
-
18
16
  s.required_ruby_version = '>= 2.0'
19
17
 
20
18
  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.6.0
4
+ version: 3.6.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: 2019-06-04 00:00:00.000000000 Z
11
+ date: 2019-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable