webmock 3.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +7 -0
  2. data/.gemtest +0 -0
  3. data/.gitignore +34 -0
  4. data/.rspec-tm +2 -0
  5. data/.travis.yml +19 -0
  6. data/CHANGELOG.md +1698 -0
  7. data/Gemfile +9 -0
  8. data/LICENSE +20 -0
  9. data/README.md +1125 -0
  10. data/Rakefile +28 -0
  11. data/lib/webmock.rb +59 -0
  12. data/lib/webmock/api.rb +109 -0
  13. data/lib/webmock/assertion_failure.rb +11 -0
  14. data/lib/webmock/callback_registry.rb +35 -0
  15. data/lib/webmock/config.rb +18 -0
  16. data/lib/webmock/cucumber.rb +10 -0
  17. data/lib/webmock/deprecation.rb +9 -0
  18. data/lib/webmock/errors.rb +17 -0
  19. data/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +214 -0
  20. data/lib/webmock/http_lib_adapters/curb_adapter.rb +347 -0
  21. data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +228 -0
  22. data/lib/webmock/http_lib_adapters/excon_adapter.rb +162 -0
  23. data/lib/webmock/http_lib_adapters/http_lib_adapter.rb +7 -0
  24. data/lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb +19 -0
  25. data/lib/webmock/http_lib_adapters/http_rb/client.rb +14 -0
  26. data/lib/webmock/http_lib_adapters/http_rb/request.rb +16 -0
  27. data/lib/webmock/http_lib_adapters/http_rb/response.rb +43 -0
  28. data/lib/webmock/http_lib_adapters/http_rb/streamer.rb +29 -0
  29. data/lib/webmock/http_lib_adapters/http_rb/webmock.rb +68 -0
  30. data/lib/webmock/http_lib_adapters/http_rb_adapter.rb +37 -0
  31. data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +242 -0
  32. data/lib/webmock/http_lib_adapters/manticore_adapter.rb +130 -0
  33. data/lib/webmock/http_lib_adapters/net_http.rb +361 -0
  34. data/lib/webmock/http_lib_adapters/net_http_response.rb +34 -0
  35. data/lib/webmock/http_lib_adapters/patron_adapter.rb +130 -0
  36. data/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +174 -0
  37. data/lib/webmock/matchers/any_arg_matcher.rb +13 -0
  38. data/lib/webmock/matchers/hash_argument_matcher.rb +21 -0
  39. data/lib/webmock/matchers/hash_excluding_matcher.rb +15 -0
  40. data/lib/webmock/matchers/hash_including_matcher.rb +17 -0
  41. data/lib/webmock/minitest.rb +41 -0
  42. data/lib/webmock/rack_response.rb +69 -0
  43. data/lib/webmock/request_body_diff.rb +64 -0
  44. data/lib/webmock/request_execution_verifier.rb +77 -0
  45. data/lib/webmock/request_pattern.rb +370 -0
  46. data/lib/webmock/request_registry.rb +35 -0
  47. data/lib/webmock/request_signature.rb +54 -0
  48. data/lib/webmock/request_signature_snippet.rb +61 -0
  49. data/lib/webmock/request_stub.rb +100 -0
  50. data/lib/webmock/response.rb +153 -0
  51. data/lib/webmock/responses_sequence.rb +40 -0
  52. data/lib/webmock/rspec.rb +41 -0
  53. data/lib/webmock/rspec/matchers.rb +27 -0
  54. data/lib/webmock/rspec/matchers/request_pattern_matcher.rb +78 -0
  55. data/lib/webmock/rspec/matchers/webmock_matcher.rb +67 -0
  56. data/lib/webmock/stub_registry.rb +67 -0
  57. data/lib/webmock/stub_request_snippet.rb +38 -0
  58. data/lib/webmock/test_unit.rb +22 -0
  59. data/lib/webmock/util/hash_counter.rb +39 -0
  60. data/lib/webmock/util/hash_keys_stringifier.rb +25 -0
  61. data/lib/webmock/util/hash_validator.rb +17 -0
  62. data/lib/webmock/util/headers.rb +64 -0
  63. data/lib/webmock/util/json.rb +67 -0
  64. data/lib/webmock/util/query_mapper.rb +281 -0
  65. data/lib/webmock/util/uri.rb +110 -0
  66. data/lib/webmock/util/values_stringifier.rb +20 -0
  67. data/lib/webmock/util/version_checker.rb +111 -0
  68. data/lib/webmock/version.rb +3 -0
  69. data/lib/webmock/webmock.rb +161 -0
  70. data/minitest/test_helper.rb +34 -0
  71. data/minitest/test_webmock.rb +9 -0
  72. data/minitest/webmock_spec.rb +60 -0
  73. data/spec/acceptance/async_http_client/async_http_client_spec.rb +349 -0
  74. data/spec/acceptance/async_http_client/async_http_client_spec_helper.rb +73 -0
  75. data/spec/acceptance/curb/curb_spec.rb +492 -0
  76. data/spec/acceptance/curb/curb_spec_helper.rb +147 -0
  77. data/spec/acceptance/em_http_request/em_http_request_spec.rb +406 -0
  78. data/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +77 -0
  79. data/spec/acceptance/excon/excon_spec.rb +77 -0
  80. data/spec/acceptance/excon/excon_spec_helper.rb +50 -0
  81. data/spec/acceptance/http_rb/http_rb_spec.rb +82 -0
  82. data/spec/acceptance/http_rb/http_rb_spec_helper.rb +54 -0
  83. data/spec/acceptance/httpclient/httpclient_spec.rb +217 -0
  84. data/spec/acceptance/httpclient/httpclient_spec_helper.rb +57 -0
  85. data/spec/acceptance/manticore/manticore_spec.rb +56 -0
  86. data/spec/acceptance/manticore/manticore_spec_helper.rb +35 -0
  87. data/spec/acceptance/net_http/net_http_shared.rb +153 -0
  88. data/spec/acceptance/net_http/net_http_spec.rb +331 -0
  89. data/spec/acceptance/net_http/net_http_spec_helper.rb +64 -0
  90. data/spec/acceptance/net_http/real_net_http_spec.rb +20 -0
  91. data/spec/acceptance/patron/patron_spec.rb +125 -0
  92. data/spec/acceptance/patron/patron_spec_helper.rb +54 -0
  93. data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +313 -0
  94. data/spec/acceptance/shared/callbacks.rb +148 -0
  95. data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +36 -0
  96. data/spec/acceptance/shared/enabling_and_disabling_webmock.rb +95 -0
  97. data/spec/acceptance/shared/precedence_of_stubs.rb +15 -0
  98. data/spec/acceptance/shared/request_expectations.rb +930 -0
  99. data/spec/acceptance/shared/returning_declared_responses.rb +409 -0
  100. data/spec/acceptance/shared/stubbing_requests.rb +643 -0
  101. data/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +135 -0
  102. data/spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb +60 -0
  103. data/spec/acceptance/webmock_shared.rb +41 -0
  104. data/spec/fixtures/test.txt +1 -0
  105. data/spec/quality_spec.rb +84 -0
  106. data/spec/spec_helper.rb +48 -0
  107. data/spec/support/example_curl_output.txt +22 -0
  108. data/spec/support/failures.rb +9 -0
  109. data/spec/support/my_rack_app.rb +53 -0
  110. data/spec/support/network_connection.rb +19 -0
  111. data/spec/support/webmock_server.rb +70 -0
  112. data/spec/unit/api_spec.rb +175 -0
  113. data/spec/unit/errors_spec.rb +129 -0
  114. data/spec/unit/http_lib_adapters/http_lib_adapter_registry_spec.rb +17 -0
  115. data/spec/unit/http_lib_adapters/http_lib_adapter_spec.rb +12 -0
  116. data/spec/unit/matchers/hash_excluding_matcher_spec.rb +61 -0
  117. data/spec/unit/matchers/hash_including_matcher_spec.rb +87 -0
  118. data/spec/unit/rack_response_spec.rb +112 -0
  119. data/spec/unit/request_body_diff_spec.rb +90 -0
  120. data/spec/unit/request_execution_verifier_spec.rb +208 -0
  121. data/spec/unit/request_pattern_spec.rb +601 -0
  122. data/spec/unit/request_registry_spec.rb +95 -0
  123. data/spec/unit/request_signature_snippet_spec.rb +89 -0
  124. data/spec/unit/request_signature_spec.rb +155 -0
  125. data/spec/unit/request_stub_spec.rb +199 -0
  126. data/spec/unit/response_spec.rb +282 -0
  127. data/spec/unit/stub_registry_spec.rb +103 -0
  128. data/spec/unit/stub_request_snippet_spec.rb +115 -0
  129. data/spec/unit/util/hash_counter_spec.rb +39 -0
  130. data/spec/unit/util/hash_keys_stringifier_spec.rb +27 -0
  131. data/spec/unit/util/headers_spec.rb +28 -0
  132. data/spec/unit/util/json_spec.rb +33 -0
  133. data/spec/unit/util/query_mapper_spec.rb +157 -0
  134. data/spec/unit/util/uri_spec.rb +361 -0
  135. data/spec/unit/util/version_checker_spec.rb +65 -0
  136. data/spec/unit/webmock_spec.rb +19 -0
  137. data/test/http_request.rb +24 -0
  138. data/test/shared_test.rb +108 -0
  139. data/test/test_helper.rb +23 -0
  140. data/test/test_webmock.rb +6 -0
  141. data/webmock.gemspec +45 -0
  142. metadata +496 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e772b611e0179353d7187a2e24a4d2e4afb894c8fcf60c439cf13cd3e64fdbe8
4
+ data.tar.gz: 3de0ac09c6659b28c4ad2b9abb5fa69adc67e7e489c2c0979e84e826ee576c69
5
+ SHA512:
6
+ metadata.gz: 44c7fa0892f5f0e1c1331287081bd3df86272b0843aeb34de8ea73a859dc8fb7ec3be24c5cd0ca83ff5cb699eadd5966fa9711e030d9a382f2a418c8d661bcfc
7
+ data.tar.gz: 40e5a59b2189f8b19bf7eb4a034f08e1b657e54c8a6912b212852f402f60aaaee5897178e0c58db707db0c7ef9bc0aa6d28a5c72df83e43ce8f4846a5393c3a2
File without changes
@@ -0,0 +1,34 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ .*.sw[a-z]
15
+
16
+ ## RubyMine and related
17
+ .idea
18
+
19
+ ## PROJECT::GENERAL
20
+ coverage
21
+ rdoc
22
+ pkg
23
+
24
+ ## PROJECT::SPECIFIC
25
+ *.gem
26
+ .bundle
27
+ Gemfile.lock
28
+ gemfiles/*.gemfile.lock
29
+ pkg/*
30
+ tmp/*
31
+ *.rbc
32
+ *.rbx
33
+ .ruby-gemset
34
+ .ruby-version
@@ -0,0 +1,2 @@
1
+ --rspec-version 2.0.0
2
+ --bundler
@@ -0,0 +1,19 @@
1
+ before_install:
2
+ - gem update --system
3
+ - gem update bundler
4
+ rvm:
5
+ - 2.3.8
6
+ - 2.4.6
7
+ - 2.5.5
8
+ - 2.6.3
9
+ - rbx-2
10
+ - ruby-head
11
+ - jruby-9.1.17.0
12
+ - jruby-9.2.7.0
13
+ - jruby-head
14
+ jdk: openjdk8
15
+ matrix:
16
+ allow_failures:
17
+ - rvm: jruby-head
18
+ - rvm: ruby-head
19
+ - rvm: rbx-2
@@ -0,0 +1,1698 @@
1
+ # Changelog
2
+
3
+ ## 3.7.1
4
+
5
+ * Fixed Async::HTTP::Client adapter code to not cause Ruby warning
6
+
7
+ Thanks to [y-yagi](https://github.com/y-yagi)
8
+
9
+ ## 3.7.0
10
+
11
+ * Support for Async::HTTP::Client
12
+
13
+ Thanks to [Andriy Yanko](https://github.com/ayanko)
14
+
15
+ ## 3.6.2
16
+
17
+ * Fixed Patron adapter to handle HTTP/2 status line.
18
+
19
+ Thanks to [Fábio D. Batista](https://github.com/fabiob)
20
+
21
+ ## 3.6.1
22
+
23
+ * Fixed issue with matching Addressable::Template without a period in the domain
24
+
25
+ Thanks to [Eike Send](https://github.com/eikes)
26
+
27
+ * Support for `write_timeout` in Net::HTTP
28
+
29
+ Thanks to [Claudio Poli](https://github.com/masterkain)
30
+
31
+ * Fixed issue with handling urls with ":80" or ":443" in the path.
32
+
33
+ Thanks to [Csaba Apagyi](https://github.com/thisismydesign) for reporting and to [Frederick Cheung](https://github.com/fcheung) for fixing the issue.
34
+
35
+ ## 3.6.0
36
+
37
+ * Compatibility with the latest version of hashdiff gem, with constant changed from HashDiff to Hashdiff
38
+
39
+ Thanks to [Jeff Felchner](https://github.com/jfelchner)
40
+
41
+ * Added a hint to the error message raised when `with` method is called without args or a block.
42
+
43
+ Thanks to [Adam Sokolnicki](https://github.com/asok)
44
+
45
+ * Resetting configured HTTP method in Curb adapter after each request
46
+
47
+ Thanks to [tiendo1011](https://github.com/tiendo1011)
48
+
49
+ * Added `WebMock.enable_net_connect!` as an alias for `WebMock.allow_net_connect!`
50
+ and `WebMock.disallow_net_connect!` as an alias for `WebMock.disable_net_connect!`
51
+
52
+ Thanks to [SoonKhen OwYong](https://github.com/owyongsk)
53
+
54
+ * Fixed handling of empty arrays as query params when using Faraday
55
+
56
+ Thanks to [Ryan Moret](https://github.com/rcmoret)
57
+
58
+ ## 3.5.1
59
+
60
+ * Disabling TracePoint defined in Net::BufferedIO in case of exception being raised.
61
+
62
+ Thanks to [Koichi Sasada](https://github.com/ko1)
63
+
64
+
65
+ ## 3.5.0
66
+
67
+ * Ruby 2.6.0 support
68
+
69
+ Thanks to [Arkadiy Tetelman](https://github.com/arkadiyt)
70
+
71
+ * Added `WebMock.reset_executed_requests!` method.
72
+
73
+ stub_get = stub_request(:get, "www.example.com")
74
+ Net::HTTP.get('www.example.com', '/')
75
+ WebMock::RequestRegistry.instance.times_executed(stub_get.request_pattern) # => 1
76
+ reset_executed_requests!
77
+ WebMock::RequestRegistry.instance.times_executed(stub_get.request_pattern) # => 0
78
+
79
+ Thanks to [Olia Kremmyda](https://github.com/oliakremmyda)
80
+
81
+ * Performance improvements
82
+
83
+ Thanks to [Pavel Rosický](https://github.com/ahorek)
84
+
85
+ ## 3.4.2
86
+
87
+ * Fixed `rbuf_fill` in Net::HTTP adapter to be thread-safe
88
+
89
+ Thanks to [Arkadiy Tetelman](https://github.com/arkadiyt)
90
+
91
+ * Fix invalid scheme error with Addressable::Template
92
+
93
+ Thanks to [Kazato Sugimoto](https://github.com/uiureo)
94
+
95
+ ## 3.4.1
96
+
97
+ * When comparing url encoded body to a body from request stub, which was declared as hash, only String, Numeric and boolean hash values are stringified before the comparison.
98
+
99
+ Thanks to [Lukas Pokorny](https://github.com/luk4s)
100
+
101
+ ## 3.4.0
102
+
103
+ * Ruby 2.6 support. Prevent `Net/ReadTimeout` error in Ruby 2.6
104
+
105
+ Thanks to [Koichi ITO](https://github.com/koic)
106
+
107
+ * Handling query params, which represent nested hashes with keys starting with non word characters.
108
+
109
+ Thanks to [rapides](https://github.com/rapides) for reporting the issue.
110
+
111
+ * Patron adapter handles PATCH requests with body.
112
+
113
+ Thanks to [Mattia](https://github.com/iMacTia) for reporting the issue.
114
+
115
+ * Allowing requests with url encoded body to be matched by request stubs declared with hash body with non-string values.
116
+
117
+ stub_request(:post, "www.example.com").with(body: {"a" => 1, "b" => false})
118
+
119
+ RestClient.post('www.example.com', 'a=1&b=false', :content_type => 'application/x-www-form-urlencoded') # ===> Success
120
+
121
+ Thanks to [Kenny Ortmann](https://github.com/yairgo) for suggesting this feature.
122
+
123
+ * When request headers contain 'Accept'=>'application/json' and no registered stub matches the request, WebMock prints a suggested stub code with to_return body set to '{}'.
124
+
125
+ Thanks to [redbar0n](https://github.com/redbar0n)
126
+
127
+ * Improved suggested stub output when the request stub only contains headers declaration.
128
+
129
+ Thanks to [Olia Kremmyda](https://github.com/oliakremmyda)
130
+
131
+ * Fixed Curb adapter to handle `reset` method.
132
+
133
+ Thanks tp [dinhhuydh](https://github.com/dinhhuydh) for reporting the issue.
134
+ Thanks to [Olia Kremmyda](https://github.com/oliakremmyda) for fixing it.
135
+
136
+
137
+ ## 3.3.0
138
+
139
+ * Better formatting of outputted request stub snippets, displayed on failures due to unstubbed requests.
140
+
141
+ Thanks to [Olia Kremmyda](https://github.com/oliakremmyda)
142
+
143
+
144
+ ## 3.2.1
145
+
146
+ * Fixed Ruby warning under Ruby 2.5
147
+
148
+ Thanks to [Matt Brictson](https://github.com/mattbrictson)
149
+
150
+
151
+ ## 3.2.0
152
+
153
+ * Automatically disable WebMock after Rspec suite
154
+
155
+ Thanks to [Michał Matyas](https://github.com/d4rky-pl)
156
+
157
+ * Fixed bug when handling redirection using Curb.
158
+
159
+ Thanks to [Olia Kremmyda](https://github.com/oliakremmyda)
160
+
161
+
162
+ ## 3.1.1
163
+
164
+ * Warning message is displayed only once when adding query params to URIAddressablePattern.
165
+
166
+ ## 3.1.0
167
+
168
+ * http.rb 3.0.0 compatibility
169
+
170
+ Thanks to [Piotr Boniecki](https://github.com/Bonias)
171
+
172
+ * Typhoeus 1.3.0 support
173
+
174
+ Thanks to [NARUSE, Yui](https://github.com/nurse)
175
+
176
+ * Added support for matching partial query params using hash_excluding
177
+
178
+ stub_request(:get, "www.example.com").
179
+ with(query: hash_excluding({"a" => "b"}))
180
+
181
+ RestClient.get("http://www.example.com/?a=b") # ===> Failure
182
+ RestClient.get("http://www.example.com/?a=c") # ===> Success
183
+
184
+ Thanks to [Olexandr Hoshylyk](https://github.com/Warrior109)
185
+
186
+ * Added MRI 2.3+ frozen string literal compatibility
187
+
188
+ Thanks to [Pat Allan](https://github.com/pat)
189
+
190
+ * Ensured that HTTPClient adapter does not yield block on empty response body if a block is provided
191
+
192
+ Thanks to [NARUSE, Yui](https://github.com/nurse)
193
+
194
+ * Fixed issue with `to_timeout` incorrectly raising `HTTP::ConnectionError` instead of `HTTP::TimeoutError` when using http.rb
195
+
196
+ Thanks to [Rick Song](https://github.com/RickCSong)
197
+
198
+ * Fixed problem with `response.connection.close` method being undefined when using http.rb
199
+
200
+ Thanks to [Janko Marohnić](https://github.com/janko-m)
201
+
202
+ * Fixed problem with matching Net::HTTP request header values assigned as numbers.
203
+
204
+ Thanks to [Felipe Constantino de Oliveira](https://github.com/felipecdo) for reporting the issue.
205
+
206
+ * Fixed problem with Net::HTTP adapter converting empty response body to nil for non 204 responses.
207
+
208
+ Thanks to [Jeffrey Charles](https://github.com/jeffcharles) for reporting the issue.
209
+
210
+
211
+ ## 3.0.1
212
+
213
+ * Suppressed \`warning: \`&' interpreted as argument prefix\`
214
+
215
+ Thanks to [Koichi ITO](https://github.com/koic)
216
+
217
+ ## 3.0.0
218
+
219
+ * Dropped support for Ruby 1.9.3
220
+
221
+ * Using Ruby >= 1.9 hash key syntax in stub suggestions
222
+
223
+ Thanks to [Tarmo Tänav](https://github.com/tarmo)
224
+
225
+ * Add at_least matchers for fakeweb-style expectations
226
+
227
+ Thanks to [Joe Marty](https://github.com/mltsy)
228
+
229
+ * Fix against "can't modify frozen String' error when Ruby option `frozen_string_literal` is enabled.
230
+
231
+ Thanks to [Chris Thomson](https://github.com/christhomson)
232
+
233
+ * Handling `read_timeout` option in Net::HTTP in Ruby >= 2.4
234
+
235
+ Thanks to [Christof Koenig](https://github.com/ckoenig)
236
+
237
+ * `RequestRegistry` fix for `RuntimeError - can't add a new key into hash during iteration`
238
+
239
+ Thanks to [Chung-Yi Chi](https://github.com/starsirius)
240
+
241
+ ## 2.3.2
242
+
243
+ * Restored support for Ruby 1.9.3 to comply with semantic versioning.
244
+
245
+ Thanks to [Jordan Harband](https://github.com/ljharb) for reporting the problem.
246
+
247
+ ## 2.3.1
248
+
249
+ * Added support for Ruby 2.4
250
+
251
+ Thanks to [Koichi ITO](https://github.com/koic)
252
+
253
+ * Dropped support for Ruby 1.9.3
254
+
255
+ ## 2.2.0
256
+
257
+ * Added `refute_requested` as an alias for `assert_not_requested`
258
+
259
+ Thanks to [Michael Grosser](https://github.com/grosser)
260
+
261
+ * Raising `Net::OpenTimeout` instead of `Timeout::Error` if available when a request stub is declared `to_timeout`
262
+
263
+ Thanks to [Gabe Martin-Dempesy](https://github.com/gabetax)
264
+
265
+ ## 2.1.1
266
+
267
+ * Added support for handling status messages in Excon responses.
268
+
269
+ Thanks to [Tero Marttila](https://github.com/SpComb) for reporting the issue.
270
+
271
+ ## 2.1.0
272
+
273
+ * Added support for `on_debug` callback in Curb.
274
+
275
+ Thanks to [Pavel Jurašek](https://github.com/pavel-jurasek-bcgdv-com)
276
+
277
+ * Added support for PATCH requests using Curb.
278
+
279
+ Thanks to [Pavel Jurašek](https://github.com/pavel-jurasek-bcgdv-com)
280
+
281
+ ## 2.0.3
282
+
283
+ * Handling headers passed as an Array to Curl::Easy
284
+
285
+ Thanks to [Chelsea](https://github.com/grosscr) for reporting the issue.
286
+
287
+ * Removed Ruby warnings.
288
+
289
+ Thanks to [Aaron Kromer](https://github.com/cupakromer)
290
+
291
+ ## 2.0.2
292
+
293
+ * Using `Base64.strict_encode64` instead of `Base64.encode64` to handle long user:pass basic auth credentials
294
+
295
+ Thanks to [Jonathan Schatz](https://github.com/modosc)
296
+
297
+ * Fixed handling of Authorisation header provided as string instead of array when using em-http-request.
298
+
299
+ Thanks to [Michael Richardson](https://github.com/TTransmit) for reporing the issue.
300
+
301
+ * Ensured `WebMock.net_connect_explicit_allowed?` always returns boolean.
302
+
303
+ Thanks tp [Jose Luis Honorato](https://github.com/jlhonora)
304
+
305
+ ## 2.0.1
306
+
307
+ * Added code responsible for loading em-http-request if available, which has been removed by mistake.
308
+
309
+ Thanks to [Vasiliy](https://github.com/304)
310
+
311
+ * WebMock loads "base64" if it's not yet loaded.
312
+
313
+ Thanks to [Taiki Ono](https://github.com/taiki45).
314
+
315
+ ## 2.0.0
316
+
317
+ * `require 'webmock'` does not enable WebMock anymore. `gem 'webmock'` can now be safely added to a Gemfile and no http client libs will be modified when it's loaded. Call `WebMock.enable!` to enable WebMock.
318
+
319
+ Please note that `require 'webmock/rspec'`, `require 'webmock/test_unit'`, `require 'webmock/minitest'` and `require 'webmock/cucumber'` still do enable WebMock.
320
+
321
+ * Dropped support for Ruby < 1.9.3
322
+
323
+ * Dropped support for em-http-request < 1.0.0
324
+
325
+ * WebMock 2.0 does not match basic authentication credentials in the userinfo part of the url, with credentials passed in `Authorization: Basic ...` header anymore.
326
+ It now treats the Authorization header and credentials in the userinfo part of a url as two completely separate attributes of a request.
327
+
328
+ The following stub declaration, which used to work in WebMock 1.x, is not going to work anymore
329
+
330
+ stub_request(:get, "user:pass@www.example.com")
331
+
332
+ Net::HTTP.start('www.example.com') do |http|
333
+ req = Net::HTTP::Get.new('/')
334
+ req.basic_auth 'user', 'pass'
335
+ http.request(req)
336
+ end # ===> Failure
337
+
338
+ In order to stub a request with basic authentication credentials provided in the Authorization header, please use the following code:
339
+
340
+ stub_request(:get, "www.example.com").with(basic_auth: ['user', 'pass'])
341
+
342
+ or
343
+
344
+ stub_request(:get, "www.example.com").
345
+ with(headers: 'Authorization' => "Basic #{ Base64.strict_encode64('user:pass').chomp}")
346
+
347
+ In order to stub a request with basic authentication credentials provided in the url, please use the following code:
348
+
349
+ stub_request(:get, "user:pass@www.example.com")
350
+
351
+ RestClient.get('user:pass@www.example.com') # ===> Success
352
+
353
+ ## 1.24.6
354
+
355
+ * Fixed issue with RUBY_VERSION comparison using old RubyGems.
356
+
357
+ Thanks to [Chris Griego](https://github.com/cgriego).
358
+
359
+ * Support for http.rb >= 2.0.0
360
+
361
+ ## 1.24.4
362
+
363
+ * Fixed the issue with parsing query to a hash with nested array i.e. `a[][b][]=one&a[][c][]=two`
364
+
365
+ Thanks to [Tim Diggins](https://github.com/timdiggins) for reporting the issue.
366
+ Thanks to [Cedric Pimenta](https://github.com/cedricpim) for finding the solution.
367
+
368
+ ## 1.24.3
369
+
370
+ * Allow Net:HTTP headers keys to be provided as symbols if `RUBY_VERSION` >= 2.3.0
371
+
372
+ Thanks to [Alex Kestner](https://github.com/akestner)
373
+
374
+ * Added a clear message on an attempt to match a multipart encoded request body.
375
+ WebMock doesn't support requests with multipart body... yet.
376
+
377
+ * `WebMock.disable_net_connect` `:allow` option, provided as regexp, matches https URIs correctly.
378
+
379
+ * `WebMock.disable_net_connect` `:allow` option can be set as a url string with scheme, host and port.
380
+
381
+ WebMock.disable_net_connect!(:allow => 'https://www.google.pl')
382
+
383
+ Thanks to [Gabriel Chaney](https://github.com/gabrieljoelc) for reporting the issue.
384
+
385
+ ## 1.24.2
386
+
387
+ * Improve parsing of params on request
388
+
389
+ Thanks to [Cedric Pimenta](https://github.com/cedricpim)
390
+
391
+ ## 1.24.1
392
+
393
+ * HTTPClient adapter supports reading basic authentication credentials directly from Authorization header.
394
+
395
+ Thanks to [Michiel Karnebeek](https://github.com/mkarnebeek)
396
+
397
+ ## 1.24.0
398
+
399
+ * Enabled support for Curb > 0.8.6
400
+
401
+ ## 1.23.0
402
+
403
+ * `WebMock.disable_net_connect` accepts `:allow` option with an object that responds to `#call`, receiving a `URI` object and returning a boolean:
404
+
405
+
406
+ blacklist = ['google.com', 'facebook.com', 'apple.com']
407
+ allowed_sites = lambda{|uri|
408
+ blacklist.none?{|site| uri.host.include?(site) }
409
+ }
410
+ WebMock.disable_net_connect!(:allow => allowed_sites)
411
+
412
+ RestClient.get('www.example.org', '/') # ===> Allowed
413
+ RestClient.get('www.facebook.com', '/') # ===> Failure
414
+ RestClient.get('apple.com', '/') # ===> Failure
415
+
416
+ Thanks to [Pablo Brasero](https://github.com/pablobm)
417
+
418
+ * Support for HTTPClient stream responses with body chunks
419
+
420
+ Thanks to [Cedric Pimenta](https://github.com/cedricpim)
421
+
422
+
423
+ ## 1.22.6
424
+
425
+ * Fixes [issue](https://github.com/bblimke/webmock/issues/568) around
426
+ WebMock restricting [Addressable](https://github.com/sporkmonger/addressable)
427
+ version, based on Ruby 1.8.7 for all versions of Ruby.
428
+
429
+ This change inverts that, and forces Ruby 1.8.7 users to specify in thier
430
+ Gemfile an Addressable version < 2.4.0.
431
+
432
+ Thanks to [PikachuEXE](https://github.com/PikachuEXE) and
433
+ [Matthew Rudy Jacobs](https://github.com/matthewrudy).
434
+
435
+ ## 1.22.5
436
+
437
+ * Fixes [bug](https://github.com/bblimke/webmock/issues/565) where WebMock tries
438
+ to alias a method that is deprecated in Ruby Versions > 1.9.2 ('sysread' for class 'StringIO')
439
+
440
+ Thanks to [Marcos Acosta](https://github.com/mmaa) for discovering this bug.
441
+
442
+ ## 1.22.4
443
+
444
+ * Adds support for JSONClient (a subclass of HTTPClient)
445
+
446
+ Thanks to [Andrew Kozin](https://github.com/nepalez)
447
+
448
+ * Adds support for Ruby 2.3.0
449
+
450
+ Thanks to [Charles Pence](https://github.com/cpence)
451
+
452
+ * Adds support for [http](https://github.com/httprb/http) versions >= 1.0.0
453
+
454
+ Thanks to [Alexey Zapparov](https://github.com/ixti)
455
+
456
+ * Fixes support for Ruby 1.8.7 by restrciting Addressable version < 2.4.0
457
+
458
+ Thanks to [Matthew Rudy Jacobs](https://github.com/matthewrudy)
459
+
460
+ ## 1.22.3
461
+
462
+ * Return "effective_url" attribute in Typhoeus::Response
463
+
464
+ Thanks to [Senya](https://github.com/cmrd-senya)
465
+
466
+ ## 1.22.2
467
+
468
+ * Fix: prevents adding an extra =true to urls with parameters without values
469
+
470
+ Thanks to [David Begin](https://github.com/davidbegin)
471
+
472
+ ## 1.22.1
473
+
474
+ * Adds Rack as a development dependency and removes require rack/utils in main lib.
475
+
476
+ Thanks to [Keenan Brock](https://github.com/kbrock)
477
+
478
+ ## 1.22.0
479
+
480
+ All the credit for preparing this release go to [David Begin](https://github.com/davidbegin)!
481
+
482
+ * Adds [Manticore](https://github.com/cheald/manticore) support.
483
+
484
+ Thanks to [Mike Knepper](https://github.com/mikeknep), [David Abdemoulaie](https://github.com/hobodave)
485
+
486
+ * Update to Show a hash diff for requests that have stubs with a body.
487
+
488
+ Thanks to [yurivm](https://github.com/yurivm)
489
+
490
+ * Update to mirror Net::HTTP handling of headers as symbols
491
+
492
+ * Update to ignore non-comparable-values error when sorting
493
+ query values, because sorting is just a convience.
494
+
495
+ Thanks to [Magne Land](https://github.com/magneland)
496
+
497
+ * Covert Boolean values to Strings when using them to define
498
+ the body of a request.
499
+
500
+ Thanks to [Krzysztof Rygielski](https://github.com/riggy)
501
+
502
+ * Fixes WebMock's parsing Multibyte characters
503
+
504
+ Thanks to [Zhao Wen](https://github.com/VincentZhao)
505
+
506
+ * Updates to be compatible with httpclient 2.6.0
507
+
508
+ * Converts keys from symbols to strings when for QueryMapper.to_query
509
+
510
+ Thanks to [Ramon Tayag](https://github.com/ramontayag)
511
+
512
+ * Restricts http.rb version to 0.7.3 for Ruby 1.8.7
513
+
514
+ * Fixes issue emulating em-http-request's handling of multiple requests.
515
+
516
+ Thanks to [Matt Palmer](https://github.com/mpalmer)
517
+
518
+ * WebMock requires only the necessary parts of crack to avoid pulling in safe_yaml
519
+
520
+ Thanks to [Johannes Schlumberger](https://github.com/spjsschl)
521
+
522
+ ## 1.21.0
523
+
524
+ * Support for http.rb >= 0.8.0
525
+
526
+ Thanks to [Zachary Anker](https://github.com/zanker), [Aleksey V. Zapparov](https://github.com/ixti)
527
+
528
+ * Support for http.rb 0.7.0
529
+
530
+ Thanks to [Mattias Putman](https://github.com/challengee)
531
+
532
+ * Added support for RSpec3-like `and_return`, `and_raise`, `and_timeout` syntax.
533
+
534
+ Thanks to [Franky Wahl](https://github.com/frankywahl)
535
+
536
+ * Restricted Curb support up to version 0.8.6. WebMock specs fail with Curb 0.8.7.
537
+
538
+ ## 1.20.4
539
+
540
+ * Fixed support for `hash_including` matcher in RSpec 3
541
+
542
+ ## 1.20.3
543
+
544
+ * `with` method raises error if provided without options hash and without block
545
+
546
+ * `with` and `to_return` raise an error if invoked with invalid keys in options hash.
547
+
548
+ ## 1.20.2
549
+
550
+ * WebMock provides a helpful error message if an incompatible object is given as response body.
551
+
552
+ Thanks to [Mark Lorenz](https://github.com/dapplebeforedawn)
553
+
554
+ ## 1.20.1
555
+
556
+ * `assert_requested` and `assert_not_requested` accept `at_least_times` and `at_most_times` options
557
+
558
+ Thanks to [Dan Buettner](https://github.com/Capncavedan)
559
+
560
+ * Silenced `instance variable undefined` warnings in Curb adapted.
561
+
562
+ Thanks to [Sven Riedel](https://github.com/sriedel)
563
+
564
+ ## 1.20.0
565
+
566
+ * Add support for on_missing callback of Curb::Easy
567
+
568
+ Thanks to [Tasos Stathopoulos](https://github.com/astathopoulos)
569
+
570
+ * Add at_least_times and at_most_times matchers
571
+
572
+ Thanks to [Dan Buettner](https://github.com/Capncavedan)
573
+
574
+ ## 1.19.0
575
+
576
+ * Fixed issue with Excon adapter giving warning message when redirects middleware was enabled.
577
+
578
+ Thanks to [Theo Hultberg](https://github.com/iconara) for reporting that.
579
+
580
+ * Fixed issue with `undefined method 'valid_request_keys' for Excon::Utils:Module`
581
+
582
+ Thanks to [Pablo Jairala](https://github.com/davidjairala)
583
+
584
+ * Fixed query mapper to encode `'one' => ['1','2']` as `'one[]=1&one[]=2'`.
585
+
586
+ Thanks to [Insoo Buzz Jung](https://github.com/insoul)
587
+
588
+ * Improved cookies support for em-http-request
589
+
590
+ Thanks to [Carlos Alonso Pérez](https://github.com/calonso)
591
+
592
+ * Fix HTTP Gem adapter to ensure uri attribute is set on response object.
593
+
594
+ Thanks to [Aleksey V. Zapparov](https://github.com/ixti)
595
+
596
+ * Fixed HTTPClient adapter. The response header now receives `request_method`, `request_uri`, and `request_query` transferred from request header
597
+
598
+ Thanks to [trlorenz](https://github.com/trlorenz)
599
+
600
+ * Query mapper supports nested data structures i.e. `{"first" => [{"two" => [{"three" => "four"}, "five"]}]}`
601
+
602
+ Thanks to [Alexander Simonov](https://github.com/simonoff)
603
+
604
+ * Fixed compatibility with latest versions of Excon which don't define `VALID_REQUEST_KEYS` anymore.
605
+
606
+ Thanks to [Pablo Jairala](https://github.com/davidjairala)
607
+
608
+ * Request method is always a symbol is request signatures. This fixes the issue of WebMock not matching Typhoeus requests with request method defined as string.
609
+
610
+ Thanks to [Thorbjørn Hermanse](https://github.com/thhermansen)
611
+
612
+ * Stubbing instructions which are displayed when no matching stub is found, can be disabled with `Config.instance.show_stubbing_instructions = false`
613
+
614
+ Thanks to [Mark Lorenz](https://github.com/dapplebeforedawn)
615
+
616
+ * Notation used for mapping query strings to data structure can be configured i.e. `WebMock::Config.instance.query_values_notation = :subscript`. This allows setting `:flat_array` notation which supports duplicated parameter names in query string.
617
+
618
+ Thanks to [tjsousa](https://github.com/tjsousa)
619
+
620
+ ## 1.18.0
621
+
622
+ * Updated dependency on Addressable to versions >= 2.3.6
623
+
624
+ * Added support for matching uris using RFC 6570 (URI Templates)
625
+
626
+ uri_template = Addressable::Template.new "www.example.com/{id}/"
627
+ stub_request(:any, uri_template)
628
+
629
+ Thanks to [Max Lincoln](https://github.com/maxlinc)
630
+
631
+ * Fixed content length calculation for Rack responses with UTF8 body
632
+
633
+ Thanks to [Oleg Gritsenko](https://github.com/Claster)
634
+
635
+ * Add missing Curl::Easy aliases
636
+
637
+ Thanks to [Hwan-Joon Choi](https://github.com/hc5duke)
638
+
639
+ * HTTP Gem >= 0.6.0 compatibility
640
+
641
+ Thanks to [Aleksey V. Zapparov](https://github.com/ixti)
642
+
643
+ * Minitest 4 and 5 compatibility.
644
+
645
+ Thanks to [SHIBATA Hiroshi](https://github.com/hsbt)
646
+
647
+ ## 1.17.4
648
+
649
+ * Update matchers for RSpec 3's matcher protocol
650
+
651
+ Thanks to [Rob Olson](https://github.com/robolson)
652
+
653
+ ## 1.17.3
654
+
655
+ * Fixed issue with Rack response removing 'Content-Type' header
656
+
657
+ Thanks to [Bo Jeanes](https://github.com/bjeanes) and [Matthew Conway](https://github.com/mattonrails)
658
+
659
+ ## 1.17.2
660
+
661
+ * Support for chunked responses in Curb
662
+
663
+ Thanks to [Zachary Belzer](https://github.com/zbelzer)
664
+
665
+ * Fixed handling of request body passed as a hash to `Typhoeus.post`
666
+
667
+ Thanks to [Mason Chang](https://github.com/changmason) for reporting.
668
+
669
+ ## 1.17.1
670
+
671
+ * Added missing license statements.
672
+
673
+ Thanks to [Praveen Arimbrathodiyil](https://github.com/pravi)
674
+
675
+ ## 1.17.0
676
+
677
+ * HTTP gem support!
678
+
679
+ Thanks to [Aleksey V. Zapparov](https://github.com/ixti)
680
+
681
+ * Limited Excon gem requirement to version < 0.30 until the compatibility with version > 0.30.0 is fixed.
682
+
683
+ Thanks to [Aleksey V. Zapparov](https://github.com/ixti)
684
+
685
+ * Fixed issue where empty query key caused a `TypeError`
686
+
687
+ Thanks to [Jon Rowe](https://github.com/JonRowe)
688
+
689
+ * Handling Typhoeus `on_headers` and `on_body` params.
690
+
691
+ Thanks to [Matt Burke](https://github.com/spraints)
692
+
693
+ ## 1.16.1
694
+
695
+ * Fixed "NameError: uninitialized constant WebMock::Response::Pathname" issue.
696
+
697
+ Thanks to [Alex Stupakow and Karen Wang](https://github.com/stupakov) for the fix.
698
+
699
+ ## 1.16.0
700
+
701
+ * Allow a Pathname to be passed as a Response body
702
+
703
+ stub_request(:get, /example.com/).to_return(
704
+ body: Rails.root.join('test/fixtures/foo.txt')
705
+ )
706
+
707
+ Thanks to [Ben Pickles](https://github.com/benpickles)
708
+
709
+ * `hash_including` matcher can be initialized with empty keys to match any values.
710
+
711
+ stub_request(:post, "www.example.com").with(:body => hash_including(:a, :b => {'c'}))
712
+ RestClient.post('www.example.com', '{"a":"1","b":"c"}', :content_type => 'application/json')
713
+
714
+ Thanks to [Stefano Uliari](https://github.com/steookk)
715
+
716
+ ## 1.15.2
717
+
718
+ * Fixed `hash_including` to accept a splat of solitary keys.
719
+
720
+ Thanks to [Tamir Duberstein](https://github.com/tamird) and [https://github.com/strongriley](https://github.com/strongriley)
721
+
722
+ ## 1.15.0
723
+
724
+ * Excon >= 0.27.5 compatibility.
725
+
726
+ Thanks to [Brian D. Burns](https://github.com/burns)
727
+
728
+ ## 1.14.0
729
+
730
+ * Handling non UTF-8 characters in query params.
731
+
732
+ Thanks to [Florian Dütsch](https://github.com/der-flo) for reporting the issue.
733
+
734
+ * Added support for `request_block` param in Excon
735
+
736
+ Thanks to [Dmitry Gutov](https://github.com/dgutov) for reporting the issue.
737
+
738
+ * Fixed compatibility with latest Curb
739
+
740
+ Thanks to [Ian Lesperance](https://github.com/elliterate) and [Matthew Horan](https://github.com/mhoran)
741
+
742
+ * Triggering errbacks assynchronously in em-http-request adapter.
743
+
744
+ Thanks to [Ian Lesperance](https://github.com/elliterate) and [Matthew Horan](https://github.com/mhoran)
745
+
746
+ * Handling query params with a hashes nested inside arrays.
747
+
748
+ Thanks to [Ian Asaff](https://github.com/montague)
749
+
750
+ * Changed NetConnectNotAllowedError to inherit from Exception to allow it to bubble up into a test suite.
751
+
752
+ Thanks to [Daniel van Hoesel](https://github.com/s0meone)
753
+
754
+ * HTTPClient adapter is thread safe.
755
+
756
+ Thanks to [Tom Beauvais](https://github.com/tbeauvais)
757
+
758
+ ## 1.13.0
759
+
760
+ * Net::HTTP::Persistent compatibility.
761
+ WebMock doesn't disconnect previously started connections upon a request anymore.
762
+
763
+
764
+ ## 1.12.3
765
+
766
+ * Fixed issue with handling Addressable::URI with query params passed to `Net::HTTP.get_response`
767
+
768
+ Thanks to [Leif Bladt](https://github.com/leifbladt)
769
+
770
+ * Fixed HTTPClient adapter to not raise an error if a request with multipart body is executed.
771
+
772
+ ## 1.12.2
773
+
774
+ * Fixed issue with handling request.path when Addressable::URI is passed to #request instead of URI with Ruby 2.0.
775
+
776
+ Thanks to [Leif Bladt](https://github.com/leifbladt)
777
+
778
+ * Accept integers as query param values in request stubs
779
+
780
+ i.e. `stub_request(:get, /.*/).with(:query => {"a" => 1})`
781
+
782
+ Thanks to [Mitsutaka Mimura](https://github.com/takkanm)
783
+
784
+ ## 1.12.1
785
+
786
+ * Fixed Minitest < 5.0 compatibility
787
+
788
+ Thanks to [Alex Tomlins](https://github.com/alext) for reporting the issue.
789
+
790
+ ## 1.12.0
791
+
792
+ * Not using Gem spec anymore to check loaded Curb version.
793
+
794
+ * `WebMock.disable_net_connect!` now accepts array of regexps as allow param:
795
+
796
+ i.e. `WebMock.disable_net_connect!(:allow => [/google.com/, /yahoo.com/])`
797
+
798
+ Thanks to [Bastien Vaucher](https://github.com/bastien)
799
+
800
+ * Fixed `on_header` Curb callback behaviour in Curb adapter
801
+
802
+ Thanks to [Joel Chippindale](https://github.com/mocoso)
803
+
804
+ * Fixed aws-sdk compatibility with Ruby 2.0, by supporting `continue_timeout` accessor on Net::HTTP socket.
805
+
806
+ Thanks to [Lin Jen-Shin](https://github.com/godfat)
807
+
808
+ * Fixed WebMock::Server to not give "log writing failed. can't be called from trap context" warning with Ruby 2.0
809
+
810
+ Thanks to [Murahashi Sanemat Kenichi](https://github.com/sanemat)
811
+
812
+ * Added support for EM-HTTP-Request streaming data off disk feature.
813
+
814
+ Thanks to [Lin Jen-Shin](https://github.com/godfat)
815
+
816
+ * Added compatibility with Minitest 5
817
+
818
+ Thanks to [Tim Kurvers](https://github.com/timkurvers)
819
+
820
+ * Excon >= 0.22 compatibility.
821
+
822
+ * README has nice sytnax hightlighting and fixed code styling!
823
+
824
+ Thanks to [Ilya Vassilevsky](https://github.com/vassilevsky)
825
+
826
+ * Compatibility with Rails 4 `rack.session.options`
827
+
828
+ Thanks to [gotwalt](https://github.com/gotwalt)
829
+
830
+ ## 1.11.0
831
+
832
+ * Excon >= 0.17 support.
833
+
834
+ Thanks to [Nathan Sutton](https://github.com/nate) for reporting this issue and to [Wesley Beary](https://github.com/geemus) and [Myron Marston](https://github.com/myronmarston) for help.
835
+
836
+ ## 1.10.2
837
+
838
+ * '+' in request path is treated as plus, but in query params always as a space.
839
+
840
+ ## 1.10.1
841
+
842
+ * '+' in request body is still treated as a space. This fixes a bug introduced in previous version.
843
+
844
+ Thanks to [Erik Michaels-Ober](https://github.com/sferik) for reporting this problem.
845
+
846
+ * Fixed issue: response body declared as Proc was not evaluated again on subsequent requests.
847
+
848
+ Thanks to [Rick Fletcher](https://github.com/rfletcher) for reporting this issue.
849
+
850
+ ## 1.10.0
851
+
852
+ * '+' in query params is not treated as space anymore and is encoded as %2B
853
+
854
+ Thanks to [goblin](https://github.com/goblin) for reporting this issue.
855
+
856
+ * added `remove_request_stub` method to the api to allow removing unused stubs i.e.
857
+
858
+ stub_get = stub_request(:get, "www.example.com")
859
+ remove_request_stub(stub_get)
860
+
861
+ * `assert_requested` and `assert_not_requested` raise an error if a stub object is provided together with a block.
862
+
863
+ ## 1.9.3
864
+
865
+ * Fixed issue with unavailable constant Mutex in Ruby < 1.9
866
+
867
+ Thanks to [Lucas Dohmen](https://github.com/moonglum) for reporting this issue.
868
+
869
+ ## 1.9.2
870
+
871
+ * Added support for Excon's :response_block parameter
872
+
873
+ Thanks to [Myron Marston](https://github.com/myronmarston) for reporting this issue.
874
+
875
+ ## 1.9.1
876
+
877
+ * Fix 'rack.errors' not being set for Rack apps
878
+
879
+ Thanks to [Alex Grant](https://github.com/grantovich)
880
+
881
+ * Added support for minitest assertions count
882
+
883
+ Thanks to [Mokevnin Kirill](https://github.com/mokevnin)
884
+
885
+ * Fixed issues with registering http requests in multi-threaded environments
886
+
887
+ Thanks to [Tom Beauvais](https://github.com/tbeauvais)
888
+
889
+ * Bumped Crack version to >=0.3.2
890
+
891
+ Thanks to [Jake Benilov](https://github.com/benilovj)
892
+
893
+ * Fixed issues in Typhoeus 0.6. Defaulted method to GET when no method specified.
894
+
895
+ Thanks to [Hans Hasselberg](https://github.com/i0rek)
896
+
897
+ * Add license information to the gemspec
898
+
899
+ Thanks to [Jordi Massaguer Pla](https://github.com/jordimassaguerpla) and [Murahashi Sanemat Kenichi](https://github.com/sanemat)
900
+
901
+ * Added support for :expects option in Excon adapter
902
+
903
+ Thanks to [Evgeniy Dolzhenko](https://github.com/dolzenko)
904
+
905
+ * Fixed Faye compatibility by treating StringIO in Net::HTTP adapter properly
906
+
907
+ Thanks to [Pavel Forkert](https://github.com/fxposter)
908
+
909
+ * Updated VCR link
910
+
911
+ Thanks to [Rex Feng](https://github.com/xta)
912
+
913
+ ## 1.9.0
914
+
915
+ * Added support for Typhoeus >= 0.5.0 and removed support for Typhoeus < 0.5.0.
916
+
917
+ Thanks to [Hans Hasselberg](https://github.com/i0rek)
918
+
919
+ ## 1.8.11
920
+
921
+ * Fix excon adapter to handle `:body => some_file_object`
922
+
923
+ Thanks to [Myron Marston](https://github.com/myronmarston)
924
+
925
+ ## 1.8.10
926
+
927
+ * em-http-request fix. After request callbacks are correctly invoked for 3xx responses,
928
+ when :redirects option is set.
929
+
930
+ Thanks to [Myron Marston](https://github.com/myronmarston) for reporting that issue.
931
+
932
+ * Fixed compatibility with Net::HTTP::DigestAuth
933
+
934
+ Thanks to [Jonathan Hyman](https://github.com/jonhyman) for reporting that issue.
935
+
936
+ * Fixed problem in em-http-request 0.x appending the query to the client URI twice.
937
+
938
+ Thanks to [Paweł Pierzchała](https://github.com/wrozka)
939
+
940
+ ## 1.8.9
941
+
942
+ * Fixed problem with caching nil responses when the same HTTPClient instance is used.
943
+
944
+ Thanks to [Myron Marston](https://github.com/myronmarston)
945
+
946
+ * Added support for Addressable >= 2.3.0. Addressable 2.3.0 removed support for multiple query value notations and broke backwards compatibility.
947
+
948
+ https://github.com/sporkmonger/addressable/commit/f51e290b5f68a98293327a7da84eb9e2d5f21c62
949
+ https://github.com/sporkmonger/addressable/issues/77
950
+
951
+
952
+ ## 1.8.8
953
+
954
+ * Fixed Net::HTTP adapter so that it returns `nil` for an empty body response.
955
+
956
+ Thanks to [Myron Marston](https://github.com/myronmarston)
957
+
958
+ * Gemspec defines compatibility with Addressable ~> 2.2.8, not >= 2.3.0
959
+
960
+ * Specs compatibility with Typhoeus 0.4.0
961
+
962
+ Thanks to [Hans Hasselberg](https://github.com/i0rek)
963
+
964
+ * Handling content types that specify a charset
965
+
966
+ Thanks to [Kevin Glowacz](https://github.com/kjg)
967
+
968
+ * Fixed em-http-request adapter to correctly fetch authorization header from a request
969
+
970
+ Thanks to [Julien Boyer](https://github.com/chatgris)
971
+
972
+ * Fixing travis-ci image to report master's status
973
+
974
+ Thanks to [Ryan Schlesinger](https://github.com/ryansch)
975
+
976
+ * Fixed problem with em-http-request callback triggering if there were other EM::Deferred callbacks registered
977
+
978
+ Thanks to [Jon Leighton](https://github.com/jonleighton)
979
+
980
+ * Fixed problem with em-http-request appending the query to the URI a second time, and
981
+ the parameters are repeated.
982
+
983
+ Thanks to [Jon Leighton](https://github.com/jonleighton)
984
+
985
+ ## 1.8.7
986
+
987
+ * Compatibility with RSpec >= 2.10
988
+
989
+ Thanks to [erwanlr](https://github.com/erwanlr) for reporting this issue.
990
+
991
+ * Add missing required rack environment variable SCRIPT_NAME
992
+
993
+ Thanks to [Eric Oestrich](https://github.com/oestrich)
994
+
995
+ * Fixed warnings due to @query_params not being initialized
996
+
997
+ Thanks to [Ben Bleything](https://github.com/bleything)
998
+
999
+ ## 1.8.6
1000
+
1001
+ * Pass through SERVER_PORT when stubbing to rack
1002
+
1003
+ Thanks to [Eric Oestrich](https://github.com/oestrich)
1004
+
1005
+ * Fixed problem with missing parenthesis in `WebMock#net_connect_allowed?` conditions.
1006
+
1007
+ Thanks to [aindustries](https://github.com/aindustries)
1008
+
1009
+ ## 1.8.5
1010
+
1011
+ * WebMock::RackResponse supports basic auth
1012
+
1013
+ Thanks to [jugyo](https://github.com/jugyo)
1014
+
1015
+ ## 1.8.4
1016
+
1017
+ * Warning message is printed when an unsupported version of a http library is loaded.
1018
+
1019
+ Thanks to [Alexander Staubo](https://github.com/alexstaubo) for reporting the problem and to [Myron Marston](https://github.com/myronmarston) for a help with solution.
1020
+
1021
+ ## 1.8.3
1022
+
1023
+ * Fixed compatibility with latest em-http-request
1024
+
1025
+ Thanks to [Paul Cortens](https://github.com/thoughtless)
1026
+
1027
+ ## 1.8.2
1028
+
1029
+ * Prevent Webmock `hash_including` from overriding RSpec version 1 `hash_including` method.
1030
+
1031
+ Thanks to [Joe Karayusuf](https://github.com/karayusuf)
1032
+
1033
+ * Ensured WebMock handles RSpec 1 `hash_including` matcher for matching query params and body.
1034
+
1035
+ ## 1.8.1
1036
+
1037
+ * Ensured WebMock doesn't interfere with `em-synchrony`, when `em-synchrony/em-http` is not included.
1038
+
1039
+ Thanks to [Nick Recobra](https://github.com/oruen)
1040
+
1041
+ * Improved README
1042
+
1043
+ Thanks to [Jordan Elver](https://github.com/jordelver)
1044
+
1045
+
1046
+ ## 1.8.0
1047
+
1048
+ * Matching request body against partial hash.
1049
+
1050
+ stub_http_request(:post, "www.example.com").
1051
+ with(:body => hash_including({:data => {:a => '1', :b => 'five'}}))
1052
+
1053
+ RestClient.post('www.example.com', "data[a]=1&data[b]=five&x=1",
1054
+ :content_type => 'application/x-www-form-urlencoded') # ===> Success
1055
+
1056
+ request(:post, "www.example.com").
1057
+ with(:body => hash_including({:data => {:a => '1', :b => 'five'}}),
1058
+ :headers => 'Content-Type' => 'application/json').should have_been_made # ===> Success
1059
+
1060
+ Thanks to [Marnen Laibow-Koser](https://github.com/marnen) for help with this solution
1061
+
1062
+ * Matching request query params against partial hash.
1063
+
1064
+ stub_http_request(:get, "www.example.com").with(:query => hash_including({"a" => ["b", "c"]}))
1065
+
1066
+ RestClient.get("http://www.example.com/?a[]=b&a[]=c&x=1") # ===> Success
1067
+
1068
+ request(:get, "www.example.com").
1069
+ with(:query => hash_including({"a" => ["b", "c"]})).should have_been_made # ===> Success
1070
+
1071
+ * Added support for Excon.
1072
+
1073
+ Thanks to [Dimitrij Denissenko](https://github.com/dim)
1074
+
1075
+ * Added support for setting expectations on the request stub with `assert_requested`
1076
+
1077
+ stub_get = stub_request(:get, "www.example.com")
1078
+ stub_post = stub_request(:post, "www.example.com")
1079
+
1080
+ Net::HTTP.get('www.example.com', '/')
1081
+
1082
+ assert_requested(stub_get)
1083
+ assert_not_requested(stub_post)
1084
+
1085
+ Thanks to [Nicolas Fouché](https://github.com/nfo)
1086
+
1087
+ * `WebMock.disable_net_connect!` accepts `RegExp` as `:allow` parameter
1088
+
1089
+ Thanks to [Frank Schumacher](https://github.com/thenoseman)
1090
+
1091
+ * Ensure multiple values for the same header can be recorded and played back
1092
+
1093
+ Thanks to [Myron Marston](https://github.com/myronmarston)
1094
+
1095
+ * Updated dependency on Addressable to version >= 2.2.7 to handle nested hash query values. I.e. `?one[two][three][]=four&one[two][three][]=five`
1096
+
1097
+ * Fixed compatibility with Curb >= 0.7.16 This breaks compatibility with Curb < 0.7.16
1098
+
1099
+ * Fix #to_rack to handle non-array response bodies.
1100
+
1101
+ Thanks to [Tammer Saleh](https://github.com/tsaleh)
1102
+
1103
+ * Added `read_timeout` accessor to StubSocket which fixes compatibility with aws-sdk
1104
+
1105
+ Thanks to [Lin Jen-Shin](https://github.com/godfat)
1106
+
1107
+ * Fix warning "instance variable @query_params not initialized"
1108
+
1109
+ Thanks to [Joe Van Dyk](https://github.com/joevandyk)
1110
+
1111
+ * Using bytesize of message instead of its length for content-length header in em-http-request adapter.
1112
+ This fixes a problem with messages getting truncated in Ruby >= 1.9
1113
+
1114
+ Thanks to [Mark Abramov](https://github.com/markiz)
1115
+
1116
+ * Fixed problem with body params being matched even if params were different.
1117
+
1118
+ Thanks to [Evgeniy Dolzhenko](https://github.com/dolzenko) for reporting this issue.
1119
+
1120
+ ## 1.7.10
1121
+
1122
+ * Yanked 1.7.9 and rebuilt gem on 1.8.7 to deal with syck/psych incompatibilties in gemspec.
1123
+
1124
+ ## 1.7.9
1125
+
1126
+ * Fixed support for native Typhoeus timeouts.
1127
+
1128
+ Thanks to [Albert Llop](https://github.com/mrsimo)
1129
+
1130
+ * Fixed problem with WebMock and RSpec compatibility on TeamCity servers. See [this article](http://www.coding4streetcred.com/blog/post/Issue-RubyMine-31-Webmock-162-and-%E2%80%9CSpecconfigure%E2%80%9D-curse.aspx) for more details.
1131
+
1132
+ Thanks to [Christopher Pickslay](https://github.com/chrispix) from [Two Bit Labs](https://github.com/twobitlabs)
1133
+
1134
+
1135
+ ## 1.7.8
1136
+
1137
+ * Fix each adapter so that it calls a `stub.with` block only once per
1138
+ request. Previously, the block would be called two or three times per
1139
+ request [Myron Marston](https://github.com/myronmarston).
1140
+
1141
+ ## 1.7.7 - RuPy 2011 release
1142
+
1143
+ * Passing response object to a block passed to `HTTPClient#do_get_block`. This fixes `HTTPClient.get_content` failures. [issue 130](https://github.com/bblimke/webmock/pull/130)
1144
+
1145
+ Thanks to [Chris McGrath](https://github.com/chrismcg)
1146
+
1147
+ * Cleaned up ruby warnings when running WebMock code with `-w`.
1148
+
1149
+ Thanks to [Stephen Celis](https://github.com/stephencelis)
1150
+
1151
+ * Curb adapter now correctly calls on_failure for 4xx response codes.
1152
+
1153
+ Thanks to [Eugene Pimenov](https://github.com/libc)
1154
+
1155
+ ## 1.7.6
1156
+
1157
+ * Support for the HTTPClient's request_filter feature
1158
+
1159
+ Thanks to [Roman Shterenzon](https://github.com/romanbsd)
1160
+
1161
+ ## 1.7.5
1162
+
1163
+ * Added support for Patron 0.4.15. This change is not backward compatible so please upgrade Patron to version >= 0.4.15 if you want to use it with WebMock.
1164
+
1165
+ Thanks to [Andreas Garnæs](https://github.com/andreas)
1166
+
1167
+ ## 1.7.4
1168
+
1169
+ * Added support for matching EM-HTTP-Request requests with body declared as a Hash
1170
+
1171
+ Thanks to [David Yeu](https://github.com/daveyeu)
1172
+
1173
+ ## 1.7.3
1174
+
1175
+ * Added `Get`, `Post`, `Delete`, `Put`, `Head`, `Option` constants to replaced `Net::HTTP` to make it possible to marshal objects with these constants assigned to properties. This fixed problem with `tvdb_party` gem which serializes HTTParty responses.
1176
+
1177
+ Thanks to [Klaus Hartl](https://github.com/carhartl) for reporting this issue.
1178
+
1179
+ ## 1.7.2
1180
+
1181
+ * Redefined `const_get` and `constants` methods on the replaced `Net::HTTP` to return same values as original `Net::HTTP`
1182
+
1183
+ ## 1.7.1
1184
+
1185
+ * Redefined `const_defined?` on the replaced `Net::HTTP` so that it returns true if constant is defined on the original `Net::HTTP`. This fixes problems with `"Net::HTTP::Get".constantize`.
1186
+
1187
+ Thanks to [Cássio Marques](https://github.com/cassiomarques) for reporting the issue and to [Myron Marston](https://github.com/myronmarston) for help with the solution.
1188
+
1189
+ ## 1.7.0
1190
+
1191
+ * Fixed Net::HTTP adapter to not break normal Net::HTTP behaviour when network connections are allowed. This fixes **selenium-webdriver compatibility**!!!
1192
+
1193
+ * Added support for EM-HTTP-Request 1.0.x and EM-Synchrony. Thanks to [Steve Hull](https://github.com/sdhull)
1194
+
1195
+ * Added support for setting expectations to on a stub itself i.e.
1196
+
1197
+ stub = stub_request(:get, "www.example.com")
1198
+ # ... make requests ...
1199
+ stub.should have_been_requested
1200
+
1201
+ Thanks to [Aidan Feldman](https://github.com/afeld)
1202
+
1203
+ * Minitest support! Thanks to [Peter Higgins](https://github.com/phiggins)
1204
+
1205
+ * Added support for Typhoeus::Hydra
1206
+
1207
+ * 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)
1208
+
1209
+ * Rack support. Requests can be stubbed to respond with a Rack app i.e.
1210
+
1211
+ class MyRackApp
1212
+ def self.call(env)
1213
+ [200, {}, ["Hello"]]
1214
+ end
1215
+ end
1216
+
1217
+ stub_request(:get, "www.example.com").to_rack(MyRackApp)
1218
+
1219
+ RestClient.get("www.example.com") # ===> "Hello"
1220
+
1221
+
1222
+ Thanks to [Jay Adkisson](https://github.com/jayferd)
1223
+
1224
+ * Added support for selective disabling and enabling of http lib adapters
1225
+
1226
+ WebMock.disable! #disable WebMock (all adapters)
1227
+ WebMock.disable!(:except => [:net_http]) #disable WebMock for all libs except Net::HTTP
1228
+ WebMock.enable! #enable WebMock (all adapters)
1229
+ WebMock.enable!(:except => [:patron]) #enable WebMock for all libs except Patron
1230
+
1231
+ * The error message on an unstubbed request shows a code snippet with body as a hash when it was in url encoded form.
1232
+
1233
+ > RestClient.post('www.example.com', "data[a]=1&data[b]=2", :content_type => 'application/x-www-form-urlencoded')
1234
+
1235
+ WebMock::NetConnectNotAllowedError: Real HTTP connections are disabled....
1236
+
1237
+ You can stub this request with the following snippet:
1238
+
1239
+ stub_request(:post, "http://www.example.com/").
1240
+ with(:body => {"data"=>{"a"=>"1", "b"=>"2"}},
1241
+ :headers => { 'Content-Type'=>'application/x-www-form-urlencoded' }).
1242
+ to_return(:status => 200, :body => "", :headers => {})
1243
+
1244
+ Thanks to [Alex Rothenberg](https://github.com/alexrothenberg)
1245
+
1246
+ * The error message on an unstubbed request shows currently registered request stubs.
1247
+
1248
+ > stub_request(:get, "www.example.net")
1249
+ > stub_request(:get, "www.example.org")
1250
+ > RestClient.get("www.example.com")
1251
+ WebMock::NetConnectNotAllowedError: Real HTTP connections are disabled....
1252
+
1253
+ You can stub this request with the following snippet:
1254
+
1255
+ stub_request(:get, "http://www.example.com/").
1256
+ to_return(:status => 200, :body => "", :headers => {})
1257
+
1258
+ registered request stubs:
1259
+
1260
+ stub_request(:get, "http://www.example.net/")
1261
+ stub_request(:get, "http://www.example.org/")
1262
+
1263
+ Thanks to [Lin Jen-Shin](https://github.com/godfat) for suggesting this feature.
1264
+
1265
+ * 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.
1266
+
1267
+ * 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.
1268
+
1269
+ * External requests can be disabled while allowing selected ports on selected hosts
1270
+
1271
+ WebMock.disable_net_connect!(:allow => "www.example.com:8080")
1272
+ RestClient.get("www.example.com:80") # ===> Failure
1273
+ RestClient.get("www.example.com:8080") # ===> Allowed.
1274
+
1275
+ Thanks to [Zach Dennis](https://github.com/zdennis)
1276
+
1277
+ * Fixed syntax error in README examples, showing the ways of setting request expectations. Thanks to [Nikita Fedyashev](https://github.com/nfedyashev)
1278
+
1279
+
1280
+ **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.**
1281
+
1282
+ ## 1.6.4
1283
+
1284
+ This is a quick slip release to regenerate the gemspec. Apparently
1285
+ jeweler inserts dependencies twice if you use the `gemspec` method in
1286
+ your Gemfile and declare gem dependencies in your gemspec.
1287
+
1288
+ https://github.com/technicalpickles/jeweler/issues/154
1289
+
1290
+ josevalim:
1291
+
1292
+ > This just bit me. I just released a gem with the wrong dependencies
1293
+ > because I have updated jeweler. This should have been opt-in,
1294
+ > otherwise a bunch of people using jeweler are going to release gems
1295
+ > with the wrong dependencies because you are automatically importing
1296
+ > from the Gemfile.
1297
+
1298
+ ## 1.6.3
1299
+
1300
+ * Update the dependency on addressable to get around an issue in v2.2.5.
1301
+ Thanks to [Peter Higgins](https://github.com/phiggins).
1302
+
1303
+ * Add support for matching parameter values using a regular expression
1304
+ as well as a string. Thanks to [Oleg M Prozorov](https://github.com/oleg).
1305
+
1306
+ * Fix integration with httpclient as the internal API has changed.
1307
+ Thanks to [Frank Prößdorf](https://github.com/endor).
1308
+
1309
+ * Ensure Curl::Easy#content_type is always set. Thanks to [Peter
1310
+ Higgins](https://github.com/phiggins).
1311
+
1312
+ * Fix bug with em-http-request adapter stubbing responses that have a
1313
+ chunked transfer encoding. Thanks to [Myron
1314
+ Marston](https://github.com/myronmarston).
1315
+
1316
+ * Fix a load of spec failures with Patron, httpclient, and specs that
1317
+ depended on the behaviour of example.com. Thanks to [Alex
1318
+ Grigorovich](https://github.com/grig).
1319
+
1320
+ ## 1.6.2
1321
+
1322
+ * Em-http-request adapter sets `last_effective_url` property. Thanks to [Sam Stokes](https://github.com/samstokes).
1323
+
1324
+ * Curb adapter supports `Curb::Easy#http_post` and `Curb::Easy#http_put` without arguments (by setting `post_body` or `put_data` beforehand). Thanks to [Eugene Bolshakov](https://github.com/eugenebolshakov)
1325
+
1326
+ ## 1.6.1
1327
+
1328
+ * Fixed issue with `webmock/rspec` which didn't load correctly if `rspec/core` was already required but `rspec/expectations` not.
1329
+
1330
+ ## 1.6.0
1331
+
1332
+ * Simplified integration with Test::Unit, RSpec and Cucumber. Now only a single file has to be required i.e.
1333
+
1334
+ require 'webmock/test_unit'
1335
+ require 'webmock/rspec'
1336
+ require 'webmock/cucumber'
1337
+
1338
+ * 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.
1339
+
1340
+ * The expectation failure message now contains a list of made requests. Thanks to Martyn Loughran for suggesting this feature.
1341
+
1342
+ * Added `WebMock.print_executed_requests` method which can be useful to find out what requests were made until a given point.
1343
+
1344
+ * em-http-request adapter is now activated by replacing EventMachine::HttpRequest constant, instead of monkeypatching the original class.
1345
+
1346
+ 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:
1347
+
1348
+ EventMachine::WebMockHttpRequest.activate!
1349
+ EventMachine::WebMockHttpRequest.deactivate!
1350
+
1351
+ Thanks to Martyn Loughran for suggesting this feature.
1352
+
1353
+ * `WebMock.reset_webmock` is deprecated in favour of new `WebMock.reset!`
1354
+
1355
+ * Fixed integration with Cucumber. Previously documented example didn't work with new versions of Cucumber.
1356
+
1357
+ * Fixed stubbing requests with body declared as a hash. Thanks to Erik Michaels-Ober for reporting the issue.
1358
+
1359
+ * Fixed issue with em-http-request adapter which didn't work when :query option value was passed as a string, not a hash. Thanks to Chee Yeo for reporting the issue.
1360
+
1361
+ * Fixed problem with assert_requested which didn't work if used outside rspec or test/unit
1362
+
1363
+ * Removed dependency on json gem
1364
+
1365
+ ## 1.5.0
1366
+
1367
+ * Support for dynamically evaluated raw responses recorded with `curl -is` <br/>
1368
+ i.e.
1369
+
1370
+ `curl -is www.example.com > /tmp/www.example.com.txt`
1371
+ stub_request(:get, "www.example.com").to_return(lambda { |request| File.new("/tmp/#{request.uri.host.to_s}.txt" }))
1372
+
1373
+ * `:net_http_connect_on_start` option can be passed to `WebMock.allow_net_connect!` and `WebMock.disable_net_connect!` methods, i.e.
1374
+
1375
+ WebMock.allow_net_connect!(:net_http_connect_on_start => true)
1376
+
1377
+ This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`. Check 'Connecting on Net::HTTP.start' in README for more information.
1378
+
1379
+ Thanks to Alastair Brunton for reporting the issue and for fix suggestions.
1380
+
1381
+ * Fixed an issue where Patron spec tried to remove system temporary directory.
1382
+ Thanks to Hans de Graaff
1383
+
1384
+ * WebMock specs now use RSpec 2
1385
+
1386
+ * `rake spec NO_CONNECTION=true` can now be used to only run WebMock specs which do not make real network connections
1387
+
1388
+ ## 1.4.0
1389
+
1390
+ * Curb support!!! Thanks to the awesome work of Pete Higgins!
1391
+
1392
+ * `include WebMock` is now deprecated to avoid method and constant name conflicts. Please `include WebMock::API` instead.
1393
+
1394
+ * `WebMock::API#request` is renamed to `WebMock::API#a_request` to prevent method name conflicts with i.e. Rails controller specs.
1395
+ WebMock.request is still available.
1396
+
1397
+ * 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.
1398
+
1399
+ * Removed `WebMock.response_for_request` and `WebMock.assertion_failure` which were only used internally and were not documented.
1400
+
1401
+ * :allow_localhost => true' now permits 0.0.0.0 in addition to 127.0.0.1 and 'localhost'. Thanks to Myron Marston and Mike Gehard for suggesting this.
1402
+
1403
+ * Fixed issue with both RSpec 1.x and 2.x being available.
1404
+
1405
+ WebMock now tries to use already loaded version of RSpec (1.x or 2.x). Previously it was loading RSpec 2.0 if available, even if RSpec 1.3 was already loaded.
1406
+
1407
+ Thanks to Hans de Graaff for reporting this.
1408
+
1409
+ * Changed runtime dependency on Addressable version 2.2.2 which fixes handling of percent-escaped '+'
1410
+
1411
+ ## 1.3.5
1412
+
1413
+ * External requests can be disabled while allowing selected hosts. Thanks to Charles Li and Ryan Bigg
1414
+
1415
+ This feature was available before only for localhost with `:allow_localhost => true`
1416
+
1417
+ WebMock.disable_net_connect!(:allow => "www.example.org")
1418
+
1419
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
1420
+
1421
+ Net::HTTP.get('www.example.org', '/') # ===> Allowed.
1422
+
1423
+ * Fixed Net::HTTP adapter so that it preserves the original behavior of Net::HTTP.
1424
+
1425
+ When making a request with a block that calls #read_body on the request,
1426
+ Net::HTTP causes the body to be set to a Net::ReadAdapter, but WebMock was causing the body to be set to a string.
1427
+
1428
+ ## 1.3.4
1429
+
1430
+ * Fixed Net::HTTP adapter to handle cases where a block with `read_body` call is passed to `request`.
1431
+ This fixes compatibility with `open-uri`. Thanks to Mark Evans for reporting the issue.
1432
+
1433
+ ## 1.3.3
1434
+
1435
+ * Fixed handling of multiple values for the same response header for Net::HTTP. Thanks to Myron Marston for reporting the issue.
1436
+
1437
+ ## 1.3.2
1438
+
1439
+ * Fixed compatibility with EM-HTTP-Request >= 0.2.9. Thanks to Myron Marston for reporting the issue.
1440
+
1441
+ ## 1.3.1
1442
+
1443
+ * The less hacky way to get the stream behaviour working for em-http-request. Thanks to Martyn Loughran
1444
+
1445
+ * Fixed issues where Net::HTTP was not accepting valid nil response body. Thanks to Muness Alrubaie
1446
+
1447
+ ## 1.3.0
1448
+
1449
+ * Added support for [em-http-request](http://github.com/igrigorik/em-http-request)
1450
+
1451
+ * Matching query params using a hash
1452
+
1453
+ stub_http_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
1454
+
1455
+ RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
1456
+
1457
+ request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]}).should have_been_made # ===> Success
1458
+
1459
+ * Matching request body against a hash. Body can be URL-Encoded, JSON or XML.
1460
+
1461
+ (Thanks to Steve Tooke for the idea and a solution for url-encoded bodies)
1462
+
1463
+ stub_http_request(:post, "www.example.com").
1464
+ with(:body => {:data => {:a => '1', :b => 'five'}})
1465
+
1466
+ RestClient.post('www.example.com', "data[a]=1&data[b]=five",
1467
+ :content_type => 'application/x-www-form-urlencoded') # ===> Success
1468
+
1469
+ RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
1470
+ :content_type => 'application/json') # ===> Success
1471
+
1472
+ RestClient.post('www.example.com', '<data a="1" b="five" />',
1473
+ :content_type => 'application/xml' ) # ===> Success
1474
+
1475
+ request(:post, "www.example.com").
1476
+ with(:body => {:data => {:a => '1', :b => 'five'}},
1477
+ :headers => 'Content-Type' => 'application/json').should have_been_made # ===> Success
1478
+
1479
+ * Request callbacks (Thanks to Myron Marston for all suggestions)
1480
+
1481
+ WebMock can now invoke callbacks for stubbed or real requests:
1482
+
1483
+ WebMock.after_request do |request_signature, response|
1484
+ puts "Request #{request_signature} was made and #{response} was returned"
1485
+ end
1486
+
1487
+ invoke callbacks for real requests only and except requests made with Patron client
1488
+
1489
+ WebMock.after_request(:except => [:patron], :real_requests_only => true) do |request_signature, response|
1490
+ puts "Request #{request_signature} was made and #{response} was returned"
1491
+ end
1492
+
1493
+ * `to_raise()` now accepts an exception instance or a string as argument in addition to an exception class
1494
+
1495
+ stub_request(:any, 'www.example.net').to_raise(StandardError.new("some error"))
1496
+
1497
+ stub_request(:any, 'www.example.net').to_raise("some error")
1498
+
1499
+ * Matching requests based on a URI is 30% faster
1500
+
1501
+ * Fixed constant namespace issues in HTTPClient adapter. Thanks to Nathaniel Bibler for submitting a patch.
1502
+
1503
+ ## 1.2.2
1504
+
1505
+ * Fixed problem where ArgumentError was raised if query params were made up of an array e.g. data[]=a&data[]=b. Thanks to Steve Tooke
1506
+
1507
+ ## 1.2.1
1508
+
1509
+ * Changed license from GPL to MIT
1510
+
1511
+ * Fixed gemspec file. Thanks to Razic
1512
+
1513
+ ## 1.2.0
1514
+
1515
+ * RSpec 2 compatibility. Thanks to Sam Phillips!
1516
+
1517
+ * :allow_localhost => true' now permits 127.0.0.1 as well as 'localhost'. Thanks to Mack Earnhardt
1518
+
1519
+ * Request URI matching in now 2x faster!
1520
+
1521
+
1522
+ ## 1.1.0
1523
+
1524
+ * [VCR](http://github.com/myronmarston/vcr/) compatibility. Many thanks to Myron Marston for all suggestions.
1525
+
1526
+ * Support for stubbing requests and returning responses with multiple headers with the same name. i.e multiple Accept headers.
1527
+
1528
+ stub_http_request(:get, 'www.example.com').
1529
+ with(:headers => {'Accept' => ['image/png', 'image/jpeg']}).
1530
+ to_return(:body => 'abc')
1531
+ RestClient.get('www.example.com',
1532
+ {"Accept" => ['image/png', 'image/jpeg']}) # ===> "abc\n"
1533
+
1534
+ * When real net connections are disabled and unstubbed request is made, WebMock throws WebMock::NetConnectNotAllowedError instead of assertion error or StandardError.
1535
+
1536
+ * Added WebMock.version()
1537
+
1538
+
1539
+ ## 1.0.0
1540
+
1541
+ * Added support for [Patron](http://toland.github.com/patron/)
1542
+
1543
+ * Responses dynamically evaluated from block (idea and implementation by Tom Ward)
1544
+
1545
+ stub_request(:any, 'www.example.net').
1546
+ to_return { |request| {:body => request.body} }
1547
+
1548
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
1549
+
1550
+ * Responses dynamically evaluated from lambda (idea and implementation by Tom Ward)
1551
+
1552
+ stub_request(:any, 'www.example.net').
1553
+ to_return(lambda { |request| {:body => request.body} })
1554
+
1555
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
1556
+
1557
+ * Response with custom status message
1558
+
1559
+ stub_request(:any, "www.example.com").to_return(:status => [500, "Internal Server Error"])
1560
+
1561
+ req = Net::HTTP::Get.new("/")
1562
+ Net::HTTP.start("www.example.com") { |http| http.request(req) }.message # ===> "Internal Server Error"
1563
+
1564
+ * Raising timeout errors (suggested by Jeffrey Jones) (compatibility with Ruby 1.8.6 by Mack Earnhardt)
1565
+
1566
+ stub_request(:any, 'www.example.net').to_timeout
1567
+
1568
+ RestClient.post('www.example.net', 'abc') # ===> RestClient::RequestTimeout
1569
+
1570
+ * External requests can be disabled while allowing localhost (idea and implementation by Mack Earnhardt)
1571
+
1572
+ WebMock.disable_net_connect!(:allow_localhost => true)
1573
+
1574
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
1575
+
1576
+ Net::HTTP.get('localhost:9887', '/') # ===> Allowed. Perhaps to Selenium?
1577
+
1578
+
1579
+ ### Bug fixes
1580
+
1581
+ * Fixed issue where Net::HTTP adapter didn't work for requests with body responding to read (reported by Tekin Suleyman)
1582
+ * Fixed issue where request stub with headers declared as nil was matching requests with non empty headers
1583
+
1584
+ ## 0.9.1
1585
+
1586
+ * Fixed issue where response status code was not read from raw (curl -is) responses
1587
+
1588
+ ## 0.9.0
1589
+
1590
+ * Matching requests against provided block (by Sergio Gil)
1591
+
1592
+ stub_request(:post, "www.example.com").with { |request| request.body == "abc" }.to_return(:body => "def")
1593
+ RestClient.post('www.example.com', 'abc') # ===> "def\n"
1594
+ request(:post, "www.example.com").with { |req| req.body == "abc" }.should have_been_made
1595
+ #or
1596
+ assert_requested(:post, "www.example.com") { |req| req.body == "abc" }
1597
+
1598
+ * Matching request body against regular expressions (suggested by Ben Pickles)
1599
+
1600
+ stub_request(:post, "www.example.com").with(:body => /^.*world$/).to_return(:body => "abc")
1601
+ RestClient.post('www.example.com', 'hello world') # ===> "abc\n"
1602
+
1603
+ * Matching request headers against regular expressions (suggested by Ben Pickles)
1604
+
1605
+ stub_request(:post, "www.example.com").with(:headers => {"Content-Type" => /image\/.+/}).to_return(:body => "abc")
1606
+ RestClient.post('www.example.com', '', {'Content-Type' => 'image/png'}) # ===> "abc\n"
1607
+
1608
+ * Replaying raw responses recorded with `curl -is`
1609
+
1610
+ `curl -is www.example.com > /tmp/example_curl_-is_output.txt`
1611
+ raw_response_file = File.new("/tmp/example_curl_-is_output.txt")
1612
+
1613
+ from file
1614
+
1615
+ stub_request(:get, "www.example.com").to_return(raw_response_file)
1616
+
1617
+ or string
1618
+
1619
+ stub_request(:get, "www.example.com").to_return(raw_response_file.read)
1620
+
1621
+ * Multiple responses for repeated requests
1622
+
1623
+ stub_request(:get, "www.example.com").to_return({:body => "abc"}, {:body => "def"})
1624
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
1625
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
1626
+
1627
+ * Multiple responses using chained `to_return()` or `to_raise()` declarations
1628
+
1629
+ stub_request(:get, "www.example.com").
1630
+ to_return({:body => "abc"}).then. #then() just is a syntactic sugar
1631
+ to_return({:body => "def"}).then.
1632
+ to_raise(MyException)
1633
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
1634
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
1635
+ Net::HTTP.get('www.example.com', '/') # ===> MyException raised
1636
+
1637
+ * Specifying number of times given response should be returned
1638
+
1639
+ stub_request(:get, "www.example.com").
1640
+ to_return({:body => "abc"}).times(2).then.
1641
+ to_return({:body => "def"})
1642
+
1643
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
1644
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
1645
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
1646
+
1647
+ * Added support for `Net::HTTP::Post#body_stream`
1648
+
1649
+ This fixes compatibility with new versions of RestClient
1650
+
1651
+ * WebMock doesn't suppress default request headers added by http clients anymore.
1652
+
1653
+ i.e. Net::HTTP adds `'Accept'=>'*/*'` to all requests by default
1654
+
1655
+
1656
+
1657
+ ## 0.8.2
1658
+
1659
+ * Fixed issue where WebMock was not closing IO object passed as response body after reading it.
1660
+ * 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
1661
+
1662
+
1663
+ ## 0.8.1
1664
+
1665
+ * Fixed HTTPClient adapter compatibility with Ruby 1.8.6 (reported by Piotr Usewicz)
1666
+ * Net:HTTP adapter now handles request body assigned as Net::HTTP::Post#body attribute (fixed by Mack Earnhardt)
1667
+ * Fixed issue where requests were not matching stubs with Accept header set.(reported by Piotr Usewicz)
1668
+ * Fixed compatibility with Ruby 1.9.1, 1.9.2 and JRuby 1.3.1 (reported by Diego E. “Flameeyes” Pettenò)
1669
+ * Fixed issue with response body declared as IO object and multiple requests (reported by Niels Meersschaert)
1670
+ * Fixed "undefined method `assertion_failure'" error (reported by Nick Plante)
1671
+
1672
+
1673
+ ## 0.8.0
1674
+
1675
+ * Support for HTTPClient (sync and async requests)
1676
+ * Support for dynamic responses. Response body and headers can be now declared as lambda.
1677
+ (Thanks to Ivan Vega ( @ivanyv ) for suggesting this feature)
1678
+ * Support for stubbing and expecting requests with empty body
1679
+ * Executing non-stubbed request leads to failed expectation instead of error
1680
+
1681
+
1682
+ ### Bug fixes
1683
+
1684
+ * Basic authentication now works correctly
1685
+ * Fixed problem where WebMock didn't call a block with the response when block was provided
1686
+ * Fixed problem where uris with single slash were not matching uris without path provided
1687
+
1688
+
1689
+ ## 0.7.3
1690
+
1691
+ * Clarified documentation
1692
+ * Fixed some issues with loading of Webmock classes
1693
+ * Test::Unit and RSpec adapters have to be required separately
1694
+
1695
+
1696
+ ## 0.7.2
1697
+
1698
+ * Added support for matching escaped and non escaped URLs