webmock 1.6.4 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +3 -1
  3. data/.travis.yml +6 -0
  4. data/CHANGELOG.md +211 -118
  5. data/Gemfile +16 -1
  6. data/Guardfile +24 -0
  7. data/LICENSE +1 -1
  8. data/README.md +64 -15
  9. data/Rakefile +19 -6
  10. data/lib/webmock.rb +9 -4
  11. data/lib/webmock/api.rb +5 -4
  12. data/lib/webmock/assertion_failure.rb +1 -1
  13. data/lib/webmock/callback_registry.rb +1 -1
  14. data/lib/webmock/config.rb +2 -2
  15. data/lib/webmock/cucumber.rb +1 -1
  16. data/lib/webmock/errors.rb +17 -5
  17. data/lib/webmock/http_lib_adapters/{curb.rb → curb_adapter.rb} +79 -49
  18. data/lib/webmock/http_lib_adapters/{em_http_request.rb → em_http_request/em_http_request_0_x.rb} +20 -15
  19. data/lib/webmock/http_lib_adapters/em_http_request/em_http_request_1_x.rb +201 -0
  20. data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +11 -0
  21. data/lib/webmock/http_lib_adapters/http_lib_adapter.rb +7 -0
  22. data/lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb +19 -0
  23. data/lib/webmock/http_lib_adapters/{httpclient.rb → httpclient_adapter.rb} +35 -8
  24. data/lib/webmock/http_lib_adapters/net_http.rb +84 -25
  25. data/lib/webmock/http_lib_adapters/net_http_response.rb +17 -17
  26. data/lib/webmock/http_lib_adapters/patron_adapter.rb +124 -0
  27. data/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +166 -0
  28. data/lib/webmock/minitest.rb +15 -0
  29. data/lib/webmock/rack_response.rb +52 -0
  30. data/lib/webmock/request_pattern.rb +4 -2
  31. data/lib/webmock/request_signature.rb +4 -0
  32. data/lib/webmock/request_stub.rb +35 -2
  33. data/lib/webmock/responses_sequence.rb +2 -2
  34. data/lib/webmock/rspec.rb +2 -2
  35. data/lib/webmock/rspec/matchers.rb +9 -4
  36. data/lib/webmock/rspec/matchers/webmock_matcher.rb +1 -1
  37. data/lib/webmock/stub_registry.rb +1 -1
  38. data/lib/webmock/stub_request_snippet.rb +14 -11
  39. data/lib/webmock/util/hash_keys_stringifier.rb +4 -4
  40. data/lib/webmock/util/headers.rb +3 -3
  41. data/lib/webmock/util/json.rb +54 -0
  42. data/lib/webmock/util/uri.rb +1 -1
  43. data/lib/webmock/version.rb +1 -1
  44. data/lib/webmock/webmock.rb +20 -3
  45. data/minitest/test_helper.rb +29 -0
  46. data/minitest/test_webmock.rb +6 -0
  47. data/minitest/webmock_spec.rb +30 -0
  48. data/spec/curb_spec.rb +26 -8
  49. data/spec/curb_spec_helper.rb +6 -6
  50. data/spec/em_http_request_spec.rb +95 -1
  51. data/spec/em_http_request_spec_helper.rb +16 -16
  52. data/spec/errors_spec.rb +19 -4
  53. data/spec/example_curl_output.txt +22 -22
  54. data/spec/http_lib_adapters/http_lib_adapter_registry_spec.rb +17 -0
  55. data/spec/http_lib_adapters/http_lib_adapter_spec.rb +12 -0
  56. data/spec/httpclient_spec.rb +1 -1
  57. data/spec/httpclient_spec_helper.rb +3 -38
  58. data/spec/my_rack_app.rb +18 -0
  59. data/spec/net_http_shared.rb +125 -0
  60. data/spec/net_http_spec.rb +27 -31
  61. data/spec/net_http_spec_helper.rb +4 -34
  62. data/spec/network_connection.rb +1 -1
  63. data/spec/patron_spec_helper.rb +4 -7
  64. data/spec/quality_spec.rb +60 -0
  65. data/spec/rack_response_spec.rb +33 -0
  66. data/spec/real_net_http_spec.rb +20 -0
  67. data/spec/request_execution_verifier_spec.rb +8 -8
  68. data/spec/request_pattern_spec.rb +3 -3
  69. data/spec/request_stub_spec.rb +19 -19
  70. data/spec/response_spec.rb +8 -8
  71. data/spec/spec_helper.rb +14 -11
  72. data/spec/stub_request_snippet_spec.rb +85 -37
  73. data/spec/support/webmock_server.rb +62 -0
  74. data/spec/typhoeus_hydra_spec.rb +53 -0
  75. data/spec/typhoeus_hydra_spec_helper.rb +50 -0
  76. data/spec/util/headers_spec.rb +5 -5
  77. data/spec/util/json_spec.rb +7 -0
  78. data/spec/util/uri_spec.rb +1 -1
  79. data/spec/vendor/addressable/lib/uri.rb +1 -0
  80. data/spec/vendor/crack/lib/crack.rb +1 -0
  81. data/spec/vendor/right_http_connection-1.2.4/History.txt +4 -4
  82. data/spec/vendor/right_http_connection-1.2.4/README.txt +4 -4
  83. data/spec/vendor/right_http_connection-1.2.4/Rakefile +3 -3
  84. data/spec/vendor/right_http_connection-1.2.4/lib/net_fix.rb +4 -4
  85. data/spec/vendor/right_http_connection-1.2.4/setup.rb +4 -4
  86. data/spec/webmock_shared.rb +375 -143
  87. data/spec/webmock_spec.rb +7 -0
  88. data/test/http_request.rb +24 -0
  89. data/test/shared_test.rb +47 -0
  90. data/test/test_helper.rb +6 -3
  91. data/test/test_webmock.rb +2 -67
  92. data/webmock.gemspec +8 -7
  93. metadata +153 -88
  94. data/lib/webmock/http_lib_adapters/patron.rb +0 -100
  95. data/spec/other_net_http_libs_spec.rb +0 -30
data/.gemtest ADDED
File without changes
data/.gitignore CHANGED
@@ -11,7 +11,7 @@ tmtags
11
11
  .\#*
12
12
 
13
13
  ## VIM
14
- *.swp
14
+ .*.sw[a-z]
15
15
 
16
16
  ## PROJECT::GENERAL
17
17
  coverage
@@ -23,3 +23,5 @@ pkg
23
23
  .bundle
24
24
  Gemfile.lock
25
25
  pkg/*
26
+ tmp/*
27
+ *.rbc
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ree
6
+ - jruby
data/CHANGELOG.md CHANGED
@@ -1,5 +1,98 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.0
4
+
5
+ * Fixed Net::HTTP adapter to not break normal Net::HTTP behaviour when network connections are allowed. This fixes **selenium-webdriver compatibility**!!!
6
+
7
+ * Added support for EM-HTTP-Request 1.0.x and EM-Synchrony. Thanks to [Steve Hull](https://github.com/sdhull)
8
+
9
+ * Added support for setting expectations to on a stub itself i.e.
10
+
11
+ stub = stub_request(:get, "www.example.com")
12
+ # ... make requests ...
13
+ stub.should have_been_requested
14
+
15
+ Thanks to [Aidan Feldman](https://github.com/afeld)
16
+
17
+ * Minitest support! Thanks to [Peter Higgins](https://github.com/phiggins)
18
+
19
+ * Added support for Typhoeus::Hydra
20
+
21
+ * Added support for `Curb::Easy#http_post` and `Curb::Easy#http_post` with multiple arguments. Thanks to [Salvador Fuentes Jr](https://github.com/fuentesjr) and [Alex Rothenberg](https://github.com/alexrothenberg)
22
+
23
+ * Rack support. Requests can be stubbed to respond with a Rack app i.e.
24
+
25
+ class MyRackApp
26
+ def self.call(env)
27
+ [200, {}, ["Hello"]]
28
+ end
29
+ end
30
+
31
+ stub_request(:get, "www.example.com").to_rack(MyRackApp)
32
+
33
+ RestClient.get("www.example.com") # ===> "Hello"
34
+
35
+
36
+ Thanks to [Jay Adkisson](https://github.com/jayferd)
37
+
38
+ * Added support for selective disabling and enabling of http lib adapters
39
+
40
+ WebMock.disable! #disable WebMock (all adapters)
41
+ WebMock.disable!(:except => [:net_http]) #disable WebMock for all libs except Net::HTTP
42
+ WebMock.enable! #enable WebMock (all adapters)
43
+ WebMock.enable!(:except => [:patron]) #enable WebMock for all libs except Patron
44
+
45
+ * The error message on an unstubbed request shows a code snippet with body as a hash when it was in url encoded form.
46
+
47
+ > RestClient.post('www.example.com', "data[a]=1&data[b]=2", :content_type => 'application/x-www-form-urlencoded')
48
+
49
+ WebMock::NetConnectNotAllowedError: Real HTTP connections are disabled....
50
+
51
+ You can stub this request with the following snippet:
52
+
53
+ stub_request(:post, "http://www.example.com/").
54
+ with(:body => {"data"=>{"a"=>"1", "b"=>"2"}},
55
+ :headers => { 'Content-Type'=>'application/x-www-form-urlencoded' }).
56
+ to_return(:status => 200, :body => "", :headers => {})
57
+
58
+ Thanks to [Alex Rothenberg](https://github.com/alexrothenberg)
59
+
60
+ * The error message on an unstubbed request shows currently registered request stubs.
61
+
62
+ > stub_request(:get, "www.example.net")
63
+ > stub_request(:get, "www.example.org")
64
+ > RestClient.get("www.example.com")
65
+ WebMock::NetConnectNotAllowedError: Real HTTP connections are disabled....
66
+
67
+ You can stub this request with the following snippet:
68
+
69
+ stub_request(:get, "http://www.example.com/").
70
+ to_return(:status => 200, :body => "", :headers => {})
71
+
72
+ registered request stubs:
73
+
74
+ stub_request(:get, "http://www.example.net/")
75
+ stub_request(:get, "http://www.example.org/")
76
+
77
+ Thanks to [Lin Jen-Shin](https://github.com/godfat) for suggesting this feature.
78
+
79
+ * Fixed problem with matching requests with json body, when json strings have date format. Thanks to [Joakim Ekberg](https://github.com/kalasjocke) for reporting this issue.
80
+
81
+ * WebMock now attempts to require each http library before monkey patching it. This is to avoid problem when http library is required after WebMock is required. Thanks to [Myron Marston](https://github.com/myronmarston) for suggesting this change.
82
+
83
+ * External requests can be disabled while allowing selected ports on selected hosts
84
+
85
+ WebMock.disable_net_connect!(:allow => "www.example.com:8080")
86
+ RestClient.get("www.example.com:80") # ===> Failure
87
+ RestClient.get("www.example.com:8080") # ===> Allowed.
88
+
89
+ Thanks to [Zach Dennis](https://github.com/zdennis)
90
+
91
+ * Fixed syntax error in README examples, showing the ways of setting request expectations. Thanks to [Nikita Fedyashev](https://github.com/nfedyashev)
92
+
93
+
94
+ **Many thanks to WebMock co-maintainer [James Conroy-Finn](https://github.com/jcf) who did a great job maintaining WebMock on his own for the last couple of months.**
95
+
3
96
  ## 1.6.4
4
97
 
5
98
  This is a quick slip release to regenerate the gemspec. Apparently
@@ -52,9 +145,9 @@ josevalim:
52
145
 
53
146
  * Simplified integration with Test::Unit, RSpec and Cucumber. Now only a single file has to be required i.e.
54
147
 
55
- require 'webmock/test_unit'
56
- require 'webmock/rspec'
57
- require 'webmock/cucumber'
148
+ require 'webmock/test_unit'
149
+ require 'webmock/rspec'
150
+ require 'webmock/cucumber'
58
151
 
59
152
  * The error message on unstubbed request now contains code snippet which can be used to stub this request. Thanks to Martyn Loughran for suggesting this feature.
60
153
 
@@ -66,12 +159,12 @@ josevalim:
66
159
 
67
160
  This technique is borrowed from em-http-request native mocking module. It allows switching WebMock adapter on an off, and using it interchangeably with em-http-request native mocking i.e:
68
161
 
69
- EventMachine::WebMockHttpRequest.activate!
70
- EventMachine::WebMockHttpRequest.deactivate!
162
+ EventMachine::WebMockHttpRequest.activate!
163
+ EventMachine::WebMockHttpRequest.deactivate!
164
+
165
+ Thanks to Martyn Loughran for suggesting this feature.
71
166
 
72
- Thanks to Martyn Loughran for suggesting this feature.
73
-
74
- * `WebMock.reset_webmock` is deprecated in favour of new `WebMock.reset!`
167
+ * `WebMock.reset_webmock` is deprecated in favour of new `WebMock.reset!`
75
168
 
76
169
  * Fixed integration with Cucumber. Previously documented example didn't work with new versions of Cucumber.
77
170
 
@@ -88,12 +181,12 @@ josevalim:
88
181
  * Support for dynamically evaluated raw responses recorded with `curl -is` <br/>
89
182
  i.e.
90
183
 
91
- `curl -is www.example.com > /tmp/www.example.com.txt`
92
- stub_request(:get, "www.example.com").to_return(lambda { |request| File.new("/tmp/#{request.uri.host.to_s}.txt" }))
184
+ `curl -is www.example.com > /tmp/www.example.com.txt`
185
+ stub_request(:get, "www.example.com").to_return(lambda { |request| File.new("/tmp/#{request.uri.host.to_s}.txt" }))
93
186
 
94
187
  * `:net_http_connect_on_start` option can be passed to `WebMock.allow_net_connect!` and `WebMock.disable_net_connect!` methods, i.e.
95
188
 
96
- WebMock.allow_net_connect!(:net_http_connect_on_start => true)
189
+ WebMock.allow_net_connect!(:net_http_connect_on_start => true)
97
190
 
98
191
  This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`. Check 'Connecting on Net::HTTP.start' in README for more information.
99
192
 
@@ -112,7 +205,7 @@ josevalim:
112
205
 
113
206
  * `include WebMock` is now deprecated to avoid method and constant name conflicts. Please `include WebMock::API` instead.
114
207
 
115
- * `WebMock::API#request` is renamed to `WebMock::API#a_request` to prevent method name conflicts with i.e. Rails controller specs.
208
+ * `WebMock::API#request` is renamed to `WebMock::API#a_request` to prevent method name conflicts with i.e. Rails controller specs.
116
209
  WebMock.request is still available.
117
210
 
118
211
  * Deprecated `WebMock#request`, `WebMock#allow_net_connect!`, `WebMock#net_connect_allowed?`, `WebMock#registered_request?`, `WebMock#reset_callbacks`, `WebMock#after_request` instance methods. These methods are still available, but only as WebMock class methods.
@@ -135,11 +228,11 @@ josevalim:
135
228
 
136
229
  This feature was available before only for localhost with `:allow_localhost => true`
137
230
 
138
- WebMock.disable_net_connect!(:allow => "www.example.org")
231
+ WebMock.disable_net_connect!(:allow => "www.example.org")
139
232
 
140
- Net::HTTP.get('www.something.com', '/') # ===> Failure
233
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
141
234
 
142
- Net::HTTP.get('www.example.org', '/') # ===> Allowed.
235
+ Net::HTTP.get('www.example.org', '/') # ===> Allowed.
143
236
 
144
237
  * Fixed Net::HTTP adapter so that it preserves the original behavior of Net::HTTP.
145
238
 
@@ -169,53 +262,53 @@ josevalim:
169
262
 
170
263
  * Added support for [em-http-request](http://github.com/igrigorik/em-http-request)
171
264
 
172
- * Matching query params using a hash
265
+ * Matching query params using a hash
173
266
 
174
- stub_http_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
175
-
176
- RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
177
-
178
- request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]}).should have_been_made # ===> Success
267
+ stub_http_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
268
+
269
+ RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
270
+
271
+ request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]}).should have_been_made # ===> Success
179
272
 
180
273
  * Matching request body against a hash. Body can be URL-Encoded, JSON or XML.
181
274
 
182
275
  (Thanks to Steve Tooke for the idea and a solution for url-encoded bodies)
183
276
 
184
- stub_http_request(:post, "www.example.com").
185
- with(:body => {:data => {:a => '1', :b => 'five'}})
186
-
187
- RestClient.post('www.example.com', "data[a]=1&data[b]=five",
188
- :content_type => 'application/x-www-form-urlencoded') # ===> Success
189
-
190
- RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
191
- :content_type => 'application/json') # ===> Success
192
-
193
- RestClient.post('www.example.com', '<data a="1" b="five" />',
194
- :content_type => 'application/xml' ) # ===> Success
195
-
196
- request(:post, "www.example.com").
197
- with(:body => {:data => {:a => '1', :b => 'five'}},
198
- :headers => 'Content-Type' => 'application/json').should have_been_made # ===> Success
277
+ stub_http_request(:post, "www.example.com").
278
+ with(:body => {:data => {:a => '1', :b => 'five'}})
279
+
280
+ RestClient.post('www.example.com', "data[a]=1&data[b]=five",
281
+ :content_type => 'application/x-www-form-urlencoded') # ===> Success
282
+
283
+ RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
284
+ :content_type => 'application/json') # ===> Success
285
+
286
+ RestClient.post('www.example.com', '<data a="1" b="five" />',
287
+ :content_type => 'application/xml' ) # ===> Success
288
+
289
+ request(:post, "www.example.com").
290
+ with(:body => {:data => {:a => '1', :b => 'five'}},
291
+ :headers => 'Content-Type' => 'application/json').should have_been_made # ===> Success
199
292
 
200
293
  * Request callbacks (Thanks to Myron Marston for all suggestions)
201
294
 
202
295
  WebMock can now invoke callbacks for stubbed or real requests:
203
296
 
204
- WebMock.after_request do |request_signature, response|
205
- puts "Request #{request_signature} was made and #{response} was returned"
206
- end
207
-
297
+ WebMock.after_request do |request_signature, response|
298
+ puts "Request #{request_signature} was made and #{response} was returned"
299
+ end
300
+
208
301
  invoke callbacks for real requests only and except requests made with Patron client
209
302
 
210
- WebMock.after_request(:except => [:patron], :real_requests_only => true) do |request_signature, response|
211
- puts "Request #{request_signature} was made and #{response} was returned"
212
- end
303
+ WebMock.after_request(:except => [:patron], :real_requests_only => true) do |request_signature, response|
304
+ puts "Request #{request_signature} was made and #{response} was returned"
305
+ end
213
306
 
214
307
  * `to_raise()` now accepts an exception instance or a string as argument in addition to an exception class
215
308
 
216
- stub_request(:any, 'www.example.net').to_raise(StandardError.new("some error"))
217
-
218
- stub_request(:any, 'www.example.net').to_raise("some error")
309
+ stub_request(:any, 'www.example.net').to_raise(StandardError.new("some error"))
310
+
311
+ stub_request(:any, 'www.example.net').to_raise("some error")
219
312
 
220
313
  * Matching requests based on a URI is 30% faster
221
314
 
@@ -231,7 +324,7 @@ josevalim:
231
324
 
232
325
  * Fixed gemspec file. Thanks to Razic
233
326
 
234
- ## 1.2.0
327
+ ## 1.2.0
235
328
 
236
329
  * RSpec 2 compatibility. Thanks to Sam Phillips!
237
330
 
@@ -243,14 +336,14 @@ josevalim:
243
336
  ## 1.1.0
244
337
 
245
338
  * [VCR](http://github.com/myronmarston/vcr/) compatibility. Many thanks to Myron Marston for all suggestions.
246
-
247
- * Support for stubbing requests and returning responses with multiple headers with the same name. i.e multiple Accept headers.
248
339
 
249
- stub_http_request(:get, 'www.example.com').
250
- with(:headers => {'Accept' => ['image/png', 'image/jpeg']}).
251
- to_return(:body => 'abc')
252
- RestClient.get('www.example.com',
253
- {"Accept" => ['image/png', 'image/jpeg']}) # ===> "abc\n"
340
+ * Support for stubbing requests and returning responses with multiple headers with the same name. i.e multiple Accept headers.
341
+
342
+ stub_http_request(:get, 'www.example.com').
343
+ with(:headers => {'Accept' => ['image/png', 'image/jpeg']}).
344
+ to_return(:body => 'abc')
345
+ RestClient.get('www.example.com',
346
+ {"Accept" => ['image/png', 'image/jpeg']}) # ===> "abc\n"
254
347
 
255
348
  * When real net connections are disabled and unstubbed request is made, WebMock throws WebMock::NetConnectNotAllowedError instead of assertion error or StandardError.
256
349
 
@@ -263,38 +356,38 @@ josevalim:
263
356
 
264
357
  * Responses dynamically evaluated from block (idea and implementation by Tom Ward)
265
358
 
266
- stub_request(:any, 'www.example.net').
267
- to_return { |request| {:body => request.body} }
359
+ stub_request(:any, 'www.example.net').
360
+ to_return { |request| {:body => request.body} }
268
361
 
269
- RestClient.post('www.example.net', 'abc') # ===> "abc\n"
362
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
270
363
 
271
364
  * Responses dynamically evaluated from lambda (idea and implementation by Tom Ward)
272
365
 
273
- stub_request(:any, 'www.example.net').
274
- to_return(lambda { |request| {:body => request.body} })
366
+ stub_request(:any, 'www.example.net').
367
+ to_return(lambda { |request| {:body => request.body} })
275
368
 
276
- RestClient.post('www.example.net', 'abc') # ===> "abc\n"
369
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
277
370
 
278
- * Response with custom status message
371
+ * Response with custom status message
279
372
 
280
- stub_request(:any, "www.example.com").to_return(:status => [500, "Internal Server Error"])
373
+ stub_request(:any, "www.example.com").to_return(:status => [500, "Internal Server Error"])
281
374
 
282
- req = Net::HTTP::Get.new("/")
283
- Net::HTTP.start("www.example.com") { |http| http.request(req) }.message # ===> "Internal Server Error"
375
+ req = Net::HTTP::Get.new("/")
376
+ Net::HTTP.start("www.example.com") { |http| http.request(req) }.message # ===> "Internal Server Error"
284
377
 
285
378
  * Raising timeout errors (suggested by Jeffrey Jones) (compatibility with Ruby 1.8.6 by Mack Earnhardt)
286
379
 
287
- stub_request(:any, 'www.example.net').to_timeout
380
+ stub_request(:any, 'www.example.net').to_timeout
288
381
 
289
- RestClient.post('www.example.net', 'abc') # ===> RestClient::RequestTimeout
382
+ RestClient.post('www.example.net', 'abc') # ===> RestClient::RequestTimeout
290
383
 
291
384
  * External requests can be disabled while allowing localhost (idea and implementation by Mack Earnhardt)
292
385
 
293
- WebMock.disable_net_connect!(:allow_localhost => true)
386
+ WebMock.disable_net_connect!(:allow_localhost => true)
294
387
 
295
- Net::HTTP.get('www.something.com', '/') # ===> Failure
388
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
296
389
 
297
- Net::HTTP.get('localhost:9887', '/') # ===> Allowed. Perhaps to Selenium?
390
+ Net::HTTP.get('localhost:9887', '/') # ===> Allowed. Perhaps to Selenium?
298
391
 
299
392
 
300
393
  ### Bug fixes
@@ -307,82 +400,82 @@ josevalim:
307
400
  * Fixed issue where response status code was not read from raw (curl -is) responses
308
401
 
309
402
  ## 0.9.0
310
-
403
+
311
404
  * Matching requests against provided block (by Sergio Gil)
312
405
 
313
- stub_request(:post, "www.example.com").with { |request| request.body == "abc" }.to_return(:body => "def")
314
- RestClient.post('www.example.com', 'abc') # ===> "def\n"
315
- request(:post, "www.example.com").with { |req| req.body == "abc" }.should have_been_made
316
- #or
317
- assert_requested(:post, "www.example.com") { |req| req.body == "abc" }
406
+ stub_request(:post, "www.example.com").with { |request| request.body == "abc" }.to_return(:body => "def")
407
+ RestClient.post('www.example.com', 'abc') # ===> "def\n"
408
+ request(:post, "www.example.com").with { |req| req.body == "abc" }.should have_been_made
409
+ #or
410
+ assert_requested(:post, "www.example.com") { |req| req.body == "abc" }
318
411
 
319
412
  * Matching request body against regular expressions (suggested by Ben Pickles)
320
413
 
321
- stub_request(:post, "www.example.com").with(:body => /^.*world$/).to_return(:body => "abc")
322
- RestClient.post('www.example.com', 'hello world') # ===> "abc\n"
323
-
414
+ stub_request(:post, "www.example.com").with(:body => /^.*world$/).to_return(:body => "abc")
415
+ RestClient.post('www.example.com', 'hello world') # ===> "abc\n"
416
+
324
417
  * Matching request headers against regular expressions (suggested by Ben Pickles)
325
418
 
326
- stub_request(:post, "www.example.com").with(:headers => {"Content-Type" => /image\/.+/}).to_return(:body => "abc")
327
- RestClient.post('www.example.com', '', {'Content-Type' => 'image/png'}) # ===> "abc\n"
419
+ stub_request(:post, "www.example.com").with(:headers => {"Content-Type" => /image\/.+/}).to_return(:body => "abc")
420
+ RestClient.post('www.example.com', '', {'Content-Type' => 'image/png'}) # ===> "abc\n"
328
421
 
329
422
  * Replaying raw responses recorded with `curl -is`
330
423
 
331
- `curl -is www.example.com > /tmp/example_curl_-is_output.txt`
332
- raw_response_file = File.new("/tmp/example_curl_-is_output.txt")
333
-
334
- from file
335
-
336
- stub_request(:get, "www.example.com").to_return(raw_response_file)
424
+ `curl -is www.example.com > /tmp/example_curl_-is_output.txt`
425
+ raw_response_file = File.new("/tmp/example_curl_-is_output.txt")
426
+
427
+ from file
337
428
 
338
- or string
339
-
340
- stub_request(:get, "www.example.com").to_return(raw_response_file.read)
429
+ stub_request(:get, "www.example.com").to_return(raw_response_file)
430
+
431
+ or string
432
+
433
+ stub_request(:get, "www.example.com").to_return(raw_response_file.read)
341
434
 
342
435
  * Multiple responses for repeated requests
343
436
 
344
- stub_request(:get, "www.example.com").to_return({:body => "abc"}, {:body => "def"})
345
- Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
346
- Net::HTTP.get('www.example.com', '/') # ===> "def\n"
437
+ stub_request(:get, "www.example.com").to_return({:body => "abc"}, {:body => "def"})
438
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
439
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
347
440
 
348
441
  * Multiple responses using chained `to_return()` or `to_raise()` declarations
349
442
 
350
- stub_request(:get, "www.example.com").
351
- to_return({:body => "abc"}).then. #then() just is a syntactic sugar
352
- to_return({:body => "def"}).then.
353
- to_raise(MyException)
354
- Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
355
- Net::HTTP.get('www.example.com', '/') # ===> "def\n"
356
- Net::HTTP.get('www.example.com', '/') # ===> MyException raised
357
-
443
+ stub_request(:get, "www.example.com").
444
+ to_return({:body => "abc"}).then. #then() just is a syntactic sugar
445
+ to_return({:body => "def"}).then.
446
+ to_raise(MyException)
447
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
448
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
449
+ Net::HTTP.get('www.example.com', '/') # ===> MyException raised
450
+
358
451
  * Specifying number of times given response should be returned
359
452
 
360
- stub_request(:get, "www.example.com").
361
- to_return({:body => "abc"}).times(2).then.
362
- to_return({:body => "def"})
363
-
364
- Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
365
- Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
366
- Net::HTTP.get('www.example.com', '/') # ===> "def\n"
367
-
453
+ stub_request(:get, "www.example.com").
454
+ to_return({:body => "abc"}).times(2).then.
455
+ to_return({:body => "def"})
456
+
457
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
458
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
459
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
460
+
368
461
  * Added support for `Net::HTTP::Post#body_stream`
369
462
 
370
- This fixes compatibility with new versions of RestClient
371
-
463
+ This fixes compatibility with new versions of RestClient
464
+
372
465
  * WebMock doesn't suppress default request headers added by http clients anymore.
373
466
 
374
- i.e. Net::HTTP adds `'Accept'=>'*/*'` to all requests by default
375
-
376
-
377
-
467
+ i.e. Net::HTTP adds `'Accept'=>'*/*'` to all requests by default
468
+
469
+
470
+
378
471
  ## 0.8.2
379
-
472
+
380
473
  * Fixed issue where WebMock was not closing IO object passed as response body after reading it.
381
474
  * Ruby 1.9.2 compat: Use `File#expand_path` for require path because "." is not be included in LOAD_PATH since Ruby 1.9.2
382
475
 
383
476
 
384
477
  ## 0.8.1
385
-
478
+
386
479
  * Fixed HTTPClient adapter compatibility with Ruby 1.8.6 (reported by Piotr Usewicz)
387
480
  * Net:HTTP adapter now handles request body assigned as Net::HTTP::Post#body attribute (fixed by Mack Earnhardt)
388
481
  * Fixed issue where requests were not matching stubs with Accept header set.(reported by Piotr Usewicz)
@@ -394,8 +487,8 @@ josevalim:
394
487
  ## 0.8.0
395
488
 
396
489
  * Support for HTTPClient (sync and async requests)
397
- * Support for dynamic responses. Response body and headers can be now declared as lambda.
398
- (Thanks to Ivan Vega ( @ivanyv ) for suggesting this feature)
490
+ * Support for dynamic responses. Response body and headers can be now declared as lambda.
491
+ (Thanks to Ivan Vega ( @ivanyv ) for suggesting this feature)
399
492
  * Support for stubbing and expecting requests with empty body
400
493
  * Executing non-stubbed request leads to failed expectation instead of error
401
494