webmock 3.9.1 → 3.18.1

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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/CI.yml +38 -0
  3. data/CHANGELOG.md +180 -6
  4. data/Gemfile +1 -1
  5. data/README.md +63 -30
  6. data/Rakefile +12 -2
  7. data/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +11 -4
  8. data/lib/webmock/http_lib_adapters/curb_adapter.rb +2 -2
  9. data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +6 -3
  10. data/lib/webmock/http_lib_adapters/http_rb/client.rb +2 -1
  11. data/lib/webmock/http_lib_adapters/http_rb/response.rb +17 -3
  12. data/lib/webmock/http_lib_adapters/http_rb/streamer.rb +4 -2
  13. data/lib/webmock/http_lib_adapters/http_rb/webmock.rb +6 -2
  14. data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +23 -6
  15. data/lib/webmock/http_lib_adapters/manticore_adapter.rb +8 -1
  16. data/lib/webmock/http_lib_adapters/net_http.rb +29 -115
  17. data/lib/webmock/request_pattern.rb +30 -8
  18. data/lib/webmock/request_signature.rb +2 -2
  19. data/lib/webmock/request_stub.rb +15 -0
  20. data/lib/webmock/response.rb +19 -13
  21. data/lib/webmock/stub_registry.rb +24 -9
  22. data/lib/webmock/test_unit.rb +1 -3
  23. data/lib/webmock/version.rb +1 -1
  24. data/lib/webmock/webmock.rb +12 -2
  25. data/minitest/webmock_spec.rb +1 -1
  26. data/spec/acceptance/async_http_client/async_http_client_spec.rb +27 -5
  27. data/spec/acceptance/curb/curb_spec.rb +11 -0
  28. data/spec/acceptance/em_http_request/em_http_request_spec.rb +57 -1
  29. data/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +1 -1
  30. data/spec/acceptance/excon/excon_spec.rb +2 -2
  31. data/spec/acceptance/manticore/manticore_spec.rb +32 -0
  32. data/spec/acceptance/net_http/net_http_shared.rb +46 -9
  33. data/spec/acceptance/net_http/net_http_spec.rb +75 -23
  34. data/spec/acceptance/net_http/real_net_http_spec.rb +1 -1
  35. data/spec/acceptance/patron/patron_spec.rb +19 -21
  36. data/spec/acceptance/patron/patron_spec_helper.rb +2 -2
  37. data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +14 -14
  38. data/spec/acceptance/shared/callbacks.rb +2 -2
  39. data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +1 -1
  40. data/spec/acceptance/shared/stubbing_requests.rb +17 -0
  41. data/spec/unit/request_pattern_spec.rb +82 -46
  42. data/spec/unit/request_signature_spec.rb +21 -1
  43. data/spec/unit/request_stub_spec.rb +35 -0
  44. data/spec/unit/response_spec.rb +51 -19
  45. data/spec/unit/webmock_spec.rb +54 -0
  46. data/test/test_webmock.rb +6 -0
  47. data/webmock.gemspec +6 -5
  48. metadata +49 -35
  49. data/.travis.yml +0 -24
@@ -534,69 +534,105 @@ describe WebMock::RequestPattern do
534
534
  end
535
535
 
536
536
  describe "for request with json body and content type is set to json" do
537
- it "should match when hash matches body" do
538
- expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
539
- to match(WebMock::RequestSignature.new(:post, "www.example.com", headers: {content_type: 'application/json'},
540
- body: "{\"a\":\"1\",\"c\":{\"d\":[\"e\",\"f\"]},\"b\":\"five\"}"))
541
- end
537
+ shared_examples "a json body" do
538
+ it "should match when hash matches body" do
539
+ expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
540
+ to match(WebMock::RequestSignature.new(:post, "www.example.com", headers: {content_type: content_type},
541
+ body: "{\"a\":\"1\",\"c\":{\"d\":[\"e\",\"f\"]},\"b\":\"five\"}"))
542
+ end
542
543
 
543
- it "should match if hash matches body in different form" do
544
- expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
545
- to match(WebMock::RequestSignature.new(:post, "www.example.com", headers: {content_type: 'application/json'},
546
- body: "{\"a\":\"1\",\"b\":\"five\",\"c\":{\"d\":[\"e\",\"f\"]}}"))
547
- end
544
+ it "should match if hash matches body in different form" do
545
+ expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
546
+ to match(WebMock::RequestSignature.new(:post, "www.example.com", headers: {content_type: content_type},
547
+ body: "{\"a\":\"1\",\"b\":\"five\",\"c\":{\"d\":[\"e\",\"f\"]}}"))
548
+ end
549
+
550
+ it "should match if the request body has a top level array" do
551
+ expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: [{a: 1}])).
552
+ to match(WebMock::RequestSignature.new(:post, "www.example.com",
553
+ headers: {content_type: content_type}, body: "[{\"a\":1}]"))
554
+ end
548
555
 
549
- it "should not match when body is not json" do
550
- expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
551
- not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
552
- headers: {content_type: 'application/json'}, body: "foo bar"))
553
- end
556
+ it "should not match if the request body has a different top level array" do
557
+ expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: ["a", "b"])).
558
+ not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
559
+ headers: {content_type: content_type}, body: "[\"a\", \"c\"]"))
560
+ end
561
+
562
+ it "should not match when body is not json" do
563
+ expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
564
+ not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
565
+ headers: {content_type: content_type}, body: "foo bar"))
566
+ end
567
+
568
+ it "should not match if request body is different" do
569
+ expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: {a: 1, b: 2})).
570
+ not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
571
+ headers: {content_type: content_type}, body: "{\"a\":1,\"c\":null}"))
572
+ end
573
+
574
+ it "should not match if request body is has less params than pattern" do
575
+ expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: {a: 1, b: 2})).
576
+ not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
577
+ headers: {content_type: content_type}, body: "{\"a\":1}"))
578
+ end
554
579
 
555
- it "should not match if request body is different" do
556
- expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: {a: 1, b: 2})).
557
- not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
558
- headers: {content_type: 'application/json'}, body: "{\"a\":1,\"c\":null}"))
580
+ it "should not match if request body is has more params than pattern" do
581
+ expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: {a: 1})).
582
+ not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
583
+ headers: {content_type: content_type}, body: "{\"a\":1,\"c\":1}"))
584
+ end
559
585
  end
560
586
 
561
- it "should not match if request body is has less params than pattern" do
562
- expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: {a: 1, b: 2})).
563
- not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
564
- headers: {content_type: 'application/json'}, body: "{\"a\":1}"))
587
+ context "standard application/json" do
588
+ let(:content_type) { 'application/json' }
589
+ it_behaves_like "a json body"
565
590
  end
566
591
 
567
- it "should not match if request body is has more params than pattern" do
568
- expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: {a: 1})).
569
- not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
570
- headers: {content_type: 'application/json'}, body: "{\"a\":1,\"c\":1}"))
592
+ context "custom json content type" do
593
+ let(:content_type) { 'application/vnd.api+json' }
594
+ it_behaves_like "a json body"
571
595
  end
572
596
  end
573
597
 
574
598
  describe "for request with xml body and content type is set to xml" do
575
599
  let(:body_hash) { {"opt" => {:a => '1', :b => 'five', 'c' => {'d' => ['e', 'f']}}} }
576
600
 
577
- it "should match when hash matches body" do
578
- expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
579
- to match(WebMock::RequestSignature.new(:post, "www.example.com", headers: {content_type: 'application/xml'},
580
- body: "<opt a=\"1\" b=\"five\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n"))
581
- end
601
+ shared_examples "a xml body" do
602
+ it "should match when hash matches body" do
603
+ expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
604
+ to match(WebMock::RequestSignature.new(:post, "www.example.com", headers: {content_type: content_type},
605
+ body: "<opt a=\"1\" b=\"five\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n"))
606
+ end
582
607
 
583
- it "should match if hash matches body in different form" do
584
- expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
585
- to match(WebMock::RequestSignature.new(:post, "www.example.com", headers: {content_type: 'application/xml'},
586
- body: "<opt b=\"five\" a=\"1\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n"))
587
- end
608
+ it "should match if hash matches body in different form" do
609
+ expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
610
+ to match(WebMock::RequestSignature.new(:post, "www.example.com", headers: {content_type: content_type},
611
+ body: "<opt b=\"five\" a=\"1\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n"))
612
+ end
588
613
 
589
- it "should not match when body is not xml" do
590
- expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
591
- not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
592
- headers: {content_type: 'application/xml'}, body: "foo bar"))
593
- end
614
+ it "should not match when body is not xml" do
615
+ expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
616
+ not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
617
+ headers: {content_type: content_type}, body: "foo bar"))
618
+ end
594
619
 
595
- it "matches when the content type include a charset" do
596
- expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
597
- to match(WebMock::RequestSignature.new(:post, "www.example.com", headers: {content_type: 'application/xml;charset=UTF-8'},
598
- body: "<opt a=\"1\" b=\"five\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n"))
620
+ it "matches when the content type include a charset" do
621
+ expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
622
+ to match(WebMock::RequestSignature.new(:post, "www.example.com", headers: {content_type: "#{content_type};charset=UTF-8"},
623
+ body: "<opt a=\"1\" b=\"five\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n"))
624
+
625
+ end
626
+ end
627
+
628
+ context "standard application/xml" do
629
+ let(:content_type) { 'application/xml' }
630
+ it_behaves_like "a xml body"
631
+ end
599
632
 
633
+ context "custom xml content type" do
634
+ let(:content_type) { 'application/atom+xml' }
635
+ it_behaves_like "a xml body"
600
636
  end
601
637
  end
602
638
  end
@@ -18,7 +18,7 @@ describe WebMock::RequestSignature do
18
18
  end
19
19
 
20
20
  it "assigns normalized headers" do
21
- expect(WebMock::Util::Headers).to receive(:normalize_headers).with('A' => 'a').and_return('B' => 'b')
21
+ allow(WebMock::Util::Headers).to receive(:normalize_headers).with({'A' => 'a'}.freeze).and_return('B' => 'b')
22
22
  expect(
23
23
  WebMock::RequestSignature.new(:get, "www.example.com", headers: {'A' => 'a'}).headers
24
24
  ).to eq({'B' => 'b'})
@@ -125,11 +125,21 @@ describe WebMock::RequestSignature do
125
125
  expect(subject.url_encoded?).to be true
126
126
  end
127
127
 
128
+ it "returns true if the headers are urlencoded with a specified charset" do
129
+ subject.headers = { "Content-Type" => "application/x-www-form-urlencoded; charset=UTF-8" }
130
+ expect(subject.url_encoded?).to be true
131
+ end
132
+
128
133
  it "returns false if the headers are NOT urlencoded" do
129
134
  subject.headers = { "Content-Type" => "application/made-up-format" }
130
135
  expect(subject.url_encoded?).to be false
131
136
  end
132
137
 
138
+ it "returns false when no content type header is present" do
139
+ subject.headers = { "Some-Header" => "some-value" }
140
+ expect(subject.url_encoded?).to be false
141
+ end
142
+
133
143
  it "returns false when no headers are set" do
134
144
  subject.headers = nil
135
145
  expect(subject.url_encoded?).to be false
@@ -142,11 +152,21 @@ describe WebMock::RequestSignature do
142
152
  expect(subject.json_headers?).to be true
143
153
  end
144
154
 
155
+ it "returns true if the headers are json with a specified charset" do
156
+ subject.headers = { "Content-Type" => "application/json; charset=UTF-8" }
157
+ expect(subject.json_headers?).to be true
158
+ end
159
+
145
160
  it "returns false if the headers are NOT json" do
146
161
  subject.headers = { "Content-Type" => "application/made-up-format" }
147
162
  expect(subject.json_headers?).to be false
148
163
  end
149
164
 
165
+ it "returns false when no content type header is present" do
166
+ subject.headers = { "Some-Header" => "some-value" }
167
+ expect(subject.json_headers?).to be false
168
+ end
169
+
150
170
  it "returns false when no headers are set" do
151
171
  subject.headers = nil
152
172
  expect(subject.json_headers?).to be false
@@ -50,6 +50,41 @@ describe WebMock::RequestStub do
50
50
 
51
51
  end
52
52
 
53
+ describe "to_return_json" do
54
+
55
+ it "should raise if a block is given" do
56
+ expect {
57
+ @request_stub.to_return_json(body: "abc", status: 500) { puts "don't call me" }
58
+ }.to raise_error(ArgumentError, '#to_return_json does not support passing a block')
59
+ end
60
+
61
+ it "should assign responses normally" do
62
+ @request_stub.to_return_json([{body: "abc"}, {body: "def"}])
63
+ expect([@request_stub.response.body, @request_stub.response.body]).to eq(["abc", "def"])
64
+ end
65
+
66
+ it "should json-ify a Hash body" do
67
+ @request_stub.to_return_json(body: {abc: "def"}, status: 500)
68
+ expect(@request_stub.response.body).to eq({abc: "def"}.to_json)
69
+ expect(@request_stub.response.status).to eq([500, ""])
70
+ end
71
+
72
+ it "should apply the content_type header" do
73
+ @request_stub.to_return_json(body: {abc: "def"}, status: 500)
74
+ expect(@request_stub.response.headers).to eq({"Content-Type"=>"application/json"})
75
+ end
76
+
77
+ it "should preserve existing headers" do
78
+ @request_stub.to_return_json(headers: {"A" => "a"}, body: "")
79
+ expect(@request_stub.response.headers).to eq({"A"=>"a", "Content-Type"=>"application/json"})
80
+ end
81
+
82
+ it "should allow callsites to override content_type header" do
83
+ @request_stub.to_return_json(headers: {content_type: 'application/super-special-json'})
84
+ expect(@request_stub.response.headers).to eq({"Content-Type"=>"application/super-special-json"})
85
+ end
86
+ end
87
+
53
88
  describe "then" do
54
89
  it "should return stub without any modifications, acting as syntactic sugar" do
55
90
  expect(@request_stub.then).to eq(@request_stub)
@@ -31,7 +31,7 @@ describe WebMock::Response do
31
31
  end
32
32
 
33
33
  it "should report normalized headers" do
34
- expect(WebMock::Util::Headers).to receive(:normalize_headers).with('A' => 'a').and_return('B' => 'b')
34
+ allow(WebMock::Util::Headers).to receive(:normalize_headers).with({'A' => 'a'}.freeze).and_return('B' => 'b')
35
35
  @response = WebMock::Response.new(headers: {'A' => 'a'})
36
36
  expect(@response.headers).to eq({'B' => 'b'})
37
37
  end
@@ -130,14 +130,46 @@ 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
145
+ describe "when input is a StringIO" do
146
+ before(:each) do
147
+ @io = StringIO.new(File.read(CURL_EXAMPLE_OUTPUT_PATH))
148
+ @response = WebMock::Response.new(@io)
149
+ end
150
+
151
+ it "should read status" do
152
+ expect(@response.status).to eq([202, "OK"])
153
+ end
154
+
155
+ it "should read headers" do
156
+ expect(@response.headers).to eq(
157
+ "Date"=>"Sat, 23 Jan 2010 01:01:05 GMT",
158
+ "Content-Type"=>"text/html; charset=UTF-8",
159
+ "Content-Length"=>"419",
160
+ "Connection"=>"Keep-Alive",
161
+ "Accept"=>"image/jpeg, image/png"
162
+ )
163
+ end
164
+
165
+ it "should read body" do
166
+ expect(@response.body.size).to eq(419)
167
+ end
168
+
169
+ it "should close IO" do
170
+ expect(@io).to be_closed
171
+ end
172
+ end
141
173
 
142
174
  describe "when input is IO" do
143
175
  before(:each) do
@@ -152,12 +184,12 @@ describe WebMock::Response do
152
184
 
153
185
  it "should read headers" do
154
186
  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
- })
187
+ "Date"=>"Sat, 23 Jan 2010 01:01:05 GMT",
188
+ "Content-Type"=>"text/html; charset=UTF-8",
189
+ "Content-Length"=>"419",
190
+ "Connection"=>"Keep-Alive",
191
+ "Accept"=>"image/jpeg, image/png"
192
+ })
161
193
  end
162
194
 
163
195
  it "should read body" do
@@ -182,12 +214,12 @@ describe WebMock::Response do
182
214
 
183
215
  it "should read headers" do
184
216
  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
- })
217
+ "Date"=>"Sat, 23 Jan 2010 01:01:05 GMT",
218
+ "Content-Type"=>"text/html; charset=UTF-8",
219
+ "Content-Length"=>"419",
220
+ "Connection"=>"Keep-Alive",
221
+ "Accept"=>"image/jpeg, image/png"
222
+ })
191
223
  end
192
224
 
193
225
  it "should read body" do
@@ -234,11 +266,11 @@ describe WebMock::Response do
234
266
  it "should evaluate new response with evaluated options" do
235
267
  request_signature = WebMock::RequestSignature.new(:post, "www.example.com", body: "abc", headers: {'A' => 'a'})
236
268
  response = WebMock::DynamicResponse.new(lambda {|request|
237
- {
238
- body: request.body,
239
- headers: request.headers,
240
- status: 302
241
- }
269
+ {
270
+ body: request.body,
271
+ headers: request.headers,
272
+ status: 302
273
+ }
242
274
  })
243
275
  evaluated_response = response.evaluate(request_signature)
244
276
  expect(evaluated_response.body).to eq("abc")
@@ -57,4 +57,58 @@ describe "WebMock" do
57
57
  end
58
58
  end
59
59
  end
60
+
61
+ describe ".net_http_connect_on_start?" do
62
+ let(:uri) { Addressable::URI.parse("http://example.org:5432") }
63
+
64
+ it "will not connect on start when false" do
65
+ WebMock.disable_net_connect!
66
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(false)
67
+ end
68
+
69
+ it "will connect on start when true" do
70
+ WebMock.disable_net_connect!(net_http_connect_on_start: true)
71
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(true)
72
+ end
73
+
74
+ it "will connect on start when regexp matches" do
75
+ WebMock.disable_net_connect!(net_http_connect_on_start: /example/)
76
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(true)
77
+ end
78
+
79
+ it "will not connect on start when regexp does not match" do
80
+ WebMock.disable_net_connect!(net_http_connect_on_start: /nope/)
81
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(false)
82
+ end
83
+
84
+ it "will connect on start when host matches" do
85
+ WebMock.disable_net_connect!(net_http_connect_on_start: "example.org")
86
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(true)
87
+ end
88
+
89
+ it "will not connect on start when host does not match" do
90
+ WebMock.disable_net_connect!(net_http_connect_on_start: "localhost")
91
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(false)
92
+ end
93
+
94
+ it "will connect on start when host + port matches" do
95
+ WebMock.disable_net_connect!(net_http_connect_on_start: "example.org:5432")
96
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(true)
97
+ end
98
+
99
+ it "will not connect on start when host + port does not match" do
100
+ WebMock.disable_net_connect!(net_http_connect_on_start: "example.org:80")
101
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(false)
102
+ end
103
+
104
+ it "will connect on start when scheme + host + port matches" do
105
+ WebMock.disable_net_connect!(net_http_connect_on_start: "http://example.org:5432")
106
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(true)
107
+ end
108
+
109
+ it "will not connect on start when scheme + host + port does not match" do
110
+ WebMock.disable_net_connect!(net_http_connect_on_start: "https://example.org:5432")
111
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(false)
112
+ end
113
+ end
60
114
  end
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
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ['Bartosz Blimke']
10
10
  s.email = ['bartosz.blimke@gmail.com']
11
- s.homepage = 'http://github.com/bblimke/webmock'
11
+ s.homepage = 'https://github.com/bblimke/webmock'
12
12
  s.summary = %q{Library for stubbing HTTP requests in Ruby.}
13
13
  s.description = %q{WebMock allows stubbing HTTP requests and setting expectations on HTTP requests.}
14
14
  s.license = "MIT"
@@ -21,9 +21,9 @@ Gem::Specification.new do |s|
21
21
  'wiki_uri' => 'https://github.com/bblimke/webmock/wiki'
22
22
  }
23
23
 
24
- s.required_ruby_version = '>= 2.0'
24
+ s.required_ruby_version = '>= 2.3'
25
25
 
26
- s.add_dependency 'addressable', '>= 2.3.6'
26
+ s.add_dependency 'addressable', '>= 2.8.0'
27
27
  s.add_dependency 'crack', '>= 0.3.2'
28
28
  s.add_dependency 'hashdiff', ['>= 0.4.0', '< 2.0.0']
29
29
 
@@ -31,6 +31,8 @@ Gem::Specification.new do |s|
31
31
  s.add_development_dependency 'patron', '>= 0.4.18'
32
32
  s.add_development_dependency 'curb', '>= 0.7.16'
33
33
  s.add_development_dependency 'typhoeus', '>= 0.5.0'
34
+ s.add_development_dependency 'em-http-request', '>= 1.0.2'
35
+ s.add_development_dependency 'em-synchrony', '>= 1.0.0'
34
36
  end
35
37
 
36
38
  s.add_development_dependency 'http', '>= 0.8.0'
@@ -38,13 +40,12 @@ Gem::Specification.new do |s|
38
40
  s.add_development_dependency 'rack', ((RUBY_VERSION < '2.2.2') ? '1.6.0' : '> 1.6')
39
41
  s.add_development_dependency 'rspec', '>= 3.1.0'
40
42
  s.add_development_dependency 'httpclient', '>= 2.2.4'
41
- s.add_development_dependency 'em-http-request', '>= 1.0.2'
42
- s.add_development_dependency 'em-synchrony', '>= 1.0.0'
43
43
  s.add_development_dependency 'excon', '>= 0.27.5'
44
44
  s.add_development_dependency 'async-http', '>= 0.48.0'
45
45
  s.add_development_dependency 'minitest', '>= 5.0.0'
46
46
  s.add_development_dependency 'test-unit', '>= 3.0.0'
47
47
  s.add_development_dependency 'rdoc', '> 3.5.0'
48
+ s.add_development_dependency 'webrick'
48
49
 
49
50
  s.files = `git ls-files`.split("\n")
50
51
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")