webmock 3.5.1 → 3.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -7
- data/CHANGELOG.md +43 -0
- data/README.md +23 -1
- data/Rakefile +0 -2
- data/lib/webmock/http_lib_adapters/curb_adapter.rb +6 -1
- data/lib/webmock/http_lib_adapters/manticore_adapter.rb +9 -6
- data/lib/webmock/http_lib_adapters/net_http.rb +3 -2
- data/lib/webmock/http_lib_adapters/patron_adapter.rb +1 -1
- data/lib/webmock/request_body_diff.rb +1 -1
- data/lib/webmock/request_pattern.rb +2 -3
- data/lib/webmock/util/query_mapper.rb +4 -2
- data/lib/webmock/util/uri.rb +3 -4
- data/lib/webmock/version.rb +1 -1
- data/lib/webmock/webmock.rb +5 -0
- data/spec/acceptance/curb/curb_spec.rb +11 -0
- data/spec/acceptance/shared/request_expectations.rb +7 -0
- data/spec/acceptance/shared/stubbing_requests.rb +5 -0
- data/spec/support/webmock_server.rb +1 -0
- data/spec/unit/request_pattern_spec.rb +6 -1
- data/spec/unit/util/query_mapper_spec.rb +7 -0
- data/spec/unit/util/uri_spec.rb +64 -2
- data/spec/unit/webmock_spec.rb +8 -0
- data/webmock.gemspec +1 -3
- metadata +11 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d54455d6752d60f630b108721f21ad51f4d2e648cf1fe492f72cce5d0e3bd66
|
4
|
+
data.tar.gz: 937d29ecd33fe244fe5f9749140d94c4ea68134b8afdcdd44a4ec41d5562df10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46ffed006b40f5d04d66ca5c3997f5874801e55d50a6580c1f3686a1c06a2fd4f69b4ab23c07f4828bdf01ace8749a0a7874a92db04780e621333a731bf89baf
|
7
|
+
data.tar.gz: 3d265897b59b5adcf8cf1954c5656160eb8bfeeb583d3abdcf9883b61b88b1b09ed050da8f45f582a190a86beb8d1bb809d55b39d89ac9ab4ed1681bc05ebeaa
|
data/.travis.yml
CHANGED
@@ -3,19 +3,17 @@ before_install:
|
|
3
3
|
- gem update bundler
|
4
4
|
rvm:
|
5
5
|
- 2.3.8
|
6
|
-
- 2.4.
|
7
|
-
- 2.5.
|
8
|
-
- 2.6.
|
6
|
+
- 2.4.6
|
7
|
+
- 2.5.5
|
8
|
+
- 2.6.3
|
9
9
|
- rbx-2
|
10
10
|
- ruby-head
|
11
11
|
- jruby-9.1.17.0
|
12
|
-
- jruby-9.2.
|
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
|
17
18
|
- rvm: ruby-head
|
18
19
|
- rvm: rbx-2
|
19
|
-
# Send builds to container-based infrastructure
|
20
|
-
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
21
|
-
sudo: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,48 @@
|
|
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
|
+
|
23
|
+
## 3.6.0
|
24
|
+
|
25
|
+
* Compatibility with the latest version of hashdiff gem, with constant changed from HashDiff to Hashdiff
|
26
|
+
|
27
|
+
Thanks to [Jeff Felchner](https://github.com/jfelchner)
|
28
|
+
|
29
|
+
* Added a hint to the error message raised when `with` method is called without args or a block.
|
30
|
+
|
31
|
+
Thanks to [Adam Sokolnicki](https://github.com/asok)
|
32
|
+
|
33
|
+
* Resetting configured HTTP method in Curb adapter after each request
|
34
|
+
|
35
|
+
Thanks to [tiendo1011](https://github.com/tiendo1011)
|
36
|
+
|
37
|
+
* Added `WebMock.enable_net_connect!` as an alias for `WebMock.allow_net_connect!`
|
38
|
+
and `WebMock.disallow_net_connect!` as an alias for `WebMock.disable_net_connect!`
|
39
|
+
|
40
|
+
Thanks to [SoonKhen OwYong](https://github.com/owyongsk)
|
41
|
+
|
42
|
+
* Fixed handling of empty arrays as query params when using Faraday
|
43
|
+
|
44
|
+
Thanks to [Ryan Moret](https://github.com/rcmoret)
|
45
|
+
|
3
46
|
## 3.5.1
|
4
47
|
|
5
48
|
* Disabling TracePoint defined in Net::BufferedIO in case of exception being raised.
|
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
WebMock
|
2
2
|
=======
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/webmock.svg)](http://badge.fury.io/rb/webmock)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/webmock.svg)](http://badge.fury.io/rb/webmock)
|
4
|
+
[![Build Status](https://secure.travis-ci.org/bblimke/webmock.svg?branch=master)](http://travis-ci.org/bblimke/webmock)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/bblimke/webmock/badges/gpa.svg)](https://codeclimate.com/github/bblimke/webmock)
|
6
|
+
[![Mentioned in Awesome Ruby](https://awesome.re/mentioned-badge.svg)](https://github.com/markets/awesome-ruby)
|
7
|
+
[![Inline docs](http://inch-ci.org/github/bblimke/webmock.svg?branch=master)](http://inch-ci.org/github/bblimke/webmock)
|
8
|
+
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=webmock&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=webmock&package-manager=bundler&version-scheme=semver)
|
4
9
|
|
5
10
|
Library for stubbing and setting expectations on HTTP requests in Ruby.
|
6
11
|
|
@@ -873,6 +878,10 @@ end
|
|
873
878
|
|
874
879
|
Please submit them here [http://github.com/bblimke/webmock/issues](http://github.com/bblimke/webmock/issues)
|
875
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
|
+
|
876
885
|
## Suggestions
|
877
886
|
|
878
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)
|
@@ -1086,6 +1095,19 @@ People who submitted patches and new features or suggested improvements. Many th
|
|
1086
1095
|
* Geremia Taglialatela
|
1087
1096
|
* Koichi Sasada
|
1088
1097
|
* Yusuke Endoh
|
1098
|
+
* Grey Baker
|
1099
|
+
* SoonKhen OwYong
|
1100
|
+
* Pavel Valena
|
1101
|
+
* Adam Sokolnicki
|
1102
|
+
* Jeff Felchner
|
1103
|
+
* Eike Send
|
1104
|
+
* Claudio Poli
|
1105
|
+
* Csaba Apagyi
|
1106
|
+
* Frederick Cheung
|
1107
|
+
* Fábio D. Batista
|
1108
|
+
|
1109
|
+
|
1110
|
+
|
1089
1111
|
|
1090
1112
|
For a full list of contributors you can visit the
|
1091
1113
|
[contributors](https://github.com/bblimke/webmock/contributors) page.
|
data/Rakefile
CHANGED
@@ -54,7 +54,6 @@ if defined?(Curl)
|
|
54
54
|
|
55
55
|
module Curl
|
56
56
|
class WebMockCurlEasy < Curl::Easy
|
57
|
-
|
58
57
|
def curb_or_webmock
|
59
58
|
request_signature = build_request_signature
|
60
59
|
WebMock::RequestRegistry.instance.requested_signatures.put(request_signature)
|
@@ -271,6 +270,8 @@ if defined?(Curl)
|
|
271
270
|
def perform
|
272
271
|
@webmock_method ||= :get
|
273
272
|
curb_or_webmock { super }
|
273
|
+
ensure
|
274
|
+
reset_webmock_method
|
274
275
|
end
|
275
276
|
|
276
277
|
def put_data= data
|
@@ -333,6 +334,10 @@ if defined?(Curl)
|
|
333
334
|
METHOD
|
334
335
|
end
|
335
336
|
|
337
|
+
def reset_webmock_method
|
338
|
+
@webmock_method = :get
|
339
|
+
end
|
340
|
+
|
336
341
|
def reset
|
337
342
|
instance_variable_set(:@body_str, nil)
|
338
343
|
super
|
@@ -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)
|
54
|
-
|
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)
|
58
|
-
|
59
|
-
|
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
|
-
|
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
|
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
|
@@ -12,7 +12,7 @@ module WebMock
|
|
12
12
|
def body_diff
|
13
13
|
return {} unless request_signature_diffable? && request_stub_diffable?
|
14
14
|
|
15
|
-
|
15
|
+
Hashdiff.diff(request_signature_body_hash, request_stub_body_hash)
|
16
16
|
end
|
17
17
|
|
18
18
|
attr_reader :request_signature, :request_stub
|
@@ -24,7 +24,7 @@ module WebMock
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def with(options = {}, &block)
|
27
|
-
raise ArgumentError.new('#with method invoked with no arguments. Either options hash or block must be specified.') if options.empty? && !block_given?
|
27
|
+
raise ArgumentError.new('#with method invoked with no arguments. Either options hash or block must be specified. Created a block with do..end? Try creating it with curly braces {} instead.') if options.empty? && !block_given?
|
28
28
|
assign_options(options)
|
29
29
|
@with_block = block
|
30
30
|
self
|
@@ -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
|
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
|
|
@@ -161,7 +161,7 @@ module WebMock::Util
|
|
161
161
|
else
|
162
162
|
if array_value
|
163
163
|
current_node[last_key] ||= []
|
164
|
-
current_node[last_key] << value
|
164
|
+
current_node[last_key] << value unless value.nil?
|
165
165
|
else
|
166
166
|
current_node[last_key] = value
|
167
167
|
end
|
@@ -186,7 +186,9 @@ module WebMock::Util
|
|
186
186
|
new_query_values = new_query_values.to_hash
|
187
187
|
new_query_values = new_query_values.inject([]) do |object, (key, value)|
|
188
188
|
key = key.to_s if key.is_a?(::Symbol) || key.nil?
|
189
|
-
if value.is_a?(Array)
|
189
|
+
if value.is_a?(Array) && value.empty?
|
190
|
+
object << [key.to_s + '[]']
|
191
|
+
elsif value.is_a?(Array)
|
190
192
|
value.each { |v| object << [key.to_s + '[]', v] }
|
191
193
|
elsif value.is_a?(Hash)
|
192
194
|
value.each { |k, v| object << ["#{key.to_s}[#{k}]", v]}
|
data/lib/webmock/util/uri.rb
CHANGED
@@ -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
|
-
|
84
|
-
[ uri, uri.gsub(%r{(:80)|(:443)}, "").freeze ]
|
83
|
+
[ uri, uri.omit(:port)]
|
85
84
|
}.flatten
|
86
85
|
end
|
87
86
|
|
data/lib/webmock/version.rb
CHANGED
data/lib/webmock/webmock.rb
CHANGED
@@ -53,6 +53,11 @@ module WebMock
|
|
53
53
|
Config.instance.net_http_connect_on_start = options[:net_http_connect_on_start]
|
54
54
|
end
|
55
55
|
|
56
|
+
class << self
|
57
|
+
alias :enable_net_connect! :allow_net_connect!
|
58
|
+
alias :disallow_net_connect! :disable_net_connect!
|
59
|
+
end
|
60
|
+
|
56
61
|
def self.net_connect_allowed?(uri = nil)
|
57
62
|
if uri.is_a?(String)
|
58
63
|
uri = WebMock::Util::URI.normalize_uri(uri)
|
@@ -411,6 +411,17 @@ unless RUBY_PLATFORM =~ /java/
|
|
411
411
|
it_should_behave_like "Curb"
|
412
412
|
include CurbSpecHelper::NamedHttp
|
413
413
|
|
414
|
+
it "should reset @webmock_method after each call" do
|
415
|
+
stub_request(:post, "www.example.com").with(body: "01234")
|
416
|
+
c = Curl::Easy.new
|
417
|
+
c.url = "http://www.example.com"
|
418
|
+
c.post_body = "01234"
|
419
|
+
c.http_post
|
420
|
+
expect {
|
421
|
+
c.perform
|
422
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com))
|
423
|
+
end
|
424
|
+
|
414
425
|
it "should work with blank arguments for post" do
|
415
426
|
stub_request(:post, "www.example.com").with(body: "01234")
|
416
427
|
c = Curl::Easy.new
|
@@ -172,6 +172,13 @@ shared_context "request expectations" do |*adapter_info|
|
|
172
172
|
expect(a_request(:get, "www.example.com").with(query: hash_excluding(a: ['b', 'c']))).to have_been_made
|
173
173
|
}.not_to raise_error
|
174
174
|
end
|
175
|
+
|
176
|
+
it 'should satisfy expectation if the request was executed with an empty array in the query params' do
|
177
|
+
expect {
|
178
|
+
http_request(:get, "http://www.example.com/?a[]")
|
179
|
+
expect(a_request(:get, "www.example.com").with(query: hash_including(a: []))).to have_been_made
|
180
|
+
}.not_to raise_error
|
181
|
+
end
|
175
182
|
end
|
176
183
|
|
177
184
|
context "when using flat array notation" do
|
@@ -68,6 +68,11 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
68
68
|
stub_request(:get, 'www.example.com').with(query: hash_excluding(a: ['b', 'c'])).to_return(body: 'abc')
|
69
69
|
expect(http_request(:get, 'http://www.example.com/?a[]=c&a[]=d&b=1').body).to eq('abc')
|
70
70
|
end
|
71
|
+
|
72
|
+
it "should return stubbed response when stub expects an empty array" do
|
73
|
+
stub_request(:get, 'www.example.com').with(query: { a: [] }).to_return(body: 'abc')
|
74
|
+
expect(http_request(:get, 'http://www.example.com/?a[]').body).to eq('abc')
|
75
|
+
end
|
71
76
|
end
|
72
77
|
|
73
78
|
describe "based on method" do
|
@@ -58,7 +58,7 @@ describe WebMock::RequestPattern do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should raise an error if neither options or block is provided" do
|
61
|
-
expect { @request_pattern.with() }.to raise_error('#with method invoked with no arguments. Either options hash or block must be specified.')
|
61
|
+
expect { @request_pattern.with() }.to raise_error('#with method invoked with no arguments. Either options hash or block must be specified. Created a block with do..end? Try creating it with curly braces {} instead.')
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -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}")
|
@@ -147,4 +147,11 @@ describe WebMock::Util::QueryMapper do
|
|
147
147
|
expect(subject.values_to_query values).to eq query
|
148
148
|
expect(subject.query_to_values query).to eq values
|
149
149
|
end
|
150
|
+
|
151
|
+
it 'converts an empty array to ?' do
|
152
|
+
query = "one%5B%5D"
|
153
|
+
values = {"one" => []}
|
154
|
+
expect(subject.values_to_query values).to eq query
|
155
|
+
expect(subject.query_to_values query).to eq values
|
156
|
+
end
|
150
157
|
end
|
data/spec/unit/util/uri_spec.rb
CHANGED
@@ -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
|
data/spec/unit/webmock_spec.rb
CHANGED
@@ -8,4 +8,12 @@ describe "WebMock version" do
|
|
8
8
|
it "should not require safe_yaml" do
|
9
9
|
expect(defined?SafeYAML).to eq(nil)
|
10
10
|
end
|
11
|
+
|
12
|
+
it "should alias enable_net_connect! to allow_net_connect!" do
|
13
|
+
expect(WebMock.method(:enable_net_connect!)).to eq(WebMock.method(:allow_net_connect!))
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should alias disallow_net_connect! to disable_net_connect!" do
|
17
|
+
expect(WebMock.method(:disallow_net_connect!)).to eq(WebMock.method(:disable_net_connect!))
|
18
|
+
end
|
11
19
|
end
|
data/webmock.gemspec
CHANGED
@@ -13,13 +13,11 @@ 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'
|
21
19
|
s.add_dependency 'crack', '>= 0.3.2'
|
22
|
-
s.add_dependency 'hashdiff'
|
20
|
+
s.add_dependency 'hashdiff', ['>= 0.4.0', '< 2.0.0']
|
23
21
|
|
24
22
|
unless RUBY_PLATFORM =~ /java/
|
25
23
|
s.add_development_dependency 'patron', '>= 0.4.18'
|
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.
|
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:
|
11
|
+
date: 2019-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -44,14 +44,20 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.4.0
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.0.0
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
55
|
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
57
|
+
version: 0.4.0
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.0.0
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: patron
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -398,8 +404,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
398
404
|
- !ruby/object:Gem::Version
|
399
405
|
version: '0'
|
400
406
|
requirements: []
|
401
|
-
|
402
|
-
rubygems_version: 2.7.6
|
407
|
+
rubygems_version: 3.0.3
|
403
408
|
signing_key:
|
404
409
|
specification_version: 4
|
405
410
|
summary: Library for stubbing HTTP requests in Ruby.
|