webmock 3.5.1 → 3.18.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/CI.yml +38 -0
  3. data/CHANGELOG.md +343 -2
  4. data/Gemfile +1 -1
  5. data/README.md +116 -32
  6. data/Rakefile +12 -4
  7. data/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +221 -0
  8. data/lib/webmock/http_lib_adapters/curb_adapter.rb +12 -3
  9. data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +7 -4
  10. data/lib/webmock/http_lib_adapters/excon_adapter.rb +3 -0
  11. data/lib/webmock/http_lib_adapters/http_rb/client.rb +2 -1
  12. data/lib/webmock/http_lib_adapters/http_rb/response.rb +27 -3
  13. data/lib/webmock/http_lib_adapters/http_rb/streamer.rb +5 -3
  14. data/lib/webmock/http_lib_adapters/http_rb/webmock.rb +6 -2
  15. data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +23 -6
  16. data/lib/webmock/http_lib_adapters/manticore_adapter.rb +33 -15
  17. data/lib/webmock/http_lib_adapters/net_http.rb +35 -103
  18. data/lib/webmock/http_lib_adapters/patron_adapter.rb +1 -1
  19. data/lib/webmock/request_body_diff.rb +1 -1
  20. data/lib/webmock/request_pattern.rb +106 -56
  21. data/lib/webmock/request_signature.rb +2 -2
  22. data/lib/webmock/request_stub.rb +15 -0
  23. data/lib/webmock/response.rb +19 -13
  24. data/lib/webmock/rspec.rb +2 -1
  25. data/lib/webmock/stub_registry.rb +26 -11
  26. data/lib/webmock/test_unit.rb +1 -3
  27. data/lib/webmock/util/query_mapper.rb +4 -2
  28. data/lib/webmock/util/uri.rb +8 -8
  29. data/lib/webmock/version.rb +1 -1
  30. data/lib/webmock/webmock.rb +20 -3
  31. data/lib/webmock.rb +1 -0
  32. data/minitest/webmock_spec.rb +1 -1
  33. data/spec/acceptance/async_http_client/async_http_client_spec.rb +375 -0
  34. data/spec/acceptance/async_http_client/async_http_client_spec_helper.rb +73 -0
  35. data/spec/acceptance/curb/curb_spec.rb +34 -5
  36. data/spec/acceptance/em_http_request/em_http_request_spec.rb +57 -1
  37. data/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +2 -2
  38. data/spec/acceptance/excon/excon_spec.rb +2 -2
  39. data/spec/acceptance/excon/excon_spec_helper.rb +2 -0
  40. data/spec/acceptance/http_rb/http_rb_spec.rb +11 -0
  41. data/spec/acceptance/manticore/manticore_spec.rb +51 -0
  42. data/spec/acceptance/net_http/net_http_shared.rb +46 -9
  43. data/spec/acceptance/net_http/net_http_spec.rb +87 -23
  44. data/spec/acceptance/net_http/real_net_http_spec.rb +1 -1
  45. data/spec/acceptance/patron/patron_spec.rb +19 -21
  46. data/spec/acceptance/patron/patron_spec_helper.rb +2 -2
  47. data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +14 -14
  48. data/spec/acceptance/shared/callbacks.rb +3 -2
  49. data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +1 -1
  50. data/spec/acceptance/shared/request_expectations.rb +7 -0
  51. data/spec/acceptance/shared/returning_declared_responses.rb +36 -15
  52. data/spec/acceptance/shared/stubbing_requests.rb +40 -0
  53. data/spec/support/webmock_server.rb +1 -0
  54. data/spec/unit/request_pattern_spec.rb +201 -49
  55. data/spec/unit/request_signature_spec.rb +21 -1
  56. data/spec/unit/request_stub_spec.rb +35 -0
  57. data/spec/unit/response_spec.rb +51 -19
  58. data/spec/unit/util/query_mapper_spec.rb +7 -0
  59. data/spec/unit/util/uri_spec.rb +74 -2
  60. data/spec/unit/webmock_spec.rb +108 -5
  61. data/test/test_webmock.rb +6 -0
  62. data/webmock.gemspec +15 -7
  63. metadata +78 -35
  64. data/.travis.yml +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1f4b12d21d9712fdf49cc29d9494285c36926b29eda702e3821caab05ba7a97
4
- data.tar.gz: 24a7edb6ce921ef9735043588ee89ab31b895f9e99bccf3c655d20f645b3cf55
3
+ metadata.gz: 3a7e964f28dd42787fd854c5fcc87dba4cd61ef214c3dee485d9bd0d71fc1cdd
4
+ data.tar.gz: f6921a9b14ccd71f18b4674aca8d4d24bf377545a4ef8c56862f95cc56b6e8a7
5
5
  SHA512:
6
- metadata.gz: 724c7ae8d9ba016537b0e45968e9ae8d820458be36106a24eb7374ccc09cb3e06fb0df5968014443b4f94ba16349dad4643bf683cab17c4af1b32ae9c5b1112d
7
- data.tar.gz: 440171bbd565223139df3aec8581378497cfe359dc766c4b5e8dcf0b865a6c6adf759029d551b3ffac084d7b9683401baabd0b713930017563b7d79cb09320e8
6
+ metadata.gz: 80e85d1bb83018bdaab80aed649134757ee8ac591b98e9ccf1b6df10c0d8930db167dd5fd3bb039dd56a955d22c0cc6b1a1227bb88e8f3e56d31d0e1c9d7708e
7
+ data.tar.gz: c67f1f8486d6ee932bd9d01dff2bfcec35d9c3e3ed937e50e1f56d34f664ca11db4c9399c51e82da9316245c1d4727c726b9e307646aef80477764609ecf95ee
@@ -0,0 +1,38 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby:
16
+ - head
17
+ - '3.1'
18
+ - '3.0'
19
+ - '2.7'
20
+ - '2.6'
21
+ - '2.5'
22
+ - jruby
23
+ continue-on-error: ${{ matrix.ruby == 'head' }}
24
+ name: Ruby ${{ matrix.ruby }}
25
+ env:
26
+ JRUBY_OPTS: "--debug"
27
+ steps:
28
+ - uses: actions/checkout@v2
29
+ - name: Install Apt Packages
30
+ run: |
31
+ sudo apt-get install libcurl4-openssl-dev -y
32
+ - uses: ruby/setup-ruby@v1
33
+ continue-on-error: true
34
+ with:
35
+ ruby-version: ${{ matrix.ruby }}
36
+ bundler-cache: true
37
+ - run: |
38
+ bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,5 +1,346 @@
1
1
  # Changelog
2
2
 
3
+ # 3.18.1
4
+
5
+ * Reverted simplified connection handing in Net::HTTP adapter due to https://github.com/bblimke/webmock/issues/999
6
+
7
+ # 3.18.0
8
+
9
+ * Net::BufferedIO is not replaced anymore.
10
+
11
+ Thanks to [Ray Zane](https://github.com/rzane)
12
+
13
+ * Simplified connection handing in Net::HTTP adapter.
14
+
15
+ Thanks to [Ray Zane](https://github.com/rzane)
16
+
17
+ # 3.17.1
18
+
19
+ * Fixed Syntax Error
20
+
21
+ Thanks to [Mark Spangler](https://github.com/mspangler)
22
+
23
+ # 3.17.0
24
+
25
+ * Minimum required Ruby version is 2.3
26
+
27
+ Thanks to [Go Sueyoshi](https://github.com/sue445)
28
+
29
+ * When using Net::HTTP, stubbed socket StubSocket#close and StubSocket#closed? behave more like the real sockets.
30
+
31
+ Thanks to [Ray Zane](https://github.com/rzane)
32
+
33
+ * Added `peeraddr`, `ssl_version` and `cipher` methods to stubbed sockets used by Net::HTTP.
34
+
35
+ Thanks to [Ray Zane](https://github.com/rzane)
36
+
37
+ * Added support for matching top-level array in JSON request body.
38
+
39
+ E.g.
40
+
41
+ ````
42
+ stub_request(:post, 'www.example.com').with(body: [{a: 1}])
43
+ ````
44
+
45
+ Thanks to [Cedric Sohrauer](https://github.com/cedrics)
46
+
47
+ # 3.16.2
48
+
49
+ * Minimum required Ruby version is 2.0.
50
+
51
+ # 3.16.0 (yanked)
52
+
53
+ * Fix leaky file descriptors and reuse socket for persistent connections.
54
+
55
+ Thanks to [Ray Zane](https://github.com/rzane)
56
+
57
+ * Allow specifying for what URIs or hosts, Net::HTTP should connect on start.
58
+
59
+ Thanks to [Ray Zane](https://github.com/rzane)
60
+
61
+ # 3.15.2
62
+
63
+ * Minimum required Ruby version is 2.0.
64
+
65
+ # 3.15.0 (yanked)
66
+
67
+ * fixed async-http adapter on Windows
68
+
69
+ Thanks to [Pavel Rosický](https://github.com/ahorek)
70
+
71
+ * Support for http.rb >= 5.0.2
72
+
73
+ Thanks to [ojab](https://github.com/ojab)
74
+
75
+ * Curb adapter supports headers with `:` character in the header value
76
+
77
+ Thanks to [Giorgio Gambino](https://github.com/mrbuzz)
78
+
79
+ * Support for matching body of JSON or application/x-www-form-urlencoded requests with content type header including charset.
80
+
81
+ Thanks to [Timmitry](https://github.com/Timmitry)
82
+
83
+ * Prevent double-wrapping http.rb features on non-stubbed requests
84
+
85
+ Thanks to [Michael Fairley](https://github.com/michaelfairley)
86
+
87
+ # 3.14.0
88
+
89
+ * Bump Addressable from 2.3.6 to 2.8.0
90
+
91
+ Thanks to [Eduardo Hernandez](https://github.com/EduardoGHdez)
92
+
93
+ # 3.13.0
94
+
95
+ * Support http.rb 5.x
96
+
97
+ Thanks to [Will Storey](https://github.com/horgh)
98
+
99
+ # 3.12.2
100
+
101
+ * Fixed em-http-request adapter to avoid calling middleware twice.
102
+
103
+ Thanks to [Alex Vondrak](https://github.com/ajvondrak)
104
+
105
+ # 3.12.1
106
+
107
+ * Fixed handling of URIs with IPv6 addresses with square brackets when in Net::HTTP adapter.
108
+
109
+ Thanks to [Johanna Hartmann](https://github.com/JohannaHartmann)
110
+
111
+ # 3.12.0
112
+
113
+ * Added support for handling custom JSON and XML content types e.g. 'application/vnd.api+json'
114
+
115
+ # 3.11.3
116
+
117
+ * Fixed async-http adapter to only considered requests as real if they are real.
118
+
119
+ Thanks to Thanks to [Tony Schneider](https://github.com/tonywok) and [Samuel Williams](https://github.com/ioquatix)
120
+
121
+ # 3.11.2
122
+
123
+ * Fix for Manticore streaming mode
124
+
125
+ Thanks to [Oleksiy Kovyrin](https://github.com/kovyrin)
126
+
127
+ # 3.11.1
128
+
129
+ * Compatibility with async-http 0.54+
130
+
131
+ Thanks to [Jun Jiang](https://github.com/jasl)
132
+
133
+ # 3.11.0
134
+
135
+ * Added support for `features` in http.rb adapter.
136
+
137
+ Thanks to [Carl (ce07c3)](https://github.com/ce07c3)
138
+
139
+ # 3.10.0
140
+
141
+ * Added option to global stubs to have lower priority than local stubs.
142
+
143
+ WebMock.globally_stub_request(:after_local_stubs) do
144
+ { body: "global stub body" }
145
+ end
146
+
147
+ stub_request(:get, "www.example.com").to_return(body: 'non-global stub body')
148
+
149
+ expect(http_request(:get, "http://www.example.com/").body).to eq("non-global stub body")
150
+
151
+ Thanks to [Marek Kasztelnik](https://github.com/mkasztelnik)
152
+
153
+ # 3.9.5
154
+
155
+ * Prevent overwriting `teardown` method in Test::Unit
156
+
157
+ Thanks to [Jesse Bowes](https://github.com/jessebs)
158
+
159
+ # 3.9.4
160
+
161
+ * More intuitive error message when stubbed response body was provided as Hash
162
+
163
+ Thanks to [Ben Koshy](https://github.com/BKSpurgeon)
164
+
165
+ # 3.9.3
166
+
167
+ * Make httpclient_adapter thread-safe
168
+
169
+ Thanks to [Adam Harwood](https://github.com/adam-harwood)
170
+
171
+ # 3.9.2
172
+
173
+ * Made global stubs thread-safe
174
+
175
+ Thanks to [Adam Harwood](https://github.com/adam-harwood)
176
+
177
+ # 3.9.1
178
+
179
+ * Fixed support for passing `URI` objects as second argument of `stub_request`
180
+
181
+ Thanks to [Ryan Kerr](https://github.com/leboshi)
182
+
183
+ ## 3.9.0
184
+
185
+ * Allow using a "callable" (like a proc) as URI pattern
186
+
187
+ stub_request(:any, ->(uri) { true })
188
+
189
+ Thanks to [John Hawthorn](https://github.com/jhawthorn)
190
+
191
+ * Added stubbed IO on stubbed socket in Net::HTTP adapter.
192
+
193
+ Thanks to [Thilo Rusche](https://github.com/trusche)
194
+
195
+ * When 'webmock/rspec' is required, reset WebMock after all after(:each/example) hooks
196
+
197
+ Thanks to [Andrew Stuntz](https://github.com/drews256)
198
+
199
+ * Fixed `net_connect_allowed?` when invoked with no arguments, when there were any allowed URIs passed to `disable_net_connect?`.
200
+
201
+ Thanks to [Lucas Uyezu](https://github.com/lucasuyezu)
202
+
203
+ * Fixed async-http adapter which caused Async::HTTP::Client or Async::HTTP::Internet to hang and never return a response.
204
+
205
+ Thanks to [Bruno Sutic](https://github.com/bruno-) and [Samuel Williams](https://github.com/ioquatix)
206
+
207
+ * Fixed warning when using async-http adapter
208
+
209
+ Thanks to [Bruno Sutic](https://github.com/bruno-)
210
+
211
+ * Dropped support for Ruby 2.3 - EOL date: 2019-03-31
212
+
213
+ * Dropped support for Ruby 2.4 - EOL date: 2020-03-31
214
+
215
+ * Handling matching of Addressable::Template patterns that have an ip address without port and patterns that have ip address and don’t have schema and path.
216
+
217
+ Thanks to [Rafael França](https://github.com/rafaelfranca) and [guppy0356](https://github.com/guppy0356)
218
+
219
+ ## 3.8.3
220
+
221
+ * Fixed problem introduced in version 3.4.2, which caused matching against Addressable::Template representing host part of the URI to raise an error.
222
+
223
+ Thanks to [Vesa Laakso](https://github.com/valscion)
224
+
225
+ ## 3.8.2
226
+
227
+ * Support correct encoding parameter for HTTP.rb 2.x and earlier
228
+
229
+ Thanks to [Alex Coomans](https://github.com/drcapulet)
230
+
231
+ ## 3.8.1
232
+
233
+ * Added support for mocking non-ASCII bodies when making requests with HTTP.rb
234
+
235
+ Thanks to [Patrik Ragnarsson](https://github.com/dentarg)
236
+
237
+ ## 3.8.0
238
+
239
+ * Fixed options handling when initialising Async::HTTP::Client
240
+
241
+ Thanks to [Samuel Williams](https://github.com/ioquatix)
242
+
243
+ * Ruby 2.7 support.
244
+
245
+ Thanks to [Ryan Davis](https://github.com/zenspider) and [Brandur](https://github.com/brandur)
246
+
247
+ ## 3.7.6
248
+
249
+ * Suppressed keyword argument warnings in Ruby 2.7 in async-http adapter.
250
+
251
+ Thanks to [Koichi ITO](https://github.com/koic)
252
+
253
+ ## 3.7.5
254
+
255
+ * Suppress Excon warning generated by extra key
256
+
257
+ Thanks to [Marco Costa](https://github.com/marcotc)
258
+
259
+ ## 3.7.4
260
+
261
+ * Resetting memoized response fields in Curb adapter.
262
+
263
+ Thanks to [Andrei Sidorov](https://github.com/heretge)
264
+
265
+ ## 3.7.3
266
+
267
+ * Fix for http.rb. Allow passing an output buffer to HTTP::Response::Body#readpartial
268
+
269
+ Thanks to [George Claghorn](https://github.com/georgeclaghorn)
270
+
271
+ * Fixed Manticore adapter to invoke Manticore failure handler on stubbed timeout
272
+
273
+ Thanks to [Alex Junger](https://github.com/alexJunger)
274
+
275
+ * Added project metadata to the gemspec
276
+
277
+ Thanks to [Orien Madgwick](https://github.com/orien)
278
+
279
+ ## 3.7.2
280
+
281
+ * Fixed handling of non UTF-8 encoded urls
282
+
283
+ Thanks to [Rafael França](https://github.com/rafaelfranca)
284
+
285
+ * Fixed "shadowing outer local variable" warning
286
+
287
+ Thanks to [y-yagi](https://github.com/y-yagi)
288
+
289
+ ## 3.7.1
290
+
291
+ * Fixed Async::HTTP::Client adapter code to not cause Ruby warning
292
+
293
+ Thanks to [y-yagi](https://github.com/y-yagi)
294
+
295
+ ## 3.7.0
296
+
297
+ * Support for Async::HTTP::Client
298
+
299
+ Thanks to [Andriy Yanko](https://github.com/ayanko)
300
+
301
+ ## 3.6.2
302
+
303
+ * Fixed Patron adapter to handle HTTP/2 status line.
304
+
305
+ Thanks to [Fábio D. Batista](https://github.com/fabiob)
306
+
307
+ ## 3.6.1
308
+
309
+ * Fixed issue with matching Addressable::Template without a period in the domain
310
+
311
+ Thanks to [Eike Send](https://github.com/eikes)
312
+
313
+ * Support for `write_timeout` in Net::HTTP
314
+
315
+ Thanks to [Claudio Poli](https://github.com/masterkain)
316
+
317
+ * Fixed issue with handling urls with ":80" or ":443" in the path.
318
+
319
+ Thanks to [Csaba Apagyi](https://github.com/thisismydesign) for reporting and to [Frederick Cheung](https://github.com/fcheung) for fixing the issue.
320
+
321
+ ## 3.6.0
322
+
323
+ * Compatibility with the latest version of hashdiff gem, with constant changed from HashDiff to Hashdiff
324
+
325
+ Thanks to [Jeff Felchner](https://github.com/jfelchner)
326
+
327
+ * Added a hint to the error message raised when `with` method is called without args or a block.
328
+
329
+ Thanks to [Adam Sokolnicki](https://github.com/asok)
330
+
331
+ * Resetting configured HTTP method in Curb adapter after each request
332
+
333
+ Thanks to [tiendo1011](https://github.com/tiendo1011)
334
+
335
+ * Added `WebMock.enable_net_connect!` as an alias for `WebMock.allow_net_connect!`
336
+ and `WebMock.disallow_net_connect!` as an alias for `WebMock.disable_net_connect!`
337
+
338
+ Thanks to [SoonKhen OwYong](https://github.com/owyongsk)
339
+
340
+ * Fixed handling of empty arrays as query params when using Faraday
341
+
342
+ Thanks to [Ryan Moret](https://github.com/rcmoret)
343
+
3
344
  ## 3.5.1
4
345
 
5
346
  * Disabling TracePoint defined in Net::BufferedIO in case of exception being raised.
@@ -348,9 +689,9 @@
348
689
  * `WebMock.disable_net_connect` accepts `:allow` option with an object that responds to `#call`, receiving a `URI` object and returning a boolean:
349
690
 
350
691
 
351
- blacklist = ['google.com', 'facebook.com', 'apple.com']
692
+ denylist = ['google.com', 'facebook.com', 'apple.com']
352
693
  allowed_sites = lambda{|uri|
353
- blacklist.none?{|site| uri.host.include?(site) }
694
+ denylist.none?{|site| uri.host.include?(site) }
354
695
  }
355
696
  WebMock.disable_net_connect!(:allow => allowed_sites)
356
697
 
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org/'
1
+ source 'https://rubygems.org/'
2
2
 
3
3
  gemspec
4
4
 
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  WebMock
2
2
  =======
3
- [![Gem Version](https://badge.fury.io/rb/webmock.svg)](http://badge.fury.io/rb/webmock) [![Build Status](https://secure.travis-ci.org/bblimke/webmock.svg?branch=master)](http://travis-ci.org/bblimke/webmock) [![Dependency Status](https://gemnasium.com/bblimke/webmock.svg)](http://gemnasium.com/bblimke/webmock) [![Code Climate](https://codeclimate.com/github/bblimke/webmock/badges/gpa.svg)](https://codeclimate.com/github/bblimke/webmock) [![Mentioned in Awesome Ruby](https://awesome.re/mentioned-badge.svg)](https://github.com/markets/awesome-ruby) [![Inline docs](http://inch-ci.org/github/bblimke/webmock.svg?branch=master)](http://inch-ci.org/github/bblimke/webmock)
3
+ [![Gem Version](https://badge.fury.io/rb/webmock.svg)](http://badge.fury.io/rb/webmock)
4
+ [![Build Status](https://github.com/bblimke/webmock/workflows/CI/badge.svg?branch=master)](https://github.com/bblimke/webmock/actions)
5
+ [![Code Climate](https://codeclimate.com/github/bblimke/webmock/badges/gpa.svg)](https://codeclimate.com/github/bblimke/webmock)
6
+ [![Mentioned in Awesome Ruby](https://awesome.re/mentioned-badge.svg)](https://github.com/markets/awesome-ruby)
7
+ [![Inline docs](http://inch-ci.org/github/bblimke/webmock.svg?branch=master)](http://inch-ci.org/github/bblimke/webmock)
8
+ [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=webmock&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=webmock&package-manager=bundler&version-scheme=semver)
4
9
 
5
10
  Library for stubbing and setting expectations on HTTP requests in Ruby.
6
11
 
@@ -19,30 +24,42 @@ Features
19
24
  Supported HTTP libraries
20
25
  ------------------------
21
26
 
22
- * Net::HTTP and libraries based on Net::HTTP (i.e RightHttpConnection, REST Client, HTTParty)
23
- * HTTPClient
24
- * Patron
25
- * EM-HTTP-Request
26
- * Curb (currently only Curb::Easy)
27
- * Typhoeus (currently only Typhoeus::Hydra)
28
- * Excon
29
- * HTTP Gem
30
- * Manticore
27
+ * [Async::HTTP::Client](https://github.com/socketry/async-http)
28
+ * [Curb](https://github.com/taf2/curb) (currently only Curb::Easy)
29
+ * [EM-HTTP-Request](https://github.com/igrigorik/em-http-request)
30
+ * [Excon](https://github.com/excon/excon)
31
+ * [HTTPClient](https://github.com/nahi/httpclient)
32
+ * [HTTP Gem (also known as http.rb)](https://github.com/httprb/http)
33
+ * [httpx](https://honeyryderchuck.gitlab.io/httpx/wiki/Webmock-Adapter)
34
+ * [Manticore](https://github.com/cheald/manticore)
35
+ * [Net::HTTP](https://ruby-doc.org/stdlib-2.7.0/libdoc/net/http/rdoc/Net/HTTP.html) and other libraries based on Net::HTTP, e.g.:
36
+ * [HTTParty](https://github.com/jnunemaker/httparty)
37
+ * [REST Client](https://github.com/rest-client/rest-client)
38
+ * [Patron](https://github.com/toland/patron)
39
+ * [Typhoeus](https://github.com/typhoeus/typhoeus) (currently only Typhoeus::Hydra)
31
40
 
32
41
  Supported Ruby Interpreters
33
42
  ---------------------------
34
43
 
35
- * MRI 2.2
36
- * MRI 2.3
37
- * MRI 2.4
38
44
  * MRI 2.5
39
45
  * MRI 2.6
46
+ * MRI 2.7
40
47
  * JRuby
41
48
  * Rubinius
42
49
 
43
50
  ## Installation
44
51
 
52
+ ```bash
45
53
  gem install webmock
54
+ ```
55
+ or alternatively:
56
+
57
+ ```ruby
58
+ # add to your Gemfile
59
+ group :test do
60
+ gem "webmock"
61
+ end
62
+ ```
46
63
 
47
64
  ### or to install the latest development version from github master
48
65
 
@@ -54,36 +71,36 @@ Supported Ruby Interpreters
54
71
 
55
72
  WebMock 2.x has changed somewhat since version 1.x. Changes are listed in [CHANGELOG.md](CHANGELOG.md)
56
73
 
57
- ### Test::Unit
74
+ ### Cucumber
58
75
 
59
- Add the following code to `test/test_helper.rb`
76
+ Create a file `features/support/webmock.rb` with the following contents:
60
77
 
61
78
  ```ruby
62
- require 'webmock/test_unit'
79
+ require 'webmock/cucumber'
63
80
  ```
64
81
 
65
- ### RSpec
82
+ ### MiniTest
66
83
 
67
- Add the following code to `spec/spec_helper`:
84
+ Add the following code to `test/test_helper`:
68
85
 
69
86
  ```ruby
70
- require 'webmock/rspec'
87
+ require 'webmock/minitest'
71
88
  ```
72
89
 
73
- ### MiniTest
90
+ ### RSpec
74
91
 
75
- Add the following code to `test/test_helper`:
92
+ Add the following code to `spec/spec_helper`:
76
93
 
77
94
  ```ruby
78
- require 'webmock/minitest'
95
+ require 'webmock/rspec'
79
96
  ```
80
97
 
81
- ### Cucumber
98
+ ### Test::Unit
82
99
 
83
- Create a file `features/support/webmock.rb` with the following contents:
100
+ Add the following code to `test/test_helper.rb`
84
101
 
85
102
  ```ruby
86
- require 'webmock/cucumber'
103
+ require 'webmock/test_unit'
87
104
  ```
88
105
 
89
106
  ### Outside a test framework
@@ -97,13 +114,10 @@ include WebMock::API
97
114
  WebMock.enable!
98
115
  ```
99
116
 
100
- ## Examples
101
-
102
-
117
+ # Examples
103
118
 
104
119
  ## Stubbing
105
120
 
106
-
107
121
  ### Stubbed request based on uri only and with the default response
108
122
 
109
123
  ```ruby
@@ -236,6 +250,12 @@ stub_request(:any, /example/)
236
250
  Net::HTTP.get('www.example.com', '/') # ===> Success
237
251
  ```
238
252
 
253
+ ### Matching uris using lambda
254
+
255
+ ```ruby
256
+ stub_request(:any, ->(uri) { true })
257
+ ```
258
+
239
259
  ### Matching uris using RFC 6570 - Basic Example
240
260
 
241
261
  ```ruby
@@ -293,6 +313,12 @@ stub_request(:any, "www.example.com").
293
313
  Net::HTTP.get("www.example.com", '/') # ===> "abc"
294
314
  ```
295
315
 
316
+ Set appropriate Content-Type for HTTParty's `parsed_response`.
317
+
318
+ ```ruby
319
+ stub_request(:any, "www.example.com").to_return body: '{}', headers: {content_type: 'application/json'}
320
+ ```
321
+
296
322
  ### Response with body specified as IO object
297
323
 
298
324
  ```ruby
@@ -524,9 +550,9 @@ RestClient.get('sample.org', '/bar') # ===> Failure
524
550
  With an object that responds to `#call`, receiving a `URI` object and returning a boolean:
525
551
 
526
552
  ```ruby
527
- blacklist = ['google.com', 'facebook.com', 'apple.com']
553
+ denylist = ['google.com', 'facebook.com', 'apple.com']
528
554
  allowed_sites = lambda{|uri|
529
- blacklist.none?{|site| uri.host.include?(site) }
555
+ denylist.none?{|site| uri.host.include?(site) }
530
556
  }
531
557
  WebMock.disable_net_connect!(allow: allowed_sites)
532
558
 
@@ -873,6 +899,10 @@ end
873
899
 
874
900
  Please submit them here [http://github.com/bblimke/webmock/issues](http://github.com/bblimke/webmock/issues)
875
901
 
902
+ ## Issue triage [![Open Source Helpers](https://www.codetriage.com/bblimke/webmock/badges/users.svg)](https://www.codetriage.com/bblimke/webmock)
903
+
904
+ You can contribute by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to webmock on CodeTriage](https://www.codetriage.com/bblimke/webmock).
905
+
876
906
  ## Suggestions
877
907
 
878
908
  If you have any suggestions on how to improve WebMock please send an email to the mailing list [groups.google.com/group/webmock-users](http://groups.google.com/group/webmock-users)
@@ -1086,13 +1116,67 @@ People who submitted patches and new features or suggested improvements. Many th
1086
1116
  * Geremia Taglialatela
1087
1117
  * Koichi Sasada
1088
1118
  * Yusuke Endoh
1119
+ * Grey Baker
1120
+ * SoonKhen OwYong
1121
+ * Pavel Valena
1122
+ * Adam Sokolnicki
1123
+ * Jeff Felchner
1124
+ * Eike Send
1125
+ * Claudio Poli
1126
+ * Csaba Apagyi
1127
+ * Frederick Cheung
1128
+ * Fábio D. Batista
1129
+ * Andriy Yanko
1130
+ * y-yagi
1131
+ * Rafael França
1132
+ * George Claghorn
1133
+ * Alex Junger
1134
+ * Orien Madgwick
1135
+ * Andrei Sidorov
1136
+ * Marco Costa
1137
+ * Ryan Davis
1138
+ * Brandur
1139
+ * Samuel Williams
1140
+ * Patrik Ragnarsson
1141
+ * Alex Coomans
1142
+ * Vesa Laakso
1143
+ * John Hawthorn
1144
+ * guppy0356
1145
+ * Thilo Rusche
1146
+ * Andrew Stuntz
1147
+ * Lucas Uyezu
1148
+ * Bruno Sutic
1149
+ * Ryan Kerr
1150
+ * Adam Harwood
1151
+ * Ben Koshy
1152
+ * Jesse Bowes
1153
+ * Marek Kasztelnik
1154
+ * ce07c3
1155
+ * Jun Jiang
1156
+ * Oleksiy Kovyrin
1157
+ * Matt Larraz
1158
+ * Tony Schneider
1159
+ * Niklas Hösl
1160
+ * Johanna Hartmann
1161
+ * Alex Vondrak
1162
+ * Will Storey
1163
+ * Eduardo Hernandez
1164
+ * ojab
1165
+ * Giorgio Gambino
1166
+ * Timmitry
1167
+ * Michael Fairley
1168
+ * Ray Zane
1169
+ * Go Sueyoshi
1170
+ * Cedric Sohrauer
1171
+ * Akira Matsuda
1172
+ * Mark Spangler
1089
1173
 
1090
1174
  For a full list of contributors you can visit the
1091
1175
  [contributors](https://github.com/bblimke/webmock/contributors) page.
1092
1176
 
1093
1177
  ## Background
1094
1178
 
1095
- Thank you Fakeweb! This library was inspired by [FakeWeb](http://fakeweb.rubyforge.org).
1179
+ Thank you Fakeweb! This library was inspired by [FakeWeb](https://github.com/chrisk/fakeweb).
1096
1180
  I imported some solutions from that project to WebMock. I also copied some code i.e Net:HTTP adapter.
1097
1181
  Fakeweb architecture unfortunately didn't allow me to extend it easily with the features I needed.
1098
1182
  I also preferred some things to work differently i.e request stub precedence.