webmock 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile +2 -7
- data/README.md +54 -53
- data/Rakefile +1 -1
- data/lib/webmock/callback_registry.rb +1 -1
- data/lib/webmock/http_lib_adapters/curb_adapter.rb +68 -6
- data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +4 -4
- data/lib/webmock/http_lib_adapters/excon_adapter.rb +9 -9
- data/lib/webmock/http_lib_adapters/http_rb/request.rb +2 -2
- data/lib/webmock/http_lib_adapters/http_rb/response.rb +5 -5
- data/lib/webmock/http_lib_adapters/http_rb/webmock.rb +3 -3
- data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +5 -5
- data/lib/webmock/http_lib_adapters/manticore_adapter.rb +7 -7
- data/lib/webmock/http_lib_adapters/net_http.rb +3 -3
- data/lib/webmock/http_lib_adapters/patron_adapter.rb +4 -4
- data/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +14 -14
- data/lib/webmock/matchers/hash_including_matcher.rb +1 -1
- data/lib/webmock/rack_response.rb +3 -3
- data/lib/webmock/request_pattern.rb +8 -8
- data/lib/webmock/request_stub.rb +5 -5
- data/lib/webmock/util/uri.rb +2 -2
- data/lib/webmock/version.rb +1 -1
- data/minitest/webmock_spec.rb +3 -3
- data/spec/acceptance/curb/curb_spec.rb +64 -47
- data/spec/acceptance/curb/curb_spec_helper.rb +4 -4
- data/spec/acceptance/em_http_request/em_http_request_spec.rb +32 -32
- data/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +9 -9
- data/spec/acceptance/excon/excon_spec.rb +14 -14
- data/spec/acceptance/excon/excon_spec_helper.rb +6 -6
- data/spec/acceptance/http_rb/http_rb_spec.rb +1 -1
- data/spec/acceptance/http_rb/http_rb_spec_helper.rb +7 -7
- data/spec/acceptance/httpclient/httpclient_spec.rb +20 -20
- data/spec/acceptance/httpclient/httpclient_spec_helper.rb +5 -5
- data/spec/acceptance/manticore/manticore_spec.rb +11 -11
- data/spec/acceptance/manticore/manticore_spec_helper.rb +3 -3
- data/spec/acceptance/net_http/net_http_shared.rb +4 -4
- data/spec/acceptance/net_http/net_http_spec.rb +25 -25
- data/spec/acceptance/net_http/net_http_spec_helper.rb +4 -4
- data/spec/acceptance/net_http/real_net_http_spec.rb +1 -1
- data/spec/acceptance/patron/patron_spec.rb +10 -10
- data/spec/acceptance/patron/patron_spec_helper.rb +5 -5
- data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +36 -36
- data/spec/acceptance/shared/callbacks.rb +11 -11
- data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +5 -5
- data/spec/acceptance/shared/enabling_and_disabling_webmock.rb +4 -4
- data/spec/acceptance/shared/precedence_of_stubs.rb +4 -4
- data/spec/acceptance/shared/request_expectations.rb +90 -90
- data/spec/acceptance/shared/returning_declared_responses.rb +49 -49
- data/spec/acceptance/shared/stubbing_requests.rb +78 -78
- data/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +11 -11
- data/spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb +8 -8
- data/spec/spec_helper.rb +6 -3
- data/spec/support/webmock_server.rb +1 -1
- data/spec/unit/api_spec.rb +2 -2
- data/spec/unit/errors_spec.rb +3 -3
- data/spec/unit/matchers/hash_including_matcher_spec.rb +16 -16
- data/spec/unit/rack_response_spec.rb +2 -2
- data/spec/unit/request_body_diff_spec.rb +1 -1
- data/spec/unit/request_execution_verifier_spec.rb +1 -1
- data/spec/unit/request_pattern_spec.rb +115 -115
- data/spec/unit/request_signature_snippet_spec.rb +2 -2
- data/spec/unit/request_signature_spec.rb +16 -16
- data/spec/unit/request_stub_spec.rb +20 -20
- data/spec/unit/response_spec.rb +28 -28
- data/spec/unit/stub_registry_spec.rb +10 -10
- data/spec/unit/stub_request_snippet_spec.rb +6 -6
- data/spec/unit/util/hash_keys_stringifier_spec.rb +4 -4
- data/spec/unit/util/query_mapper_spec.rb +2 -2
- data/spec/unit/util/uri_spec.rb +1 -1
- data/test/http_request.rb +3 -3
- data/test/shared_test.rb +6 -6
- data/webmock.gemspec +4 -2
- metadata +32 -4
@@ -2,7 +2,7 @@ class MyException < StandardError; end;
|
|
2
2
|
|
3
3
|
class Responder
|
4
4
|
def call(request)
|
5
|
-
{:
|
5
|
+
{body: request.body}
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
@@ -30,7 +30,7 @@ shared_context "declared responses" do |*adapter_info|
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should raise exception after returning declared successful response first" do
|
33
|
-
stub_request(:get, "www.example.com").to_return(:
|
33
|
+
stub_request(:get, "www.example.com").to_return(body: "abc").then.to_raise(MyException)
|
34
34
|
expect(http_request(:get, "http://www.example.com/").body).to eq("abc")
|
35
35
|
expect {
|
36
36
|
http_request(:get, "http://www.example.com/")
|
@@ -47,7 +47,7 @@ shared_context "declared responses" do |*adapter_info|
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should timeout after returning declared successful response" do
|
50
|
-
stub_request(:get, "www.example.com").to_return(:
|
50
|
+
stub_request(:get, "www.example.com").to_return(body: "abc").then.to_timeout
|
51
51
|
expect(http_request(:get, "http://www.example.com/").body).to eq("abc")
|
52
52
|
expect {
|
53
53
|
http_request(:get, "http://www.example.com/")
|
@@ -57,29 +57,29 @@ shared_context "declared responses" do |*adapter_info|
|
|
57
57
|
|
58
58
|
describe "when request stub declares that request should return a response" do
|
59
59
|
it "should return response with declared body" do
|
60
|
-
stub_request(:get, "www.example.com").to_return(:
|
60
|
+
stub_request(:get, "www.example.com").to_return(body: "abc")
|
61
61
|
expect(http_request(:get, "http://www.example.com/").body).to eq("abc")
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should return response with declared headers" do
|
65
|
-
stub_request(:get, "www.example.com").to_return(:
|
65
|
+
stub_request(:get, "www.example.com").to_return(headers: SAMPLE_HEADERS)
|
66
66
|
response = http_request(:get, "http://www.example.com/")
|
67
67
|
expect(response.headers["Content-Length"]).to eq("8888")
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should return response with declared headers even if there are multiple headers with the same key" do
|
71
|
-
stub_request(:get, "www.example.com").to_return(:
|
71
|
+
stub_request(:get, "www.example.com").to_return(headers: {"a" => ["b", "c"]})
|
72
72
|
response = http_request(:get, "http://www.example.com/")
|
73
73
|
expect(response.headers["A"]).to eq("b, c")
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should return response with declared status code" do
|
77
|
-
stub_request(:get, "www.example.com").to_return(:
|
77
|
+
stub_request(:get, "www.example.com").to_return(status: 500)
|
78
78
|
expect(http_request(:get, "http://www.example.com/").status).to eq("500")
|
79
79
|
end
|
80
80
|
|
81
|
-
it "should return response with declared status message", :
|
82
|
-
stub_request(:get, "www.example.com").to_return(:
|
81
|
+
it "should return response with declared status message", unless: (adapter_info.include?(:no_status_message)) do
|
82
|
+
stub_request(:get, "www.example.com").to_return(status: [500, "Internal Server Error"])
|
83
83
|
response = http_request(:get, "http://www.example.com/")
|
84
84
|
expect(response.message).to eq("Internal Server Error")
|
85
85
|
end
|
@@ -89,7 +89,7 @@ shared_context "declared responses" do |*adapter_info|
|
|
89
89
|
expect(http_request(:get, "http://www.example.com/").status).to eq("200")
|
90
90
|
end
|
91
91
|
|
92
|
-
it "should return default response with empty message if response was not declared", :
|
92
|
+
it "should return default response with empty message if response was not declared", unless: (adapter_info.include?(:no_status_message)) do
|
93
93
|
stub_request(:get, "www.example.com")
|
94
94
|
response = http_request(:get, "http://www.example.com/")
|
95
95
|
expect(response.message).to eq("")
|
@@ -97,68 +97,68 @@ shared_context "declared responses" do |*adapter_info|
|
|
97
97
|
|
98
98
|
describe "when response body was declared as IO" do
|
99
99
|
it "should return response body" do
|
100
|
-
stub_request(:get, "www.example.com").to_return(:
|
100
|
+
stub_request(:get, "www.example.com").to_return(body: File.new(__FILE__))
|
101
101
|
expect(http_request(:get, "http://www.example.com/").body).to eq(File.read(__FILE__))
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should return response body if requested many times" do
|
105
|
-
stub_request(:get, "www.example.com").to_return(:
|
105
|
+
stub_request(:get, "www.example.com").to_return(body: File.new(__FILE__))
|
106
106
|
2.times do
|
107
107
|
expect(http_request(:get, "http://www.example.com/").body).to eq(File.read(__FILE__))
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should close IO after request" do
|
112
|
-
stub_request(:get, "www.example.com").to_return(:
|
112
|
+
stub_request(:get, "www.example.com").to_return(body: @file = File.new(__FILE__))
|
113
113
|
expect(@file).to be_closed
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
117
|
describe "when response parts were declared as lambdas" do
|
118
118
|
it "should return evaluated response body" do
|
119
|
-
stub_request(:post, "www.example.com").to_return(:
|
120
|
-
expect(http_request(:post, "http://www.example.com/", :
|
119
|
+
stub_request(:post, "www.example.com").to_return(body: lambda { |request| request.body })
|
120
|
+
expect(http_request(:post, "http://www.example.com/", body: "echo").body).to eq("echo")
|
121
121
|
end
|
122
122
|
|
123
123
|
it "should return evaluated response headers" do
|
124
|
-
stub_request(:post, "www.example.com").to_return(:
|
125
|
-
expect(http_request(:post, "http://www.example.com/", :
|
126
|
-
expect(http_request(:post, "http://www.example.com/", :
|
124
|
+
stub_request(:post, "www.example.com").to_return(headers: lambda { |request| request.headers })
|
125
|
+
expect(http_request(:post, "http://www.example.com/", body: "abc", headers: {'A' => 'B'}).headers['A']).to eq('B')
|
126
|
+
expect(http_request(:post, "http://www.example.com/", body: "abc", headers: {'A' => 'C'}).headers['A']).to eq('C')
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should evaluate response body for each request" do
|
130
|
-
stub_request(:post, "www.example.com").to_return(:
|
131
|
-
expect(http_request(:post, "http://www.example.com/", :
|
132
|
-
expect(http_request(:post, "http://www.example.com/", :
|
130
|
+
stub_request(:post, "www.example.com").to_return(body: lambda { |request| request.body })
|
131
|
+
expect(http_request(:post, "http://www.example.com/", body: "echo").body).to eq("echo")
|
132
|
+
expect(http_request(:post, "http://www.example.com/", body: "foxtrot").body).to eq("foxtrot")
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
136
|
describe "when response was declared as lambda" do
|
137
137
|
it "should return evaluated response body" do
|
138
138
|
stub_request(:post, "www.example.com").to_return(lambda {|request|
|
139
|
-
{:
|
139
|
+
{body: request.body}
|
140
140
|
})
|
141
|
-
expect(http_request(:post, "http://www.example.com/", :
|
142
|
-
expect(http_request(:post, "http://www.example.com/", :
|
141
|
+
expect(http_request(:post, "http://www.example.com/", body: "echo").body).to eq("echo")
|
142
|
+
expect(http_request(:post, "http://www.example.com/", body: "foxtrot").body).to eq("foxtrot")
|
143
143
|
end
|
144
144
|
|
145
145
|
it "should return evaluated response headers" do
|
146
146
|
stub_request(:get, "www.example.com").to_return(lambda { |request|
|
147
|
-
{:
|
147
|
+
{headers: request.headers}
|
148
148
|
})
|
149
|
-
expect(http_request(:get, "http://www.example.com/", :
|
149
|
+
expect(http_request(:get, "http://www.example.com/", headers: {'A' => 'B'}).headers['A']).to eq('B')
|
150
150
|
end
|
151
151
|
|
152
152
|
it "should return dynamic response declared as a block" do
|
153
153
|
stub_request(:post, "www.example.com").to_return do |request|
|
154
|
-
{:
|
154
|
+
{body: request.body}
|
155
155
|
end
|
156
|
-
expect(http_request(:post, "http://www.example.com/", :
|
156
|
+
expect(http_request(:post, "http://www.example.com/", body: "echo").body).to eq("echo")
|
157
157
|
end
|
158
158
|
|
159
159
|
it "should return dynamic response declared as an object responding to call" do
|
160
160
|
stub_request(:post, "www.example.com").to_return(Responder.new)
|
161
|
-
expect(http_request(:post, "http://www.example.com/", :
|
161
|
+
expect(http_request(:post, "http://www.example.com/", body: "echo").body).to eq("echo")
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
@@ -188,7 +188,7 @@ shared_context "declared responses" do |*adapter_info|
|
|
188
188
|
expect(@response.status).to eq("202")
|
189
189
|
end
|
190
190
|
|
191
|
-
it "should return recorded status message", :
|
191
|
+
it "should return recorded status message", unless: (adapter_info.include?(:no_status_message)) do
|
192
192
|
expect(@response.message).to eq("OK")
|
193
193
|
end
|
194
194
|
|
@@ -222,7 +222,7 @@ shared_context "declared responses" do |*adapter_info|
|
|
222
222
|
expect(@response.status).to eq("202")
|
223
223
|
end
|
224
224
|
|
225
|
-
it "should return recorded status message", :
|
225
|
+
it "should return recorded status message", unless: (adapter_info.include?(:no_status_message)) do
|
226
226
|
expect(@response.message).to eq("OK")
|
227
227
|
end
|
228
228
|
end
|
@@ -248,7 +248,7 @@ shared_context "declared responses" do |*adapter_info|
|
|
248
248
|
describe "when response is declared as an Rack app" do
|
249
249
|
it "should return response returned by the rack app" do
|
250
250
|
stub_request(:any, "http://www.example.com/greet").to_rack(MyRackApp)
|
251
|
-
expect(http_request(:post, 'http://www.example.com/greet', :
|
251
|
+
expect(http_request(:post, 'http://www.example.com/greet', body: 'name=Jimmy').body).to eq('Good to meet you, Jimmy!')
|
252
252
|
end
|
253
253
|
|
254
254
|
it "should pass along the port number to the rack app" do
|
@@ -265,28 +265,28 @@ shared_context "declared responses" do |*adapter_info|
|
|
265
265
|
"Content-Type" => "application/json"
|
266
266
|
}
|
267
267
|
|
268
|
-
http_request(:get, url, :
|
269
|
-
expect(WebMock).to have_requested(:get, url).with(:
|
268
|
+
http_request(:get, url, headers: headers)
|
269
|
+
expect(WebMock).to have_requested(:get, url).with(headers: headers)
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
273
273
|
describe "when sequences of responses are declared" do
|
274
274
|
it "should return responses one by one if declared in array" do
|
275
|
-
stub_request(:get, "www.example.com").to_return([ {:
|
275
|
+
stub_request(:get, "www.example.com").to_return([ {body: "1"}, {body: "2"}, {body: "3"} ])
|
276
276
|
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
277
277
|
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
278
278
|
expect(http_request(:get, "http://www.example.com/").body).to eq("3")
|
279
279
|
end
|
280
280
|
|
281
281
|
it "should repeat returning last declared response from a sequence after all responses were returned" do
|
282
|
-
stub_request(:get, "www.example.com").to_return([ {:
|
282
|
+
stub_request(:get, "www.example.com").to_return([ {body: "1"}, {body: "2"} ])
|
283
283
|
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
284
284
|
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
285
285
|
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
286
286
|
end
|
287
287
|
|
288
288
|
it "should return responses one by one if declared as comma separated params" do
|
289
|
-
stub_request(:get, "www.example.com").to_return({:
|
289
|
+
stub_request(:get, "www.example.com").to_return({body: "1"}, {body: "2"}, {body: "3"})
|
290
290
|
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
291
291
|
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
292
292
|
expect(http_request(:get, "http://www.example.com/").body).to eq("3")
|
@@ -294,17 +294,17 @@ shared_context "declared responses" do |*adapter_info|
|
|
294
294
|
|
295
295
|
it "should return responses one by one if declared with several to_return invokations" do
|
296
296
|
stub_request(:get, "www.example.com").
|
297
|
-
to_return({:
|
298
|
-
to_return({:
|
299
|
-
to_return({:
|
297
|
+
to_return({body: "1"}).
|
298
|
+
to_return({body: "2"}).
|
299
|
+
to_return({body: "3"})
|
300
300
|
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
301
301
|
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
302
302
|
expect(http_request(:get, "http://www.example.com/").body).to eq("3")
|
303
303
|
end
|
304
304
|
|
305
305
|
it "should return responses one by one if declared with to_return invocations separated with then syntactic sugar" do
|
306
|
-
stub_request(:get, "www.example.com").to_return({:
|
307
|
-
to_return({:
|
306
|
+
stub_request(:get, "www.example.com").to_return({body: "1"}).then.
|
307
|
+
to_return({body: "2"}).then.to_return({body: "3"})
|
308
308
|
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
309
309
|
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
310
310
|
expect(http_request(:get, "http://www.example.com/").body).to eq("3")
|
@@ -315,8 +315,8 @@ shared_context "declared responses" do |*adapter_info|
|
|
315
315
|
describe "when responses are declared to return more than once" do
|
316
316
|
it "should repeat one response declared number of times" do
|
317
317
|
stub_request(:get, "www.example.com").
|
318
|
-
to_return({:
|
319
|
-
to_return({:
|
318
|
+
to_return({body: "1"}).times(2).
|
319
|
+
to_return({body: "2"})
|
320
320
|
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
321
321
|
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
322
322
|
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
@@ -325,8 +325,8 @@ shared_context "declared responses" do |*adapter_info|
|
|
325
325
|
|
326
326
|
it "should repeat sequence of response declared number of times" do
|
327
327
|
stub_request(:get, "www.example.com").
|
328
|
-
to_return({:
|
329
|
-
to_return({:
|
328
|
+
to_return({body: "1"}, {body: "2"}).times(2).
|
329
|
+
to_return({body: "3"})
|
330
330
|
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
331
331
|
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
332
332
|
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
@@ -337,7 +337,7 @@ shared_context "declared responses" do |*adapter_info|
|
|
337
337
|
|
338
338
|
it "should repeat infinitely last response even if number of declared times is lower" do
|
339
339
|
stub_request(:get, "www.example.com").
|
340
|
-
to_return({:
|
340
|
+
to_return({body: "1"}).times(2)
|
341
341
|
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
342
342
|
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
343
343
|
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
@@ -355,7 +355,7 @@ shared_context "declared responses" do |*adapter_info|
|
|
355
355
|
it "should repeat raising exception declared number of times" do
|
356
356
|
stub_request(:get, "www.example.com").
|
357
357
|
to_raise(MyException).times(2).
|
358
|
-
to_return({:
|
358
|
+
to_return({body: "2"})
|
359
359
|
expect {
|
360
360
|
http_request(:get, "http://www.example.com/")
|
361
361
|
}.to raise_error(MyException, "Exception from WebMock")
|
@@ -368,7 +368,7 @@ shared_context "declared responses" do |*adapter_info|
|
|
368
368
|
it "should repeat raising sequence of exceptions declared number of times" do
|
369
369
|
stub_request(:get, "www.example.com").
|
370
370
|
to_raise(MyException, ArgumentError).times(2).
|
371
|
-
to_return({:
|
371
|
+
to_return({body: "2"})
|
372
372
|
expect {
|
373
373
|
http_request(:get, "http://www.example.com/")
|
374
374
|
}.to raise_error(MyException, "Exception from WebMock")
|
@@ -4,29 +4,29 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
4
4
|
describe "when requests are stubbed" do
|
5
5
|
describe "based on uri" do
|
6
6
|
it "should return stubbed response even if request have escaped parameters" do
|
7
|
-
stub_request(:get, "www.example.com/hello+/?#{NOT_ESCAPED_PARAMS}").to_return(:
|
7
|
+
stub_request(:get, "www.example.com/hello+/?#{NOT_ESCAPED_PARAMS}").to_return(body: "abc")
|
8
8
|
expect(http_request(:get, "http://www.example.com/hello%2B/?#{ESCAPED_PARAMS}").body).to eq("abc")
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should return stubbed response even if query params have integer values" do
|
12
|
-
stub_request(:get, "www.example.com").with(:
|
12
|
+
stub_request(:get, "www.example.com").with(query: {"a" => 1}).to_return(body: "abc")
|
13
13
|
expect(http_request(:get, "http://www.example.com/?a=1").body).to eq("abc")
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should return stubbed response even if request has non escaped params" do
|
17
|
-
stub_request(:get, "www.example.com/hello%2B/?#{ESCAPED_PARAMS}").to_return(:
|
17
|
+
stub_request(:get, "www.example.com/hello%2B/?#{ESCAPED_PARAMS}").to_return(body: "abc")
|
18
18
|
expect(http_request(:get, "http://www.example.com/hello+/?#{NOT_ESCAPED_PARAMS}").body).to eq("abc")
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should return stubbed response for url with non utf query params", "ruby>1.9" => true do
|
22
22
|
param = 'aäoöuü'.encode('iso-8859-1')
|
23
23
|
param = CGI.escape(param)
|
24
|
-
stub_request(:get, "www.example.com/?#{param}").to_return(:
|
24
|
+
stub_request(:get, "www.example.com/?#{param}").to_return(body: "abc")
|
25
25
|
expect(http_request(:get, "http://www.example.com/?#{param}").body).to eq("abc")
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should return stubbed response even if stub uri is declared as regexp and request params are escaped" do
|
29
|
-
stub_request(:get, /.*x=ab c.*/).to_return(:
|
29
|
+
stub_request(:get, /.*x=ab c.*/).to_return(body: "abc")
|
30
30
|
expect(http_request(:get, "http://www.example.com/hello/?#{ESCAPED_PARAMS}").body).to eq("abc")
|
31
31
|
end
|
32
32
|
|
@@ -45,22 +45,22 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
45
45
|
|
46
46
|
describe "based on query params" do
|
47
47
|
it "should return stubbed response when stub declares query params as a hash" do
|
48
|
-
stub_request(:get, "www.example.com").with(:
|
48
|
+
stub_request(:get, "www.example.com").with(query: {"a" => ["b x", "c d"]}).to_return(body: "abc")
|
49
49
|
expect(http_request(:get, "http://www.example.com/?a[]=b+x&a[]=c%20d").body).to eq("abc")
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should return stubbed response when stub declares query params as a hash" do
|
53
|
-
stub_request(:get, "www.example.com").with(:
|
53
|
+
stub_request(:get, "www.example.com").with(query: "a[]=b&a[]=c").to_return(body: "abc")
|
54
54
|
expect(http_request(:get, "http://www.example.com/?a[]=b&a[]=c").body).to eq("abc")
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should return stubbed response when stub declares query params both in uri and as a hash" do
|
58
|
-
stub_request(:get, "www.example.com/?x=3").with(:
|
58
|
+
stub_request(:get, "www.example.com/?x=3").with(query: {"a" => ["b", "c"]}).to_return(body: "abc")
|
59
59
|
expect(http_request(:get, "http://www.example.com/?x=3&a[]=b&a[]=c").body).to eq("abc")
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should return stubbed response when stub expects only part of query params" do
|
63
|
-
stub_request(:get, "www.example.com").with(:
|
63
|
+
stub_request(:get, "www.example.com").with(query: hash_including({"a" => ["b", "c"]})).to_return(body: "abc")
|
64
64
|
expect(http_request(:get, "http://www.example.com/?a[]=b&a[]=c&b=1").body).to eq("abc")
|
65
65
|
end
|
66
66
|
end
|
@@ -88,38 +88,38 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
88
88
|
|
89
89
|
describe "based on body" do
|
90
90
|
it "should match requests if body is the same" do
|
91
|
-
stub_request(:post, "www.example.com").with(:
|
91
|
+
stub_request(:post, "www.example.com").with(body: "abc")
|
92
92
|
expect(http_request(
|
93
93
|
:post, "http://www.example.com/",
|
94
|
-
:
|
94
|
+
body: "abc").status).to eq("200")
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should match requests if body is not set in the stub" do
|
98
98
|
stub_request(:post, "www.example.com")
|
99
99
|
expect(http_request(
|
100
100
|
:post, "http://www.example.com/",
|
101
|
-
:
|
101
|
+
body: "abc").status).to eq("200")
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should not match requests if body is different" do
|
105
|
-
stub_request(:post, "www.example.com").with(:
|
105
|
+
stub_request(:post, "www.example.com").with(body: "abc")
|
106
106
|
expect {
|
107
|
-
http_request(:post, "http://www.example.com/", :
|
107
|
+
http_request(:post, "http://www.example.com/", body: "def")
|
108
108
|
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: POST http://www.example.com/ with body 'def'))
|
109
109
|
end
|
110
110
|
|
111
111
|
describe "with regular expressions" do
|
112
112
|
it "should match requests if body matches regexp" do
|
113
|
-
stub_request(:post, "www.example.com").with(:
|
113
|
+
stub_request(:post, "www.example.com").with(body: /\d+abc$/)
|
114
114
|
expect(http_request(
|
115
115
|
:post, "http://www.example.com/",
|
116
|
-
:
|
116
|
+
body: "123abc").status).to eq("200")
|
117
117
|
end
|
118
118
|
|
119
119
|
it "should not match requests if body doesn't match regexp" do
|
120
|
-
stub_request(:post, "www.example.com").with(:
|
120
|
+
stub_request(:post, "www.example.com").with(body: /^abc/)
|
121
121
|
expect {
|
122
|
-
http_request(:post, "http://www.example.com/", :
|
122
|
+
http_request(:post, "http://www.example.com/", body: "xabc")
|
123
123
|
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: POST http://www.example.com/ with body 'xabc'))
|
124
124
|
end
|
125
125
|
end
|
@@ -127,27 +127,27 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
127
127
|
describe "when body is declared as a hash" do
|
128
128
|
before(:each) do
|
129
129
|
stub_request(:post, "www.example.com").
|
130
|
-
with(:
|
130
|
+
with(body: {:a => '1', :b => 'five x', 'c' => {'d' => ['e', 'f']} })
|
131
131
|
end
|
132
132
|
|
133
133
|
describe "for request with url encoded body" do
|
134
134
|
it "should match request if hash matches body" do
|
135
135
|
expect(http_request(
|
136
136
|
:post, "http://www.example.com/",
|
137
|
-
:
|
137
|
+
body: 'a=1&c[d][]=e&c[d][]=f&b=five+x').status).to eq("200")
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should match request if hash matches body in different order of params" do
|
141
141
|
expect(http_request(
|
142
142
|
:post, "http://www.example.com/",
|
143
|
-
:
|
143
|
+
body: 'a=1&c[d][]=e&b=five+x&c[d][]=f').status).to eq("200")
|
144
144
|
end
|
145
145
|
|
146
146
|
it "should not match if hash doesn't match url encoded body" do
|
147
147
|
expect {
|
148
148
|
http_request(
|
149
149
|
:post, "http://www.example.com/",
|
150
|
-
:
|
150
|
+
body: 'c[d][]=f&a=1&c[d][]=e')
|
151
151
|
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: POST http://www.example.com/ with body 'c\[d\]\[\]=f&a=1&c\[d\]\[\]=e'))
|
152
152
|
end
|
153
153
|
end
|
@@ -156,31 +156,31 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
156
156
|
describe "for request with json body and content type is set to json" do
|
157
157
|
it "should match if hash matches body" do
|
158
158
|
expect(http_request(
|
159
|
-
:post, "http://www.example.com/", :
|
160
|
-
:
|
159
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
160
|
+
body: "{\"a\":\"1\",\"c\":{\"d\":[\"e\",\"f\"]},\"b\":\"five x\"}").status).to eq("200")
|
161
161
|
end
|
162
162
|
|
163
163
|
it "should match if hash matches body in different form" do
|
164
164
|
expect(http_request(
|
165
|
-
:post, "http://www.example.com/", :
|
166
|
-
:
|
165
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
166
|
+
body: "{\"a\":\"1\",\"b\":\"five x\",\"c\":{\"d\":[\"e\",\"f\"]}}").status).to eq("200")
|
167
167
|
end
|
168
168
|
|
169
169
|
it "should match if hash contains date string" do #Crack creates date object
|
170
170
|
WebMock.reset!
|
171
171
|
stub_request(:post, "www.example.com").
|
172
|
-
with(:
|
172
|
+
with(body: {"foo" => "2010-01-01"})
|
173
173
|
expect(http_request(
|
174
|
-
:post, "http://www.example.com/", :
|
175
|
-
:
|
174
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
175
|
+
body: "{\"foo\":\"2010-01-01\"}").status).to eq("200")
|
176
176
|
end
|
177
177
|
|
178
178
|
it "should match if any of the strings have spaces" do
|
179
179
|
WebMock.reset!
|
180
|
-
stub_request(:post, "www.example.com").with(:
|
180
|
+
stub_request(:post, "www.example.com").with(body: {"foo" => "a b c"})
|
181
181
|
expect(http_request(
|
182
|
-
:post, "http://www.example.com/", :
|
183
|
-
:
|
182
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
183
|
+
body: "{\"foo\":\"a b c\"}").status).to eq("200")
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
@@ -188,43 +188,43 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
188
188
|
before(:each) do
|
189
189
|
WebMock.reset!
|
190
190
|
stub_request(:post, "www.example.com").
|
191
|
-
with(:
|
191
|
+
with(body: { "opt" => {:a => '1', :b => 'five', 'c' => {'d' => ['e', 'f']} }})
|
192
192
|
end
|
193
193
|
|
194
194
|
it "should match if hash matches body" do
|
195
195
|
expect(http_request(
|
196
|
-
:post, "http://www.example.com/", :
|
197
|
-
:
|
196
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/xml'},
|
197
|
+
body: "<opt a=\"1\" b=\"five\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n").status).to eq("200")
|
198
198
|
end
|
199
199
|
|
200
200
|
it "should match if hash matches body in different form" do
|
201
201
|
expect(http_request(
|
202
|
-
:post, "http://www.example.com/", :
|
203
|
-
:
|
202
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/xml'},
|
203
|
+
body: "<opt b=\"five\" a=\"1\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n").status).to eq("200")
|
204
204
|
end
|
205
205
|
|
206
206
|
it "should match if hash contains date string" do #Crack creates date object
|
207
207
|
WebMock.reset!
|
208
208
|
stub_request(:post, "www.example.com").
|
209
|
-
with(:
|
209
|
+
with(body: {"opt" => {"foo" => "2010-01-01"}})
|
210
210
|
expect(http_request(
|
211
|
-
:post, "http://www.example.com/", :
|
212
|
-
:
|
211
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/xml'},
|
212
|
+
body: "<opt foo=\"2010-01-01\">\n</opt>\n").status).to eq("200")
|
213
213
|
end
|
214
214
|
end
|
215
215
|
end
|
216
216
|
|
217
217
|
describe "when body is declared as partial hash matcher" do
|
218
218
|
subject(:request) { http_request( :post, "http://www.example.com/",
|
219
|
-
:
|
219
|
+
body: 'a=1&c[d][]=e&c[d][]=f&b=five') }
|
220
220
|
|
221
221
|
subject(:wrong_request) { http_request(:post, "http://www.example.com/",
|
222
|
-
:
|
222
|
+
body: 'c[d][]=f&a=1&c[d][]=e').status }
|
223
223
|
|
224
224
|
describe "when using 'RSpec:Mocks::ArgumentMatchers#hash_including'" do
|
225
225
|
before(:each) do
|
226
226
|
stub_request(:post, "www.example.com").
|
227
|
-
with(:
|
227
|
+
with(body: hash_including(:a, c: {'d' => ['e', 'f']} ))
|
228
228
|
end
|
229
229
|
|
230
230
|
describe "for request with url encoded body" do
|
@@ -240,8 +240,8 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
240
240
|
describe "for request with json body and content type is set to json" do
|
241
241
|
it "should match if hash matches body" do
|
242
242
|
expect(http_request(
|
243
|
-
:post, "http://www.example.com/", :
|
244
|
-
:
|
243
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
244
|
+
body: "{\"a\":\"1\",\"c\":{\"d\":[\"e\",\"f\"]},\"b\":\"five\"}").status).to eq("200")
|
245
245
|
end
|
246
246
|
end
|
247
247
|
end
|
@@ -249,7 +249,7 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
249
249
|
describe "when using 'WebMock::API#hash_including'" do
|
250
250
|
before(:each) do
|
251
251
|
stub_request(:post, "www.example.com").
|
252
|
-
with(:
|
252
|
+
with(body: WebMock::API.hash_including(:a, c: {'d' => ['e', 'f']} ))
|
253
253
|
end
|
254
254
|
|
255
255
|
describe "for request with url encoded body" do
|
@@ -265,8 +265,8 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
265
265
|
describe "for request with json body and content type is set to json" do
|
266
266
|
it "should match if hash matches body" do
|
267
267
|
expect(http_request(
|
268
|
-
:post, "http://www.example.com/", :
|
269
|
-
:
|
268
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
269
|
+
body: "{\"a\":\"1\",\"c\":{\"d\":[\"e\",\"f\"]},\"b\":\"five\"}").status).to eq("200")
|
270
270
|
end
|
271
271
|
end
|
272
272
|
end
|
@@ -276,41 +276,41 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
276
276
|
|
277
277
|
describe "based on headers" do
|
278
278
|
it "should match requests if headers are the same" do
|
279
|
-
stub_request(:get, "www.example.com").with(:
|
279
|
+
stub_request(:get, "www.example.com").with(headers: SAMPLE_HEADERS )
|
280
280
|
expect(http_request(
|
281
281
|
:get, "http://www.example.com/",
|
282
|
-
:
|
282
|
+
headers: SAMPLE_HEADERS).status).to eq("200")
|
283
283
|
end
|
284
284
|
|
285
285
|
it "should match requests if headers are the same and declared as array" do
|
286
|
-
stub_request(:get, "www.example.com").with(:
|
286
|
+
stub_request(:get, "www.example.com").with(headers: {"a" => ["b"]} )
|
287
287
|
expect(http_request(
|
288
288
|
:get, "http://www.example.com/",
|
289
|
-
:
|
289
|
+
headers: {"a" => "b"}).status).to eq("200")
|
290
290
|
end
|
291
291
|
|
292
292
|
describe "when multiple headers with the same key are used" do
|
293
293
|
it "should match requests if headers are the same" do
|
294
|
-
stub_request(:get, "www.example.com").with(:
|
294
|
+
stub_request(:get, "www.example.com").with(headers: {"a" => ["b", "c"]} )
|
295
295
|
expect(http_request(
|
296
296
|
:get, "http://www.example.com/",
|
297
|
-
:
|
297
|
+
headers: {"a" => ["b", "c"]}).status).to eq("200")
|
298
298
|
end
|
299
299
|
|
300
300
|
it "should match requests if headers are the same but in different order" do
|
301
|
-
stub_request(:get, "www.example.com").with(:
|
301
|
+
stub_request(:get, "www.example.com").with(headers: {"a" => ["b", "c"]} )
|
302
302
|
expect(http_request(
|
303
303
|
:get, "http://www.example.com/",
|
304
|
-
:
|
304
|
+
headers: {"a" => ["c", "b"]}).status).to eq("200")
|
305
305
|
end
|
306
306
|
|
307
307
|
it "should not match requests if headers are different" do
|
308
|
-
stub_request(:get, "www.example.com").with(:
|
308
|
+
stub_request(:get, "www.example.com").with(headers: {"a" => ["b", "c"]})
|
309
309
|
|
310
310
|
expect {
|
311
311
|
http_request(
|
312
312
|
:get, "http://www.example.com/",
|
313
|
-
:
|
313
|
+
headers: {"a" => ["b", "d"]})
|
314
314
|
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/ with headers))
|
315
315
|
end
|
316
316
|
end
|
@@ -319,50 +319,50 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
319
319
|
stub_request(:get, "www.example.com")
|
320
320
|
expect(http_request(
|
321
321
|
:get, "http://www.example.com/",
|
322
|
-
:
|
322
|
+
headers: SAMPLE_HEADERS).status).to eq("200")
|
323
323
|
end
|
324
324
|
|
325
325
|
it "should not match requests if headers are different" do
|
326
|
-
stub_request(:get, "www.example.com").with(:
|
326
|
+
stub_request(:get, "www.example.com").with(headers: SAMPLE_HEADERS)
|
327
327
|
|
328
328
|
expect {
|
329
329
|
http_request(
|
330
330
|
:get, "http://www.example.com/",
|
331
|
-
:
|
331
|
+
headers: { 'Content-Length' => '9999'})
|
332
332
|
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/ with headers))
|
333
333
|
end
|
334
334
|
|
335
335
|
it "should not match if accept header is different" do
|
336
336
|
stub_request(:get, "www.example.com").
|
337
|
-
with(:
|
337
|
+
with(headers: { 'Accept' => 'application/json'})
|
338
338
|
expect {
|
339
339
|
http_request(
|
340
340
|
:get, "http://www.example.com/",
|
341
|
-
:
|
341
|
+
headers: { 'Accept' => 'application/xml'})
|
342
342
|
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/ with headers))
|
343
343
|
end
|
344
344
|
|
345
345
|
describe "declared as regular expressions" do
|
346
346
|
it "should match requests if header values match regular expression" do
|
347
|
-
stub_request(:get, "www.example.com").with(:
|
347
|
+
stub_request(:get, "www.example.com").with(headers: { some_header: /^MyAppName$/ })
|
348
348
|
expect(http_request(
|
349
349
|
:get, "http://www.example.com/",
|
350
|
-
:
|
350
|
+
headers: { 'some-header' => 'MyAppName' }).status).to eq("200")
|
351
351
|
end
|
352
352
|
|
353
353
|
it "should not match requests if headers values do not match regular expression" do
|
354
|
-
stub_request(:get, "www.example.com").with(:
|
354
|
+
stub_request(:get, "www.example.com").with(headers: { some_header: /^MyAppName$/ })
|
355
355
|
|
356
356
|
expect {
|
357
357
|
http_request(
|
358
358
|
:get, "http://www.example.com/",
|
359
|
-
:
|
359
|
+
headers: { 'some-header' => 'xMyAppName' })
|
360
360
|
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/ with headers))
|
361
361
|
end
|
362
362
|
end
|
363
363
|
end
|
364
364
|
|
365
|
-
describe "when stubbing request with userinfo in url", :
|
365
|
+
describe "when stubbing request with userinfo in url", unless: (adapter_info.include?(:no_url_auth)) do
|
366
366
|
it "should match if credentials are the same" do
|
367
367
|
stub_request(:get, "user:pass@www.example.com")
|
368
368
|
expect(http_request(:get, "http://user:pass@www.example.com/").status).to eq("200")
|
@@ -437,7 +437,7 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
437
437
|
expect(http_request(:get, "http://www.example.com/", basic_auth: ['user', 'pass']).status).to eq("200")
|
438
438
|
end
|
439
439
|
|
440
|
-
it "should not match if request has credentials provides in userinfo", :
|
440
|
+
it "should not match if request has credentials provides in userinfo", unless: (adapter_info.include?(:no_url_auth)) do
|
441
441
|
stub_request(:get, "www.example.com").with(basic_auth: ['user', 'pass'])
|
442
442
|
expect {
|
443
443
|
expect(http_request(:get, "http://user:pass@www.example.com/").status).to eq("200")
|
@@ -452,7 +452,7 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
452
452
|
|
453
453
|
it 'returns the response returned by the hook' do
|
454
454
|
WebMock.globally_stub_request do |request|
|
455
|
-
{ :
|
455
|
+
{ body: "global stub body" }
|
456
456
|
end
|
457
457
|
|
458
458
|
expect(http_request(:get, "http://www.example.com/").body).to eq("global stub body")
|
@@ -460,7 +460,7 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
460
460
|
|
461
461
|
it 'does not get cleared when a user calls WebMock.reset!' do
|
462
462
|
WebMock.globally_stub_request do |request|
|
463
|
-
{ :
|
463
|
+
{ body: "global stub body" }
|
464
464
|
end
|
465
465
|
WebMock.reset!
|
466
466
|
expect(http_request(:get, "http://www.example.com/").body).to eq("global stub body")
|
@@ -477,7 +477,7 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
477
477
|
passed_request = nil
|
478
478
|
WebMock.globally_stub_request do |request|
|
479
479
|
passed_request = request
|
480
|
-
{ :
|
480
|
+
{ body: "global stub body" }
|
481
481
|
end
|
482
482
|
|
483
483
|
http_request(:get, "http://www.example.com:456/bar")
|
@@ -488,7 +488,7 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
488
488
|
call_count = 0
|
489
489
|
WebMock.globally_stub_request do |request|
|
490
490
|
call_count += 1
|
491
|
-
{ :
|
491
|
+
{ body: "global stub body" }
|
492
492
|
end
|
493
493
|
http_request(:get, "http://www.example.com/")
|
494
494
|
expect(call_count).to eq(1)
|
@@ -503,7 +503,7 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
503
503
|
|
504
504
|
WebMock.globally_stub_request do |request|
|
505
505
|
stub_invocation_order << :hash_stub
|
506
|
-
{ :
|
506
|
+
{ body: "global stub body" }
|
507
507
|
end
|
508
508
|
|
509
509
|
expect(http_request(:get, "http://www.example.com/").body).to eq("global stub body")
|
@@ -513,7 +513,7 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
513
513
|
[:before, :after].each do |before_or_after|
|
514
514
|
context "when there is also a non-global registered stub #{before_or_after} the global stub" do
|
515
515
|
def stub_non_globally
|
516
|
-
stub_request(:get, "www.example.com").to_return(:
|
516
|
+
stub_request(:get, "www.example.com").to_return(body: 'non-global stub body')
|
517
517
|
end
|
518
518
|
|
519
519
|
define_method :register_stubs do |block|
|
@@ -523,7 +523,7 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
523
523
|
end
|
524
524
|
|
525
525
|
it 'uses the response from the global stub if the block returns a non-nil value' do
|
526
|
-
register_stubs(lambda { |req| { :
|
526
|
+
register_stubs(lambda { |req| { body: 'global stub body' } })
|
527
527
|
expect(http_request(:get, "http://www.example.com/").body).to eq("global stub body")
|
528
528
|
end
|
529
529
|
|
@@ -552,9 +552,9 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
552
552
|
stub_request(:post, "www.example.com").with { |request| request.body == "wadus" }
|
553
553
|
expect(http_request(
|
554
554
|
:post, "http://www.example.com/",
|
555
|
-
:
|
555
|
+
body: "wadus").status).to eq("200")
|
556
556
|
expect {
|
557
|
-
http_request(:post, "http://www.example.com/", :
|
557
|
+
http_request(:post, "http://www.example.com/", body: "jander")
|
558
558
|
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: POST http://www.example.com/ with body 'jander'))
|
559
559
|
end
|
560
560
|
|