webmock 3.9.0 → 3.9.1

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: 603d6344674ad0d4b41e3b9fb2523d0d629f781873e0b5ac6dc72331ce30139a
4
- data.tar.gz: 034c21429d7b11336d59485f198abb0b61f3dce89ec59c2298bb81d1f8cd987e
3
+ metadata.gz: 57c2c81fa3eb74334f703d9f92eb11cea8b06f1c70b713fdee1a071a90e99744
4
+ data.tar.gz: 96798ebd031599d59d06ff8d2457af877ba6d4a7e9d20ef9e464396c9104bc2c
5
5
  SHA512:
6
- metadata.gz: e4a36fc1d613f0187c361d4d1fed3a3c2f082496839b1af649a752916fa9e1285a8261aec34fe25a236a35d930782a5b6cd62de919481e99198390b65407577d
7
- data.tar.gz: c3b93eaaa8f3a513e54d90f179ced6b48f08805232060ebd2cf41407bdd2f000d5cd8a01e584237bb634ad0ca5a00607d000ec7c257b51ebdbe96790937cc7ae
6
+ metadata.gz: d6f0e72a1ecc925a006b9f781cb2e873a8dcafef0a6b80be74df2ad34bdb3eba0a9d02571f72fa825321da86d2a0afdbbdfb4b56e7c3b280bc1643b2acd76100
7
+ data.tar.gz: 123fdca940fe7ea90b015cb6b085a063a00becef933df84335d1cf762780c12066590ab943c4cd5eba91bba4603f3663d4e8532ca374c036f5c0f306de03e28f
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ # 3.9.1
4
+
5
+ Fixed support for passing `URI` objects as second argument of `stub_request`
6
+
7
+ Thanks to [Ryan Kerr](https://github.com/leboshi)
8
+
3
9
  ## 3.9.0
4
10
 
5
11
  * Allow using a "callable" (like a proc) as URI pattern
data/README.md CHANGED
@@ -1136,6 +1136,7 @@ People who submitted patches and new features or suggested improvements. Many th
1136
1136
  * Andrew Stuntz
1137
1137
  * Lucas Uyezu
1138
1138
  * Bruno Sutic
1139
+ * Ryan Kerr
1139
1140
 
1140
1141
  For a full list of contributors you can visit the
1141
1142
  [contributors](https://github.com/bblimke/webmock/contributors) page.
@@ -109,11 +109,13 @@ module WebMock
109
109
  include RSpecMatcherDetector
110
110
 
111
111
  def initialize(pattern)
112
- @pattern = case pattern
113
- when String
114
- WebMock::Util::URI.normalize_uri(pattern)
115
- else
112
+ @pattern = if pattern.is_a?(Addressable::URI) \
113
+ || pattern.is_a?(Addressable::Template)
114
+ pattern
115
+ elsif pattern.respond_to?(:call)
116
116
  pattern
117
+ else
118
+ WebMock::Util::URI.normalize_uri(pattern)
117
119
  end
118
120
  @query_params = nil
119
121
  end
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '3.9.0' unless defined?(::WebMock::VERSION)
2
+ VERSION = '3.9.1' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -111,6 +111,11 @@ describe WebMock::RequestPattern do
111
111
  to match(WebMock::RequestSignature.new(:get, "www.example.com"))
112
112
  end
113
113
 
114
+ it "should match if uri matches requesst uri as URI object" do
115
+ expect(WebMock::RequestPattern.new(:get, URI.parse("www.example.com"))).
116
+ to match(WebMock::RequestSignature.new(:get, "www.example.com"))
117
+ end
118
+
114
119
  it "should match if uri proc pattern returning true" do
115
120
  expect(WebMock::RequestPattern.new(:get, ->(uri) { true })).
116
121
  to match(WebMock::RequestSignature.new(:get, "www.example.com"))
@@ -233,7 +238,7 @@ describe WebMock::RequestPattern do
233
238
  to match(WebMock::RequestSignature.new(:get, "www.example.com?a[]=b&a[]=c"))
234
239
  end
235
240
 
236
- it "should match request query params if params don't match" do
241
+ it "should not match request query params if params don't match" do
237
242
  expect(WebMock::RequestPattern.new(:get, /.*example.*/, query: {"x" => ["b", "c"]})).
238
243
  not_to match(WebMock::RequestSignature.new(:get, "www.example.com?a[]=b&a[]=c"))
239
244
  end
@@ -263,13 +268,49 @@ describe WebMock::RequestPattern do
263
268
  end
264
269
  end
265
270
 
271
+ describe "when uri is described as URI" do
272
+ it "should match request query params" do
273
+ expect(WebMock::RequestPattern.new(:get, URI.parse("www.example.com"), query: {"a" => ["b", "c"]})).
274
+ to match(WebMock::RequestSignature.new(:get, "www.example.com?a[]=b&a[]=c"))
275
+ end
276
+
277
+ it "should not match request query params if params don't match" do
278
+ expect(WebMock::RequestPattern.new(:get, URI.parse("www.example.com"), query: {"x" => ["b", "c"]})).
279
+ not_to match(WebMock::RequestSignature.new(:get, "www.example.com?a[]=b&a[]=c"))
280
+ end
281
+
282
+ it "should match when query params are declared as HashIncluding matcher matching params" do
283
+ expect(WebMock::RequestPattern.new(:get, URI.parse("www.example.com"),
284
+ query: WebMock::Matchers::HashIncludingMatcher.new({"a" => ["b", "c"]}))).
285
+ to match(WebMock::RequestSignature.new(:get, "www.example.com?a[]=b&a[]=c&b=1"))
286
+ end
287
+
288
+ it "should not match when query params are declared as HashIncluding matcher not matching params" do
289
+ expect(WebMock::RequestPattern.new(:get, URI.parse("www.example.com"),
290
+ query: WebMock::Matchers::HashIncludingMatcher.new({"x" => ["b", "c"]}))).
291
+ not_to match(WebMock::RequestSignature.new(:get, "www.example.com?a[]=b&a[]=c&b=1"))
292
+ end
293
+
294
+ it "should match when query params are declared as RSpec HashIncluding matcher matching params" do
295
+ expect(WebMock::RequestPattern.new(:get, URI.parse("www.example.com"),
296
+ query: RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher.new({"a" => ["b", "c"]}))).
297
+ to match(WebMock::RequestSignature.new(:get, "www.example.com?a[]=b&a[]=c&b=1"))
298
+ end
299
+
300
+ it "should not match when query params are declared as RSpec HashIncluding matcher not matching params" do
301
+ expect(WebMock::RequestPattern.new(:get, URI.parse("www.example.com"),
302
+ query: RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher.new({"a" => ["b", "d"]}))).
303
+ not_to match(WebMock::RequestSignature.new(:get, "www.example.com?a[]=b&a[]=c&b=1"))
304
+ end
305
+ end
306
+
266
307
  describe "when uri is described as a proc" do
267
308
  it "should match request query params" do
268
309
  expect(WebMock::RequestPattern.new(:get, ->(uri) { true }, query: {"a" => ["b", "c"]})).
269
310
  to match(WebMock::RequestSignature.new(:get, "www.example.com?a[]=b&a[]=c"))
270
311
  end
271
312
 
272
- it "should match request query params if params don't match" do
313
+ it "should not match request query params if params don't match" do
273
314
  expect(WebMock::RequestPattern.new(:get, ->(uri) { true }, query: {"x" => ["b", "c"]})).
274
315
  not_to match(WebMock::RequestSignature.new(:get, "www.example.com?a[]=b&a[]=c"))
275
316
  end
@@ -305,7 +346,7 @@ describe WebMock::RequestPattern do
305
346
  to match(WebMock::RequestSignature.new(:get, "www.example.com?a[]=b&a[]=c"))
306
347
  end
307
348
 
308
- it "should match request query params if params don't match" do
349
+ it "should not match request query params if params don't match" do
309
350
  expect(WebMock::RequestPattern.new(:get, Addressable::Template.new("www.example.com"), query: {"x" => ["b", "c"]})).
310
351
  not_to match(WebMock::RequestSignature.new(:get, "www.example.com?a[]=b&a[]=c"))
311
352
  end
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.9.0
4
+ version: 3.9.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: 2020-09-13 00:00:00.000000000 Z
11
+ date: 2020-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -407,9 +407,9 @@ licenses:
407
407
  - MIT
408
408
  metadata:
409
409
  bug_tracker_uri: https://github.com/bblimke/webmock/issues
410
- changelog_uri: https://github.com/bblimke/webmock/blob/v3.9.0/CHANGELOG.md
411
- documentation_uri: https://www.rubydoc.info/gems/webmock/3.9.0
412
- source_code_uri: https://github.com/bblimke/webmock/tree/v3.9.0
410
+ changelog_uri: https://github.com/bblimke/webmock/blob/v3.9.1/CHANGELOG.md
411
+ documentation_uri: https://www.rubydoc.info/gems/webmock/3.9.1
412
+ source_code_uri: https://github.com/bblimke/webmock/tree/v3.9.1
413
413
  wiki_uri: https://github.com/bblimke/webmock/wiki
414
414
  post_install_message:
415
415
  rdoc_options: []