webmock 3.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'http://rubygems.org/'
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
6
+
7
+ platforms :jruby do
8
+ gem 'jruby-openssl'
9
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009-2010 Bartosz Blimke
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,1125 @@
1
+ WebMock
2
+ =======
3
+ [![Gem Version](https://badge.fury.io/rb/webmock.svg)](http://badge.fury.io/rb/webmock)
4
+ [![Build Status](https://secure.travis-ci.org/bblimke/webmock.svg?branch=master)](http://travis-ci.org/bblimke/webmock)
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)
9
+
10
+ Library for stubbing and setting expectations on HTTP requests in Ruby.
11
+
12
+ Features
13
+ --------
14
+
15
+ * Stubbing HTTP requests at low http client lib level (no need to change tests when you change HTTP library)
16
+ * Setting and verifying expectations on HTTP requests
17
+ * Matching requests based on method, URI, headers and body
18
+ * Smart matching of the same URIs in different representations (also encoded and non encoded forms)
19
+ * Smart matching of the same headers in different representations.
20
+ * Support for Test::Unit
21
+ * Support for RSpec
22
+ * Support for MiniTest
23
+
24
+ Supported HTTP libraries
25
+ ------------------------
26
+
27
+ * Net::HTTP and libraries based on Net::HTTP (i.e RightHttpConnection, REST Client, HTTParty)
28
+ * HTTPClient
29
+ * Patron
30
+ * EM-HTTP-Request
31
+ * Curb (currently only Curb::Easy)
32
+ * Typhoeus (currently only Typhoeus::Hydra)
33
+ * Excon
34
+ * HTTP Gem
35
+ * Manticore
36
+ * Async::HTTP::Client
37
+
38
+ Supported Ruby Interpreters
39
+ ---------------------------
40
+
41
+ * MRI 2.2
42
+ * MRI 2.3
43
+ * MRI 2.4
44
+ * MRI 2.5
45
+ * MRI 2.6
46
+ * JRuby
47
+ * Rubinius
48
+
49
+ ## Installation
50
+
51
+ gem install webmock
52
+
53
+ ### or to install the latest development version from github master
54
+
55
+ git clone http://github.com/bblimke/webmock.git
56
+ cd webmock
57
+ rake install
58
+
59
+ ## Upgrading from v1.x to v2.x
60
+
61
+ WebMock 2.x has changed somewhat since version 1.x. Changes are listed in [CHANGELOG.md](CHANGELOG.md)
62
+
63
+ ### Test::Unit
64
+
65
+ Add the following code to `test/test_helper.rb`
66
+
67
+ ```ruby
68
+ require 'webmock/test_unit'
69
+ ```
70
+
71
+ ### RSpec
72
+
73
+ Add the following code to `spec/spec_helper`:
74
+
75
+ ```ruby
76
+ require 'webmock/rspec'
77
+ ```
78
+
79
+ ### MiniTest
80
+
81
+ Add the following code to `test/test_helper`:
82
+
83
+ ```ruby
84
+ require 'webmock/minitest'
85
+ ```
86
+
87
+ ### Cucumber
88
+
89
+ Create a file `features/support/webmock.rb` with the following contents:
90
+
91
+ ```ruby
92
+ require 'webmock/cucumber'
93
+ ```
94
+
95
+ ### Outside a test framework
96
+
97
+ You can also use WebMock outside a test framework:
98
+
99
+ ```ruby
100
+ require 'webmock'
101
+ include WebMock::API
102
+
103
+ WebMock.enable!
104
+ ```
105
+
106
+ ## Examples
107
+
108
+
109
+
110
+ ## Stubbing
111
+
112
+
113
+ ### Stubbed request based on uri only and with the default response
114
+
115
+ ```ruby
116
+ stub_request(:any, "www.example.com")
117
+
118
+ Net::HTTP.get("www.example.com", "/") # ===> Success
119
+ ```
120
+
121
+ ### Stubbing requests based on method, uri, body and headers
122
+
123
+ ```ruby
124
+ stub_request(:post, "www.example.com").
125
+ with(body: "abc", headers: { 'Content-Length' => 3 })
126
+
127
+ uri = URI.parse("http://www.example.com/")
128
+ req = Net::HTTP::Post.new(uri.path)
129
+ req['Content-Length'] = 3
130
+
131
+ res = Net::HTTP.start(uri.host, uri.port) do |http|
132
+ http.request(req, "abc")
133
+ end # ===> Success
134
+ ```
135
+
136
+ ### Matching request body and headers against regular expressions
137
+
138
+ ```ruby
139
+ stub_request(:post, "www.example.com").
140
+ with(body: /world$/, headers: {"Content-Type" => /image\/.+/}).
141
+ to_return(body: "abc")
142
+
143
+ uri = URI.parse('http://www.example.com/')
144
+ req = Net::HTTP::Post.new(uri.path)
145
+ req['Content-Type'] = 'image/png'
146
+
147
+ res = Net::HTTP.start(uri.host, uri.port) do |http|
148
+ http.request(req, 'hello world')
149
+ end # ===> Success
150
+ ```
151
+
152
+ ### Matching request body against a hash. Body can be URL-Encoded, JSON or XML.
153
+
154
+ ```ruby
155
+ stub_request(:post, "www.example.com").
156
+ with(body: {data: {a: '1', b: 'five'}})
157
+
158
+ RestClient.post('www.example.com', "data[a]=1&data[b]=five",
159
+ content_type: 'application/x-www-form-urlencoded') # ===> Success
160
+
161
+ RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
162
+ content_type: 'application/json') # ===> Success
163
+
164
+ RestClient.post('www.example.com', '<data a="1" b="five" />',
165
+ content_type: 'application/xml') # ===> Success
166
+ ```
167
+
168
+ ### Matching request body against partial hash.
169
+
170
+ ```ruby
171
+ stub_request(:post, "www.example.com").
172
+ with(body: hash_including({data: {a: '1', b: 'five'}}))
173
+
174
+ RestClient.post('www.example.com', "data[a]=1&data[b]=five&x=1",
175
+ :content_type => 'application/x-www-form-urlencoded') # ===> Success
176
+ ```
177
+
178
+ ### Matching custom request headers
179
+
180
+ ```ruby
181
+ stub_request(:any, "www.example.com").
182
+ with(headers:{ 'Header-Name' => 'Header-Value' })
183
+
184
+ uri = URI.parse('http://www.example.com/')
185
+ req = Net::HTTP::Post.new(uri.path)
186
+ req['Header-Name'] = 'Header-Value'
187
+
188
+ res = Net::HTTP.start(uri.host, uri.port) do |http|
189
+ http.request(req, 'abc')
190
+ end # ===> Success
191
+ ```
192
+
193
+ ### Matching multiple headers with the same name
194
+
195
+ ```ruby
196
+ stub_request(:get, 'www.example.com').
197
+ with(headers: {'Accept' => ['image/jpeg', 'image/png'] })
198
+
199
+ req = Net::HTTP::Get.new("/")
200
+ req['Accept'] = ['image/png']
201
+ req.add_field('Accept', 'image/jpeg')
202
+ Net::HTTP.start("www.example.com") {|http| http.request(req) } # ===> Success
203
+ ```
204
+
205
+ ### Matching requests against provided block
206
+
207
+ ```ruby
208
+ stub_request(:post, "www.example.com").with { |request| request.body == "abc" }
209
+ RestClient.post('www.example.com', 'abc') # ===> Success
210
+ ```
211
+
212
+ ### Request with basic authentication header
213
+
214
+ ```ruby
215
+ stub_request(:get, "www.example.com").with(basic_auth: ['user', 'pass'])
216
+ # or
217
+ # stub_request(:get, "www.example.com").
218
+ # with(headers: {'Authorization' => "Basic #{ Base64.strict_encode64('user:pass').chomp}"})
219
+
220
+ Net::HTTP.start('www.example.com') do |http|
221
+ req = Net::HTTP::Get.new('/')
222
+ req.basic_auth 'user', 'pass'
223
+ http.request(req)
224
+ end # ===> Success
225
+ ```
226
+
227
+ ##### Important! Since version 2.0.0, WebMock does not match credentials provided in Authorization header and credentials provided in the userinfo of a url. I.e. `stub_request(:get, "user:pass@www.example.com")` does not match a request with credentials provided in the Authorization header.
228
+
229
+ ### Request with basic authentication in the url
230
+
231
+ ```ruby
232
+ stub_request(:get, "user:pass@www.example.com")
233
+
234
+ RestClient.get('user:pass@www.example.com') # ===> Success
235
+ ```
236
+
237
+ ### Matching uris using regular expressions
238
+
239
+ ```ruby
240
+ stub_request(:any, /example/)
241
+
242
+ Net::HTTP.get('www.example.com', '/') # ===> Success
243
+ ```
244
+
245
+ ### Matching uris using RFC 6570 - Basic Example
246
+
247
+ ```ruby
248
+ uri_template = Addressable::Template.new "www.example.com/{id}/"
249
+ stub_request(:any, uri_template)
250
+
251
+ Net::HTTP.get('www.example.com', '/webmock/') # ===> Success
252
+ ```
253
+
254
+ ### Matching uris using RFC 6570 - Advanced Example
255
+
256
+ ```ruby
257
+ uri_template =
258
+ Addressable::Template.new "www.example.com/thing/{id}.json{?x,y,z}{&other*}"
259
+ stub_request(:any, uri_template)
260
+
261
+ Net::HTTP.get('www.example.com',
262
+ '/thing/5.json?x=1&y=2&z=3&anyParam=4') # ===> Success
263
+ ```
264
+
265
+ ### Matching query params using hash
266
+
267
+ ```ruby
268
+ stub_request(:get, "www.example.com").with(query: {"a" => ["b", "c"]})
269
+
270
+ RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
271
+ ```
272
+
273
+ ### Matching partial query params using hash
274
+
275
+ ```ruby
276
+ stub_request(:get, "www.example.com").
277
+ with(query: hash_including({"a" => ["b", "c"]}))
278
+
279
+ RestClient.get("http://www.example.com/?a[]=b&a[]=c&x=1") # ===> Success
280
+ ```
281
+
282
+ ### Matching partial query params using hash_excluding
283
+
284
+ ```ruby
285
+ stub_request(:get, "www.example.com").
286
+ with(query: hash_excluding({"a" => "b"}))
287
+
288
+ RestClient.get("http://www.example.com/?a=b") # ===> Failure
289
+ RestClient.get("http://www.example.com/?a=c") # ===> Success
290
+ ```
291
+
292
+ ### Stubbing with custom response
293
+
294
+ ```ruby
295
+ stub_request(:any, "www.example.com").
296
+ to_return(body: "abc", status: 200,
297
+ headers: { 'Content-Length' => 3 })
298
+
299
+ Net::HTTP.get("www.example.com", '/') # ===> "abc"
300
+ ```
301
+
302
+ ### Response with body specified as IO object
303
+
304
+ ```ruby
305
+ File.open('/tmp/response_body.txt', 'w') { |f| f.puts 'abc' }
306
+
307
+ stub_request(:any, "www.example.com").
308
+ to_return(body: File.new('/tmp/response_body.txt'), status: 200)
309
+
310
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
311
+ ```
312
+
313
+ ### Response with custom status message
314
+
315
+ ```ruby
316
+ stub_request(:any, "www.example.com").
317
+ to_return(status: [500, "Internal Server Error"])
318
+
319
+ req = Net::HTTP::Get.new("/")
320
+ Net::HTTP.start("www.example.com") { |http| http.request(req) }.
321
+ message # ===> "Internal Server Error"
322
+ ```
323
+
324
+ ### Replaying raw responses recorded with `curl -is`
325
+
326
+ ```
327
+ curl -is www.example.com > /tmp/example_curl_-is_output.txt
328
+ ```
329
+
330
+ ```ruby
331
+ raw_response_file = File.new("/tmp/example_curl_-is_output.txt")
332
+ ```
333
+
334
+ from file
335
+
336
+ ```ruby
337
+ stub_request(:get, "www.example.com").to_return(raw_response_file)
338
+ ```
339
+
340
+ or string
341
+
342
+ ```ruby
343
+ stub_request(:get, "www.example.com").to_return(raw_response_file.read)
344
+ ```
345
+
346
+ ### Responses dynamically evaluated from block
347
+
348
+ ```ruby
349
+ stub_request(:any, 'www.example.net').
350
+ to_return { |request| {body: request.body} }
351
+
352
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
353
+ ```
354
+
355
+ ### Responses dynamically evaluated from lambda
356
+
357
+ ```ruby
358
+ stub_request(:any, 'www.example.net').
359
+ to_return(lambda { |request| {body: request.body} })
360
+
361
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
362
+ ```
363
+
364
+ ### Dynamically evaluated raw responses recorded with `curl -is`
365
+
366
+ `curl -is www.example.com > /tmp/www.example.com.txt`
367
+ ```ruby
368
+ stub_request(:get, "www.example.com").
369
+ to_return(lambda { |request| File.new("/tmp/#{request.uri.host.to_s}.txt") })
370
+ ```
371
+
372
+ ### Responses with dynamically evaluated parts
373
+
374
+ ```ruby
375
+ stub_request(:any, 'www.example.net').
376
+ to_return(body: lambda { |request| request.body })
377
+
378
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
379
+ ```
380
+
381
+ ### Rack responses
382
+
383
+ ```ruby
384
+ class MyRackApp
385
+ def self.call(env)
386
+ [200, {}, ["Hello"]]
387
+ end
388
+ end
389
+
390
+ stub_request(:get, "www.example.com").to_rack(MyRackApp)
391
+
392
+ RestClient.post('www.example.com') # ===> "Hello"
393
+ ```
394
+
395
+ ### Raising errors
396
+
397
+ #### Exception declared by class
398
+
399
+ ```ruby
400
+ stub_request(:any, 'www.example.net').to_raise(StandardError)
401
+
402
+ RestClient.post('www.example.net', 'abc') # ===> StandardError
403
+ ```
404
+
405
+ #### or by exception instance
406
+
407
+ ```ruby
408
+ stub_request(:any, 'www.example.net').to_raise(StandardError.new("some error"))
409
+ ```
410
+
411
+ #### or by string
412
+
413
+ ```ruby
414
+ stub_request(:any, 'www.example.net').to_raise("some error")
415
+ ```
416
+
417
+ ### Raising timeout errors
418
+
419
+ ```ruby
420
+ stub_request(:any, 'www.example.net').to_timeout
421
+
422
+ RestClient.post('www.example.net', 'abc') # ===> RestClient::RequestTimeout
423
+ ```
424
+
425
+ ### Multiple responses for repeated requests
426
+
427
+ ```ruby
428
+ stub_request(:get, "www.example.com").
429
+ to_return({body: "abc"}, {body: "def"})
430
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
431
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
432
+
433
+ #after all responses are used the last response will be returned infinitely
434
+
435
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
436
+ ```
437
+
438
+ ### Multiple responses using chained `to_return()`, `to_raise()` or `to_timeout` declarations
439
+
440
+ ```ruby
441
+ stub_request(:get, "www.example.com").
442
+ to_return({body: "abc"}).then. #then() is just a syntactic sugar
443
+ to_return({body: "def"}).then.
444
+ to_raise(MyException)
445
+
446
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
447
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
448
+ Net::HTTP.get('www.example.com', '/') # ===> MyException raised
449
+ ```
450
+
451
+ ### Specifying number of times given response should be returned
452
+
453
+ ```ruby
454
+ stub_request(:get, "www.example.com").
455
+ to_return({body: "abc"}).times(2).then.
456
+ to_return({body: "def"})
457
+
458
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
459
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
460
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
461
+ ```
462
+
463
+ ### Removing unused stubs
464
+
465
+ ```ruby
466
+ stub_get = stub_request(:get, "www.example.com")
467
+ remove_request_stub(stub_get)
468
+ ```
469
+
470
+ ### Real requests to network can be allowed or disabled
471
+
472
+ ```ruby
473
+ WebMock.allow_net_connect!
474
+
475
+ stub_request(:any, "www.example.com").to_return(body: "abc")
476
+
477
+ Net::HTTP.get('www.example.com', '/') # ===> "abc"
478
+
479
+ Net::HTTP.get('www.something.com', '/') # ===> /.+Something.+/
480
+
481
+ WebMock.disable_net_connect!
482
+
483
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
484
+ ```
485
+
486
+ ### External requests can be disabled while allowing localhost
487
+
488
+ ```ruby
489
+ WebMock.disable_net_connect!(allow_localhost: true)
490
+
491
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
492
+
493
+ Net::HTTP.get('localhost:9887', '/') # ===> Allowed. Perhaps to Selenium?
494
+ ```
495
+
496
+ ### External requests can be disabled while allowing specific requests
497
+
498
+ Allowed requests can be specified in a number of ways.
499
+
500
+ With a `String` specifying a host name:
501
+
502
+ ```ruby
503
+ WebMock.disable_net_connect!(allow: 'www.example.org')
504
+
505
+ RestClient.get('www.something.com', '/') # ===> Failure
506
+ RestClient.get('www.example.org', '/') # ===> Allowed
507
+ RestClient.get('www.example.org:8080', '/') # ===> Allowed
508
+ ```
509
+
510
+ With a `String` specifying a host name and a port:
511
+
512
+ ```ruby
513
+ WebMock.disable_net_connect!(allow: 'www.example.org:8080')
514
+
515
+ RestClient.get('www.something.com', '/') # ===> Failure
516
+ RestClient.get('www.example.org', '/') # ===> Failure
517
+ RestClient.get('www.example.org:8080', '/') # ===> Allowed
518
+ ```
519
+
520
+ With a `Regexp` matching the URI:
521
+
522
+ ```ruby
523
+ WebMock.disable_net_connect!(allow: %r{ample.org/foo})
524
+
525
+ RestClient.get('www.example.org', '/foo/bar') # ===> Allowed
526
+ RestClient.get('sample.org', '/foo') # ===> Allowed
527
+ RestClient.get('sample.org', '/bar') # ===> Failure
528
+ ```
529
+
530
+ With an object that responds to `#call`, receiving a `URI` object and returning a boolean:
531
+
532
+ ```ruby
533
+ blacklist = ['google.com', 'facebook.com', 'apple.com']
534
+ allowed_sites = lambda{|uri|
535
+ blacklist.none?{|site| uri.host.include?(site) }
536
+ }
537
+ WebMock.disable_net_connect!(allow: allowed_sites)
538
+
539
+ RestClient.get('www.example.org', '/') # ===> Allowed
540
+ RestClient.get('www.facebook.com', '/') # ===> Failure
541
+ RestClient.get('apple.com', '/') # ===> Failure
542
+ ```
543
+
544
+ With an `Array` of any of the above:
545
+
546
+ ```ruby
547
+ WebMock.disable_net_connect!(allow: [
548
+ lambda{|uri| uri.host.length % 2 == 0 },
549
+ /ample.org/,
550
+ 'bbc.co.uk',
551
+ ])
552
+
553
+ RestClient.get('www.example.org', '/') # ===> Allowed
554
+ RestClient.get('bbc.co.uk', '/') # ===> Allowed
555
+ RestClient.get('bbc.com', '/') # ===> Allowed
556
+ RestClient.get('www.bbc.com', '/') # ===> Failure
557
+ ```
558
+
559
+ ## Connecting on Net::HTTP.start
560
+
561
+ HTTP protocol has 3 steps: connect, request and response (or 4 with close). Most Ruby HTTP client libraries
562
+ treat connect as a part of request step, with the exception of `Net::HTTP` which
563
+ allows opening connection to the server separately to the request, by using `Net::HTTP.start`.
564
+
565
+ WebMock API was also designed with connect being part of request step, and it only allows stubbing
566
+ requests, not connections. When `Net::HTTP.start` is called, WebMock doesn't know yet whether
567
+ a request is stubbed or not. WebMock by default delays a connection until the request is invoked,
568
+ so when there is no request, `Net::HTTP.start` doesn't do anything.
569
+ **This means that WebMock breaks the Net::HTTP behaviour by default!**
570
+
571
+ To workaround this issue, WebMock offers `:net_http_connect_on_start` option,
572
+ which can be passed to `WebMock.allow_net_connect!` and `WebMock.disable_net_connect!` methods, i.e.
573
+
574
+ ```ruby
575
+ WebMock.allow_net_connect!(net_http_connect_on_start: true)
576
+ ```
577
+
578
+ This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`.
579
+
580
+ ## Setting Expectations
581
+
582
+ ### Setting expectations in Test::Unit
583
+
584
+ ```ruby
585
+ require 'webmock/test_unit'
586
+
587
+ stub_request(:any, "www.example.com")
588
+
589
+ uri = URI.parse('http://www.example.com/')
590
+ req = Net::HTTP::Post.new(uri.path)
591
+ req['Content-Length'] = 3
592
+
593
+ res = Net::HTTP.start(uri.host, uri.port) do |http|
594
+ http.request(req, 'abc')
595
+ end
596
+
597
+ assert_requested :post, "http://www.example.com",
598
+ headers: {'Content-Length' => 3}, body: "abc",
599
+ times: 1 # ===> Success
600
+
601
+ assert_not_requested :get, "http://www.something.com" # ===> Success
602
+
603
+ assert_requested(:post, "http://www.example.com",
604
+ times: 1) { |req| req.body == "abc" }
605
+ ```
606
+
607
+ ### Expecting real (not stubbed) requests
608
+
609
+ ```ruby
610
+ WebMock.allow_net_connect!
611
+
612
+ Net::HTTP.get('www.example.com', '/') # ===> Success
613
+
614
+ assert_requested :get, "http://www.example.com" # ===> Success
615
+ ```
616
+
617
+ ### Setting expectations in Test::Unit on the stub
618
+
619
+ ```ruby
620
+ stub_get = stub_request(:get, "www.example.com")
621
+ stub_post = stub_request(:post, "www.example.com")
622
+
623
+ Net::HTTP.get('www.example.com', '/')
624
+
625
+ assert_requested(stub_get)
626
+ assert_not_requested(stub_post)
627
+ ```
628
+
629
+
630
+ ### Setting expectations in RSpec on `WebMock` module
631
+ This style is borrowed from [fakeweb-matcher](http://github.com/pat/fakeweb-matcher)
632
+
633
+ ```ruby
634
+ require 'webmock/rspec'
635
+
636
+ expect(WebMock).to have_requested(:get, "www.example.com").
637
+ with(body: "abc", headers: {'Content-Length' => 3}).twice
638
+
639
+ expect(WebMock).not_to have_requested(:get, "www.something.com")
640
+
641
+ expect(WebMock).to have_requested(:post, "www.example.com").
642
+ with { |req| req.body == "abc" }
643
+ # Note that the block with `do ... end` instead of curly brackets won't work!
644
+ # Why? See this comment https://github.com/bblimke/webmock/issues/174#issuecomment-34908908
645
+
646
+ expect(WebMock).to have_requested(:get, "www.example.com").
647
+ with(query: {"a" => ["b", "c"]})
648
+
649
+ expect(WebMock).to have_requested(:get, "www.example.com").
650
+ with(query: hash_including({"a" => ["b", "c"]}))
651
+
652
+ expect(WebMock).to have_requested(:get, "www.example.com").
653
+ with(body: {"a" => ["b", "c"]},
654
+ headers: {'Content-Type' => 'application/json'})
655
+ ```
656
+
657
+ ### Setting expectations in RSpec with `a_request`
658
+
659
+ ```ruby
660
+ expect(a_request(:post, "www.example.com").
661
+ with(body: "abc", headers: {'Content-Length' => 3})).
662
+ to have_been_made.once
663
+
664
+ expect(a_request(:post, "www.something.com")).to have_been_made.times(3)
665
+
666
+ expect(a_request(:post, "www.something.com")).to have_been_made.at_least_once
667
+
668
+ expect(a_request(:post, "www.something.com")).
669
+ to have_been_made.at_least_times(3)
670
+
671
+ expect(a_request(:post, "www.something.com")).to have_been_made.at_most_twice
672
+
673
+ expect(a_request(:post, "www.something.com")).to have_been_made.at_most_times(3)
674
+
675
+ expect(a_request(:any, "www.example.com")).not_to have_been_made
676
+
677
+ expect(a_request(:post, "www.example.com").with { |req| req.body == "abc" }).
678
+ to have_been_made
679
+
680
+ expect(a_request(:get, "www.example.com").with(query: {"a" => ["b", "c"]})).
681
+ to have_been_made
682
+
683
+ expect(a_request(:get, "www.example.com").
684
+ with(query: hash_including({"a" => ["b", "c"]}))).to have_been_made
685
+
686
+ expect(a_request(:post, "www.example.com").
687
+ with(body: {"a" => ["b", "c"]},
688
+ headers: {'Content-Type' => 'application/json'})).to have_been_made
689
+ ```
690
+
691
+ ### Setting expectations in RSpec on the stub
692
+
693
+ ```ruby
694
+ stub = stub_request(:get, "www.example.com")
695
+ # ... make requests ...
696
+ expect(stub).to have_been_requested
697
+ ```
698
+
699
+ ## Clearing stubs and request history
700
+
701
+ If you want to reset all current stubs and history of requests use `WebMock.reset!`
702
+
703
+ ```ruby
704
+ stub_request(:any, "www.example.com")
705
+
706
+ Net::HTTP.get('www.example.com', '/') # ===> Success
707
+
708
+ WebMock.reset!
709
+
710
+ Net::HTTP.get('www.example.com', '/') # ===> Failure
711
+
712
+ assert_not_requested :get, "www.example.com" # ===> Success
713
+ ```
714
+
715
+ ## Clearing request counters
716
+
717
+ If you want to reset **only** the counters of the executed requests use `WebMock.reset_executed_requests!`
718
+
719
+ ```ruby
720
+ stub = stub_request(:get, "www.example.com")
721
+ stub2 = stub_request(:get, "www.example2.com")
722
+
723
+ Net::HTTP.get('www.example.com', '/')
724
+ Net::HTTP.get('www.example.com', '/')
725
+
726
+ Net::HTTP.get('www.example2.com', '/')
727
+
728
+ expect(stub).to have_been_requested.times(2)
729
+ expect(stub2).to have_been_requested.times(1)
730
+
731
+ WebMock.reset_executed_requests!
732
+
733
+ expect(stub).not_to have_been_requested
734
+ expect(stub2).not_to have_been_requested
735
+ ```
736
+
737
+ ## Disabling and enabling WebMock or only some http client adapters
738
+
739
+ ```ruby
740
+ # Disable WebMock (all adapters)
741
+ WebMock.disable!
742
+
743
+ # Disable WebMock for all libs except Net::HTTP
744
+ WebMock.disable!(except: [:net_http])
745
+
746
+ # Enable WebMock (all adapters)
747
+ WebMock.enable!
748
+
749
+ # Enable WebMock for all libs except Patron
750
+ WebMock.enable!(except: [:patron])
751
+ ```
752
+
753
+ ## Matching requests
754
+
755
+ An executed request matches stubbed request if it passes following criteria:
756
+
757
+ - When request URI matches stubbed request URI string, Regexp pattern or RFC 6570 URI Template
758
+ - And request method is the same as stubbed request method or stubbed request method is :any
759
+ - And request body is the same as stubbed request body or stubbed request body is not specified
760
+ - And request headers match stubbed request headers, or stubbed request headers match a subset of request headers, or stubbed request headers are not specified
761
+ - And request matches provided block or block is not provided
762
+
763
+ ## Precedence of stubs
764
+
765
+ Always the last declared stub matching the request will be applied i.e:
766
+
767
+ ```ruby
768
+ stub_request(:get, "www.example.com").to_return(body: "abc")
769
+ stub_request(:get, "www.example.com").to_return(body: "def")
770
+
771
+ Net::HTTP.get('www.example.com', '/') # ====> "def"
772
+ ```
773
+
774
+ ## Matching URIs
775
+
776
+ WebMock will match all different representations of the same URI.
777
+
778
+ I.e all the following representations of the URI are equal:
779
+
780
+ ```ruby
781
+ "www.example.com"
782
+ "www.example.com/"
783
+ "www.example.com:80"
784
+ "www.example.com:80/"
785
+ "http://www.example.com"
786
+ "http://www.example.com/"
787
+ "http://www.example.com:80"
788
+ "http://www.example.com:80/"
789
+ ```
790
+
791
+ The following URIs with userinfo are also equal for WebMock
792
+
793
+ ```ruby
794
+ "a b:pass@www.example.com"
795
+ "a b:pass@www.example.com/"
796
+ "a b:pass@www.example.com:80"
797
+ "a b:pass@www.example.com:80/"
798
+ "http://a b:pass@www.example.com"
799
+ "http://a b:pass@www.example.com/"
800
+ "http://a b:pass@www.example.com:80"
801
+ "http://a b:pass@www.example.com:80/"
802
+ "a%20b:pass@www.example.com"
803
+ "a%20b:pass@www.example.com/"
804
+ "a%20b:pass@www.example.com:80"
805
+ "a%20b:pass@www.example.com:80/"
806
+ "http://a%20b:pass@www.example.com"
807
+ "http://a%20b:pass@www.example.com/"
808
+ "http://a%20b:pass@www.example.com:80"
809
+ "http://a%20b:pass@www.example.com:80/"
810
+ ```
811
+
812
+ or these
813
+
814
+ ```ruby
815
+ "www.example.com/my path/?a=my param&b=c"
816
+ "www.example.com/my%20path/?a=my%20param&b=c"
817
+ "www.example.com:80/my path/?a=my param&b=c"
818
+ "www.example.com:80/my%20path/?a=my%20param&b=c"
819
+ "http://www.example.com/my path/?a=my param&b=c"
820
+ "http://www.example.com/my%20path/?a=my%20param&b=c"
821
+ "http://www.example.com:80/my path/?a=my param&b=c"
822
+ "http://www.example.com:80/my%20path/?a=my%20param&b=c"
823
+ ```
824
+
825
+ If you provide Regexp to match URI, WebMock will try to match it against every valid form of the same url.
826
+
827
+ I.e `/my path/` will match `www.example.com/my%20path` because it is equivalent of `www.example.com/my path`
828
+
829
+ ## Matching with URI Templates
830
+
831
+ If you use [Addressable::Template](https://github.com/sporkmonger/addressable#uri-templates) for matching, then WebMock will defer the matching rules to Addressable, which complies with [RFC 6570](http://tools.ietf.org/html/rfc6570).
832
+
833
+ If you use any of the WebMock methods for matching query params, then Addressable will be used to match the base URI and WebMock will match the query params. If you do not, then WebMock will let Addressable match the full URI.
834
+
835
+ ## Matching headers
836
+
837
+ WebMock will match request headers against stubbed request headers in the following situations:
838
+
839
+ 1. Stubbed request has headers specified and request headers are the same as stubbed headers <br/>
840
+ i.e stubbed headers: `{ 'Header1' => 'Value1', 'Header2' => 'Value2' }`, requested: `{ 'Header1' => 'Value1', 'Header2' => 'Value2' }`
841
+
842
+ 2. Stubbed request has headers specified and stubbed request headers are a subset of request headers <br/>
843
+ i.e stubbed headers: `{ 'Header1' => 'Value1' }`, requested: `{ 'Header1' => 'Value1', 'Header2' => 'Value2' }`
844
+
845
+ 3. Stubbed request has no headers <br/>
846
+ i.e stubbed headers: `nil`, requested: `{ 'Header1' => 'Value1', 'Header2' => 'Value2' }`
847
+
848
+ WebMock normalises headers and treats all forms of same headers as equal:
849
+ i.e the following two sets of headers are equal:
850
+
851
+ `{ "Header1" => "value1", content_length: 123, X_CuStOm_hEAder: :value }`
852
+
853
+ `{ header1: "value1", "Content-Length" => 123, "x-cuSTOM-HeAder" => "value" }`
854
+
855
+ ## Recording real requests and responses and replaying them later
856
+
857
+ To record your application's real HTTP interactions and replay them later in tests you can use [VCR](https://github.com/vcr/vcr) with WebMock.
858
+
859
+ ## Request callbacks
860
+
861
+ #### WebMock can invoke callbacks stubbed or real requests:
862
+
863
+ ```ruby
864
+ WebMock.after_request do |request_signature, response|
865
+ puts "Request #{request_signature} was made and #{response} was returned"
866
+ end
867
+ ```
868
+
869
+ #### invoke callbacks for real requests only and except requests made with Patron
870
+
871
+ ```ruby
872
+ WebMock.after_request(except: [:patron],
873
+ real_requests_only: true) do |req_signature, response|
874
+ puts "Request #{req_signature} was made and #{response} was returned"
875
+ end
876
+ ```
877
+
878
+ ## Bugs and Issues
879
+
880
+ Please submit them here [http://github.com/bblimke/webmock/issues](http://github.com/bblimke/webmock/issues)
881
+
882
+ ## Issue triage [![Open Source Helpers](https://www.codetriage.com/bblimke/webmock/badges/users.svg)](https://www.codetriage.com/bblimke/webmock)
883
+
884
+ 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).
885
+
886
+ ## Suggestions
887
+
888
+ 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)
889
+
890
+ I'm particularly interested in how the DSL could be improved.
891
+
892
+ ## Development
893
+
894
+ In order to work on Webmock you first need to fork and clone the repo.
895
+ Please do any work on a dedicated branch and rebase against master
896
+ before sending a pull request.
897
+
898
+ ## Credits
899
+
900
+ The initial lines of this project were written during New Bamboo [Hack Day](http://blog.new-bamboo.co.uk/2009/11/13/hackday-results)
901
+ Thanks to my fellow [Bambinos](http://new-bamboo.co.uk/) for all the great suggestions!
902
+
903
+ People who submitted patches and new features or suggested improvements. Many thanks to these people:
904
+
905
+ * Ben Pickles
906
+ * Mark Evans
907
+ * Ivan Vega
908
+ * Piotr Usewicz
909
+ * Nick Plante
910
+ * Nick Quaranto
911
+ * Diego E. "Flameeyes" Pettenò
912
+ * Niels Meersschaert
913
+ * Mack Earnhardt
914
+ * Arvicco
915
+ * Sergio Gil
916
+ * Jeffrey Jones
917
+ * Tekin Suleyman
918
+ * Tom Ward
919
+ * Nadim Bitar
920
+ * Myron Marston
921
+ * Sam Phillips
922
+ * Jose Angel Cortinas
923
+ * Razic
924
+ * Steve Tooke
925
+ * Nathaniel Bibler
926
+ * Martyn Loughran
927
+ * Muness Alrubaie
928
+ * Charles Li
929
+ * Ryan Bigg
930
+ * Pete Higgins
931
+ * Hans de Graaff
932
+ * Alastair Brunton
933
+ * Sam Stokes
934
+ * Eugene Bolshakov
935
+ * James Conroy-Finn
936
+ * Salvador Fuentes Jr
937
+ * Alex Rothenberg
938
+ * Aidan Feldman
939
+ * Steve Hull
940
+ * Jay Adkisson
941
+ * Zach Dennis
942
+ * Nikita Fedyashev
943
+ * Lin Jen-Shin
944
+ * David Yeu
945
+ * Andreas Garnæs
946
+ * Roman Shterenzon
947
+ * Chris McGrath
948
+ * Stephen Celis
949
+ * Eugene Pimenov
950
+ * Albert Llop
951
+ * Christopher Pickslay
952
+ * Tammer Saleh
953
+ * Nicolas Fouché
954
+ * Joe Van Dyk
955
+ * Mark Abramov
956
+ * Frank Schumacher
957
+ * Dimitrij Denissenko
958
+ * Marnen Laibow-Koser
959
+ * Evgeniy Dolzhenko
960
+ * Nick Recobra
961
+ * Jordan Elver
962
+ * Joe Karayusuf
963
+ * Paul Cortens
964
+ * jugyo
965
+ * aindustries
966
+ * Eric Oestrich
967
+ * erwanlr
968
+ * Ben Bleything
969
+ * Jon Leighton
970
+ * Ryan Schlesinger
971
+ * Julien Boyer
972
+ * Kevin Glowacz
973
+ * Hans Hasselberg
974
+ * Andrew France
975
+ * Jonathan Hyman
976
+ * Rex Feng
977
+ * Pavel Forkert
978
+ * Jordi Massaguer Pla
979
+ * Jake Benilov
980
+ * Tom Beauvais
981
+ * Mokevnin Kirill
982
+ * Alex Grant
983
+ * Lucas Dohmen
984
+ * Bastien Vaucher
985
+ * Joost Baaij
986
+ * Joel Chippindale
987
+ * Murahashi Sanemat Kenichi
988
+ * Tim Kurvers
989
+ * Ilya Vassilevsky
990
+ * gotwalt
991
+ * Leif Bladt
992
+ * Alex Tomlins
993
+ * Mitsutaka Mimura
994
+ * Tomy Kaira
995
+ * Daniel van Hoesel
996
+ * Ian Asaff
997
+ * Ian Lesperance
998
+ * Matthew Horan
999
+ * Dmitry Gutov
1000
+ * Florian Dütsch
1001
+ * Manuel Meurer
1002
+ * Brian D. Burns
1003
+ * Riley Strong
1004
+ * Tamir Duberstein
1005
+ * Stefano Uliari
1006
+ * Alex Stupakov
1007
+ * Karen Wang
1008
+ * Matt Burke
1009
+ * Jon Rowe
1010
+ * Aleksey V. Zapparov
1011
+ * Praveen Arimbrathodiyil
1012
+ * Bo Jeanes
1013
+ * Matthew Conway
1014
+ * Rob Olson
1015
+ * Max Lincoln
1016
+ * Oleg Gritsenko
1017
+ * Hwan-Joon Choi
1018
+ * SHIBATA Hiroshi
1019
+ * Caleb Thompson
1020
+ * Theo Hultberg
1021
+ * Pablo Jairala
1022
+ * Insoo Buzz Jung
1023
+ * Carlos Alonso Pérez
1024
+ * trlorenz
1025
+ * Alexander Simonov
1026
+ * Thorbjørn Hermanse
1027
+ * Mark Lorenz
1028
+ * tjsousa
1029
+ * Tasos Stathopoulos
1030
+ * Dan Buettner
1031
+ * Sven Riedel
1032
+ * Mark Lorenz
1033
+ * Dávid Kovács
1034
+ * fishermand46
1035
+ * Franky Wahl
1036
+ * ChaYoung You
1037
+ * Simon Russell
1038
+ * Steve Mitchell
1039
+ * Mattias Putman
1040
+ * Zachary Anker
1041
+ * Emmanuel Sambo
1042
+ * Ramon Tayag
1043
+ * Johannes Schlumberger
1044
+ * Siôn Le Roux
1045
+ * Matt Palmer
1046
+ * Zhao Wen
1047
+ * Krzysztof Rygielski
1048
+ * Magne Land
1049
+ * yurivm
1050
+ * Mike Knepper
1051
+ * Charles Pence
1052
+ * Alexey Zapparov
1053
+ * Pablo Brasero
1054
+ * Cedric Pimenta
1055
+ * Michiel Karnebeek
1056
+ * Alex Kestner
1057
+ * Manfred Stienstra
1058
+ * Tim Diggins
1059
+ * Gabriel Chaney
1060
+ * Chris Griego
1061
+ * Taiki Ono
1062
+ * Jonathan Schatz
1063
+ * Jose Luis Honorato
1064
+ * Aaron Kromer
1065
+ * Pavel Jurašek
1066
+ * Jake Worth
1067
+ * Gabe Martin-Dempesy
1068
+ * Michael Grosser
1069
+ * Aleksei Maridashvili
1070
+ * Ville Lautanala
1071
+ * Koichi ITO
1072
+ * Jordan Harband
1073
+ * Tarmo Tänav
1074
+ * Joe Marty
1075
+ * Chris Thomson
1076
+ * Vít Ondruch
1077
+ * George Ulmer
1078
+ * Christof Koenig
1079
+ * Chung-Yi Chi
1080
+ * Olexandr Hoshylyk
1081
+ * Janko Marohnić
1082
+ * Pat Allan
1083
+ * Rick Song
1084
+ * NARUSE, Yui
1085
+ * Piotr Boniecki
1086
+ * Olia Kremmyda
1087
+ * Michał Matyas
1088
+ * Matt Brictson
1089
+ * Kenny Ortmann
1090
+ * redbar0n
1091
+ * Lukas Pokorny
1092
+ * Arkadiy Tetelman
1093
+ * Kazato Sugimoto
1094
+ * Olle Jonsson
1095
+ * Pavel Rosický
1096
+ * Geremia Taglialatela
1097
+ * Koichi Sasada
1098
+ * Yusuke Endoh
1099
+ * Grey Baker
1100
+ * SoonKhen OwYong
1101
+ * Pavel Valena
1102
+ * Adam Sokolnicki
1103
+ * Jeff Felchner
1104
+ * Eike Send
1105
+ * Claudio Poli
1106
+ * Csaba Apagyi
1107
+ * Frederick Cheung
1108
+ * Fábio D. Batista
1109
+ * Andriy Yanko
1110
+ * y-yagi
1111
+
1112
+
1113
+ For a full list of contributors you can visit the
1114
+ [contributors](https://github.com/bblimke/webmock/contributors) page.
1115
+
1116
+ ## Background
1117
+
1118
+ Thank you Fakeweb! This library was inspired by [FakeWeb](http://fakeweb.rubyforge.org).
1119
+ I imported some solutions from that project to WebMock. I also copied some code i.e Net:HTTP adapter.
1120
+ Fakeweb architecture unfortunately didn't allow me to extend it easily with the features I needed.
1121
+ I also preferred some things to work differently i.e request stub precedence.
1122
+
1123
+ ## Copyright
1124
+
1125
+ Copyright (c) 2009-2010 Bartosz Blimke. See LICENSE for details.