webmock 3.17.0 → 3.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -0
- data/lib/webmock/http_lib_adapters/net_http.rb +1 -31
- data/lib/webmock/request_pattern.rb +1 -1
- data/lib/webmock/version.rb +1 -1
- data/spec/acceptance/net_http/net_http_spec.rb +6 -23
- data/spec/acceptance/patron/patron_spec.rb +19 -21
- data/spec/unit/request_pattern_spec.rb +6 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4cbe1f0f2f191bea7fda094073e265aeff44e1669d1222da5cb724e5124eb55
|
4
|
+
data.tar.gz: e631266b6f082b93800e815a9dc0aa071a60a89c1f803bf3eee739e6b97820a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4911f51bd82520812df827796996ab8cf9975f1bee625a158f4644f8c121bbf34172266cd3097ef0609750d51d0c987ea7a645df077f936924f2ea0915f1c0a1
|
7
|
+
data.tar.gz: bc053c6d94f668d75c1e97629dd9ba38f018ffb2355f5cd97e1f5e54015f6adf02c6f9cac2abf6b5c13d7d4fcd69d1bae77b45cffa2b2b8488fa4d0a1c53e1b3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1169,6 +1169,7 @@ People who submitted patches and new features or suggested improvements. Many th
|
|
1169
1169
|
* Go Sueyoshi
|
1170
1170
|
* Cedric Sohrauer
|
1171
1171
|
* Akira Matsuda
|
1172
|
+
* Mark Spangler
|
1172
1173
|
|
1173
1174
|
For a full list of contributors you can visit the
|
1174
1175
|
[contributors](https://github.com/bblimke/webmock/contributors) page.
|
@@ -165,7 +165,7 @@ module WebMock
|
|
165
165
|
response.extend Net::WebMockHTTPResponse
|
166
166
|
|
167
167
|
if webmock_response.should_timeout
|
168
|
-
raise
|
168
|
+
raise Net::OpenTimeout, "execution expired"
|
169
169
|
end
|
170
170
|
|
171
171
|
webmock_response.raise_error_if_any
|
@@ -175,16 +175,6 @@ module WebMock
|
|
175
175
|
response
|
176
176
|
end
|
177
177
|
|
178
|
-
def timeout_exception
|
179
|
-
if defined?(Net::OpenTimeout)
|
180
|
-
# Ruby 2.x
|
181
|
-
Net::OpenTimeout
|
182
|
-
else
|
183
|
-
# Fallback, if things change
|
184
|
-
Timeout::Error
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
178
|
def build_webmock_response(net_http_response)
|
189
179
|
webmock_response = WebMock::Response.new
|
190
180
|
webmock_response.status = [
|
@@ -328,7 +318,6 @@ module WebMock
|
|
328
318
|
method = request.method.downcase.to_sym
|
329
319
|
|
330
320
|
headers = Hash[*request.to_hash.map {|k,v| [k, v]}.inject([]) {|r,x| r + x}]
|
331
|
-
validate_headers(headers)
|
332
321
|
|
333
322
|
if request.body_stream
|
334
323
|
body = request.body_stream.read
|
@@ -353,25 +342,6 @@ module WebMock
|
|
353
342
|
"#{protocol}://#{hostname}:#{net_http.port}#{path}"
|
354
343
|
end
|
355
344
|
|
356
|
-
def self.validate_headers(headers)
|
357
|
-
# For Ruby versions < 2.3.0, if you make a request with headers that are symbols
|
358
|
-
# Net::HTTP raises a NoMethodError
|
359
|
-
#
|
360
|
-
# WebMock normalizes headers when creating a RequestSignature,
|
361
|
-
# and will update all headers from symbols to strings.
|
362
|
-
#
|
363
|
-
# This could create a false positive in a test suite with WebMock.
|
364
|
-
#
|
365
|
-
# So before this point, WebMock raises an ArgumentError if any of the headers are symbols
|
366
|
-
# instead of the cryptic NoMethodError "undefined method `split' ...` from Net::HTTP
|
367
|
-
if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.3.0')
|
368
|
-
header_as_symbol = headers.keys.find {|header| header.is_a? Symbol}
|
369
|
-
if header_as_symbol
|
370
|
-
raise ArgumentError.new("Net:HTTP does not accept headers as symbols")
|
371
|
-
end
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
345
|
def self.check_right_http_connection
|
376
346
|
@was_right_http_connection_loaded = defined?(RightHttpConnection)
|
377
347
|
end
|
@@ -359,7 +359,7 @@ module WebMock
|
|
359
359
|
|
360
360
|
query_parameters.each_with_index do |actual, index|
|
361
361
|
expected = pattern[index]
|
362
|
-
|
362
|
+
return false unless matching_values(actual, expected, content_type)
|
363
363
|
end
|
364
364
|
|
365
365
|
true
|
data/lib/webmock/version.rb
CHANGED
@@ -115,33 +115,16 @@ describe "Net:HTTP" do
|
|
115
115
|
expect(Net::HTTP.start("www.example.com") { |http| http.request(req)}.body).to eq("abc")
|
116
116
|
end
|
117
117
|
|
118
|
-
it "raises an ArgumentError if passed headers as symbols
|
118
|
+
it "raises an ArgumentError if passed headers as symbols" do
|
119
119
|
uri = URI.parse("http://google.com/")
|
120
120
|
http = Net::HTTP.new(uri.host, uri.port)
|
121
121
|
request = Net::HTTP::Get.new(uri.request_uri)
|
122
|
+
request[:InvalidHeaderSinceItsASymbol] = "this will not be valid"
|
122
123
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
if :symbol.respond_to?(:downcase)
|
128
|
-
request[:InvalidHeaderSinceItsASymbol] = "this will not be valid"
|
129
|
-
else
|
130
|
-
request.instance_eval do
|
131
|
-
@header = request.to_hash.merge({InvalidHeaderSinceItsASymbol: "this will not be valid"})
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.3.0')
|
136
|
-
expect do
|
137
|
-
http.request(request)
|
138
|
-
end.to raise_error ArgumentError, "Net:HTTP does not accept headers as symbols"
|
139
|
-
else
|
140
|
-
stub_http_request(:get, "google.com").with(headers: { InvalidHeaderSinceItsASymbol: "this will not be valid" })
|
141
|
-
expect do
|
142
|
-
http.request(request)
|
143
|
-
end.not_to raise_error
|
144
|
-
end
|
124
|
+
stub_http_request(:get, "google.com").with(headers: { InvalidHeaderSinceItsASymbol: "this will not be valid" })
|
125
|
+
expect do
|
126
|
+
http.request(request)
|
127
|
+
end.not_to raise_error
|
145
128
|
end
|
146
129
|
|
147
130
|
it "should handle multiple values for the same response header" do
|
@@ -93,31 +93,29 @@ unless RUBY_PLATFORM =~ /java/
|
|
93
93
|
@sess.copy("/abc", "/def")
|
94
94
|
end
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
96
|
+
describe "handling encoding same way as patron" do
|
97
|
+
around(:each) do |example|
|
98
|
+
@encoding = Encoding.default_internal
|
99
|
+
Encoding.default_internal = "UTF-8"
|
100
|
+
example.run
|
101
|
+
Encoding.default_internal = @encoding
|
102
|
+
end
|
104
103
|
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
it "should not encode body with default encoding" do
|
105
|
+
stub_request(:get, "www.example.com").
|
106
|
+
to_return(body: "Øl")
|
108
107
|
|
109
|
-
|
110
|
-
|
111
|
-
|
108
|
+
expect(@sess.get("").body.encoding).to eq(Encoding::ASCII_8BIT)
|
109
|
+
expect(@sess.get("").inspectable_body.encoding).to eq(Encoding::UTF_8)
|
110
|
+
end
|
112
111
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
112
|
+
it "should not encode body to default internal" do
|
113
|
+
stub_request(:get, "www.example.com").
|
114
|
+
to_return(headers: {'Content-Type' => 'text/html; charset=iso-8859-1'},
|
115
|
+
body: "Øl".encode("iso-8859-1"))
|
117
116
|
|
118
|
-
|
119
|
-
|
120
|
-
end
|
117
|
+
expect(@sess.get("").body.encoding).to eq(Encoding::ASCII_8BIT)
|
118
|
+
expect(@sess.get("").decoded_body.encoding).to eq(Encoding.default_internal)
|
121
119
|
end
|
122
120
|
end
|
123
121
|
end
|
@@ -553,6 +553,12 @@ describe WebMock::RequestPattern do
|
|
553
553
|
headers: {content_type: content_type}, body: "[{\"a\":1}]"))
|
554
554
|
end
|
555
555
|
|
556
|
+
it "should not match if the request body has a different top level array" do
|
557
|
+
expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: ["a", "b"])).
|
558
|
+
not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
|
559
|
+
headers: {content_type: content_type}, body: "[\"a\", \"c\"]"))
|
560
|
+
end
|
561
|
+
|
556
562
|
it "should not match when body is not json" do
|
557
563
|
expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
|
558
564
|
not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
|
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.17.
|
4
|
+
version: 3.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartosz Blimke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -421,9 +421,9 @@ licenses:
|
|
421
421
|
- MIT
|
422
422
|
metadata:
|
423
423
|
bug_tracker_uri: https://github.com/bblimke/webmock/issues
|
424
|
-
changelog_uri: https://github.com/bblimke/webmock/blob/v3.17.
|
425
|
-
documentation_uri: https://www.rubydoc.info/gems/webmock/3.17.
|
426
|
-
source_code_uri: https://github.com/bblimke/webmock/tree/v3.17.
|
424
|
+
changelog_uri: https://github.com/bblimke/webmock/blob/v3.17.1/CHANGELOG.md
|
425
|
+
documentation_uri: https://www.rubydoc.info/gems/webmock/3.17.1
|
426
|
+
source_code_uri: https://github.com/bblimke/webmock/tree/v3.17.1
|
427
427
|
wiki_uri: https://github.com/bblimke/webmock/wiki
|
428
428
|
post_install_message:
|
429
429
|
rdoc_options: []
|