webmock 1.20.3 → 1.20.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/CHANGELOG.md +4 -0
  2. data/README.md +21 -22
  3. data/lib/webmock/matchers/hash_including_matcher.rb +1 -1
  4. data/lib/webmock/version.rb +1 -1
  5. data/spec/acceptance/curb/curb_spec.rb +36 -36
  6. data/spec/acceptance/em_http_request/em_http_request_spec.rb +24 -24
  7. data/spec/acceptance/excon/excon_spec.rb +11 -11
  8. data/spec/acceptance/httpclient/httpclient_spec.rb +9 -9
  9. data/spec/acceptance/net_http/net_http_shared.rb +23 -23
  10. data/spec/acceptance/net_http/net_http_spec.rb +29 -29
  11. data/spec/acceptance/patron/patron_spec.rb +11 -11
  12. data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +29 -29
  13. data/spec/acceptance/shared/callbacks.rb +18 -18
  14. data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +3 -3
  15. data/spec/acceptance/shared/enabling_and_disabling_webmock.rb +10 -10
  16. data/spec/acceptance/shared/precedence_of_stubs.rb +2 -2
  17. data/spec/acceptance/shared/request_expectations.rb +302 -302
  18. data/spec/acceptance/shared/returning_declared_responses.rb +92 -92
  19. data/spec/acceptance/shared/stubbing_requests.rb +103 -103
  20. data/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +8 -8
  21. data/spec/quality_spec.rb +3 -3
  22. data/spec/spec_helper.rb +0 -6
  23. data/spec/unit/errors_spec.rb +16 -16
  24. data/spec/unit/http_lib_adapters/http_lib_adapter_registry_spec.rb +1 -1
  25. data/spec/unit/http_lib_adapters/http_lib_adapter_spec.rb +2 -2
  26. data/spec/unit/rack_response_spec.rb +14 -14
  27. data/spec/unit/request_execution_verifier_spec.rb +31 -31
  28. data/spec/unit/request_pattern_spec.rb +202 -197
  29. data/spec/unit/request_registry_spec.rb +10 -9
  30. data/spec/unit/request_signature_spec.rb +21 -20
  31. data/spec/unit/request_stub_spec.rb +54 -53
  32. data/spec/unit/response_spec.rb +44 -44
  33. data/spec/unit/stub_registry_spec.rb +15 -15
  34. data/spec/unit/stub_request_snippet_spec.rb +8 -8
  35. data/spec/unit/util/hash_counter_spec.rb +6 -6
  36. data/spec/unit/util/hash_keys_stringifier_spec.rb +1 -1
  37. data/spec/unit/util/headers_spec.rb +4 -4
  38. data/spec/unit/util/json_spec.rb +1 -1
  39. data/spec/unit/util/uri_spec.rb +30 -30
  40. data/spec/unit/util/version_checker_spec.rb +9 -9
  41. data/spec/unit/webmock_spec.rb +1 -1
  42. data/webmock.gemspec +1 -1
  43. metadata +10 -9
@@ -8,92 +8,92 @@ shared_context "request expectations" do |*adapter_info|
8
8
  end
9
9
 
10
10
  it "should satisfy expectation if request was executed with the same uri and method" do
11
- lambda {
11
+ expect {
12
12
  http_request(:get, "http://www.example.com/")
13
- a_request(:get, "http://www.example.com").should have_been_made.once
14
- }.should_not raise_error
13
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.once
14
+ }.not_to raise_error
15
15
  end
16
16
 
17
17
  it "should satisfy expectation declared on WebMock.resuest" do
18
- lambda {
18
+ expect {
19
19
  http_request(:get, "http://www.example.com/")
20
- WebMock.request(:get, "http://www.example.com").should have_been_made.once
21
- }.should_not raise_error
20
+ expect(WebMock.request(:get, "http://www.example.com")).to have_been_made.once
21
+ }.not_to raise_error
22
22
  end
23
23
 
24
24
  it "should satisfy expectation if request was not expected and not executed" do
25
- lambda {
26
- a_request(:get, "http://www.example.com").should_not have_been_made
27
- }.should_not raise_error
25
+ expect {
26
+ expect(a_request(:get, "http://www.example.com")).not_to have_been_made
27
+ }.not_to raise_error
28
28
  end
29
29
 
30
30
  it "should fail if request was not expected but executed" do
31
- lambda {
31
+ expect {
32
32
  http_request(:get, "http://www.example.com/")
33
- a_request(:get, "http://www.example.com").should_not have_been_made
34
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute 0 times but it executed 1 time))
33
+ expect(a_request(:get, "http://www.example.com")).not_to have_been_made
34
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 0 times but it executed 1 time))
35
35
  end
36
36
 
37
37
  it "should fail resulting with failure with a message and executed requests listed" do
38
- lambda {
38
+ expect {
39
39
  http_request(:get, "http://www.example.com/")
40
- a_request(:get, "http://www.example.com").should_not have_been_made
41
- }.should fail_with(%r{The following requests were made:\n\nGET http://www.example.com/.+was made 1 time})
40
+ expect(a_request(:get, "http://www.example.com")).not_to have_been_made
41
+ }.to fail_with(%r{The following requests were made:\n\nGET http://www.example.com/.+was made 1 time})
42
42
  end
43
43
 
44
44
  it "should fail if request was not executed" do
45
- lambda {
46
- a_request(:get, "http://www.example.com").should have_been_made
47
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute 1 time but it executed 0 times))
45
+ expect {
46
+ expect(a_request(:get, "http://www.example.com")).to have_been_made
47
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 1 time but it executed 0 times))
48
48
  end
49
49
 
50
50
  it "should fail if request was executed to different uri" do
51
- lambda {
51
+ expect {
52
52
  http_request(:get, "http://www.example.com/")
53
- a_request(:get, "http://www.example.org").should have_been_made
54
- }.should fail_with(%r(The request GET http://www.example.org/ was expected to execute 1 time but it executed 0 times))
53
+ expect(a_request(:get, "http://www.example.org")).to have_been_made
54
+ }.to fail_with(%r(The request GET http://www.example.org/ was expected to execute 1 time but it executed 0 times))
55
55
  end
56
56
 
57
57
  it "should fail if request was executed with different method" do
58
- lambda {
58
+ expect {
59
59
  http_request(:post, "http://www.example.com/", :body => "abc")
60
- a_request(:get, "http://www.example.com").should have_been_made
61
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute 1 time but it executed 0 times))
60
+ expect(a_request(:get, "http://www.example.com")).to have_been_made
61
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 1 time but it executed 0 times))
62
62
  end
63
63
 
64
64
  it "should satisfy expectation if request was executed with different form of uri" do
65
- lambda {
65
+ expect {
66
66
  http_request(:get, "http://www.example.com/")
67
- a_request(:get, "www.example.com").should have_been_made
68
- }.should_not raise_error
67
+ expect(a_request(:get, "www.example.com")).to have_been_made
68
+ }.not_to raise_error
69
69
  end
70
70
 
71
71
  it "should satisfy expectation if request was executed with different form of uri without port " do
72
- lambda {
72
+ expect {
73
73
  http_request(:get, "http://www.example.com/")
74
- a_request(:get, "www.example.com:80").should have_been_made
75
- }.should_not raise_error
74
+ expect(a_request(:get, "www.example.com:80")).to have_been_made
75
+ }.not_to raise_error
76
76
  end
77
77
 
78
78
  it "should satisfy expectation if request was executed with different form of uri with port" do
79
- lambda {
79
+ expect {
80
80
  http_request(:get, "http://www.example.com/")
81
- a_request(:get, "www.example.com:80").should have_been_made
82
- }.should_not raise_error
81
+ expect(a_request(:get, "www.example.com:80")).to have_been_made
82
+ }.not_to raise_error
83
83
  end
84
84
 
85
85
  it "should fail if request was executed to a different port" do
86
- lambda {
86
+ expect {
87
87
  http_request(:get, "http://www.example.com:80/")
88
- a_request(:get, "www.example.com:90").should have_been_made
89
- }.should fail_with(%r(The request GET http://www.example.com:90/ was expected to execute 1 time but it executed 0 times))
88
+ expect(a_request(:get, "www.example.com:90")).to have_been_made
89
+ }.to fail_with(%r(The request GET http://www.example.com:90/ was expected to execute 1 time but it executed 0 times))
90
90
  end
91
91
 
92
92
  it "should satisfy expectation if request was executed with different form of uri with https port" do
93
- lambda {
93
+ expect {
94
94
  http_request(:get, "https://www.example.com/")
95
- a_request(:get, "https://www.example.com:443/").should have_been_made
96
- }.should_not raise_error
95
+ expect(a_request(:get, "https://www.example.com:443/")).to have_been_made
96
+ }.not_to raise_error
97
97
  end
98
98
 
99
99
  describe "when matching requests with escaped or unescaped uris" do
@@ -103,24 +103,24 @@ shared_context "request expectations" do |*adapter_info|
103
103
  end
104
104
 
105
105
  it "should satisfy expectation if request was executed with escaped params" do
106
- lambda {
106
+ expect {
107
107
  http_request(:get, "http://www.example.com/?#{ESCAPED_PARAMS}")
108
- a_request(:get, "http://www.example.com/?#{NOT_ESCAPED_PARAMS}").should have_been_made
109
- }.should_not raise_error
108
+ expect(a_request(:get, "http://www.example.com/?#{NOT_ESCAPED_PARAMS}")).to have_been_made
109
+ }.not_to raise_error
110
110
  end
111
111
 
112
112
  it "should satisfy expectation if request was executed with non escaped params" do
113
- lambda {
113
+ expect {
114
114
  http_request(:get, "http://www.example.com/?#{NOT_ESCAPED_PARAMS}")
115
- a_request(:get, "http://www.example.com/?#{ESCAPED_PARAMS}").should have_been_made
116
- }.should_not raise_error
115
+ expect(a_request(:get, "http://www.example.com/?#{ESCAPED_PARAMS}")).to have_been_made
116
+ }.not_to raise_error
117
117
  end
118
118
 
119
119
  it "should satisfy expectation if request was executed with escaped params and uri matching regexp was expected" do
120
- lambda {
120
+ expect {
121
121
  http_request(:get, "http://www.example.com/?#{ESCAPED_PARAMS}")
122
- a_request(:get, /.*example.*/).should have_been_made
123
- }.should_not raise_error
122
+ expect(a_request(:get, /.*example.*/)).to have_been_made
123
+ }.not_to raise_error
124
124
  end
125
125
 
126
126
  end
@@ -131,31 +131,31 @@ shared_context "request expectations" do |*adapter_info|
131
131
  end
132
132
 
133
133
  it "should satisfy expectation if the request was executed with query params declared as a hash in a query option" do
134
- lambda {
134
+ expect {
135
135
  http_request(:get, "http://www.example.com/?a[]=b&a[]=c")
136
- a_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]}).should have_been_made
137
- }.should_not raise_error
136
+ expect(a_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})).to have_been_made
137
+ }.not_to raise_error
138
138
  end
139
139
 
140
140
  it "should satisfy expectation if the request was executed with query params declared as string in query option" do
141
- lambda {
141
+ expect {
142
142
  http_request(:get, "http://www.example.com/?a[]=b&a[]=c")
143
- a_request(:get, "www.example.com").with(:query => "a[]=b&a[]=c").should have_been_made
144
- }.should_not raise_error
143
+ expect(a_request(:get, "www.example.com").with(:query => "a[]=b&a[]=c")).to have_been_made
144
+ }.not_to raise_error
145
145
  end
146
146
 
147
147
  it "should satisfy expectation if the request was executed with query params both in uri and in query option" do
148
- lambda {
148
+ expect {
149
149
  http_request(:get, "http://www.example.com/?x=3&a[]=b&a[]=c")
150
- a_request(:get, "www.example.com/?x=3").with(:query => {"a" => ["b", "c"]}).should have_been_made
151
- }.should_not raise_error
150
+ expect(a_request(:get, "www.example.com/?x=3").with(:query => {"a" => ["b", "c"]})).to have_been_made
151
+ }.not_to raise_error
152
152
  end
153
153
 
154
154
  it "should satisfy expectation if the request was executed with only part query params declared as a hash in a query option" do
155
- lambda {
155
+ expect {
156
156
  http_request(:get, "http://www.example.com/?a[]=b&a[]=c&b=1")
157
- a_request(:get, "www.example.com").with(:query => hash_including({"a" => ["b", "c"]})).should have_been_made
158
- }.should_not raise_error
157
+ expect(a_request(:get, "www.example.com").with(:query => hash_including({"a" => ["b", "c"]}))).to have_been_made
158
+ }.not_to raise_error
159
159
  end
160
160
  end
161
161
 
@@ -165,11 +165,11 @@ shared_context "request expectations" do |*adapter_info|
165
165
  end
166
166
 
167
167
  it "should satisfy expectation if request includes different repeated query params in flat array notation" do
168
- lambda {
168
+ expect {
169
169
  stub_request(:get, "http://www.example.com/?a=1&a=2")
170
170
  http_request(:get, "http://www.example.com/?a=1&a=2")
171
- a_request(:get, "http://www.example.com/?a=1&a=2").should have_been_made
172
- }.should_not raise_error
171
+ expect(a_request(:get, "http://www.example.com/?a=1&a=2")).to have_been_made
172
+ }.not_to raise_error
173
173
  end
174
174
 
175
175
  after :all do
@@ -181,115 +181,115 @@ shared_context "request expectations" do |*adapter_info|
181
181
 
182
182
  describe "at_most_times" do
183
183
  it "fails if request was made more times than maximum" do
184
- lambda {
184
+ expect {
185
185
  http_request(:get, "http://www.example.com/")
186
186
  http_request(:get, "http://www.example.com/")
187
187
  http_request(:get, "http://www.example.com/")
188
- a_request(:get, "http://www.example.com").should have_been_made.at_most_times(2)
189
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute at most 2 times but it executed 3 times))
188
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_times(2)
189
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute at most 2 times but it executed 3 times))
190
190
  end
191
191
 
192
192
  it "passes if request was made the maximum number of times" do
193
- lambda {
193
+ expect {
194
194
  http_request(:get, "http://www.example.com/")
195
195
  http_request(:get, "http://www.example.com/")
196
- a_request(:get, "http://www.example.com").should have_been_made.at_most_times(2)
197
- }.should_not raise_error
196
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_times(2)
197
+ }.not_to raise_error
198
198
  end
199
199
 
200
200
  it "passes if request was made fewer than the maximum number of times" do
201
- lambda {
201
+ expect {
202
202
  http_request(:get, "http://www.example.com/")
203
- a_request(:get, "http://www.example.com").should have_been_made.at_most_times(2)
204
- }.should_not raise_error
203
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_times(2)
204
+ }.not_to raise_error
205
205
  end
206
206
 
207
207
  it "passes if request was not made at all" do
208
- lambda {
209
- a_request(:get, "http://www.example.com").should have_been_made.at_most_times(2)
210
- }.should_not raise_error
208
+ expect {
209
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_times(2)
210
+ }.not_to raise_error
211
211
  end
212
212
  end
213
213
 
214
214
 
215
215
  describe "at_least_times" do
216
216
  it "fails if request was made fewer times than minimum" do
217
- lambda {
217
+ expect {
218
218
  http_request(:get, "http://www.example.com/")
219
- a_request(:get, "http://www.example.com").should have_been_made.at_least_times(2)
220
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute at least 2 times but it executed 1 time))
219
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_times(2)
220
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute at least 2 times but it executed 1 time))
221
221
  end
222
222
 
223
223
  it "passes if request was made the minimum number of times" do
224
- lambda {
224
+ expect {
225
225
  http_request(:get, "http://www.example.com/")
226
226
  http_request(:get, "http://www.example.com/")
227
- a_request(:get, "http://www.example.com").should have_been_made.at_least_times(2)
228
- }.should_not raise_error
227
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_times(2)
228
+ }.not_to raise_error
229
229
  end
230
230
 
231
231
  it "passes if request was made more than the minimum number of times" do
232
- lambda {
232
+ expect {
233
233
  http_request(:get, "http://www.example.com/")
234
234
  http_request(:get, "http://www.example.com/")
235
235
  http_request(:get, "http://www.example.com/")
236
- a_request(:get, "http://www.example.com").should have_been_made.at_least_times(2)
237
- }.should_not raise_error
236
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_times(2)
237
+ }.not_to raise_error
238
238
  end
239
239
 
240
240
  context "descriptive at_most_ matcher" do
241
241
  context "at_most_once" do
242
242
  it "succeeds if no request was executed" do
243
- lambda {
244
- a_request(:get, "http://www.example.com").should have_been_made.at_most_once
245
- }.should_not raise_error
243
+ expect {
244
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_once
245
+ }.not_to raise_error
246
246
  end
247
247
 
248
248
  it "satisfies expectation if request was executed with the same uri and method once" do
249
- lambda {
249
+ expect {
250
250
  http_request(:get, "http://www.example.com/")
251
- a_request(:get, "http://www.example.com").should have_been_made.at_most_once
252
- }.should_not raise_error
251
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_once
252
+ }.not_to raise_error
253
253
  end
254
254
 
255
255
  it "fails if request was executed with the same uri and method twice" do
256
- lambda {
256
+ expect {
257
257
  http_request(:get, "http://www.example.com/")
258
258
  http_request(:get, "http://www.example.com/")
259
- a_request(:get, "http://www.example.com").should have_been_made.at_most_once
260
- }.should raise_error
259
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_once
260
+ }.to raise_error
261
261
  end
262
262
  end
263
263
 
264
264
  context "at_most_twice" do
265
265
  it "succeeds if no request was executed" do
266
- lambda {
267
- a_request(:get, "http://www.example.com").should have_been_made.at_most_twice
268
- }.should_not raise_error
266
+ expect {
267
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_twice
268
+ }.not_to raise_error
269
269
  end
270
270
 
271
271
  it "succeeds if too few requests were executed" do
272
- lambda {
272
+ expect {
273
273
  http_request(:get, "http://www.example.com/")
274
- a_request(:get, "http://www.example.com").should have_been_made.at_most_twice
275
- }.should_not raise_error
274
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_twice
275
+ }.not_to raise_error
276
276
  end
277
277
 
278
278
  it "satisfies expectation if request was executed with the same uri and method twice" do
279
- lambda {
279
+ expect {
280
280
  http_request(:get, "http://www.example.com/")
281
281
  http_request(:get, "http://www.example.com/")
282
- a_request(:get, "http://www.example.com").should have_been_made.at_most_twice
283
- }.should_not raise_error
282
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_twice
283
+ }.not_to raise_error
284
284
  end
285
285
 
286
286
  it "fails if request was executed with the same uri and method three times" do
287
- lambda {
287
+ expect {
288
288
  http_request(:get, "http://www.example.com/")
289
289
  http_request(:get, "http://www.example.com/")
290
290
  http_request(:get, "http://www.example.com/")
291
- a_request(:get, "http://www.example.com").should have_been_made.at_most_twice
292
- }.should raise_error
291
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_twice
292
+ }.to raise_error
293
293
  end
294
294
  end
295
295
  end
@@ -297,112 +297,112 @@ shared_context "request expectations" do |*adapter_info|
297
297
  context "descriptive at_least_ matcher" do
298
298
  context "at_least_once" do
299
299
  it "fails if no request was executed" do
300
- lambda {
301
- a_request(:get, "http://www.example.com").should have_been_made.at_least_once
302
- }.should raise_error
300
+ expect {
301
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_once
302
+ }.to raise_error
303
303
  end
304
304
 
305
305
  it "satisfies expectation if request was executed with the same uri and method once" do
306
- lambda {
306
+ expect {
307
307
  http_request(:get, "http://www.example.com/")
308
- a_request(:get, "http://www.example.com").should have_been_made.at_least_once
309
- }.should_not raise_error
308
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_once
309
+ }.not_to raise_error
310
310
  end
311
311
 
312
312
  it "satisfies expectation if request was executed with the same uri and method twice" do
313
- lambda {
313
+ expect {
314
314
  http_request(:get, "http://www.example.com/")
315
315
  http_request(:get, "http://www.example.com/")
316
- a_request(:get, "http://www.example.com").should have_been_made.at_least_once
317
- }.should_not raise_error
316
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_once
317
+ }.not_to raise_error
318
318
  end
319
319
  end
320
320
 
321
321
  context "at_least_twice" do
322
322
  it "fails if no request was executed" do
323
- lambda {
324
- a_request(:get, "http://www.example.com").should have_been_made.at_least_twice
325
- }.should raise_error
323
+ expect {
324
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_twice
325
+ }.to raise_error
326
326
  end
327
327
 
328
328
  it "fails if too few requests were executed" do
329
- lambda {
329
+ expect {
330
330
  http_request(:get, "http://www.example.com/")
331
- a_request(:get, "http://www.example.com").should have_been_made.at_least_twice
332
- }.should raise_error
331
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_twice
332
+ }.to raise_error
333
333
  end
334
334
 
335
335
  it "satisfies expectation if request was executed with the same uri and method twice" do
336
- lambda {
336
+ expect {
337
337
  http_request(:get, "http://www.example.com/")
338
338
  http_request(:get, "http://www.example.com/")
339
- a_request(:get, "http://www.example.com").should have_been_made.at_least_twice
340
- }.should_not raise_error
339
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_twice
340
+ }.not_to raise_error
341
341
  end
342
342
 
343
343
  it "satisfies expectation if request was executed with the same uri and method three times" do
344
- lambda {
344
+ expect {
345
345
  http_request(:get, "http://www.example.com/")
346
346
  http_request(:get, "http://www.example.com/")
347
347
  http_request(:get, "http://www.example.com/")
348
- a_request(:get, "http://www.example.com").should have_been_made.at_least_twice
349
- }.should_not raise_error
348
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_twice
349
+ }.not_to raise_error
350
350
  end
351
351
  end
352
352
  end
353
353
  end
354
354
 
355
355
  it "should fail if request was made more times than expected" do
356
- lambda {
356
+ expect {
357
357
  http_request(:get, "http://www.example.com/")
358
358
  http_request(:get, "http://www.example.com/")
359
- a_request(:get, "http://www.example.com").should have_been_made
360
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute 1 time but it executed 2 times))
359
+ expect(a_request(:get, "http://www.example.com")).to have_been_made
360
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 1 time but it executed 2 times))
361
361
  end
362
362
 
363
363
  it "should fail if request was made less times than expected" do
364
- lambda {
364
+ expect {
365
365
  http_request(:get, "http://www.example.com/")
366
- a_request(:get, "http://www.example.com").should have_been_made.twice
367
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute 2 times but it executed 1 time))
366
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.twice
367
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 2 times but it executed 1 time))
368
368
  end
369
369
 
370
370
  it "should fail if request was made less times than expected when 3 times expected" do
371
- lambda {
371
+ expect {
372
372
  http_request(:get, "http://www.example.com/")
373
- a_request(:get, "http://www.example.com").should have_been_made.times(3)
374
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute 3 times but it executed 1 time))
373
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.times(3)
374
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 3 times but it executed 1 time))
375
375
  end
376
376
 
377
377
  it "should satisfy expectation if request was executed with the same body" do
378
- lambda {
378
+ expect {
379
379
  http_request(:post, "http://www.example.com/", :body => "abc")
380
- a_request(:post, "www.example.com").with(:body => "abc").should have_been_made
381
- }.should_not raise_error
380
+ expect(a_request(:post, "www.example.com").with(:body => "abc")).to have_been_made
381
+ }.not_to raise_error
382
382
  end
383
383
 
384
384
  it "should fail if request was executed with different body" do
385
- lambda {
385
+ expect {
386
386
  http_request(:post, "http://www.example.com/", :body => "abc")
387
- a_request(:post, "www.example.com").
388
- with(:body => "def").should have_been_made
389
- }.should fail_with(%r(The request POST http://www.example.com/ with body "def" was expected to execute 1 time but it executed 0 times))
387
+ expect(a_request(:post, "www.example.com").
388
+ with(:body => "def")).to have_been_made
389
+ }.to fail_with(%r(The request POST http://www.example.com/ with body "def" was expected to execute 1 time but it executed 0 times))
390
390
  end
391
391
 
392
392
  describe "when expected request body is declared as a regexp" do
393
393
  it "should satisfy expectation if request was executed with body matching regexp" do
394
- lambda {
394
+ expect {
395
395
  http_request(:post, "http://www.example.com/", :body => "abc")
396
- a_request(:post, "www.example.com").with(:body => /^abc$/).should have_been_made
397
- }.should_not raise_error
396
+ expect(a_request(:post, "www.example.com").with(:body => /^abc$/)).to have_been_made
397
+ }.not_to raise_error
398
398
  end
399
399
 
400
400
  it "should fail if request was executed with body not matching regexp" do
401
- lambda {
401
+ expect {
402
402
  http_request(:post, "http://www.example.com/", :body => "abc")
403
- a_request(:post, "www.example.com").
404
- with(:body => /^xabc/).should have_been_made
405
- }.should fail_with(%r(The request POST http://www.example.com/ with body /\^xabc/ was expected to execute 1 time but it executed 0 times))
403
+ expect(a_request(:post, "www.example.com").
404
+ with(:body => /^xabc/)).to have_been_made
405
+ }.to fail_with(%r(The request POST http://www.example.com/ with body /\^xabc/ was expected to execute 1 time but it executed 0 times))
406
406
  end
407
407
 
408
408
  end
@@ -413,50 +413,50 @@ shared_context "request expectations" do |*adapter_info|
413
413
 
414
414
  describe "when request is made with url encoded body matching hash" do
415
415
  it "should satisfy expectation" do
416
- lambda {
416
+ expect {
417
417
  http_request(:post, "http://www.example.com/", :body => 'a=1&c[d][]=e&c[d][]=f&b=five')
418
- a_request(:post, "www.example.com").with(:body => body_hash).should have_been_made
419
- }.should_not raise_error
418
+ expect(a_request(:post, "www.example.com").with(:body => body_hash)).to have_been_made
419
+ }.not_to raise_error
420
420
  end
421
421
 
422
422
  it "should satisfy expectation even if url encoded params have different order" do
423
- lambda {
423
+ expect {
424
424
  http_request(:post, "http://www.example.com/", :body => 'a=1&c[d][]=e&b=five&c[d][]=f')
425
- a_request(:post, "www.example.com").with(:body => body_hash).should have_been_made
426
- }.should_not raise_error
425
+ expect(a_request(:post, "www.example.com").with(:body => body_hash)).to have_been_made
426
+ }.not_to raise_error
427
427
  end
428
428
 
429
429
  it "should fail if request is executed with url encoded body not matching hash" do
430
- lambda {
430
+ expect {
431
431
  http_request(:post, "http://www.example.com/", :body => 'c[d][]=f&a=1&c[d][]=e')
432
- a_request(:post, "www.example.com").with(:body => body_hash).should have_been_made
433
- }.should fail_with(fail_message)
432
+ expect(a_request(:post, "www.example.com").with(:body => body_hash)).to have_been_made
433
+ }.to fail_with(fail_message)
434
434
  end
435
435
  end
436
436
 
437
437
  describe "when request is executed with json body matching hash and Content-Type is set to json" do
438
438
  it "should satisfy expectation" do
439
- lambda {
439
+ expect {
440
440
  http_request(:post, "http://www.example.com/", :headers => {'Content-Type' => 'application/json'},
441
441
  :body => "{\"a\":\"1\",\"c\":{\"d\":[\"e\",\"f\"]},\"b\":\"five\"}")
442
- a_request(:post, "www.example.com").with(:body => body_hash).should have_been_made
443
- }.should_not raise_error
442
+ expect(a_request(:post, "www.example.com").with(:body => body_hash)).to have_been_made
443
+ }.not_to raise_error
444
444
  end
445
445
 
446
446
  it "should satisfy expectation even if json body is in different form" do
447
- lambda {
447
+ expect {
448
448
  http_request(:post, "http://www.example.com/", :headers => {'Content-Type' => 'application/json'},
449
449
  :body => "{\"a\":\"1\",\"b\":\"five\",\"c\":{\"d\":[\"e\",\"f\"]}}")
450
- a_request(:post, "www.example.com").with(:body => body_hash).should have_been_made
451
- }.should_not raise_error
450
+ expect(a_request(:post, "www.example.com").with(:body => body_hash)).to have_been_made
451
+ }.not_to raise_error
452
452
  end
453
453
 
454
454
  it "should satisfy expectation even if json body contains date string" do
455
- lambda {
455
+ expect {
456
456
  http_request(:post, "http://www.example.com/", :headers => {'Content-Type' => 'application/json'},
457
457
  :body => "{\"foo\":\"2010-01-01\"}")
458
- a_request(:post, "www.example.com").with(:body => {"foo" => "2010-01-01"}).should have_been_made
459
- }.should_not raise_error
458
+ expect(a_request(:post, "www.example.com").with(:body => {"foo" => "2010-01-01"})).to have_been_made
459
+ }.not_to raise_error
460
460
  end
461
461
  end
462
462
 
@@ -465,27 +465,27 @@ shared_context "request expectations" do |*adapter_info|
465
465
  let(:body_hash) { { "opt" => {:a => "1", :b => 'five', 'c' => {'d' => ['e', 'f']}} }}
466
466
 
467
467
  it "should satisfy expectation" do
468
- lambda {
468
+ expect {
469
469
  http_request(:post, "http://www.example.com/", :headers => {'Content-Type' => 'application/xml'},
470
470
  :body => "<opt a=\"1\" b=\"five\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n")
471
- a_request(:post, "www.example.com").with(:body => body_hash).should have_been_made
472
- }.should_not raise_error
471
+ expect(a_request(:post, "www.example.com").with(:body => body_hash)).to have_been_made
472
+ }.not_to raise_error
473
473
  end
474
474
 
475
475
  it "should satisfy expectation even if xml body is in different form" do
476
- lambda {
476
+ expect {
477
477
  http_request(:post, "http://www.example.com/", :headers => {'Content-Type' => 'application/xml'},
478
478
  :body => "<opt b=\"five\" a=\"1\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n")
479
- a_request(:post, "www.example.com").with(:body => body_hash).should have_been_made
480
- }.should_not raise_error
479
+ expect(a_request(:post, "www.example.com").with(:body => body_hash)).to have_been_made
480
+ }.not_to raise_error
481
481
  end
482
482
 
483
483
  it "should satisfy expectation even if xml body contains date string" do
484
- lambda {
484
+ expect {
485
485
  http_request(:post, "http://www.example.com/", :headers => {'Content-Type' => 'application/xml'},
486
486
  :body => "<opt foo=\"2010-01-01\">\n</opt>\n")
487
- a_request(:post, "www.example.com").with(:body => {"opt" => {"foo" => "2010-01-01"}}).should have_been_made
488
- }.should_not raise_error
487
+ expect(a_request(:post, "www.example.com").with(:body => {"opt" => {"foo" => "2010-01-01"}})).to have_been_made
488
+ }.not_to raise_error
489
489
  end
490
490
  end
491
491
  end
@@ -496,137 +496,137 @@ shared_context "request expectations" do |*adapter_info|
496
496
 
497
497
  describe "when request is made with url encoded body matching hash" do
498
498
  it "should satisfy expectation" do
499
- lambda {
499
+ expect {
500
500
  http_request(:post, "http://www.example.com/", :body => 'a=1&c[d][]=e&c[d][]=f&b=five')
501
- a_request(:post, "www.example.com").with(:body => body_hash).should have_been_made
502
- }.should_not raise_error
501
+ expect(a_request(:post, "www.example.com").with(:body => body_hash)).to have_been_made
502
+ }.not_to raise_error
503
503
  end
504
504
 
505
505
  it "should fail if request is executed with url encoded body not matching hash" do
506
- lambda {
506
+ expect {
507
507
  http_request(:post, "http://www.example.com/", :body => 'c[d][]=f&a=1&c[d][]=e')
508
- a_request(:post, "www.example.com").with(:body => body_hash).should have_been_made
509
- }.should fail_with(fail_message)
508
+ expect(a_request(:post, "www.example.com").with(:body => body_hash)).to have_been_made
509
+ }.to fail_with(fail_message)
510
510
  end
511
511
  end
512
512
  end
513
513
 
514
514
  describe "when request with headers is expected" do
515
515
  it "should satisfy expectation if request was executed with the same headers" do
516
- lambda {
516
+ expect {
517
517
  http_request(:get, "http://www.example.com/", :headers => SAMPLE_HEADERS)
518
- a_request(:get, "www.example.com").
519
- with(:headers => SAMPLE_HEADERS).should have_been_made
520
- }.should_not raise_error
518
+ expect(a_request(:get, "www.example.com").
519
+ with(:headers => SAMPLE_HEADERS)).to have_been_made
520
+ }.not_to raise_error
521
521
  end
522
522
 
523
523
  it "should satisfy expectation if request was executed with the same headers but with header value declared as array" do
524
- lambda {
524
+ expect {
525
525
  http_request(:get, "http://www.example.com/", :headers => {"a" => "b"})
526
- a_request(:get, "www.example.com").
527
- with(:headers => {"a" => ["b"]}).should have_been_made
528
- }.should_not raise_error
526
+ expect(a_request(:get, "www.example.com").
527
+ with(:headers => {"a" => ["b"]})).to have_been_made
528
+ }.not_to raise_error
529
529
  end
530
530
 
531
531
  describe "when multiple headers with the same key are passed" do
532
532
  it "should satisfy expectation" do
533
- lambda {
533
+ expect {
534
534
  http_request(:get, "http://www.example.com/", :headers => {"a" => ["b", "c"]})
535
- a_request(:get, "www.example.com").
536
- with(:headers => {"a" => ["b", "c"]}).should have_been_made
537
- }.should_not raise_error
535
+ expect(a_request(:get, "www.example.com").
536
+ with(:headers => {"a" => ["b", "c"]})).to have_been_made
537
+ }.not_to raise_error
538
538
  end
539
539
 
540
540
  it "should satisfy expectation even if request was executed with the same headers but different order" do
541
- lambda {
541
+ expect {
542
542
  http_request(:get, "http://www.example.com/", :headers => {"a" => ["b", "c"]})
543
- a_request(:get, "www.example.com").
544
- with(:headers => {"a" => ["c", "b"]}).should have_been_made
545
- }.should_not raise_error
543
+ expect(a_request(:get, "www.example.com").
544
+ with(:headers => {"a" => ["c", "b"]})).to have_been_made
545
+ }.not_to raise_error
546
546
  end
547
547
 
548
548
  it "should fail if request was executed with different headers" do
549
- lambda {
549
+ expect {
550
550
  http_request(:get, "http://www.example.com/", :headers => {"a" => ["b", "c"]})
551
- a_request(:get, "www.example.com").
552
- with(:headers => {"a" => ["b", "d"]}).should have_been_made
553
- }.should fail_with(%r(The request GET http://www.example.com/ with headers \{'A'=>\['b', 'd'\]\} was expected to execute 1 time but it executed 0 times))
551
+ expect(a_request(:get, "www.example.com").
552
+ with(:headers => {"a" => ["b", "d"]})).to have_been_made
553
+ }.to fail_with(%r(The request GET http://www.example.com/ with headers \{'A'=>\['b', 'd'\]\} was expected to execute 1 time but it executed 0 times))
554
554
  end
555
555
  end
556
556
 
557
557
  it "should fail if request was executed with different headers" do
558
- lambda {
558
+ expect {
559
559
  http_request(:get, "http://www.example.com/", :headers => SAMPLE_HEADERS)
560
- a_request(:get, "www.example.com").
561
- with(:headers => { 'Content-Length' => '9999'}).should have_been_made
562
- }.should fail_with(%r(The request GET http://www.example.com/ with headers \{'Content-Length'=>'9999'\} was expected to execute 1 time but it executed 0 times))
560
+ expect(a_request(:get, "www.example.com").
561
+ with(:headers => { 'Content-Length' => '9999'})).to have_been_made
562
+ }.to fail_with(%r(The request GET http://www.example.com/ with headers \{'Content-Length'=>'9999'\} was expected to execute 1 time but it executed 0 times))
563
563
  end
564
564
 
565
565
  it "should fail if request was executed with less headers" do
566
- lambda {
566
+ expect {
567
567
  http_request(:get, "http://www.example.com/", :headers => {'A' => 'a'})
568
- a_request(:get, "www.example.com").
569
- with(:headers => {'A' => 'a', 'B' => 'b'}).should have_been_made
570
- }.should fail_with(%r(The request GET http://www.example.com/ with headers \{'A'=>'a', 'B'=>'b'\} was expected to execute 1 time but it executed 0 times))
568
+ expect(a_request(:get, "www.example.com").
569
+ with(:headers => {'A' => 'a', 'B' => 'b'})).to have_been_made
570
+ }.to fail_with(%r(The request GET http://www.example.com/ with headers \{'A'=>'a', 'B'=>'b'\} was expected to execute 1 time but it executed 0 times))
571
571
  end
572
572
 
573
573
  it "should satisfy expectation if request was executed with more headers" do
574
- lambda {
574
+ expect {
575
575
  http_request(:get, "http://www.example.com/",
576
576
  :headers => {'A' => 'a', 'B' => 'b'}
577
577
  )
578
- a_request(:get, "www.example.com").
579
- with(:headers => {'A' => 'a'}).should have_been_made
580
- }.should_not raise_error
578
+ expect(a_request(:get, "www.example.com").
579
+ with(:headers => {'A' => 'a'})).to have_been_made
580
+ }.not_to raise_error
581
581
  end
582
582
 
583
583
  it "should satisfy expectation if request was executed with body and headers but they were not specified in expectantion" do
584
- lambda {
584
+ expect {
585
585
  http_request(:post, "http://www.example.com/",
586
586
  :body => "abc",
587
587
  :headers => SAMPLE_HEADERS
588
588
  )
589
- a_request(:post, "www.example.com").should have_been_made
590
- }.should_not raise_error
589
+ expect(a_request(:post, "www.example.com")).to have_been_made
590
+ }.not_to raise_error
591
591
  end
592
592
 
593
593
  it "should satisfy expectation if request was executed with headers matching regular expressions" do
594
- lambda {
594
+ expect {
595
595
  http_request(:get, "http://www.example.com/", :headers => { 'some-header' => 'MyAppName' })
596
- a_request(:get, "www.example.com").
597
- with(:headers => { :some_header => /^MyAppName$/ }).should have_been_made
598
- }.should_not raise_error
596
+ expect(a_request(:get, "www.example.com").
597
+ with(:headers => { :some_header => /^MyAppName$/ })).to have_been_made
598
+ }.not_to raise_error
599
599
  end
600
600
 
601
601
  it "should fail if request was executed with headers not matching regular expression" do
602
- lambda {
602
+ expect {
603
603
  http_request(:get, "http://www.example.com/", :headers => { 'some-header' => 'xMyAppName' })
604
- a_request(:get, "www.example.com").
605
- with(:headers => { :some_header => /^MyAppName$/ }).should have_been_made
606
- }.should fail_with(%r(The request GET http://www.example.com/ with headers \{'Some-Header'=>/\^MyAppName\$/\} was expected to execute 1 time but it executed 0 times))
604
+ expect(a_request(:get, "www.example.com").
605
+ with(:headers => { :some_header => /^MyAppName$/ })).to have_been_made
606
+ }.to fail_with(%r(The request GET http://www.example.com/ with headers \{'Some-Header'=>/\^MyAppName\$/\} was expected to execute 1 time but it executed 0 times))
607
607
  end
608
608
  end
609
609
 
610
610
  describe "when expectation contains a request matching block" do
611
611
  it "should satisfy expectation if request was executed and block evaluated to true" do
612
- lambda {
612
+ expect {
613
613
  http_request(:post, "http://www.example.com/", :body => "wadus")
614
- a_request(:post, "www.example.com").with { |req| req.body == "wadus" }.should have_been_made
615
- }.should_not raise_error
614
+ expect(a_request(:post, "www.example.com").with { |req| req.body == "wadus" }).to have_been_made
615
+ }.not_to raise_error
616
616
  end
617
617
 
618
618
  it "should fail if request was executed and block evaluated to false" do
619
- lambda {
619
+ expect {
620
620
  http_request(:post, "http://www.example.com/", :body => "abc")
621
- a_request(:post, "www.example.com").with { |req| req.body == "wadus" }.should have_been_made
622
- }.should fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 1 time but it executed 0 times))
621
+ expect(a_request(:post, "www.example.com").with { |req| req.body == "wadus" }).to have_been_made
622
+ }.to fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 1 time but it executed 0 times))
623
623
  end
624
624
 
625
625
  it "should fail if request was not expected but it executed and block matched request" do
626
- lambda {
626
+ expect {
627
627
  http_request(:post, "http://www.example.com/", :body => "wadus")
628
- a_request(:post, "www.example.com").with { |req| req.body == "wadus" }.should_not have_been_made
629
- }.should fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 0 times but it executed 1 time))
628
+ expect(a_request(:post, "www.example.com").with { |req| req.body == "wadus" }).not_to have_been_made
629
+ }.to fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 0 times but it executed 1 time))
630
630
  end
631
631
  end
632
632
 
@@ -637,147 +637,147 @@ shared_context "request expectations" do |*adapter_info|
637
637
  end
638
638
 
639
639
  it "should satisfy expectation if request was executed with expected credentials" do
640
- lambda {
640
+ expect {
641
641
  http_request(:get, "http://user:pass@www.example.com/")
642
- a_request(:get, "http://user:pass@www.example.com").should have_been_made.once
643
- }.should_not raise_error
642
+ expect(a_request(:get, "http://user:pass@www.example.com")).to have_been_made.once
643
+ }.not_to raise_error
644
644
  end
645
645
 
646
646
  it "should fail if request was executed with different credentials than expected" do
647
- lambda {
647
+ expect {
648
648
  http_request(:get, "http://user:pass@www.example.com/")
649
- a_request(:get, "http://user:pazz@www.example.com").should have_been_made.once
650
- }.should fail_with(%r(The request GET http://user:pazz@www.example.com/ was expected to execute 1 time but it executed 0 times))
649
+ expect(a_request(:get, "http://user:pazz@www.example.com")).to have_been_made.once
650
+ }.to fail_with(%r(The request GET http://user:pazz@www.example.com/ was expected to execute 1 time but it executed 0 times))
651
651
  end
652
652
 
653
653
  it "should fail if request was executed without credentials and credentials were expected" do
654
- lambda {
654
+ expect {
655
655
  http_request(:get, "http://www.example.com/")
656
- a_request(:get, "http://user:pass@www.example.com").should have_been_made.once
657
- }.should fail_with(%r(The request GET http://user:pass@www.example.com/ was expected to execute 1 time but it executed 0 times))
656
+ expect(a_request(:get, "http://user:pass@www.example.com")).to have_been_made.once
657
+ }.to fail_with(%r(The request GET http://user:pass@www.example.com/ was expected to execute 1 time but it executed 0 times))
658
658
  end
659
659
 
660
660
  it "should fail if request was executed with credentials but expected without credentials" do
661
- lambda {
661
+ expect {
662
662
  http_request(:get, "http://user:pass@www.example.com/")
663
- a_request(:get, "http://www.example.com").should have_been_made.once
664
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute 1 time but it executed 0 times))
663
+ expect(a_request(:get, "http://www.example.com")).to have_been_made.once
664
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 1 time but it executed 0 times))
665
665
  end
666
666
 
667
667
  it "should satisfy expectations even if requests were executed in different order than expectations were declared" do
668
668
  stub_request(:post, "http://www.example.com")
669
669
  http_request(:post, "http://www.example.com/", :body => "def")
670
670
  http_request(:post, "http://www.example.com/", :body => "abc")
671
- WebMock.should have_requested(:post, "www.example.com").with(:body => "abc")
672
- WebMock.should have_requested(:post, "www.example.com").with(:body => "def")
671
+ expect(WebMock).to have_requested(:post, "www.example.com").with(:body => "abc")
672
+ expect(WebMock).to have_requested(:post, "www.example.com").with(:body => "def")
673
673
  end
674
674
  end
675
675
 
676
676
  describe "when expectations were set on WebMock object" do
677
677
  it "should satisfy expectation if expected request was made" do
678
- lambda {
678
+ expect {
679
679
  http_request(:get, "http://www.example.com/")
680
- WebMock.should have_requested(:get, "http://www.example.com").once
681
- }.should_not raise_error
680
+ expect(WebMock).to have_requested(:get, "http://www.example.com").once
681
+ }.not_to raise_error
682
682
  end
683
683
 
684
684
  it "should satisfy expectation if request with body and headers was expected and request was made" do
685
- lambda {
685
+ expect {
686
686
  http_request(:post, "http://www.example.com/", :body => "abc", :headers => {'A' => 'a'})
687
- WebMock.should have_requested(:post, "http://www.example.com").with(:body => "abc", :headers => {'A' => 'a'}).once
688
- }.should_not raise_error
687
+ expect(WebMock).to have_requested(:post, "http://www.example.com").with(:body => "abc", :headers => {'A' => 'a'}).once
688
+ }.not_to raise_error
689
689
  end
690
690
 
691
691
  it "should fail if request expected not to be made was made" do
692
- lambda {
692
+ expect {
693
693
  http_request(:get, "http://www.example.com/")
694
- WebMock.should_not have_requested(:get, "http://www.example.com")
695
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute 0 times but it executed 1 time))
694
+ expect(WebMock).not_to have_requested(:get, "http://www.example.com")
695
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 0 times but it executed 1 time))
696
696
  end
697
697
 
698
698
  it "should satisfy expectation if request was executed and expectation had block which evaluated to true" do
699
- lambda {
699
+ expect {
700
700
  http_request(:post, "http://www.example.com/", :body => "wadus")
701
- WebMock.should have_requested(:post, "www.example.com").with { |req| req.body == "wadus" }
702
- }.should_not raise_error
701
+ expect(WebMock).to have_requested(:post, "www.example.com").with { |req| req.body == "wadus" }
702
+ }.not_to raise_error
703
703
  end
704
704
 
705
705
  it "should fail if request was executed and expectation had block which evaluated to false" do
706
- lambda {
706
+ expect {
707
707
  http_request(:post, "http://www.example.com/", :body => "abc")
708
- WebMock.should have_requested(:post, "www.example.com").with { |req| req.body == "wadus" }
709
- }.should fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 1 time but it executed 0 times))
708
+ expect(WebMock).to have_requested(:post, "www.example.com").with { |req| req.body == "wadus" }
709
+ }.to fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 1 time but it executed 0 times))
710
710
  end
711
711
 
712
712
  it "should fail if request was expected not to be made but was made and block matched request" do
713
- lambda {
713
+ expect {
714
714
  http_request(:post, "http://www.example.com/", :body => "wadus")
715
- WebMock.should_not have_requested(:post, "www.example.com").with { |req| req.body == "wadus" }
716
- }.should fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 0 times but it executed 1 time))
715
+ expect(WebMock).not_to have_requested(:post, "www.example.com").with { |req| req.body == "wadus" }
716
+ }.to fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 0 times but it executed 1 time))
717
717
  end
718
718
  end
719
719
 
720
720
  describe "when expectation is declared using assert_requested" do
721
721
  it "should satisfy expectation if requests was made" do
722
- lambda {
722
+ expect {
723
723
  http_request(:get, "http://www.example.com/")
724
724
  assert_requested(:get, "http://www.example.com", :times => 1)
725
725
  assert_requested(:get, "http://www.example.com")
726
- }.should_not raise_error
726
+ }.not_to raise_error
727
727
  end
728
728
 
729
729
  it "should satisfy expectation if request was made with body and headers" do
730
- lambda {
730
+ expect {
731
731
  http_request(:post, "http://www.example.com/", :body => "abc", :headers => {'A' => 'a'})
732
732
  assert_requested(:post, "http://www.example.com", :body => "abc", :headers => {'A' => 'a'})
733
- }.should_not raise_error
733
+ }.not_to raise_error
734
734
  end
735
735
 
736
736
  it "should fail if request expected not to be made was not wade" do
737
- lambda {
737
+ expect {
738
738
  http_request(:get, "http://www.example.com/")
739
739
  assert_not_requested(:get, "http://www.example.com")
740
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute 0 times but it executed 1 time))
740
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 0 times but it executed 1 time))
741
741
  end
742
742
 
743
743
  it "should fail if request expected not to be made was made and expectation block evaluated to true" do
744
- lambda {
744
+ expect {
745
745
  http_request(:post, "http://www.example.com/", :body => "wadus")
746
746
  assert_not_requested(:post, "www.example.com") { |req| req.body == "wadus" }
747
- }.should fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 0 times but it executed 1 time))
747
+ }.to fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 0 times but it executed 1 time))
748
748
  end
749
749
 
750
750
  it "should satisfy expectation if request was made and expectation block evaluated to true" do
751
- lambda {
751
+ expect {
752
752
  http_request(:post, "http://www.example.com/", :body => "wadus")
753
753
  assert_requested(:post, "www.example.com") { |req| req.body == "wadus" }
754
- }.should_not raise_error
754
+ }.not_to raise_error
755
755
  end
756
756
 
757
757
  it "should fail if request was made and expectation block evaluated to false" do
758
- lambda {
758
+ expect {
759
759
  http_request(:post, "http://www.example.com/", :body => "abc")
760
760
  assert_requested(:post, "www.example.com") { |req| req.body == "wadus" }
761
- }.should fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 1 time but it executed 0 times))
761
+ }.to fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 1 time but it executed 0 times))
762
762
  end
763
763
  end
764
764
 
765
765
  describe "when expectation is declared using assert_requested" do
766
766
  it "should satisfy expectation if requests was made" do
767
767
  stub_http = stub_http_request(:get, "http://www.example.com")
768
- lambda {
768
+ expect {
769
769
  http_request(:get, "http://www.example.com/")
770
770
  assert_requested(stub_http, :times => 1)
771
771
  assert_requested(stub_http)
772
- }.should_not raise_error
772
+ }.not_to raise_error
773
773
  end
774
774
 
775
775
  it "should fail if request expected not to be made was not wade" do
776
776
  stub_http = stub_http_request(:get, "http://www.example.com")
777
- lambda {
777
+ expect {
778
778
  http_request(:get, "http://www.example.com/")
779
779
  assert_not_requested(stub_http)
780
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute 0 times but it executed 1 time))
780
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 0 times but it executed 1 time))
781
781
  end
782
782
  end
783
783
  end
@@ -787,52 +787,52 @@ shared_context "request expectations" do |*adapter_info|
787
787
  it "should satisfy expectation if expected request was made" do
788
788
  stub = stub_request(:get, "http://www.example.com/")
789
789
  http_request(:get, "http://www.example.com/")
790
- stub.should have_been_requested.once
790
+ expect(stub).to have_been_requested.once
791
791
  end
792
792
 
793
793
  it "should satisfy expectations if subsequent requests were made" do
794
794
  stub = stub_request(:get, "http://www.example.com/")
795
795
  http_request(:get, "http://www.example.com/")
796
- stub.should have_been_requested.once
796
+ expect(stub).to have_been_requested.once
797
797
  http_request(:get, "http://www.example.com/")
798
- stub.should have_been_requested.twice
798
+ expect(stub).to have_been_requested.twice
799
799
  end
800
800
 
801
801
  it "should satisfy expectation if expected request with body and headers was made" do
802
802
  stub = stub_request(:post, "http://www.example.com").with(:body => "abc", :headers => {'A' => 'a'})
803
803
  http_request(:post, "http://www.example.com/", :body => "abc", :headers => {'A' => 'a'})
804
- stub.should have_been_requested.once
804
+ expect(stub).to have_been_requested.once
805
805
  end
806
806
 
807
807
  it "should fail if request not expected to be made was made" do
808
- lambda {
808
+ expect {
809
809
  stub = stub_request(:get, "http://www.example.com")
810
810
  http_request(:get, "http://www.example.com/")
811
- stub.should_not have_been_requested
812
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute 0 times but it executed 1 time))
811
+ expect(stub).not_to have_been_requested
812
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 0 times but it executed 1 time))
813
813
  end
814
814
 
815
815
  it "should fail request not expected to be made was made and expectation block evaluated to true" do
816
- lambda {
816
+ expect {
817
817
  stub = stub_request(:post, "www.example.com").with { |req| req.body == "wadus" }
818
818
  http_request(:post, "http://www.example.com/", :body => "wadus")
819
- stub.should_not have_been_requested
820
- }.should fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 0 times but it executed 1 time))
819
+ expect(stub).not_to have_been_requested
820
+ }.to fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 0 times but it executed 1 time))
821
821
  end
822
822
 
823
823
  it "should satisfy expectation if request was made and expectation block evaluated to true" do
824
824
  stub = stub_request(:post, "www.example.com").with { |req| req.body == "wadus" }
825
825
  http_request(:post, "http://www.example.com/", :body => "wadus")
826
- stub.should have_been_requested
826
+ expect(stub).to have_been_requested
827
827
  end
828
828
 
829
829
  it "should satisfy expectation if request was made and expectation block evaluated to false" do
830
- lambda {
830
+ expect {
831
831
  stub_request(:any, /.+/) #stub any request
832
832
  stub = stub_request(:post, "www.example.com").with { |req| req.body == "wadus" }
833
833
  http_request(:post, "http://www.example.com/", :body => "abc")
834
- stub.should have_been_requested
835
- }.should fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 1 time but it executed 0 times))
834
+ expect(stub).to have_been_requested
835
+ }.to fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 1 time but it executed 0 times))
836
836
  end
837
837
  end
838
838
 
@@ -842,17 +842,17 @@ shared_context "request expectations" do |*adapter_info|
842
842
  end
843
843
 
844
844
  it "should satisfy expectation if expected requests was made" do
845
- lambda {
845
+ expect {
846
846
  http_request(:get, "http://www.example.com/")
847
- a_request(:get, "http://www.example.com").should have_been_made
848
- }.should_not raise_error
847
+ expect(a_request(:get, "http://www.example.com")).to have_been_made
848
+ }.not_to raise_error
849
849
  end
850
850
 
851
851
  it "should fail request expected not to be made, was made" do
852
- lambda {
852
+ expect {
853
853
  http_request(:get, "http://www.example.com/")
854
- a_request(:get, "http://www.example.com").should_not have_been_made
855
- }.should fail_with(%r(The request GET http://www.example.com/ was expected to execute 0 times but it executed 1 time))
854
+ expect(a_request(:get, "http://www.example.com")).not_to have_been_made
855
+ }.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 0 times but it executed 1 time))
856
856
  end
857
857
  end
858
858
  end