webmock 3.0.0 → 3.14.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.
Files changed (84) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/CI.yml +37 -0
  3. data/CHANGELOG.md +416 -0
  4. data/Gemfile +1 -1
  5. data/README.md +157 -31
  6. data/Rakefile +12 -4
  7. data/lib/webmock/api.rb +12 -0
  8. data/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +216 -0
  9. data/lib/webmock/http_lib_adapters/curb_adapter.rb +17 -3
  10. data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +7 -4
  11. data/lib/webmock/http_lib_adapters/excon_adapter.rb +5 -2
  12. data/lib/webmock/http_lib_adapters/http_rb/client.rb +4 -1
  13. data/lib/webmock/http_lib_adapters/http_rb/request.rb +7 -1
  14. data/lib/webmock/http_lib_adapters/http_rb/response.rb +24 -3
  15. data/lib/webmock/http_lib_adapters/http_rb/streamer.rb +6 -2
  16. data/lib/webmock/http_lib_adapters/http_rb/webmock.rb +2 -2
  17. data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +28 -9
  18. data/lib/webmock/http_lib_adapters/manticore_adapter.rb +33 -15
  19. data/lib/webmock/http_lib_adapters/net_http.rb +54 -14
  20. data/lib/webmock/http_lib_adapters/net_http_response.rb +1 -1
  21. data/lib/webmock/http_lib_adapters/patron_adapter.rb +4 -4
  22. data/lib/webmock/matchers/any_arg_matcher.rb +13 -0
  23. data/lib/webmock/matchers/hash_argument_matcher.rb +21 -0
  24. data/lib/webmock/matchers/hash_excluding_matcher.rb +15 -0
  25. data/lib/webmock/matchers/hash_including_matcher.rb +4 -23
  26. data/lib/webmock/rack_response.rb +1 -1
  27. data/lib/webmock/request_body_diff.rb +1 -1
  28. data/lib/webmock/request_execution_verifier.rb +2 -3
  29. data/lib/webmock/request_pattern.rb +108 -46
  30. data/lib/webmock/request_registry.rb +1 -1
  31. data/lib/webmock/request_signature.rb +1 -1
  32. data/lib/webmock/request_signature_snippet.rb +4 -4
  33. data/lib/webmock/response.rb +11 -5
  34. data/lib/webmock/rspec.rb +10 -3
  35. data/lib/webmock/stub_registry.rb +26 -11
  36. data/lib/webmock/stub_request_snippet.rb +10 -6
  37. data/lib/webmock/test_unit.rb +1 -3
  38. data/lib/webmock/util/hash_counter.rb +4 -4
  39. data/lib/webmock/util/headers.rb +17 -2
  40. data/lib/webmock/util/json.rb +1 -2
  41. data/lib/webmock/util/query_mapper.rb +9 -7
  42. data/lib/webmock/util/uri.rb +10 -10
  43. data/lib/webmock/util/values_stringifier.rb +20 -0
  44. data/lib/webmock/version.rb +1 -1
  45. data/lib/webmock/webmock.rb +10 -3
  46. data/lib/webmock.rb +53 -48
  47. data/minitest/webmock_spec.rb +2 -2
  48. data/spec/acceptance/async_http_client/async_http_client_spec.rb +375 -0
  49. data/spec/acceptance/async_http_client/async_http_client_spec_helper.rb +73 -0
  50. data/spec/acceptance/curb/curb_spec.rb +33 -0
  51. data/spec/acceptance/em_http_request/em_http_request_spec.rb +56 -0
  52. data/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +1 -1
  53. data/spec/acceptance/excon/excon_spec.rb +4 -2
  54. data/spec/acceptance/excon/excon_spec_helper.rb +2 -0
  55. data/spec/acceptance/http_rb/http_rb_spec.rb +20 -0
  56. data/spec/acceptance/http_rb/http_rb_spec_helper.rb +5 -2
  57. data/spec/acceptance/httpclient/httpclient_spec.rb +8 -1
  58. data/spec/acceptance/manticore/manticore_spec.rb +51 -0
  59. data/spec/acceptance/net_http/net_http_shared.rb +1 -1
  60. data/spec/acceptance/net_http/net_http_spec.rb +53 -1
  61. data/spec/acceptance/patron/patron_spec.rb +7 -0
  62. data/spec/acceptance/patron/patron_spec_helper.rb +3 -3
  63. data/spec/acceptance/shared/callbacks.rb +3 -2
  64. data/spec/acceptance/shared/request_expectations.rb +14 -0
  65. data/spec/acceptance/shared/returning_declared_responses.rb +36 -15
  66. data/spec/acceptance/shared/stubbing_requests.rb +95 -0
  67. data/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +1 -1
  68. data/spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb +1 -1
  69. data/spec/support/webmock_server.rb +1 -0
  70. data/spec/unit/api_spec.rb +103 -3
  71. data/spec/unit/matchers/hash_excluding_matcher_spec.rb +61 -0
  72. data/spec/unit/request_execution_verifier_spec.rb +12 -12
  73. data/spec/unit/request_pattern_spec.rb +195 -49
  74. data/spec/unit/request_signature_snippet_spec.rb +2 -2
  75. data/spec/unit/response_spec.rb +22 -18
  76. data/spec/unit/stub_request_snippet_spec.rb +30 -10
  77. data/spec/unit/util/query_mapper_spec.rb +13 -0
  78. data/spec/unit/util/uri_spec.rb +74 -2
  79. data/spec/unit/webmock_spec.rb +54 -5
  80. data/test/shared_test.rb +15 -2
  81. data/test/test_webmock.rb +6 -0
  82. data/webmock.gemspec +11 -3
  83. metadata +66 -17
  84. data/.travis.yml +0 -20
@@ -130,11 +130,15 @@ describe WebMock::Response do
130
130
  # Users of webmock commonly make the mistake of stubbing the response
131
131
  # body to return a hash, to prevent this:
132
132
  #
133
- it "should error if not given one of the allowed types" do
133
+ it "should error if given a non-allowed type: a hash" do
134
134
  expect { WebMock::Response.new(body: Hash.new) }.to \
135
135
  raise_error(WebMock::Response::InvalidBody)
136
136
  end
137
137
 
138
+ it "should error if given a non-allowed type: something that is not a hash" do
139
+ expect { WebMock::Response.new(body: 123) }.to \
140
+ raise_error(WebMock::Response::InvalidBody)
141
+ end
138
142
  end
139
143
 
140
144
  describe "from raw response" do
@@ -152,12 +156,12 @@ describe WebMock::Response do
152
156
 
153
157
  it "should read headers" do
154
158
  expect(@response.headers).to eq({
155
- "Date"=>"Sat, 23 Jan 2010 01:01:05 GMT",
156
- "Content-Type"=>"text/html; charset=UTF-8",
157
- "Content-Length"=>"419",
158
- "Connection"=>"Keep-Alive",
159
- "Accept"=>"image/jpeg, image/png"
160
- })
159
+ "Date"=>"Sat, 23 Jan 2010 01:01:05 GMT",
160
+ "Content-Type"=>"text/html; charset=UTF-8",
161
+ "Content-Length"=>"419",
162
+ "Connection"=>"Keep-Alive",
163
+ "Accept"=>"image/jpeg, image/png"
164
+ })
161
165
  end
162
166
 
163
167
  it "should read body" do
@@ -182,12 +186,12 @@ describe WebMock::Response do
182
186
 
183
187
  it "should read headers" do
184
188
  expect(@response.headers).to eq({
185
- "Date"=>"Sat, 23 Jan 2010 01:01:05 GMT",
186
- "Content-Type"=>"text/html; charset=UTF-8",
187
- "Content-Length"=>"419",
188
- "Connection"=>"Keep-Alive",
189
- "Accept"=>"image/jpeg, image/png"
190
- })
189
+ "Date"=>"Sat, 23 Jan 2010 01:01:05 GMT",
190
+ "Content-Type"=>"text/html; charset=UTF-8",
191
+ "Content-Length"=>"419",
192
+ "Connection"=>"Keep-Alive",
193
+ "Accept"=>"image/jpeg, image/png"
194
+ })
191
195
  end
192
196
 
193
197
  it "should read body" do
@@ -234,11 +238,11 @@ describe WebMock::Response do
234
238
  it "should evaluate new response with evaluated options" do
235
239
  request_signature = WebMock::RequestSignature.new(:post, "www.example.com", body: "abc", headers: {'A' => 'a'})
236
240
  response = WebMock::DynamicResponse.new(lambda {|request|
237
- {
238
- body: request.body,
239
- headers: request.headers,
240
- status: 302
241
- }
241
+ {
242
+ body: request.body,
243
+ headers: request.headers,
244
+ status: 302
245
+ }
242
246
  })
243
247
  evaluated_response = response.evaluate(request_signature)
244
248
  expect(evaluated_response.body).to eq("abc")
@@ -16,7 +16,7 @@ describe WebMock::StubRequestSnippet do
16
16
  it "should print stub request snippet with body if available" do
17
17
  @request_signature.body = "abcdef"
18
18
  expected = %Q(stub_request(:get, "http://www.example.com/?a=b&c=d").)+
19
- "\n with(body: \"abcdef\")." +
19
+ "\n with(\n body: \"abcdef\")." +
20
20
  "\n to_return(status: 200, body: \"\", headers: {})"
21
21
  @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
22
22
  expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
@@ -25,7 +25,7 @@ describe WebMock::StubRequestSnippet do
25
25
  it "should print stub request snippet with multiline body" do
26
26
  @request_signature.body = "abc\ndef"
27
27
  expected = %Q(stub_request(:get, "http://www.example.com/?a=b&c=d").)+
28
- "\n with(body: \"abc\\ndef\")." +
28
+ "\n with(\n body: \"abc\\ndef\")." +
29
29
  "\n to_return(status: 200, body: \"\", headers: {})"
30
30
  @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
31
31
  expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
@@ -34,7 +34,7 @@ describe WebMock::StubRequestSnippet do
34
34
  it "should print stub request snippet with headers if any" do
35
35
  @request_signature.headers = {'B' => 'b', 'A' => 'a'}
36
36
  expected = 'stub_request(:get, "http://www.example.com/?a=b&c=d").'+
37
- "\n with(headers: {\'A\'=>\'a\', \'B\'=>\'b\'})." +
37
+ "\n with(\n headers: {\n\t\ 'A\'=>\'a\',\n\t \'B\'=>\'b\'\n })." +
38
38
  "\n to_return(status: 200, body: \"\", headers: {})"
39
39
  @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
40
40
  expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
@@ -44,7 +44,7 @@ describe WebMock::StubRequestSnippet do
44
44
  @request_signature.body = "abcdef"
45
45
  @request_signature.headers = {'B' => 'b', 'A' => 'a'}
46
46
  expected = 'stub_request(:get, "http://www.example.com/?a=b&c=d").'+
47
- "\n with(body: \"abcdef\",\n headers: {\'A\'=>\'a\', \'B\'=>\'b\'})." +
47
+ "\n with(\n body: \"abcdef\",\n headers: {\n\t \'A\'=>\'a\',\n\t \'B\'=>\'b\'\n })." +
48
48
  "\n to_return(status: 200, body: \"\", headers: {})"
49
49
  @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
50
50
  expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
@@ -52,7 +52,7 @@ describe WebMock::StubRequestSnippet do
52
52
 
53
53
  it "should not print to_return part if not wanted" do
54
54
  expected = 'stub_request(:get, "http://www.example.com/").'+
55
- "\n with(body: \"abcdef\")"
55
+ "\n with(\n body: \"abcdef\")"
56
56
  stub = WebMock::RequestStub.new(:get, "www.example.com").with(body: "abcdef").to_return(body: "hello")
57
57
  expect(WebMock::StubRequestSnippet.new(stub).to_s(false)).to eq(expected)
58
58
  end
@@ -68,8 +68,11 @@ describe WebMock::StubRequestSnippet do
68
68
  @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
69
69
  expected = <<-STUB
70
70
  stub_request(:post, "http://www.example.com/").
71
- with(body: {"user"=>{"first_name"=>"Bartosz"}},
72
- headers: {'Content-Type'=>'application/x-www-form-urlencoded'}).
71
+ with(
72
+ body: {"user"=>{"first_name"=>"Bartosz"}},
73
+ headers: {
74
+ \t 'Content-Type'=>'application/x-www-form-urlencoded'
75
+ }).
73
76
  to_return(status: 200, body: \"\", headers: {})
74
77
  STUB
75
78
  expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected.strip)
@@ -82,14 +85,31 @@ stub_request(:post, "http://www.example.com/").
82
85
  @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
83
86
  expected = <<-STUB
84
87
  stub_request(:post, "http://www.example.com/").
85
- with(body: "#{multipart_form_body}",
86
- headers: {'Content-Type'=>'multipart/form-data; boundary=ABC123'}).
88
+ with(
89
+ body: "#{multipart_form_body}",
90
+ headers: {
91
+ \t 'Content-Type'=>'multipart/form-data; boundary=ABC123'
92
+ }).
87
93
  to_return(status: 200, body: \"\", headers: {})
88
94
  STUB
89
95
  expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected.strip)
90
96
  end
91
- end
92
97
 
98
+ it "should print stub request snippet with valid JSON body when request header contains 'Accept'=>'application/json' " do
99
+ @request_signature = WebMock::RequestSignature.new(:post, "www.example.com",
100
+ headers: {'Accept' => 'application/json'})
101
+ @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
102
+ expected = <<-STUB
103
+ stub_request(:post, "http://www.example.com/").
104
+ with(
105
+ headers: {
106
+ \t 'Accept'=>'application/json'
107
+ }).
108
+ to_return(status: 200, body: \"{}\", headers: {})
109
+ STUB
110
+ expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected.strip)
111
+ end
112
+ end
93
113
 
94
114
  end
95
115
  end
@@ -70,6 +70,12 @@ describe WebMock::Util::QueryMapper do
70
70
  hsh = subject.query_to_values(query)
71
71
  expect(hsh['a']).to eq('foo')
72
72
  end
73
+
74
+ it "should parse hash query with key starting with non word character" do
75
+ query = "a[$in]=1".freeze
76
+ hsh = subject.query_to_values(query)
77
+ expect(hsh).to eql({'a' => {'$in' => '1'}})
78
+ end
73
79
  end
74
80
 
75
81
  context '#to_query' do
@@ -141,4 +147,11 @@ describe WebMock::Util::QueryMapper do
141
147
  expect(subject.values_to_query values).to eq query
142
148
  expect(subject.query_to_values query).to eq values
143
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
144
157
  end
@@ -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,37 @@ 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
+
180
+ it "should find all variations of uris with https, basic auth, a non-standard port and a path" do
181
+ uri = "https://~%8A:pass@www.example.com:9000/foo"
182
+ variations = [
183
+ "https://~%8A:pass@www.example.com:9000/foo",
184
+ "https://~\x8A:pass@www.example.com:9000/foo".force_encoding(Encoding::ASCII_8BIT)
185
+ ]
186
+
187
+ expect(WebMock::Util::URI.variations_of_uri_as_strings(uri)).to eq(variations)
188
+ end
189
+
118
190
  end
119
191
 
120
192
  describe "normalized uri equality" do
@@ -1,11 +1,60 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "WebMock version" do
4
- it "should report version" do
5
- expect(WebMock.version).to eq(WebMock::VERSION)
3
+ describe "WebMock" do
4
+
5
+ describe ".version" do
6
+ it "should report version" do
7
+ expect(WebMock.version).to eq(WebMock::VERSION)
8
+ end
9
+
10
+ it "should not require safe_yaml" do
11
+ expect(defined?SafeYAML).to eq(nil)
12
+ end
13
+
14
+ it "should alias enable_net_connect! to allow_net_connect!" do
15
+ expect(WebMock.method(:enable_net_connect!)).to eq(WebMock.method(:allow_net_connect!))
16
+ end
17
+
18
+ it "should alias disallow_net_connect! to disable_net_connect!" do
19
+ expect(WebMock.method(:disallow_net_connect!)).to eq(WebMock.method(:disable_net_connect!))
20
+ end
6
21
  end
7
22
 
8
- it "should not require safe_yaml" do
9
- expect(defined?SafeYAML).to eq(nil)
23
+ describe ".net_connect_allowed?" do
24
+ context 'enabled globally' do
25
+ before do
26
+ WebMock.enable_net_connect!
27
+ end
28
+
29
+ context 'without arguments' do
30
+ it 'returns WebMock::Config.instance.allow_net_connect' do
31
+ expect(WebMock.net_connect_allowed?).to eql(true)
32
+ end
33
+ end
34
+ end
35
+
36
+ context 'disabled with allowed remote string' do
37
+ before do
38
+ WebMock.disable_net_connect!(allow: "http://192.168.64.2:20031")
39
+ end
40
+
41
+ context 'without arguments' do
42
+ it 'returns WebMock::Config.instance.allow_net_connect' do
43
+ expect(WebMock.net_connect_allowed?).to eql(false)
44
+ end
45
+ end
46
+ end
47
+
48
+ context 'disabled globally' do
49
+ before do
50
+ WebMock.disable_net_connect!
51
+ end
52
+
53
+ context 'without arguments' do
54
+ it 'returns WebMock::Config.instance.allow_net_connect' do
55
+ expect(WebMock.net_connect_allowed?).to eql(false)
56
+ end
57
+ end
58
+ end
10
59
  end
11
60
  end
data/test/shared_test.rb CHANGED
@@ -41,7 +41,7 @@ module SharedTest
41
41
 
42
42
  def test_verification_that_expected_request_didnt_occur
43
43
  expected_message = "The request GET http://www.example.com/ was expected to execute 1 time but it executed 0 times"
44
- expected_message << "\n\nThe following requests were made:\n\nNo requests were made.\n============================================================"
44
+ expected_message += "\n\nThe following requests were made:\n\nNo requests were made.\n============================================================"
45
45
  assert_fail(expected_message) do
46
46
  assert_requested(:get, "http://www.example.com")
47
47
  end
@@ -49,7 +49,7 @@ module SharedTest
49
49
 
50
50
  def test_verification_that_expected_stub_didnt_occur
51
51
  expected_message = "The request ANY http://www.example.com/ was expected to execute 1 time but it executed 0 times"
52
- expected_message << "\n\nThe following requests were made:\n\nNo requests were made.\n============================================================"
52
+ expected_message += "\n\nThe following requests were made:\n\nNo requests were made.\n============================================================"
53
53
  assert_fail(expected_message) do
54
54
  assert_requested(@stub_http)
55
55
  end
@@ -69,6 +69,19 @@ module SharedTest
69
69
  query: hash_including({"a" => ["b", "c"]}))
70
70
  end
71
71
 
72
+ def test_verification_that_expected_request_not_occured_with_query_params
73
+ stub_request(:any, 'http://www.example.com').with(query: hash_including(a: ['b', 'c']))
74
+ stub_request(:any, 'http://www.example.com').with(query: hash_excluding(a: ['b', 'c']))
75
+ http_request(:get, 'http://www.example.com/?a[]=b&a[]=c&x=1')
76
+ assert_not_requested(:get, 'http://www.example.com', query: hash_excluding('a' => ['b', 'c']))
77
+ end
78
+
79
+ def test_verification_that_expected_request_occured_with_excluding_query_params
80
+ stub_request(:any, 'http://www.example.com').with(query: hash_excluding('a' => ['b', 'c']))
81
+ http_request(:get, 'http://www.example.com/?a[]=x&a[]=y&x=1')
82
+ assert_requested(:get, 'http://www.example.com', query: hash_excluding('a' => ['b', 'c']))
83
+ end
84
+
72
85
  def test_verification_that_non_expected_request_didnt_occur
73
86
  expected_message = %r(The request GET http://www.example.com/ was not expected to execute but it executed 1 time\n\nThe following requests were made:\n\nGET http://www.example.com/ with headers .+ was made 1 time\n\n============================================================)
74
87
  assert_fail(expected_message) do
data/test/test_webmock.rb CHANGED
@@ -3,4 +3,10 @@ require File.expand_path(File.dirname(__FILE__) + '/shared_test')
3
3
 
4
4
  class TestWebMock < Test::Unit::TestCase
5
5
  include SharedTest
6
+
7
+ def teardown
8
+ # Ensure global Test::Unit teardown was called
9
+ assert_empty WebMock::RequestRegistry.instance.requested_signatures.hash
10
+ assert_empty WebMock::StubRegistry.instance.request_stubs
11
+ end
6
12
  end
data/webmock.gemspec CHANGED
@@ -13,13 +13,19 @@ 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'
16
+ s.metadata = {
17
+ 'bug_tracker_uri' => 'https://github.com/bblimke/webmock/issues',
18
+ 'changelog_uri' => "https://github.com/bblimke/webmock/blob/v#{s.version}/CHANGELOG.md",
19
+ 'documentation_uri' => "https://www.rubydoc.info/gems/webmock/#{s.version}",
20
+ 'source_code_uri' => "https://github.com/bblimke/webmock/tree/v#{s.version}",
21
+ 'wiki_uri' => 'https://github.com/bblimke/webmock/wiki'
22
+ }
17
23
 
18
24
  s.required_ruby_version = '>= 2.0'
19
25
 
20
- s.add_dependency 'addressable', '>= 2.3.6'
26
+ s.add_dependency 'addressable', '>= 2.8.0'
21
27
  s.add_dependency 'crack', '>= 0.3.2'
22
- s.add_dependency 'hashdiff'
28
+ s.add_dependency 'hashdiff', ['>= 0.4.0', '< 2.0.0']
23
29
 
24
30
  unless RUBY_PLATFORM =~ /java/
25
31
  s.add_development_dependency 'patron', '>= 0.4.18'
@@ -35,9 +41,11 @@ Gem::Specification.new do |s|
35
41
  s.add_development_dependency 'em-http-request', '>= 1.0.2'
36
42
  s.add_development_dependency 'em-synchrony', '>= 1.0.0'
37
43
  s.add_development_dependency 'excon', '>= 0.27.5'
44
+ s.add_development_dependency 'async-http', '>= 0.48.0'
38
45
  s.add_development_dependency 'minitest', '>= 5.0.0'
39
46
  s.add_development_dependency 'test-unit', '>= 3.0.0'
40
47
  s.add_development_dependency 'rdoc', '> 3.5.0'
48
+ s.add_development_dependency 'webrick'
41
49
 
42
50
  s.files = `git ls-files`.split("\n")
43
51
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
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.0.0
4
+ version: 3.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartosz Blimke
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-12 00:00:00.000000000 Z
11
+ date: 2021-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.6
19
+ version: 2.8.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.3.6
26
+ version: 2.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: crack
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -112,16 +118,16 @@ dependencies:
112
118
  name: rack
113
119
  requirement: !ruby/object:Gem::Requirement
114
120
  requirements:
115
- - - '='
121
+ - - ">"
116
122
  - !ruby/object:Gem::Version
117
- version: 1.6.0
123
+ version: '1.6'
118
124
  type: :development
119
125
  prerelease: false
120
126
  version_requirements: !ruby/object:Gem::Requirement
121
127
  requirements:
122
- - - '='
128
+ - - ">"
123
129
  - !ruby/object:Gem::Version
124
- version: 1.6.0
130
+ version: '1.6'
125
131
  - !ruby/object:Gem::Dependency
126
132
  name: rspec
127
133
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +198,20 @@ dependencies:
192
198
  - - ">="
193
199
  - !ruby/object:Gem::Version
194
200
  version: 0.27.5
201
+ - !ruby/object:Gem::Dependency
202
+ name: async-http
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: 0.48.0
208
+ type: :development
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ version: 0.48.0
195
215
  - !ruby/object:Gem::Dependency
196
216
  name: minitest
197
217
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +254,20 @@ dependencies:
234
254
  - - ">"
235
255
  - !ruby/object:Gem::Version
236
256
  version: 3.5.0
257
+ - !ruby/object:Gem::Dependency
258
+ name: webrick
259
+ requirement: !ruby/object:Gem::Requirement
260
+ requirements:
261
+ - - ">="
262
+ - !ruby/object:Gem::Version
263
+ version: '0'
264
+ type: :development
265
+ prerelease: false
266
+ version_requirements: !ruby/object:Gem::Requirement
267
+ requirements:
268
+ - - ">="
269
+ - !ruby/object:Gem::Version
270
+ version: '0'
237
271
  description: WebMock allows stubbing HTTP requests and setting expectations on HTTP
238
272
  requests.
239
273
  email:
@@ -243,9 +277,9 @@ extensions: []
243
277
  extra_rdoc_files: []
244
278
  files:
245
279
  - ".gemtest"
280
+ - ".github/workflows/CI.yml"
246
281
  - ".gitignore"
247
282
  - ".rspec-tm"
248
- - ".travis.yml"
249
283
  - CHANGELOG.md
250
284
  - Gemfile
251
285
  - LICENSE
@@ -259,6 +293,7 @@ files:
259
293
  - lib/webmock/cucumber.rb
260
294
  - lib/webmock/deprecation.rb
261
295
  - lib/webmock/errors.rb
296
+ - lib/webmock/http_lib_adapters/async_http_client_adapter.rb
262
297
  - lib/webmock/http_lib_adapters/curb_adapter.rb
263
298
  - lib/webmock/http_lib_adapters/em_http_request_adapter.rb
264
299
  - lib/webmock/http_lib_adapters/excon_adapter.rb
@@ -276,6 +311,9 @@ files:
276
311
  - lib/webmock/http_lib_adapters/net_http_response.rb
277
312
  - lib/webmock/http_lib_adapters/patron_adapter.rb
278
313
  - lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb
314
+ - lib/webmock/matchers/any_arg_matcher.rb
315
+ - lib/webmock/matchers/hash_argument_matcher.rb
316
+ - lib/webmock/matchers/hash_excluding_matcher.rb
279
317
  - lib/webmock/matchers/hash_including_matcher.rb
280
318
  - lib/webmock/minitest.rb
281
319
  - lib/webmock/rack_response.rb
@@ -302,12 +340,15 @@ files:
302
340
  - lib/webmock/util/json.rb
303
341
  - lib/webmock/util/query_mapper.rb
304
342
  - lib/webmock/util/uri.rb
343
+ - lib/webmock/util/values_stringifier.rb
305
344
  - lib/webmock/util/version_checker.rb
306
345
  - lib/webmock/version.rb
307
346
  - lib/webmock/webmock.rb
308
347
  - minitest/test_helper.rb
309
348
  - minitest/test_webmock.rb
310
349
  - minitest/webmock_spec.rb
350
+ - spec/acceptance/async_http_client/async_http_client_spec.rb
351
+ - spec/acceptance/async_http_client/async_http_client_spec_helper.rb
311
352
  - spec/acceptance/curb/curb_spec.rb
312
353
  - spec/acceptance/curb/curb_spec_helper.rb
313
354
  - spec/acceptance/em_http_request/em_http_request_spec.rb
@@ -349,6 +390,7 @@ files:
349
390
  - spec/unit/errors_spec.rb
350
391
  - spec/unit/http_lib_adapters/http_lib_adapter_registry_spec.rb
351
392
  - spec/unit/http_lib_adapters/http_lib_adapter_spec.rb
393
+ - spec/unit/matchers/hash_excluding_matcher_spec.rb
352
394
  - spec/unit/matchers/hash_including_matcher_spec.rb
353
395
  - spec/unit/rack_response_spec.rb
354
396
  - spec/unit/request_body_diff_spec.rb
@@ -377,8 +419,13 @@ files:
377
419
  homepage: http://github.com/bblimke/webmock
378
420
  licenses:
379
421
  - MIT
380
- metadata: {}
381
- post_install_message:
422
+ metadata:
423
+ bug_tracker_uri: https://github.com/bblimke/webmock/issues
424
+ changelog_uri: https://github.com/bblimke/webmock/blob/v3.14.0/CHANGELOG.md
425
+ documentation_uri: https://www.rubydoc.info/gems/webmock/3.14.0
426
+ source_code_uri: https://github.com/bblimke/webmock/tree/v3.14.0
427
+ wiki_uri: https://github.com/bblimke/webmock/wiki
428
+ post_install_message:
382
429
  rdoc_options: []
383
430
  require_paths:
384
431
  - lib
@@ -393,12 +440,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
393
440
  - !ruby/object:Gem::Version
394
441
  version: '0'
395
442
  requirements: []
396
- rubyforge_project: webmock
397
- rubygems_version: 2.2.2
398
- signing_key:
443
+ rubygems_version: 3.1.2
444
+ signing_key:
399
445
  specification_version: 4
400
446
  summary: Library for stubbing HTTP requests in Ruby.
401
447
  test_files:
448
+ - spec/acceptance/async_http_client/async_http_client_spec.rb
449
+ - spec/acceptance/async_http_client/async_http_client_spec_helper.rb
402
450
  - spec/acceptance/curb/curb_spec.rb
403
451
  - spec/acceptance/curb/curb_spec_helper.rb
404
452
  - spec/acceptance/em_http_request/em_http_request_spec.rb
@@ -440,6 +488,7 @@ test_files:
440
488
  - spec/unit/errors_spec.rb
441
489
  - spec/unit/http_lib_adapters/http_lib_adapter_registry_spec.rb
442
490
  - spec/unit/http_lib_adapters/http_lib_adapter_spec.rb
491
+ - spec/unit/matchers/hash_excluding_matcher_spec.rb
443
492
  - spec/unit/matchers/hash_including_matcher_spec.rb
444
493
  - spec/unit/rack_response_spec.rb
445
494
  - spec/unit/request_body_diff_spec.rb
data/.travis.yml DELETED
@@ -1,20 +0,0 @@
1
- rvm:
2
- - 2.0.0
3
- - 2.1.0
4
- - 2.2.1
5
- - 2.2.3
6
- - 2.3.0
7
- - 2.4.0
8
- - rbx-2
9
- - ruby-head
10
- - jruby-9.0.5.0
11
- - jruby-9.1.5.0
12
- - jruby-head
13
- matrix:
14
- allow_failures:
15
- - rvm: jruby-head
16
- - rvm: ruby-head
17
- - rvm: rbx-2
18
- # Send builds to container-based infrastructure
19
- # http://docs.travis-ci.com/user/workers/container-based-infrastructure/
20
- sudo: false