webmock 3.4.1 → 3.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: '086af9d48e21a095a9447cee1e20b2630a9fcbe299a5212a9f13e8daa5209f71'
4
- data.tar.gz: 7afbd414ac88a4da8180934c81adea158230a8bac7eaa0c24f7cefceab056101
2
+ SHA1:
3
+ metadata.gz: 91d9ae63bf5035f1d5ca0279cd0a8f4ec3ea80e9
4
+ data.tar.gz: b59813f02e62e3f5fa9b86e396d6da32f61f1a35
5
5
  SHA512:
6
- metadata.gz: 995f6f1be116147e3b832a0070b6cf780bfcaf45b2aae80c0a61f990c20c199955418cc809ba6489cbce7cef0c568571e811bb93a42633e0fb512f48c3b003c5
7
- data.tar.gz: 5d2f3395dedcc227e1e492e5e7d6938cb9224e0084a09b6d157e204cc7205835c87816cb62068cbcbbf6290a0fb4f4a5f41465345da0fd30e065f74b3d36b8e0
6
+ metadata.gz: 576e5b246b09980d0a371a3b83468ef8d715917b29d1f6bc07fbb0c7398346c7effbcd3a9b8a6dcf9634f9531d49f8b85fe9f196f5afcaddbddc1cc6be5cb5c7
7
+ data.tar.gz: 19eb107133e2f8a12bf9859fd0cf444afe78d8d6da3057d93928344e2d67c8c99ccd2554d749dcae94f4cad3ebea915ba54b8f5296c42d7a8809023f10e242dc
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.4.2
4
+
5
+ * Fixed `rbuf_fill` in Net::HTTP adapter to be thread-safe
6
+
7
+ Thanks to [Arkadiy Tetelman](https://github.com/arkadiyt)
8
+
9
+ * Fix invalid scheme error with Addressable::Template
10
+
11
+ Thanks to [Kazato Sugimoto](https://github.com/uiureo)
12
+
3
13
  ## 3.4.1
4
14
 
5
15
  * When comparing url encoded body to a body from request stub, which was declared as hash, only String, Numeric and boolean hash values are stringified before the comparison.
data/README.md CHANGED
@@ -1056,6 +1056,8 @@ People who submitted patches and new features or suggested improvements. Many th
1056
1056
  * Kenny Ortmann
1057
1057
  * redbar0n
1058
1058
  * Lukas Pokorny
1059
+ * Arkadiy Tetelman
1060
+ * Kazato Sugimoto
1059
1061
 
1060
1062
  For a full list of contributors you can visit the
1061
1063
  [contributors](https://github.com/bblimke/webmock/contributors) page.
@@ -274,7 +274,10 @@ module Net #:nodoc: all
274
274
 
275
275
  if RUBY_VERSION >= '2.6.0'
276
276
  def rbuf_fill
277
+ current_thread_id = Thread.current.object_id
278
+
277
279
  trace = TracePoint.trace(:line) do |tp|
280
+ next unless Thread.current.object_id == current_thread_id
278
281
  if tp.binding.local_variable_defined?(:tmp)
279
282
  tp.binding.local_variable_set(:tmp, nil)
280
283
  end
@@ -155,10 +155,10 @@ module WebMock
155
155
  def matches?(uri)
156
156
  if @query_params.nil?
157
157
  # Let Addressable check the whole URI
158
- WebMock::Util::URI.variations_of_uri_as_strings(uri).any? { |u| @pattern.match(u) }
158
+ matches_with_variations?(uri)
159
159
  else
160
160
  # WebMock checks the query, Addressable checks everything else
161
- WebMock::Util::URI.variations_of_uri_as_strings(uri.omit(:query)).any? { |u| @pattern.match(u) } &&
161
+ matches_with_variations?(uri.omit(:query)) &&
162
162
  @query_params == WebMock::Util::QueryMapper.query_to_values(uri.query)
163
163
  end
164
164
  end
@@ -177,6 +177,15 @@ module WebMock
177
177
  str += " with variables #{@pattern.variables.inspect}" if @pattern.variables
178
178
  str
179
179
  end
180
+
181
+ private
182
+
183
+ def matches_with_variations?(uri)
184
+ normalized_template = Addressable::Template.new(WebMock::Util::URI.heuristic_parse(@pattern.pattern))
185
+
186
+ WebMock::Util::URI.variations_of_uri_as_strings(uri, only_with_scheme: true)
187
+ .any? { |u| normalized_template.match(u) }
188
+ end
180
189
  end
181
190
 
182
191
  class URIStringPattern < URIPattern
@@ -33,7 +33,7 @@ module WebMock
33
33
  NORMALIZED_URIS[uri].dup
34
34
  end
35
35
 
36
- def self.variations_of_uri_as_strings(uri_object)
36
+ def self.variations_of_uri_as_strings(uri_object, only_with_scheme: false)
37
37
  normalized_uri = normalize_uri(uri_object.dup).freeze
38
38
  uris = [ normalized_uri ]
39
39
 
@@ -47,7 +47,7 @@ module WebMock
47
47
  uris = uris_with_inferred_port_and_without(uris)
48
48
  end
49
49
 
50
- if normalized_uri.scheme == "http"
50
+ if normalized_uri.scheme == "http" && !only_with_scheme
51
51
  uris = uris_with_scheme_and_without(uris)
52
52
  end
53
53
 
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '3.4.1' unless defined?(::WebMock::VERSION)
2
+ VERSION = '3.4.2' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -121,6 +121,12 @@ 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 Addressable::Template pattern that has ip address host matches request uri" do
125
+ signature = WebMock::RequestSignature.new(:get, "127.0.0.1:3000/1234")
126
+ uri = Addressable::Template.new("127.0.0.1:3000/{id}")
127
+ expect(WebMock::RequestPattern.new(:get, uri)).to match(signature)
128
+ end
129
+
124
130
  it "should match for uris with same parameters as pattern" do
125
131
  expect(WebMock::RequestPattern.new(:get, "www.example.com?a=1&b=2")).
126
132
  to match(WebMock::RequestSignature.new(:get, "www.example.com?a=1&b=2"))
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.1
4
+ version: 3.4.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: 2018-05-01 00:00:00.000000000 Z
11
+ date: 2018-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -399,7 +399,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
399
399
  version: '0'
400
400
  requirements: []
401
401
  rubyforge_project: webmock
402
- rubygems_version: 2.7.6
402
+ rubygems_version: 2.6.11
403
403
  signing_key:
404
404
  specification_version: 4
405
405
  summary: Library for stubbing HTTP requests in Ruby.