webmock 3.5.1 → 3.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1f4b12d21d9712fdf49cc29d9494285c36926b29eda702e3821caab05ba7a97
4
- data.tar.gz: 24a7edb6ce921ef9735043588ee89ab31b895f9e99bccf3c655d20f645b3cf55
3
+ metadata.gz: 137bc694f0b4f457b84a5fc6f93a7b2227ff19bcb6e8bd1525244649df56898c
4
+ data.tar.gz: f998d2cd340cffd2637bcc3cf8cfe322c85de1055d07b51c7e193acde549d340
5
5
  SHA512:
6
- metadata.gz: 724c7ae8d9ba016537b0e45968e9ae8d820458be36106a24eb7374ccc09cb3e06fb0df5968014443b4f94ba16349dad4643bf683cab17c4af1b32ae9c5b1112d
7
- data.tar.gz: 440171bbd565223139df3aec8581378497cfe359dc766c4b5e8dcf0b865a6c6adf759029d551b3ffac084d7b9683401baabd0b713930017563b7d79cb09320e8
6
+ metadata.gz: 9b36a8ce4d2b4b779e89f5e7db1ed1c8e17817f1088fcd9d92e8f2154373a254292240dffc0d7f376fb86c1230f0371aefa6a56163710cc2ed86301915270b52
7
+ data.tar.gz: 54d26c28e44ebec703628a4473f4bc1547f7c6fad2eeefbffea77398fed62759f131f94bd7fceb78275a8be70d30c94586383ecb43c1f16882a8dfe4e89dcf53
@@ -3,19 +3,16 @@ before_install:
3
3
  - gem update bundler
4
4
  rvm:
5
5
  - 2.3.8
6
- - 2.4.5
7
- - 2.5.3
8
- - 2.6.0
6
+ - 2.4.6
7
+ - 2.5.5
8
+ - 2.6.2
9
9
  - rbx-2
10
10
  - ruby-head
11
11
  - jruby-9.1.17.0
12
- - jruby-9.2.5.0
12
+ - jruby-9.2.6.0
13
13
  - jruby-head
14
14
  matrix:
15
15
  allow_failures:
16
16
  - rvm: jruby-head
17
17
  - rvm: ruby-head
18
18
  - rvm: rbx-2
19
- # Send builds to container-based infrastructure
20
- # http://docs.travis-ci.com/user/workers/container-based-infrastructure/
21
- sudo: false
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.6.0
4
+
5
+ * Compatibility with the latest version of hashdiff gem, with constant changed from HashDiff to Hashdiff
6
+
7
+ Thanks to [Jeff Felchner](https://github.com/jfelchner)
8
+
9
+ * Added a hint to the error message raised when `with` method is called without args or a block.
10
+
11
+ Thanks to [Adam Sokolnicki](https://github.com/asok)
12
+
13
+ * Resetting configured HTTP method in Curb adapter after each request
14
+
15
+ Thanks to [tiendo1011](https://github.com/tiendo1011)
16
+
17
+ * Added `WebMock.enable_net_connect!` as an alias for `WebMock.allow_net_connect!`
18
+ and `WebMock.disallow_net_connect!` as an alias for `WebMock.disable_net_connect!`
19
+
20
+ Thanks to [SoonKhen OwYong](https://github.com/owyongsk)
21
+
22
+ * Fixed handling of empty arrays as query params when using Faraday
23
+
24
+ Thanks to [Ryan Moret](https://github.com/rcmoret)
25
+
3
26
  ## 3.5.1
4
27
 
5
28
  * 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) [![Build Status](https://secure.travis-ci.org/bblimke/webmock.svg?branch=master)](http://travis-ci.org/bblimke/webmock) [![Dependency Status](https://gemnasium.com/bblimke/webmock.svg)](http://gemnasium.com/bblimke/webmock) [![Code Climate](https://codeclimate.com/github/bblimke/webmock/badges/gpa.svg)](https://codeclimate.com/github/bblimke/webmock) [![Mentioned in Awesome Ruby](https://awesome.re/mentioned-badge.svg)](https://github.com/markets/awesome-ruby) [![Inline docs](http://inch-ci.org/github/bblimke/webmock.svg?branch=master)](http://inch-ci.org/github/bblimke/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
 
@@ -1086,6 +1091,11 @@ People who submitted patches and new features or suggested improvements. Many th
1086
1091
  * Geremia Taglialatela
1087
1092
  * Koichi Sasada
1088
1093
  * Yusuke Endoh
1094
+ * Grey Baker
1095
+ * SoonKhen OwYong
1096
+ * Pavel Valena
1097
+ * Adam Sokolnicki
1098
+ * Jeff Felchner
1089
1099
 
1090
1100
  For a full list of contributors you can visit the
1091
1101
  [contributors](https://github.com/bblimke/webmock/contributors) page.
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env rake
2
-
3
1
  require 'bundler'
4
2
  Bundler::GemHelper.install_tasks
5
3
 
@@ -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
@@ -12,7 +12,7 @@ module WebMock
12
12
  def body_diff
13
13
  return {} unless request_signature_diffable? && request_stub_diffable?
14
14
 
15
- HashDiff.diff(request_signature_body_hash, request_stub_body_hash)
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
@@ -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]}
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '3.5.1' unless defined?(::WebMock::VERSION)
2
+ VERSION = '3.6.0' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -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
 
@@ -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
@@ -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
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.add_dependency 'addressable', '>= 2.3.6'
21
21
  s.add_dependency 'crack', '>= 0.3.2'
22
- s.add_dependency 'hashdiff'
22
+ s.add_dependency 'hashdiff', ['>= 0.4.0', '< 2.0.0']
23
23
 
24
24
  unless RUBY_PLATFORM =~ /java/
25
25
  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.5.1
4
+ version: 3.6.0
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-12-27 00:00:00.000000000 Z
11
+ date: 2019-06-04 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: '0'
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: '0'
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
- rubyforge_project: webmock
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.