webmock 3.26.4 → 3.34.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 +4 -4
- data/CHANGELOG.md +176 -0
- data/README.md +70 -2
- data/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +20 -2
- data/lib/webmock/http_lib_adapters/curb_adapter.rb +13 -2
- data/lib/webmock/http_lib_adapters/net_http.rb +30 -6
- data/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +54 -26
- data/lib/webmock/json_body_hint.rb +77 -0
- data/lib/webmock/matchers/any_arg_matcher.rb +4 -0
- data/lib/webmock/matchers/hash_excluding_matcher.rb +1 -1
- data/lib/webmock/rack_response.rb +28 -19
- data/lib/webmock/request_execution_verifier.rb +22 -0
- data/lib/webmock/request_pattern.rb +40 -30
- data/lib/webmock/request_signature.rb +15 -5
- data/lib/webmock/request_signature_snippet.rb +10 -10
- data/lib/webmock/request_stub.rb +13 -5
- data/lib/webmock/rspec/matchers/request_pattern_matcher.rb +47 -2
- data/lib/webmock/util/content_type.rb +39 -0
- data/lib/webmock/util/uri.rb +2 -2
- data/lib/webmock/version.rb +1 -1
- data/lib/webmock/webmock.rb +25 -5
- data/lib/webmock.rb +2 -0
- metadata +7 -5
data/lib/webmock/webmock.rb
CHANGED
|
@@ -87,14 +87,12 @@ module WebMock
|
|
|
87
87
|
when Array
|
|
88
88
|
allowed.any? { |allowed_item| net_connect_explicit_allowed?(allowed_item, uri) }
|
|
89
89
|
when Regexp
|
|
90
|
-
(uri.to_s
|
|
91
|
-
(uri.
|
|
90
|
+
allowed.match?(uri.to_s) ||
|
|
91
|
+
(uri.port == uri.default_port && allowed.match?(uri.omit(:port).to_s))
|
|
92
92
|
when String
|
|
93
|
-
allowed == uri.to_s ||
|
|
94
93
|
allowed == uri.host ||
|
|
95
94
|
allowed == "#{uri.host}:#{uri.port}" ||
|
|
96
|
-
allowed
|
|
97
|
-
allowed == "#{uri.scheme}://#{uri.host}" && uri.port == uri.default_port
|
|
95
|
+
net_connect_allowed_url?(allowed, uri)
|
|
98
96
|
else
|
|
99
97
|
if allowed.respond_to?(:call)
|
|
100
98
|
allowed.call(uri)
|
|
@@ -102,6 +100,28 @@ module WebMock
|
|
|
102
100
|
end
|
|
103
101
|
end
|
|
104
102
|
|
|
103
|
+
def self.net_connect_allowed_url?(allowed, uri)
|
|
104
|
+
return false unless allowed.match?(%r{\Ahttps?://}i)
|
|
105
|
+
|
|
106
|
+
# Normalization turns an empty path into "/", so check the original URL.
|
|
107
|
+
allowed_uri = Addressable::URI.parse(allowed)
|
|
108
|
+
allow_any_path = allowed_uri.path.empty? && allowed_uri.query.nil?
|
|
109
|
+
|
|
110
|
+
# Connection URIs have no request path to match yet.
|
|
111
|
+
return false if uri.path.empty? && !allowed_uri.path.empty?
|
|
112
|
+
|
|
113
|
+
allowed_uri = WebMock::Util::URI.normalize_uri(allowed_uri)
|
|
114
|
+
request_uri = WebMock::Util::URI.normalize_uri(uri)
|
|
115
|
+
|
|
116
|
+
return false unless allowed_uri.origin == request_uri.origin
|
|
117
|
+
return true if allow_any_path
|
|
118
|
+
|
|
119
|
+
allowed_uri.path == request_uri.path && allowed_uri.query == request_uri.query
|
|
120
|
+
rescue Addressable::URI::InvalidURIError
|
|
121
|
+
false
|
|
122
|
+
end
|
|
123
|
+
private_class_method :net_connect_allowed_url?
|
|
124
|
+
|
|
105
125
|
def self.show_body_diff!
|
|
106
126
|
Config.instance.show_body_diff = true
|
|
107
127
|
end
|
data/lib/webmock.rb
CHANGED
|
@@ -13,6 +13,7 @@ require_relative 'webmock/errors'
|
|
|
13
13
|
require_relative 'webmock/util/query_mapper'
|
|
14
14
|
require_relative 'webmock/util/uri'
|
|
15
15
|
require_relative 'webmock/util/headers'
|
|
16
|
+
require_relative 'webmock/util/content_type'
|
|
16
17
|
require_relative 'webmock/util/hash_counter'
|
|
17
18
|
require_relative 'webmock/util/hash_keys_stringifier'
|
|
18
19
|
require_relative 'webmock/util/values_stringifier'
|
|
@@ -36,6 +37,7 @@ require_relative 'webmock/rack_response'
|
|
|
36
37
|
require_relative 'webmock/stub_request_snippet'
|
|
37
38
|
require_relative 'webmock/request_signature_snippet'
|
|
38
39
|
require_relative 'webmock/request_body_diff'
|
|
40
|
+
require_relative 'webmock/json_body_hint'
|
|
39
41
|
|
|
40
42
|
require_relative 'webmock/assertion_failure'
|
|
41
43
|
require_relative 'webmock/request_execution_verifier'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: webmock
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.34.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bartosz Blimke
|
|
@@ -318,6 +318,7 @@ files:
|
|
|
318
318
|
- lib/webmock/http_lib_adapters/net_http_response.rb
|
|
319
319
|
- lib/webmock/http_lib_adapters/patron_adapter.rb
|
|
320
320
|
- lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb
|
|
321
|
+
- lib/webmock/json_body_hint.rb
|
|
321
322
|
- lib/webmock/matchers/any_arg_matcher.rb
|
|
322
323
|
- lib/webmock/matchers/hash_argument_matcher.rb
|
|
323
324
|
- lib/webmock/matchers/hash_excluding_matcher.rb
|
|
@@ -340,6 +341,7 @@ files:
|
|
|
340
341
|
- lib/webmock/stub_registry.rb
|
|
341
342
|
- lib/webmock/stub_request_snippet.rb
|
|
342
343
|
- lib/webmock/test_unit.rb
|
|
344
|
+
- lib/webmock/util/content_type.rb
|
|
343
345
|
- lib/webmock/util/hash_counter.rb
|
|
344
346
|
- lib/webmock/util/hash_keys_stringifier.rb
|
|
345
347
|
- lib/webmock/util/hash_validator.rb
|
|
@@ -358,9 +360,9 @@ licenses:
|
|
|
358
360
|
- MIT
|
|
359
361
|
metadata:
|
|
360
362
|
bug_tracker_uri: https://github.com/bblimke/webmock/issues
|
|
361
|
-
changelog_uri: https://github.com/bblimke/webmock/blob/v3.
|
|
362
|
-
documentation_uri: https://www.rubydoc.info/gems/webmock/3.
|
|
363
|
-
source_code_uri: https://github.com/bblimke/webmock/tree/v3.
|
|
363
|
+
changelog_uri: https://github.com/bblimke/webmock/blob/v3.34.0/CHANGELOG.md
|
|
364
|
+
documentation_uri: https://www.rubydoc.info/gems/webmock/3.34.0
|
|
365
|
+
source_code_uri: https://github.com/bblimke/webmock/tree/v3.34.0
|
|
364
366
|
wiki_uri: https://github.com/bblimke/webmock/wiki
|
|
365
367
|
rdoc_options: []
|
|
366
368
|
require_paths:
|
|
@@ -376,7 +378,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
376
378
|
- !ruby/object:Gem::Version
|
|
377
379
|
version: '0'
|
|
378
380
|
requirements: []
|
|
379
|
-
rubygems_version: 4.0.
|
|
381
|
+
rubygems_version: 4.0.20
|
|
380
382
|
specification_version: 4
|
|
381
383
|
summary: Library for stubbing HTTP requests in Ruby.
|
|
382
384
|
test_files: []
|