acfs 1.7.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +144 -116
  3. data/README.md +19 -24
  4. data/acfs.gemspec +7 -10
  5. data/lib/acfs/collections/paginatable.rb +11 -11
  6. data/lib/acfs/configuration.rb +1 -1
  7. data/lib/acfs/errors.rb +6 -6
  8. data/lib/acfs/global.rb +2 -2
  9. data/lib/acfs/location.rb +1 -1
  10. data/lib/acfs/resource/attributes/uuid.rb +1 -1
  11. data/lib/acfs/resource/attributes.rb +1 -1
  12. data/lib/acfs/resource/dirty.rb +1 -1
  13. data/lib/acfs/resource/operational.rb +4 -4
  14. data/lib/acfs/resource/query_methods.rb +3 -3
  15. data/lib/acfs/response/status.rb +1 -1
  16. data/lib/acfs/service/middleware.rb +2 -2
  17. data/lib/acfs/singleton_resource.rb +2 -2
  18. data/lib/acfs/stub.rb +1 -1
  19. data/lib/acfs/version.rb +2 -2
  20. data/lib/acfs/yard.rb +1 -0
  21. data/spec/acfs/adapter/typhoeus_spec.rb +3 -3
  22. data/spec/acfs/configuration_spec.rb +1 -1
  23. data/spec/acfs/global_spec.rb +5 -5
  24. data/spec/acfs/location_spec.rb +1 -1
  25. data/spec/acfs/middleware/json_spec.rb +1 -1
  26. data/spec/acfs/middleware/message_pack_spec.rb +1 -1
  27. data/spec/acfs/operation_spec.rb +1 -1
  28. data/spec/acfs/resource/attributes/boolean_spec.rb +31 -31
  29. data/spec/acfs/resource/attributes/date_time_spec.rb +9 -9
  30. data/spec/acfs/resource/attributes/dict_spec.rb +10 -10
  31. data/spec/acfs/resource/attributes/float_spec.rb +11 -11
  32. data/spec/acfs/resource/attributes/integer_spec.rb +6 -6
  33. data/spec/acfs/resource/attributes/list_spec.rb +1 -1
  34. data/spec/acfs/resource/attributes/uuid_spec.rb +8 -8
  35. data/spec/acfs/resource/attributes_spec.rb +8 -8
  36. data/spec/acfs/resource/dirty_spec.rb +1 -1
  37. data/spec/acfs/resource/persistence_spec.rb +7 -7
  38. data/spec/acfs/resource/query_methods_spec.rb +1 -1
  39. data/spec/acfs/runner_spec.rb +12 -12
  40. data/spec/acfs/stub_spec.rb +13 -18
  41. data/spec/acfs_spec.rb +4 -4
  42. data/spec/spec_helper.rb +9 -5
  43. data/spec/support/hash.rb +1 -1
  44. data/vendor/bundle/ruby/3.4.0/bundler/gems/rubocop-config-67802c9d1826/LICENSE +21 -0
  45. data/vendor/bundle/ruby/3.4.0/bundler/gems/rubocop-config-67802c9d1826/README.md +23 -0
  46. data/vendor/bundle/ruby/3.4.0/bundler/gems/rubocop-config-67802c9d1826/rubocop-config.gemspec +31 -0
  47. data/vendor/bundle/ruby/3.4.0/gems/actionpack-8.0.1/CHANGELOG.md +205 -0
  48. data/vendor/bundle/ruby/3.4.0/gems/actionpack-8.0.1/MIT-LICENSE +21 -0
  49. data/vendor/bundle/ruby/3.4.0/gems/actionpack-8.0.1/README.rdoc +57 -0
  50. data/vendor/bundle/ruby/3.4.0/gems/actionview-8.0.1/CHANGELOG.md +67 -0
  51. data/vendor/bundle/ruby/3.4.0/gems/actionview-8.0.1/MIT-LICENSE +21 -0
  52. data/vendor/bundle/ruby/3.4.0/gems/actionview-8.0.1/README.rdoc +40 -0
  53. data/vendor/bundle/ruby/3.4.0/gems/activemodel-8.0.1/CHANGELOG.md +110 -0
  54. data/vendor/bundle/ruby/3.4.0/gems/activemodel-8.0.1/MIT-LICENSE +21 -0
  55. data/vendor/bundle/ruby/3.4.0/gems/activemodel-8.0.1/README.rdoc +266 -0
  56. data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.1/CHANGELOG.md +157 -0
  57. data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.1/MIT-LICENSE +20 -0
  58. data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.1/README.rdoc +40 -0
  59. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/CHANGELOG.md +301 -0
  60. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/LICENSE.txt +202 -0
  61. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/README.md +121 -0
  62. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/addressable.gemspec +28 -0
  63. data/vendor/bundle/ruby/3.4.0/gems/appraisal-2.5.0/MIT-LICENSE +21 -0
  64. data/vendor/bundle/ruby/3.4.0/gems/appraisal-2.5.0/README.md +243 -0
  65. data/vendor/bundle/ruby/3.4.0/gems/appraisal-2.5.0/appraisal.gemspec +29 -0
  66. data/vendor/bundle/ruby/3.4.0/gems/base64-0.2.0/LICENSE.txt +22 -0
  67. data/vendor/bundle/ruby/3.4.0/gems/base64-0.2.0/README.md +48 -0
  68. data/vendor/bundle/ruby/3.4.0/gems/benchmark-0.4.0/README.md +138 -0
  69. data/vendor/bundle/ruby/3.4.0/gems/benchmark-0.4.0/benchmark.gemspec +32 -0
  70. data/vendor/bundle/ruby/3.4.0/gems/bigdecimal-3.1.9/LICENSE +56 -0
  71. data/vendor/bundle/ruby/3.4.0/gems/bigdecimal-3.1.9/bigdecimal.gemspec +57 -0
  72. data/vendor/bundle/ruby/3.4.0/gems/builder-3.3.0/MIT-LICENSE +20 -0
  73. data/vendor/bundle/ruby/3.4.0/gems/builder-3.3.0/README.md +258 -0
  74. data/vendor/bundle/ruby/3.4.0/gems/builder-3.3.0/builder.gemspec +49 -0
  75. data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/CHANGELOG.md +603 -0
  76. data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/LICENSE.txt +21 -0
  77. data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/README.md +407 -0
  78. data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.0/LICENSE +20 -0
  79. data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.0/README.md +167 -0
  80. data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.0/connection_pool.gemspec +24 -0
  81. data/vendor/bundle/ruby/3.4.0/gems/crack-1.0.0/LICENSE +20 -0
  82. data/vendor/bundle/ruby/3.4.0/gems/crack-1.0.0/README.md +43 -0
  83. data/vendor/bundle/ruby/3.4.0/gems/crass-1.0.6/LICENSE +18 -0
  84. data/vendor/bundle/ruby/3.4.0/gems/crass-1.0.6/README.md +192 -0
  85. data/vendor/bundle/ruby/3.4.0/gems/crass-1.0.6/crass.gemspec +31 -0
  86. data/vendor/bundle/ruby/3.4.0/gems/diff-lcs-1.5.1/License.md +41 -0
  87. data/vendor/bundle/ruby/3.4.0/gems/diff-lcs-1.5.1/README.rdoc +84 -0
  88. data/vendor/bundle/ruby/3.4.0/gems/drb-2.2.1/LICENSE.txt +22 -0
  89. data/vendor/bundle/ruby/3.4.0/gems/drb-2.2.1/drb.gemspec +41 -0
  90. data/vendor/bundle/ruby/3.4.0/gems/erubi-1.13.1/CHANGELOG +111 -0
  91. data/vendor/bundle/ruby/3.4.0/gems/erubi-1.13.1/MIT-LICENSE +21 -0
  92. data/vendor/bundle/ruby/3.4.0/gems/erubi-1.13.1/README.rdoc +151 -0
  93. data/vendor/bundle/ruby/3.4.0/gems/ethon-0.16.0/CHANGELOG.md +375 -0
  94. data/vendor/bundle/ruby/3.4.0/gems/ethon-0.16.0/LICENSE +20 -0
  95. data/vendor/bundle/ruby/3.4.0/gems/ethon-0.16.0/README.md +118 -0
  96. data/vendor/bundle/ruby/3.4.0/gems/ethon-0.16.0/ethon.gemspec +26 -0
  97. data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.1-x86_64-linux-gnu/CHANGELOG.md +465 -0
  98. data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.1-x86_64-linux-gnu/LICENSE +24 -0
  99. data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.1-x86_64-linux-gnu/LICENSE.SPECS +22 -0
  100. data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.1-x86_64-linux-gnu/README.md +137 -0
  101. data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.1-x86_64-linux-gnu/ffi.gemspec +42 -0
  102. data/vendor/bundle/ruby/3.4.0/gems/hashdiff-1.1.2/LICENSE +19 -0
  103. data/vendor/bundle/ruby/3.4.0/gems/hashdiff-1.1.2/README.md +298 -0
  104. data/vendor/bundle/ruby/3.4.0/gems/hashdiff-1.1.2/changelog.md +119 -0
  105. data/vendor/bundle/ruby/3.4.0/gems/hashdiff-1.1.2/hashdiff.gemspec +39 -0
  106. data/vendor/bundle/ruby/3.4.0/gems/i18n-1.14.6/MIT-LICENSE +20 -0
  107. data/vendor/bundle/ruby/3.4.0/gems/i18n-1.14.6/README.md +127 -0
  108. data/vendor/bundle/ruby/3.4.0/gems/json-2.9.1/README.md +195 -0
  109. data/vendor/bundle/ruby/3.4.0/gems/json-2.9.1/json.gemspec +64 -0
  110. data/vendor/bundle/ruby/3.4.0/gems/logger-1.6.5/README.md +104 -0
  111. data/vendor/bundle/ruby/3.4.0/gems/logger-1.6.5/logger.gemspec +28 -0
  112. data/vendor/bundle/ruby/3.4.0/gems/loofah-2.24.0/CHANGELOG.md +591 -0
  113. data/vendor/bundle/ruby/3.4.0/gems/loofah-2.24.0/MIT-LICENSE.txt +23 -0
  114. data/vendor/bundle/ruby/3.4.0/gems/loofah-2.24.0/README.md +410 -0
  115. data/vendor/bundle/ruby/3.4.0/gems/minitest-5.25.4/README.rdoc +835 -0
  116. data/vendor/bundle/ruby/3.4.0/gems/multi_json-1.15.0/CHANGELOG.md +275 -0
  117. data/vendor/bundle/ruby/3.4.0/gems/multi_json-1.15.0/LICENSE.md +20 -0
  118. data/vendor/bundle/ruby/3.4.0/gems/multi_json-1.15.0/README.md +121 -0
  119. data/vendor/bundle/ruby/3.4.0/gems/nokogiri-1.18.1-x86_64-linux-gnu/LICENSE-DEPENDENCIES.md +2224 -0
  120. data/vendor/bundle/ruby/3.4.0/gems/nokogiri-1.18.1-x86_64-linux-gnu/LICENSE.md +9 -0
  121. data/vendor/bundle/ruby/3.4.0/gems/nokogiri-1.18.1-x86_64-linux-gnu/README.md +293 -0
  122. data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.1/CHANGELOG.md +491 -0
  123. data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.1/LICENSE.txt +22 -0
  124. data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.1/README.md +222 -0
  125. data/vendor/bundle/ruby/3.4.0/gems/racc-1.8.1/ChangeLog +846 -0
  126. data/vendor/bundle/ruby/3.4.0/gems/racc-1.8.1/README.ja.rdoc +58 -0
  127. data/vendor/bundle/ruby/3.4.0/gems/racc-1.8.1/README.rdoc +60 -0
  128. data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.8/CHANGELOG.md +998 -0
  129. data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.8/MIT-LICENSE +20 -0
  130. data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.8/README.md +328 -0
  131. data/vendor/bundle/ruby/3.4.0/gems/rack-session-2.1.0/license.md +72 -0
  132. data/vendor/bundle/ruby/3.4.0/gems/rack-session-2.1.0/readme.md +47 -0
  133. data/vendor/bundle/ruby/3.4.0/gems/rack-test-2.2.0/MIT-LICENSE.txt +20 -0
  134. data/vendor/bundle/ruby/3.4.0/gems/rack-test-2.2.0/README.md +139 -0
  135. data/vendor/bundle/ruby/3.4.0/gems/rails-dom-testing-2.2.0/MIT-LICENSE +23 -0
  136. data/vendor/bundle/ruby/3.4.0/gems/rails-dom-testing-2.2.0/README.md +91 -0
  137. data/vendor/bundle/ruby/3.4.0/gems/rails-html-sanitizer-1.6.2/CHANGELOG.md +255 -0
  138. data/vendor/bundle/ruby/3.4.0/gems/rails-html-sanitizer-1.6.2/MIT-LICENSE +23 -0
  139. data/vendor/bundle/ruby/3.4.0/gems/rails-html-sanitizer-1.6.2/README.md +267 -0
  140. data/vendor/bundle/ruby/3.4.0/gems/rake-13.2.1/MIT-LICENSE +21 -0
  141. data/vendor/bundle/ruby/3.4.0/gems/rake-13.2.1/README.rdoc +155 -0
  142. data/vendor/bundle/ruby/3.4.0/gems/rake-13.2.1/rake.gemspec +101 -0
  143. data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/LICENSE +21 -0
  144. data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/README.md +107 -0
  145. data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/rake-release.gemspec +23 -0
  146. data/vendor/bundle/ruby/3.4.0/gems/rexml-3.4.0/LICENSE.txt +22 -0
  147. data/vendor/bundle/ruby/3.4.0/gems/rexml-3.4.0/README.md +57 -0
  148. data/vendor/bundle/ruby/3.4.0/gems/rspec-3.13.0/LICENSE.md +27 -0
  149. data/vendor/bundle/ruby/3.4.0/gems/rspec-3.13.0/README.md +47 -0
  150. data/vendor/bundle/ruby/3.4.0/gems/rspec-collection_matchers-1.2.1/Changelog.md +68 -0
  151. data/vendor/bundle/ruby/3.4.0/gems/rspec-collection_matchers-1.2.1/LICENSE.txt +27 -0
  152. data/vendor/bundle/ruby/3.4.0/gems/rspec-collection_matchers-1.2.1/README.md +76 -0
  153. data/vendor/bundle/ruby/3.4.0/gems/rspec-collection_matchers-1.2.1/rspec-collection_matchers.gemspec +33 -0
  154. data/vendor/bundle/ruby/3.4.0/gems/rspec-core-3.13.2/Changelog.md +2415 -0
  155. data/vendor/bundle/ruby/3.4.0/gems/rspec-core-3.13.2/LICENSE.md +26 -0
  156. data/vendor/bundle/ruby/3.4.0/gems/rspec-core-3.13.2/README.md +389 -0
  157. data/vendor/bundle/ruby/3.4.0/gems/rspec-expectations-3.13.3/Changelog.md +1352 -0
  158. data/vendor/bundle/ruby/3.4.0/gems/rspec-expectations-3.13.3/LICENSE.md +25 -0
  159. data/vendor/bundle/ruby/3.4.0/gems/rspec-expectations-3.13.3/README.md +326 -0
  160. data/vendor/bundle/ruby/3.4.0/gems/rspec-its-2.0.0/Changelog.md +73 -0
  161. data/vendor/bundle/ruby/3.4.0/gems/rspec-its-2.0.0/LICENSE.txt +27 -0
  162. data/vendor/bundle/ruby/3.4.0/gems/rspec-its-2.0.0/README.md +104 -0
  163. data/vendor/bundle/ruby/3.4.0/gems/rspec-its-2.0.0/rspec-its.gemspec +31 -0
  164. data/vendor/bundle/ruby/3.4.0/gems/rspec-mocks-3.13.2/Changelog.md +1299 -0
  165. data/vendor/bundle/ruby/3.4.0/gems/rspec-mocks-3.13.2/LICENSE.md +25 -0
  166. data/vendor/bundle/ruby/3.4.0/gems/rspec-mocks-3.13.2/README.md +465 -0
  167. data/vendor/bundle/ruby/3.4.0/gems/rspec-support-3.13.2/Changelog.md +408 -0
  168. data/vendor/bundle/ruby/3.4.0/gems/rspec-support-3.13.2/LICENSE.md +23 -0
  169. data/vendor/bundle/ruby/3.4.0/gems/rspec-support-3.13.2/README.md +40 -0
  170. data/vendor/bundle/ruby/3.4.0/gems/securerandom-0.4.1/README.md +72 -0
  171. data/vendor/bundle/ruby/3.4.0/gems/thor-1.3.2/LICENSE.md +20 -0
  172. data/vendor/bundle/ruby/3.4.0/gems/thor-1.3.2/README.md +45 -0
  173. data/vendor/bundle/ruby/3.4.0/gems/thor-1.3.2/thor.gemspec +33 -0
  174. data/vendor/bundle/ruby/3.4.0/gems/typhoeus-1.4.1/CHANGELOG.md +410 -0
  175. data/vendor/bundle/ruby/3.4.0/gems/typhoeus-1.4.1/LICENSE +22 -0
  176. data/vendor/bundle/ruby/3.4.0/gems/typhoeus-1.4.1/README.md +588 -0
  177. data/vendor/bundle/ruby/3.4.0/gems/typhoeus-1.4.1/typhoeus.gemspec +25 -0
  178. data/vendor/bundle/ruby/3.4.0/gems/tzinfo-2.0.6/LICENSE +19 -0
  179. data/vendor/bundle/ruby/3.4.0/gems/tzinfo-2.0.6/README.md +406 -0
  180. data/vendor/bundle/ruby/3.4.0/gems/uri-1.0.2/README.md +55 -0
  181. data/vendor/bundle/ruby/3.4.0/gems/useragent-0.16.11/LICENSE +20 -0
  182. data/vendor/bundle/ruby/3.4.0/gems/useragent-0.16.11/README.md +42 -0
  183. data/vendor/bundle/ruby/3.4.0/gems/webmock-3.24.0/CHANGELOG.md +2104 -0
  184. data/vendor/bundle/ruby/3.4.0/gems/webmock-3.24.0/LICENSE +20 -0
  185. data/vendor/bundle/ruby/3.4.0/gems/webmock-3.24.0/README.md +1222 -0
  186. data/vendor/bundle/ruby/3.4.0/specifications/actionpack-8.0.1.gemspec +36 -0
  187. data/vendor/bundle/ruby/3.4.0/specifications/actionview-8.0.1.gemspec +33 -0
  188. data/vendor/bundle/ruby/3.4.0/specifications/activemodel-8.0.1.gemspec +26 -0
  189. data/vendor/bundle/ruby/3.4.0/specifications/activesupport-8.0.1.gemspec +38 -0
  190. data/vendor/bundle/ruby/3.4.0/specifications/addressable-2.8.7.gemspec +30 -0
  191. data/vendor/bundle/ruby/3.4.0/specifications/appraisal-2.5.0.gemspec +31 -0
  192. data/vendor/bundle/ruby/3.4.0/specifications/base64-0.2.0.gemspec +23 -0
  193. data/vendor/bundle/ruby/3.4.0/specifications/benchmark-0.4.0.gemspec +23 -0
  194. data/vendor/bundle/ruby/3.4.0/specifications/bigdecimal-3.1.9.gemspec +25 -0
  195. data/vendor/bundle/ruby/3.4.0/specifications/builder-3.3.0.gemspec +22 -0
  196. data/vendor/bundle/ruby/3.4.0/specifications/concurrent-ruby-1.3.5.gemspec +24 -0
  197. data/vendor/bundle/ruby/3.4.0/specifications/connection_pool-2.5.0.gemspec +28 -0
  198. data/vendor/bundle/ruby/3.4.0/specifications/crack-1.0.0.gemspec +27 -0
  199. data/vendor/bundle/ruby/3.4.0/specifications/crass-1.0.6.gemspec +27 -0
  200. data/vendor/bundle/ruby/3.4.0/specifications/diff-lcs-1.5.1.gemspec +37 -0
  201. data/vendor/bundle/ruby/3.4.0/specifications/drb-2.2.1.gemspec +22 -0
  202. data/vendor/bundle/ruby/3.4.0/specifications/erubi-1.13.1.gemspec +29 -0
  203. data/vendor/bundle/ruby/3.4.0/specifications/ethon-0.16.0.gemspec +24 -0
  204. data/vendor/bundle/ruby/3.4.0/specifications/ffi-1.17.1-x86_64-linux-gnu.gemspec +31 -0
  205. data/vendor/bundle/ruby/3.4.0/specifications/hashdiff-1.1.2.gemspec +30 -0
  206. data/vendor/bundle/ruby/3.4.0/specifications/i18n-1.14.6.gemspec +27 -0
  207. data/vendor/bundle/ruby/3.4.0/specifications/json-2.9.1.gemspec +0 -0
  208. data/vendor/bundle/ruby/3.4.0/specifications/logger-1.6.5.gemspec +22 -0
  209. data/vendor/bundle/ruby/3.4.0/specifications/loofah-2.24.0.gemspec +27 -0
  210. data/vendor/bundle/ruby/3.4.0/specifications/minitest-5.25.4.gemspec +31 -0
  211. data/vendor/bundle/ruby/3.4.0/specifications/multi_json-1.15.0.gemspec +26 -0
  212. data/vendor/bundle/ruby/3.4.0/specifications/nokogiri-1.18.1-x86_64-linux-gnu.gemspec +31 -0
  213. data/vendor/bundle/ruby/3.4.0/specifications/public_suffix-6.0.1.gemspec +24 -0
  214. data/vendor/bundle/ruby/3.4.0/specifications/racc-1.8.1.gemspec +28 -0
  215. data/vendor/bundle/ruby/3.4.0/specifications/rack-3.1.8.gemspec +31 -0
  216. data/vendor/bundle/ruby/3.4.0/specifications/rack-session-2.1.0.gemspec +30 -0
  217. data/vendor/bundle/ruby/3.4.0/specifications/rack-test-2.2.0.gemspec +29 -0
  218. data/vendor/bundle/ruby/3.4.0/specifications/rails-dom-testing-2.2.0.gemspec +28 -0
  219. data/vendor/bundle/ruby/3.4.0/specifications/rails-html-sanitizer-1.6.2.gemspec +27 -0
  220. data/vendor/bundle/ruby/3.4.0/specifications/rake-13.2.1.gemspec +26 -0
  221. data/vendor/bundle/ruby/3.4.0/specifications/rake-release-1.3.0.gemspec +26 -0
  222. data/vendor/bundle/ruby/3.4.0/specifications/rexml-3.4.0.gemspec +25 -0
  223. data/vendor/bundle/ruby/3.4.0/specifications/rspec-3.13.0.gemspec +31 -0
  224. data/vendor/bundle/ruby/3.4.0/specifications/rspec-collection_matchers-1.2.1.gemspec +27 -0
  225. data/vendor/bundle/ruby/3.4.0/specifications/rspec-core-3.13.2.gemspec +39 -0
  226. data/vendor/bundle/ruby/3.4.0/specifications/rspec-expectations-3.13.3.gemspec +33 -0
  227. data/vendor/bundle/ruby/3.4.0/specifications/rspec-its-2.0.0.gemspec +27 -0
  228. data/vendor/bundle/ruby/3.4.0/specifications/rspec-mocks-3.13.2.gemspec +33 -0
  229. data/vendor/bundle/ruby/3.4.0/specifications/rspec-support-3.13.2.gemspec +29 -0
  230. data/vendor/bundle/ruby/3.4.0/specifications/securerandom-0.4.1.gemspec +23 -0
  231. data/vendor/bundle/ruby/3.4.0/specifications/thor-1.3.2.gemspec +28 -0
  232. data/vendor/bundle/ruby/3.4.0/specifications/typhoeus-1.4.1.gemspec +24 -0
  233. data/vendor/bundle/ruby/3.4.0/specifications/tzinfo-2.0.6.gemspec +30 -0
  234. data/vendor/bundle/ruby/3.4.0/specifications/uri-1.0.2.gemspec +23 -0
  235. data/vendor/bundle/ruby/3.4.0/specifications/useragent-0.16.11.gemspec +25 -0
  236. data/vendor/bundle/ruby/3.4.0/specifications/webmock-3.24.0.gemspec +45 -0
  237. metadata +204 -67
@@ -0,0 +1,1222 @@
1
+ WebMock
2
+ =======
3
+ [![Gem Version](https://badge.fury.io/rb/webmock.svg)](http://badge.fury.io/rb/webmock)
4
+ [![Build Status](https://github.com/bblimke/webmock/actions/workflows/CI.yml/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
+
8
+ Library for stubbing and setting expectations on HTTP requests in Ruby.
9
+
10
+ Features
11
+ --------
12
+
13
+ * Stubbing HTTP requests at low http client lib level (no need to change tests when you change HTTP library)
14
+ * Setting and verifying expectations on HTTP requests
15
+ * Matching requests based on method, URI, headers and body
16
+ * Smart matching of the same URIs in different representations (also encoded and non encoded forms)
17
+ * Smart matching of the same headers in different representations.
18
+ * Support for Test::Unit
19
+ * Support for RSpec
20
+ * Support for MiniTest
21
+
22
+ Supported HTTP libraries
23
+ ------------------------
24
+
25
+ * [Async::HTTP::Client](https://github.com/socketry/async-http)
26
+ * [Curb](https://github.com/taf2/curb) (currently only Curb::Easy)
27
+ * [EM-HTTP-Request](https://github.com/igrigorik/em-http-request)
28
+ * [Excon](https://github.com/excon/excon)
29
+ * [HTTPClient](https://github.com/nahi/httpclient)
30
+ * [HTTP Gem (also known as http.rb)](https://github.com/httprb/http)
31
+ * [httpx](https://honeyryderchuck.gitlab.io/httpx/wiki/Webmock-Adapter)
32
+ * [Manticore](https://github.com/cheald/manticore)
33
+ * [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.:
34
+ * [HTTParty](https://github.com/jnunemaker/httparty)
35
+ * [REST Client](https://github.com/rest-client/rest-client)
36
+ * [Patron](https://github.com/toland/patron)
37
+ * [Typhoeus](https://github.com/typhoeus/typhoeus) (currently only Typhoeus::Hydra)
38
+
39
+ Supported Ruby Interpreters
40
+ ---------------------------
41
+ * MRI 2.6
42
+ * MRI 2.7
43
+ * MRI 3.0
44
+ * MRI 3.1
45
+ * MRI 3.2
46
+ * MRI 3.3
47
+ * JRuby
48
+
49
+ ## Installation
50
+
51
+ ```bash
52
+ gem install webmock
53
+ ```
54
+ or alternatively:
55
+
56
+ ```ruby
57
+ # add to your Gemfile
58
+ group :test do
59
+ gem "webmock"
60
+ end
61
+ ```
62
+
63
+ ### or to install the latest development version from github master
64
+
65
+ ```bash
66
+ git clone http://github.com/bblimke/webmock.git
67
+ cd webmock
68
+ rake install
69
+ ```
70
+
71
+ ## Upgrading from v1.x to v2.x
72
+
73
+ WebMock 2.x has changed somewhat since version 1.x. Changes are listed in [CHANGELOG.md](CHANGELOG.md)
74
+
75
+ ### Cucumber
76
+
77
+ Create a file `features/support/webmock.rb` with the following contents:
78
+
79
+ ```ruby
80
+ require 'webmock/cucumber'
81
+ ```
82
+
83
+ ### MiniTest
84
+
85
+ Add the following code to `test/test_helper`:
86
+
87
+ ```ruby
88
+ require 'webmock/minitest'
89
+ ```
90
+
91
+ ### RSpec
92
+
93
+ Add the following code to `spec/spec_helper`:
94
+
95
+ ```ruby
96
+ require 'webmock/rspec'
97
+ ```
98
+
99
+ ### Test::Unit
100
+
101
+ Add the following code to `test/test_helper.rb`
102
+
103
+ ```ruby
104
+ require 'webmock/test_unit'
105
+ ```
106
+
107
+ ### Outside a test framework
108
+
109
+ You can also use WebMock outside a test framework:
110
+
111
+ ```ruby
112
+ require 'webmock'
113
+ include WebMock::API
114
+
115
+ WebMock.enable!
116
+ ```
117
+
118
+ # Examples
119
+
120
+ ## Stubbing
121
+
122
+ ### Stubbed request based on uri only and with the default response
123
+
124
+ ```ruby
125
+ stub_request(:any, "www.example.com")
126
+
127
+ Net::HTTP.get("www.example.com", "/") # ===> Success
128
+ ```
129
+
130
+ ### Stubbing requests based on method, uri, body and headers
131
+
132
+ ```ruby
133
+ stub_request(:post, "www.example.com").
134
+ with(body: "abc", headers: { 'Content-Length' => 3 })
135
+
136
+ uri = URI.parse("http://www.example.com/")
137
+ req = Net::HTTP::Post.new(uri.path)
138
+ req['Content-Length'] = 3
139
+
140
+ res = Net::HTTP.start(uri.host, uri.port) do |http|
141
+ http.request(req, "abc")
142
+ end # ===> Success
143
+ ```
144
+
145
+ ### Matching request body and headers against regular expressions
146
+
147
+ ```ruby
148
+ stub_request(:post, "www.example.com").
149
+ with(body: /world$/, headers: {"Content-Type" => /image\/.+/}).
150
+ to_return(body: "abc")
151
+
152
+ uri = URI.parse('http://www.example.com/')
153
+ req = Net::HTTP::Post.new(uri.path)
154
+ req['Content-Type'] = 'image/png'
155
+
156
+ res = Net::HTTP.start(uri.host, uri.port) do |http|
157
+ http.request(req, 'hello world')
158
+ end # ===> Success
159
+ ```
160
+
161
+ ### Matching request body against a hash. Body can be URL-Encoded, JSON or XML.
162
+
163
+ ```ruby
164
+ stub_request(:post, "www.example.com").
165
+ with(body: {data: {a: '1', b: 'five'}})
166
+
167
+ RestClient.post('www.example.com', "data[a]=1&data[b]=five",
168
+ content_type: 'application/x-www-form-urlencoded') # ===> Success
169
+
170
+ RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
171
+ content_type: 'application/json') # ===> Success
172
+
173
+ RestClient.post('www.example.com', '<data a="1" b="five" />',
174
+ content_type: 'application/xml') # ===> Success
175
+ ```
176
+
177
+ ### Matching request body against partial hash.
178
+
179
+ ```ruby
180
+ stub_request(:post, "www.example.com").
181
+ with(body: hash_including({data: {a: '1', b: 'five'}}))
182
+
183
+ RestClient.post('www.example.com', "data[a]=1&data[b]=five&x=1",
184
+ :content_type => 'application/x-www-form-urlencoded') # ===> Success
185
+ ```
186
+
187
+ ### Matching custom request headers
188
+
189
+ ```ruby
190
+ stub_request(:any, "www.example.com").
191
+ with(headers:{ 'Header-Name' => 'Header-Value' })
192
+
193
+ uri = URI.parse('http://www.example.com/')
194
+ req = Net::HTTP::Post.new(uri.path)
195
+ req['Header-Name'] = 'Header-Value'
196
+
197
+ res = Net::HTTP.start(uri.host, uri.port) do |http|
198
+ http.request(req, 'abc')
199
+ end # ===> Success
200
+ ```
201
+
202
+ ### Matching multiple headers with the same name
203
+
204
+ ```ruby
205
+ stub_request(:get, 'www.example.com').
206
+ with(headers: {'Accept' => ['image/jpeg', 'image/png'] })
207
+
208
+ req = Net::HTTP::Get.new("/")
209
+ req['Accept'] = ['image/png']
210
+ req.add_field('Accept', 'image/jpeg')
211
+ Net::HTTP.start("www.example.com") {|http| http.request(req) } # ===> Success
212
+ ```
213
+
214
+ ### Matching requests against provided block
215
+
216
+ ```ruby
217
+ stub_request(:post, "www.example.com").with { |request| request.body == "abc" }
218
+ RestClient.post('www.example.com', 'abc') # ===> Success
219
+ ```
220
+
221
+ ### Request with basic authentication header
222
+
223
+ ```ruby
224
+ stub_request(:get, "www.example.com").with(basic_auth: ['user', 'pass'])
225
+ # or
226
+ # stub_request(:get, "www.example.com").
227
+ # with(headers: {'Authorization' => "Basic #{ Base64.strict_encode64('user:pass').chomp}"})
228
+
229
+ Net::HTTP.start('www.example.com') do |http|
230
+ req = Net::HTTP::Get.new('/')
231
+ req.basic_auth 'user', 'pass'
232
+ http.request(req)
233
+ end # ===> Success
234
+ ```
235
+
236
+ ##### 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.
237
+
238
+ ### Request with basic authentication in the url
239
+
240
+ ```ruby
241
+ stub_request(:get, "user:pass@www.example.com")
242
+
243
+ RestClient.get('user:pass@www.example.com') # ===> Success
244
+ ```
245
+
246
+ ### Matching uris using regular expressions
247
+
248
+ ```ruby
249
+ stub_request(:any, /example/)
250
+
251
+ Net::HTTP.get('www.example.com', '/') # ===> Success
252
+ ```
253
+
254
+ ### Matching uris using lambda
255
+
256
+ ```ruby
257
+ stub_request(:any, ->(uri) { true })
258
+ ```
259
+
260
+ ### Matching uris using RFC 6570 - Basic Example
261
+
262
+ ```ruby
263
+ uri_template = Addressable::Template.new "www.example.com/{id}/"
264
+ stub_request(:any, uri_template)
265
+
266
+ Net::HTTP.get('www.example.com', '/webmock/') # ===> Success
267
+ ```
268
+
269
+ ### Matching uris using RFC 6570 - Advanced Example
270
+
271
+ ```ruby
272
+ uri_template =
273
+ Addressable::Template.new "www.example.com/thing/{id}.json{?x,y,z}{&other*}"
274
+ stub_request(:any, uri_template)
275
+
276
+ Net::HTTP.get('www.example.com',
277
+ '/thing/5.json?x=1&y=2&z=3&anyParam=4') # ===> Success
278
+ ```
279
+
280
+ ### Matching query params using hash
281
+
282
+ ```ruby
283
+ stub_request(:get, "www.example.com").with(query: {"a" => ["b", "c"]})
284
+
285
+ RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
286
+ ```
287
+
288
+ ### Matching partial query params using hash
289
+
290
+ ```ruby
291
+ stub_request(:get, "www.example.com").
292
+ with(query: hash_including({"a" => ["b", "c"]}))
293
+
294
+ RestClient.get("http://www.example.com/?a[]=b&a[]=c&x=1") # ===> Success
295
+ ```
296
+
297
+ ### Matching partial query params using hash_excluding
298
+
299
+ ```ruby
300
+ stub_request(:get, "www.example.com").
301
+ with(query: hash_excluding({"a" => "b"}))
302
+
303
+ RestClient.get("http://www.example.com/?a=b") # ===> Failure
304
+ RestClient.get("http://www.example.com/?a=c") # ===> Success
305
+ ```
306
+
307
+ ### Stubbing with custom response
308
+
309
+ ```ruby
310
+ stub_request(:any, "www.example.com").
311
+ to_return(body: "abc", status: 200,
312
+ headers: { 'Content-Length' => 3 })
313
+
314
+ Net::HTTP.get("www.example.com", '/') # ===> "abc"
315
+ ```
316
+
317
+ Set appropriate Content-Type for HTTParty's `parsed_response`.
318
+
319
+ ```ruby
320
+ stub_request(:any, "www.example.com").to_return body: '{}', headers: {content_type: 'application/json'}
321
+ ```
322
+
323
+ ### Response with body specified as IO object
324
+
325
+ ```ruby
326
+ File.open('/tmp/response_body.txt', 'w') { |f| f.puts 'abc' }
327
+
328
+ stub_request(:any, "www.example.com").
329
+ to_return(body: File.new('/tmp/response_body.txt'), status: 200)
330
+
331
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
332
+ ```
333
+
334
+ ### Response with JSON body
335
+
336
+ ```ruby
337
+
338
+ stub_request(:any, "www.example.com").
339
+ to_return_json(body: {foo: "bar"})
340
+
341
+ Net::HTTP.get('www.example.com', '/') # ===> "{\"foo\": \"bar\"}"
342
+ ```
343
+
344
+ ### Response with custom status message
345
+
346
+ ```ruby
347
+ stub_request(:any, "www.example.com").
348
+ to_return(status: [500, "Internal Server Error"])
349
+
350
+ req = Net::HTTP::Get.new("/")
351
+ Net::HTTP.start("www.example.com") { |http| http.request(req) }.
352
+ message # ===> "Internal Server Error"
353
+ ```
354
+
355
+ ### Replaying raw responses recorded with `curl -is`
356
+
357
+ ```
358
+ curl -is www.example.com > /tmp/example_curl_-is_output.txt
359
+ ```
360
+
361
+ ```ruby
362
+ raw_response_file = File.new("/tmp/example_curl_-is_output.txt")
363
+ ```
364
+
365
+ from file
366
+
367
+ ```ruby
368
+ stub_request(:get, "www.example.com").to_return(raw_response_file)
369
+ ```
370
+
371
+ or string
372
+
373
+ ```ruby
374
+ stub_request(:get, "www.example.com").to_return(raw_response_file.read)
375
+ ```
376
+
377
+ ### Responses dynamically evaluated from block
378
+
379
+ ```ruby
380
+ stub_request(:any, 'www.example.net').
381
+ to_return { |request| {body: request.body} }
382
+
383
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
384
+ ```
385
+
386
+ ### Responses dynamically evaluated from lambda
387
+
388
+ ```ruby
389
+ stub_request(:any, 'www.example.net').
390
+ to_return(lambda { |request| {body: request.body} })
391
+
392
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
393
+ ```
394
+
395
+ ### Dynamically evaluated raw responses recorded with `curl -is`
396
+
397
+ `curl -is www.example.com > /tmp/www.example.com.txt`
398
+
399
+ ```ruby
400
+ stub_request(:get, "www.example.com").
401
+ to_return(lambda { |request| File.new("/tmp/#{request.uri.host.to_s}.txt") })
402
+ ```
403
+
404
+ ### Responses with dynamically evaluated parts
405
+
406
+ ```ruby
407
+ stub_request(:any, 'www.example.net').
408
+ to_return(body: lambda { |request| request.body })
409
+
410
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
411
+ ```
412
+
413
+ ### Rack responses
414
+
415
+ ```ruby
416
+ class MyRackApp
417
+ def self.call(env)
418
+ [200, {}, ["Hello"]]
419
+ end
420
+ end
421
+
422
+ stub_request(:get, "www.example.com").to_rack(MyRackApp)
423
+
424
+ RestClient.post('www.example.com') # ===> "Hello"
425
+ ```
426
+
427
+ ### Raising errors
428
+
429
+ #### Exception declared by class
430
+
431
+ ```ruby
432
+ stub_request(:any, 'www.example.net').to_raise(StandardError)
433
+
434
+ RestClient.post('www.example.net', 'abc') # ===> StandardError
435
+ ```
436
+
437
+ #### or by exception instance
438
+
439
+ ```ruby
440
+ stub_request(:any, 'www.example.net').to_raise(StandardError.new("some error"))
441
+ ```
442
+
443
+ #### or by string
444
+
445
+ ```ruby
446
+ stub_request(:any, 'www.example.net').to_raise("some error")
447
+ ```
448
+
449
+ ### Raising timeout errors
450
+
451
+ ```ruby
452
+ stub_request(:any, 'www.example.net').to_timeout
453
+
454
+ RestClient.post('www.example.net', 'abc') # ===> RestClient::RequestTimeout
455
+ ```
456
+
457
+ ### Multiple responses for repeated requests
458
+
459
+ ```ruby
460
+ stub_request(:get, "www.example.com").
461
+ to_return({body: "abc"}, {body: "def"})
462
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
463
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
464
+
465
+ #after all responses are used the last response will be returned infinitely
466
+
467
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
468
+ ```
469
+
470
+ ### Multiple responses using chained `to_return()`, `to_raise()` or `to_timeout` declarations
471
+
472
+ ```ruby
473
+ stub_request(:get, "www.example.com").
474
+ to_return({body: "abc"}).then. #then() is just a syntactic sugar
475
+ to_return({body: "def"}).then.
476
+ to_raise(MyException)
477
+
478
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
479
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
480
+ Net::HTTP.get('www.example.com', '/') # ===> MyException raised
481
+ ```
482
+
483
+ ### Specifying number of times given response should be returned
484
+
485
+ ```ruby
486
+ stub_request(:get, "www.example.com").
487
+ to_return({body: "abc"}).times(2).then.
488
+ to_return({body: "def"})
489
+
490
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
491
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
492
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
493
+ ```
494
+
495
+ ### Removing unused stubs
496
+
497
+ ```ruby
498
+ stub_get = stub_request(:get, "www.example.com")
499
+ remove_request_stub(stub_get)
500
+ ```
501
+
502
+ ### Real requests to network can be allowed or disabled
503
+
504
+ ```ruby
505
+ WebMock.allow_net_connect!
506
+
507
+ stub_request(:any, "www.example.com").to_return(body: "abc")
508
+
509
+ Net::HTTP.get('www.example.com', '/') # ===> "abc"
510
+
511
+ Net::HTTP.get('www.something.com', '/') # ===> /.+Something.+/
512
+
513
+ WebMock.disable_net_connect!
514
+
515
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
516
+ ```
517
+
518
+ ### External requests can be disabled while allowing localhost
519
+
520
+ ```ruby
521
+ WebMock.disable_net_connect!(allow_localhost: true)
522
+
523
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
524
+
525
+ Net::HTTP.get('localhost:9887', '/') # ===> Allowed. Perhaps to Selenium?
526
+ ```
527
+
528
+ ### External requests can be disabled while allowing specific requests
529
+
530
+ Allowed requests can be specified in a number of ways.
531
+
532
+ With a `String` specifying a host name:
533
+
534
+ ```ruby
535
+ WebMock.disable_net_connect!(allow: 'www.example.org')
536
+
537
+ RestClient.get('www.something.com', '/') # ===> Failure
538
+ RestClient.get('www.example.org', '/') # ===> Allowed
539
+ RestClient.get('www.example.org:8080', '/') # ===> Allowed
540
+ ```
541
+
542
+ With a `String` specifying a host name and a port:
543
+
544
+ ```ruby
545
+ WebMock.disable_net_connect!(allow: 'www.example.org:8080')
546
+
547
+ RestClient.get('www.something.com', '/') # ===> Failure
548
+ RestClient.get('www.example.org', '/') # ===> Failure
549
+ RestClient.get('www.example.org:8080', '/') # ===> Allowed
550
+ ```
551
+
552
+ With a `Regexp` matching the URI:
553
+
554
+ ```ruby
555
+ WebMock.disable_net_connect!(allow: %r{ample\.org/foo})
556
+
557
+ RestClient.get('www.example.org', '/foo/bar') # ===> Allowed
558
+ RestClient.get('sample.org', '/foo') # ===> Allowed
559
+ RestClient.get('sample.org', '/bar') # ===> Failure
560
+ ```
561
+
562
+ With an object that responds to `#call`, receiving a `URI` object and returning a boolean:
563
+
564
+ ```ruby
565
+ denylist = ['google.com', 'facebook.com', 'apple.com']
566
+ allowed_sites = lambda{|uri|
567
+ denylist.none?{|site| uri.host.include?(site) }
568
+ }
569
+ WebMock.disable_net_connect!(allow: allowed_sites)
570
+
571
+ RestClient.get('www.example.org', '/') # ===> Allowed
572
+ RestClient.get('www.facebook.com', '/') # ===> Failure
573
+ RestClient.get('apple.com', '/') # ===> Failure
574
+ ```
575
+
576
+ With an `Array` of any of the above:
577
+
578
+ ```ruby
579
+ WebMock.disable_net_connect!(allow: [
580
+ lambda{|uri| uri.host.length % 2 == 0 },
581
+ /ample.org/,
582
+ 'bbc.co.uk',
583
+ ])
584
+
585
+ RestClient.get('www.example.org', '/') # ===> Allowed
586
+ RestClient.get('bbc.co.uk', '/') # ===> Allowed
587
+ RestClient.get('bbc.com', '/') # ===> Allowed
588
+ RestClient.get('www.bbc.com', '/') # ===> Failure
589
+ ```
590
+
591
+ ## Connecting on Net::HTTP.start
592
+
593
+ HTTP protocol has 3 steps: connect, request and response (or 4 with close). Most Ruby HTTP client libraries
594
+ treat connect as a part of request step, with the exception of `Net::HTTP` which
595
+ allows opening connection to the server separately to the request, by using `Net::HTTP.start`.
596
+
597
+ WebMock API was also designed with connect being part of request step, and it only allows stubbing
598
+ requests, not connections. When `Net::HTTP.start` is called, WebMock doesn't know yet whether
599
+ a request is stubbed or not. WebMock by default delays a connection until the request is invoked,
600
+ so when there is no request, `Net::HTTP.start` doesn't do anything.
601
+ **This means that WebMock breaks the Net::HTTP behaviour by default!**
602
+
603
+ To workaround this issue, WebMock offers `:net_http_connect_on_start` option,
604
+ which can be passed to `WebMock.allow_net_connect!` and `WebMock.disable_net_connect!` methods, i.e.
605
+
606
+ ```ruby
607
+ WebMock.allow_net_connect!(net_http_connect_on_start: true)
608
+ ```
609
+
610
+ This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`. At the time of connection being made there is no information about the request or URL yet, therefore WebMock is not able to decide whether to stub a request or not and all connections are allowed. To enable connections only to a specific domain (e.g. your test server) use:
611
+
612
+ ```ruby
613
+ WebMock.allow_net_connect!(net_http_connect_on_start: "www.example.com")
614
+ ```
615
+
616
+ ## Setting Expectations
617
+
618
+ ### Setting expectations in Test::Unit
619
+
620
+ ```ruby
621
+ require 'webmock/test_unit'
622
+
623
+ stub_request(:any, "www.example.com")
624
+
625
+ uri = URI.parse('http://www.example.com/')
626
+ req = Net::HTTP::Post.new(uri.path)
627
+ req['Content-Length'] = 3
628
+
629
+ res = Net::HTTP.start(uri.host, uri.port) do |http|
630
+ http.request(req, 'abc')
631
+ end
632
+
633
+ assert_requested :post, "http://www.example.com",
634
+ headers: {'Content-Length' => 3}, body: "abc",
635
+ times: 1 # ===> Success
636
+
637
+ assert_not_requested :get, "http://www.something.com" # ===> Success
638
+
639
+ assert_requested(:post, "http://www.example.com",
640
+ times: 1) { |req| req.body == "abc" }
641
+ ```
642
+
643
+ ### Expecting real (not stubbed) requests
644
+
645
+ ```ruby
646
+ WebMock.allow_net_connect!
647
+
648
+ Net::HTTP.get('www.example.com', '/') # ===> Success
649
+
650
+ assert_requested :get, "http://www.example.com" # ===> Success
651
+ ```
652
+
653
+ ### Setting expectations in Test::Unit on the stub
654
+
655
+ ```ruby
656
+ stub_get = stub_request(:get, "www.example.com")
657
+ stub_post = stub_request(:post, "www.example.com")
658
+
659
+ Net::HTTP.get('www.example.com', '/')
660
+
661
+ assert_requested(stub_get)
662
+ assert_not_requested(stub_post)
663
+ ```
664
+
665
+
666
+ ### Setting expectations in RSpec on `WebMock` module
667
+ This style is borrowed from [fakeweb-matcher](http://github.com/pat/fakeweb-matcher)
668
+
669
+ ```ruby
670
+ require 'webmock/rspec'
671
+
672
+ expect(WebMock).to have_requested(:get, "www.example.com").
673
+ with(body: "abc", headers: {'Content-Length' => 3}).twice
674
+
675
+ expect(WebMock).not_to have_requested(:get, "www.something.com")
676
+
677
+ expect(WebMock).to have_requested(:post, "www.example.com").
678
+ with { |req| req.body == "abc" }
679
+ # Note that the block with `do ... end` instead of curly brackets won't work!
680
+ # Why? See this comment https://github.com/bblimke/webmock/issues/174#issuecomment-34908908
681
+
682
+ expect(WebMock).to have_requested(:get, "www.example.com").
683
+ with(query: {"a" => ["b", "c"]})
684
+
685
+ expect(WebMock).to have_requested(:get, "www.example.com").
686
+ with(query: hash_including({"a" => ["b", "c"]}))
687
+
688
+ expect(WebMock).to have_requested(:get, "www.example.com").
689
+ with(body: {"a" => ["b", "c"]},
690
+ headers: {'Content-Type' => 'application/json'})
691
+ ```
692
+
693
+ ### Setting expectations in RSpec with `a_request`
694
+
695
+ ```ruby
696
+ expect(a_request(:post, "www.example.com").
697
+ with(body: "abc", headers: {'Content-Length' => 3})).
698
+ to have_been_made.once
699
+
700
+ expect(a_request(:post, "www.something.com")).to have_been_made.times(3)
701
+
702
+ expect(a_request(:post, "www.something.com")).to have_been_made.at_least_once
703
+
704
+ expect(a_request(:post, "www.something.com")).
705
+ to have_been_made.at_least_times(3)
706
+
707
+ expect(a_request(:post, "www.something.com")).to have_been_made.at_most_twice
708
+
709
+ expect(a_request(:post, "www.something.com")).to have_been_made.at_most_times(3)
710
+
711
+ expect(a_request(:any, "www.example.com")).not_to have_been_made
712
+
713
+ expect(a_request(:post, "www.example.com").with { |req| req.body == "abc" }).
714
+ to have_been_made
715
+
716
+ expect(a_request(:get, "www.example.com").with(query: {"a" => ["b", "c"]})).
717
+ to have_been_made
718
+
719
+ expect(a_request(:get, "www.example.com").
720
+ with(query: hash_including({"a" => ["b", "c"]}))).to have_been_made
721
+
722
+ expect(a_request(:post, "www.example.com").
723
+ with(body: {"a" => ["b", "c"]},
724
+ headers: {'Content-Type' => 'application/json'})).to have_been_made
725
+ ```
726
+
727
+ ### Setting expectations in RSpec on the stub
728
+
729
+ ```ruby
730
+ stub = stub_request(:get, "www.example.com")
731
+ # ... make requests ...
732
+ expect(stub).to have_been_requested
733
+ ```
734
+
735
+ ## Clearing stubs and request history
736
+
737
+ If you want to reset all current stubs and history of requests use `WebMock.reset!`
738
+
739
+ ```ruby
740
+ stub_request(:any, "www.example.com")
741
+
742
+ Net::HTTP.get('www.example.com', '/') # ===> Success
743
+
744
+ WebMock.reset!
745
+
746
+ Net::HTTP.get('www.example.com', '/') # ===> Failure
747
+
748
+ assert_not_requested :get, "www.example.com" # ===> Success
749
+ ```
750
+
751
+ ## Clearing request counters
752
+
753
+ If you want to reset **only** the counters of the executed requests use `WebMock.reset_executed_requests!`
754
+
755
+ ```ruby
756
+ stub = stub_request(:get, "www.example.com")
757
+ stub2 = stub_request(:get, "www.example2.com")
758
+
759
+ Net::HTTP.get('www.example.com', '/')
760
+ Net::HTTP.get('www.example.com', '/')
761
+
762
+ Net::HTTP.get('www.example2.com', '/')
763
+
764
+ expect(stub).to have_been_requested.times(2)
765
+ expect(stub2).to have_been_requested.times(1)
766
+
767
+ WebMock.reset_executed_requests!
768
+
769
+ expect(stub).not_to have_been_requested
770
+ expect(stub2).not_to have_been_requested
771
+ ```
772
+
773
+ ## Disabling and enabling WebMock or only some http client adapters
774
+
775
+ ```ruby
776
+ # Disable WebMock (all adapters)
777
+ WebMock.disable!
778
+
779
+ # Disable WebMock for all libs except Net::HTTP
780
+ WebMock.disable!(except: [:net_http])
781
+
782
+ # Enable WebMock (all adapters)
783
+ WebMock.enable!
784
+
785
+ # Enable WebMock for all libs except Patron
786
+ WebMock.enable!(except: [:patron])
787
+ ```
788
+
789
+ ## Matching requests
790
+
791
+ An executed request matches stubbed request if it passes following criteria:
792
+
793
+ - When request URI matches stubbed request URI string, Regexp pattern or RFC 6570 URI Template
794
+ - And request method is the same as stubbed request method or stubbed request method is :any
795
+ - And request body is the same as stubbed request body or stubbed request body is not specified
796
+ - And request headers match stubbed request headers, or stubbed request headers match a subset of request headers, or stubbed request headers are not specified
797
+ - And request matches provided block or block is not provided
798
+
799
+ ## Precedence of stubs
800
+
801
+ Always the last declared stub matching the request will be applied i.e:
802
+
803
+ ```ruby
804
+ stub_request(:get, "www.example.com").to_return(body: "abc")
805
+ stub_request(:get, "www.example.com").to_return(body: "def")
806
+
807
+ Net::HTTP.get('www.example.com', '/') # ====> "def"
808
+ ```
809
+
810
+ ## Matching URIs
811
+
812
+ WebMock will match all different representations of the same URI.
813
+
814
+ I.e all the following representations of the URI are equal:
815
+
816
+ ```ruby
817
+ "www.example.com"
818
+ "www.example.com/"
819
+ "www.example.com:80"
820
+ "www.example.com:80/"
821
+ "http://www.example.com"
822
+ "http://www.example.com/"
823
+ "http://www.example.com:80"
824
+ "http://www.example.com:80/"
825
+ ```
826
+
827
+ The following URIs with userinfo are also equal for WebMock
828
+
829
+ ```ruby
830
+ "a b:pass@www.example.com"
831
+ "a b:pass@www.example.com/"
832
+ "a b:pass@www.example.com:80"
833
+ "a b:pass@www.example.com:80/"
834
+ "http://a b:pass@www.example.com"
835
+ "http://a b:pass@www.example.com/"
836
+ "http://a b:pass@www.example.com:80"
837
+ "http://a b:pass@www.example.com:80/"
838
+ "a%20b:pass@www.example.com"
839
+ "a%20b:pass@www.example.com/"
840
+ "a%20b:pass@www.example.com:80"
841
+ "a%20b:pass@www.example.com:80/"
842
+ "http://a%20b:pass@www.example.com"
843
+ "http://a%20b:pass@www.example.com/"
844
+ "http://a%20b:pass@www.example.com:80"
845
+ "http://a%20b:pass@www.example.com:80/"
846
+ ```
847
+
848
+ or these
849
+
850
+ ```ruby
851
+ "www.example.com/my path/?a=my param&b=c"
852
+ "www.example.com/my%20path/?a=my%20param&b=c"
853
+ "www.example.com:80/my path/?a=my param&b=c"
854
+ "www.example.com:80/my%20path/?a=my%20param&b=c"
855
+ "http://www.example.com/my path/?a=my param&b=c"
856
+ "http://www.example.com/my%20path/?a=my%20param&b=c"
857
+ "http://www.example.com:80/my path/?a=my param&b=c"
858
+ "http://www.example.com:80/my%20path/?a=my%20param&b=c"
859
+ ```
860
+
861
+ If you provide Regexp to match URI, WebMock will try to match it against every valid form of the same url.
862
+
863
+ I.e `/my path/` will match `www.example.com/my%20path` because it is equivalent of `www.example.com/my path`
864
+
865
+ ## Matching with URI Templates
866
+
867
+ 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).
868
+
869
+ 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.
870
+
871
+ ## Matching headers
872
+
873
+ WebMock will match request headers against stubbed request headers in the following situations:
874
+
875
+ 1. Stubbed request has headers specified and request headers are the same as stubbed headers <br/>
876
+ i.e stubbed headers: `{ 'Header1' => 'Value1', 'Header2' => 'Value2' }`, requested: `{ 'Header1' => 'Value1', 'Header2' => 'Value2' }`
877
+
878
+ 2. Stubbed request has headers specified and stubbed request headers are a subset of request headers <br/>
879
+ i.e stubbed headers: `{ 'Header1' => 'Value1' }`, requested: `{ 'Header1' => 'Value1', 'Header2' => 'Value2' }`
880
+
881
+ 3. Stubbed request has no headers <br/>
882
+ i.e stubbed headers: `nil`, requested: `{ 'Header1' => 'Value1', 'Header2' => 'Value2' }`
883
+
884
+ WebMock normalises headers and treats all forms of same headers as equal:
885
+ i.e the following two sets of headers are equal:
886
+
887
+ `{ "Header1" => "value1", content_length: 123, X_CuStOm_hEAder: :value }`
888
+
889
+ `{ header1: "value1", "Content-Length" => 123, "x-cuSTOM-HeAder" => "value" }`
890
+
891
+ ## Recording real requests and responses and replaying them later
892
+
893
+ 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.
894
+
895
+ ## Request callbacks
896
+
897
+ #### WebMock can invoke callbacks stubbed or real requests:
898
+
899
+ ```ruby
900
+ WebMock.after_request do |request_signature, response|
901
+ puts "Request #{request_signature} was made and #{response} was returned"
902
+ end
903
+ ```
904
+
905
+ #### invoke callbacks for real requests only and except requests made with Patron
906
+
907
+ ```ruby
908
+ WebMock.after_request(except: [:patron],
909
+ real_requests_only: true) do |req_signature, response|
910
+ puts "Request #{req_signature} was made and #{response} was returned"
911
+ end
912
+ ```
913
+
914
+ ## Bugs and Issues
915
+
916
+ Please submit them here [http://github.com/bblimke/webmock/issues](http://github.com/bblimke/webmock/issues)
917
+
918
+ ## Issue triage [![Open Source Helpers](https://www.codetriage.com/bblimke/webmock/badges/users.svg)](https://www.codetriage.com/bblimke/webmock)
919
+
920
+ 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).
921
+
922
+ ## Suggestions
923
+
924
+ 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)
925
+
926
+ I'm particularly interested in how the DSL could be improved.
927
+
928
+ ## Development
929
+
930
+ In order to work on Webmock you first need to fork and clone the repo.
931
+ Please do any work on a dedicated branch and rebase against master
932
+ before sending a pull request.
933
+
934
+ ## Credits
935
+
936
+ The initial lines of this project were written during New Bamboo [Hack Day](http://blog.new-bamboo.co.uk/2009/11/13/hackday-results)
937
+ Thanks to my fellow [Bambinos](http://new-bamboo.co.uk/) for all the great suggestions!
938
+
939
+ People who submitted patches and new features or suggested improvements. Many thanks to these people:
940
+
941
+ * Ben Pickles
942
+ * Mark Evans
943
+ * Ivan Vega
944
+ * Piotr Usewicz
945
+ * Nick Plante
946
+ * Nick Quaranto
947
+ * Diego E. "Flameeyes" Pettenò
948
+ * Niels Meersschaert
949
+ * Mack Earnhardt
950
+ * Arvicco
951
+ * Sergio Gil
952
+ * Jeffrey Jones
953
+ * Tekin Suleyman
954
+ * Tom Ward
955
+ * Nadim Bitar
956
+ * Myron Marston
957
+ * Sam Phillips
958
+ * Jose Angel Cortinas
959
+ * Razic
960
+ * Steve Tooke
961
+ * Nathaniel Bibler
962
+ * Martyn Loughran
963
+ * Muness Alrubaie
964
+ * Charles Li
965
+ * Ryan Bigg
966
+ * Pete Higgins
967
+ * Hans de Graaff
968
+ * Alastair Brunton
969
+ * Sam Stokes
970
+ * Eugene Bolshakov
971
+ * James Conroy-Finn
972
+ * Salvador Fuentes Jr
973
+ * Alex Rothenberg
974
+ * Aidan Feldman
975
+ * Steve Hull
976
+ * Jay Adkisson
977
+ * Zach Dennis
978
+ * Nikita Fedyashev
979
+ * Lin Jen-Shin
980
+ * David Yeu
981
+ * Andreas Garnæs
982
+ * Roman Shterenzon
983
+ * Chris McGrath
984
+ * Stephen Celis
985
+ * Eugene Pimenov
986
+ * Albert Llop
987
+ * Christopher Pickslay
988
+ * Tammer Saleh
989
+ * Nicolas Fouché
990
+ * Joe Van Dyk
991
+ * Mark Abramov
992
+ * Frank Schumacher
993
+ * Dimitrij Denissenko
994
+ * Marnen Laibow-Koser
995
+ * Evgeniy Dolzhenko
996
+ * Nick Recobra
997
+ * Jordan Elver
998
+ * Joe Karayusuf
999
+ * Paul Cortens
1000
+ * jugyo
1001
+ * aindustries
1002
+ * Eric Oestrich
1003
+ * erwanlr
1004
+ * Ben Bleything
1005
+ * Jon Leighton
1006
+ * Ryan Schlesinger
1007
+ * Julien Boyer
1008
+ * Kevin Glowacz
1009
+ * Hans Hasselberg
1010
+ * Andrew France
1011
+ * Jonathan Hyman
1012
+ * Rex Feng
1013
+ * Pavel Forkert
1014
+ * Jordi Massaguer Pla
1015
+ * Jake Benilov
1016
+ * Tom Beauvais
1017
+ * Mokevnin Kirill
1018
+ * Alex Grant
1019
+ * Lucas Dohmen
1020
+ * Bastien Vaucher
1021
+ * Joost Baaij
1022
+ * Joel Chippindale
1023
+ * Murahashi Sanemat Kenichi
1024
+ * Tim Kurvers
1025
+ * Ilya Vassilevsky
1026
+ * gotwalt
1027
+ * Leif Bladt
1028
+ * Alex Tomlins
1029
+ * Mitsutaka Mimura
1030
+ * Tomy Kaira
1031
+ * Daniel van Hoesel
1032
+ * Ian Asaff
1033
+ * Ian Lesperance
1034
+ * Matthew Horan
1035
+ * Dmitry Gutov
1036
+ * Florian Dütsch
1037
+ * Manuel Meurer
1038
+ * Brian D. Burns
1039
+ * Riley Strong
1040
+ * Tamir Duberstein
1041
+ * Stefano Uliari
1042
+ * Alex Stupakov
1043
+ * Karen Wang
1044
+ * Matt Burke
1045
+ * Jon Rowe
1046
+ * Aleksey V. Zapparov
1047
+ * Praveen Arimbrathodiyil
1048
+ * Bo Jeanes
1049
+ * Matthew Conway
1050
+ * Rob Olson
1051
+ * Max Lincoln
1052
+ * Oleg Gritsenko
1053
+ * Hwan-Joon Choi
1054
+ * SHIBATA Hiroshi
1055
+ * Caleb Thompson
1056
+ * Theo Hultberg
1057
+ * Pablo Jairala
1058
+ * Insoo Buzz Jung
1059
+ * Carlos Alonso Pérez
1060
+ * trlorenz
1061
+ * Alexander Simonov
1062
+ * Thorbjørn Hermanse
1063
+ * Mark Lorenz
1064
+ * tjsousa
1065
+ * Tasos Stathopoulos
1066
+ * Dan Buettner
1067
+ * Sven Riedel
1068
+ * Mark Lorenz
1069
+ * Dávid Kovács
1070
+ * fishermand46
1071
+ * Franky Wahl
1072
+ * ChaYoung You
1073
+ * Simon Russell
1074
+ * Steve Mitchell
1075
+ * Mattias Putman
1076
+ * Zachary Anker
1077
+ * Emmanuel Sambo
1078
+ * Ramon Tayag
1079
+ * Johannes Schlumberger
1080
+ * Siôn Le Roux
1081
+ * Matt Palmer
1082
+ * Zhao Wen
1083
+ * Krzysztof Rygielski
1084
+ * Magne Land
1085
+ * yurivm
1086
+ * Mike Knepper
1087
+ * Charles Pence
1088
+ * Alexey Zapparov
1089
+ * Pablo Brasero
1090
+ * Cedric Pimenta
1091
+ * Michiel Karnebeek
1092
+ * Alex Kestner
1093
+ * Manfred Stienstra
1094
+ * Tim Diggins
1095
+ * Gabriel Chaney
1096
+ * Chris Griego
1097
+ * Taiki Ono
1098
+ * Jonathan Schatz
1099
+ * Jose Luis Honorato
1100
+ * Aaron Kromer
1101
+ * Pavel Jurašek
1102
+ * Jake Worth
1103
+ * Gabe Martin-Dempesy
1104
+ * Michael Grosser
1105
+ * Aleksei Maridashvili
1106
+ * Ville Lautanala
1107
+ * Koichi ITO
1108
+ * Jordan Harband
1109
+ * Tarmo Tänav
1110
+ * Joe Marty
1111
+ * Chris Thomson
1112
+ * Vít Ondruch
1113
+ * George Ulmer
1114
+ * Christof Koenig
1115
+ * Chung-Yi Chi
1116
+ * Olexandr Hoshylyk
1117
+ * Janko Marohnić
1118
+ * Pat Allan
1119
+ * Rick Song
1120
+ * NARUSE, Yui
1121
+ * Piotr Boniecki
1122
+ * Olia Kremmyda
1123
+ * Michał Matyas
1124
+ * Matt Brictson
1125
+ * Kenny Ortmann
1126
+ * redbar0n
1127
+ * Lukas Pokorny
1128
+ * Arkadiy Tetelman
1129
+ * Kazato Sugimoto
1130
+ * Olle Jonsson
1131
+ * Pavel Rosický
1132
+ * Geremia Taglialatela
1133
+ * Koichi Sasada
1134
+ * Yusuke Endoh
1135
+ * Grey Baker
1136
+ * SoonKhen OwYong
1137
+ * Pavel Valena
1138
+ * Adam Sokolnicki
1139
+ * Jeff Felchner
1140
+ * Eike Send
1141
+ * Claudio Poli
1142
+ * Csaba Apagyi
1143
+ * Frederick Cheung
1144
+ * Fábio D. Batista
1145
+ * Andriy Yanko
1146
+ * y-yagi
1147
+ * Rafael França
1148
+ * George Claghorn
1149
+ * Alex Junger
1150
+ * Orien Madgwick
1151
+ * Andrei Sidorov
1152
+ * Marco Costa
1153
+ * Ryan Davis
1154
+ * Brandur
1155
+ * Samuel Williams
1156
+ * Patrik Ragnarsson
1157
+ * Alex Coomans
1158
+ * Vesa Laakso
1159
+ * John Hawthorn
1160
+ * guppy0356
1161
+ * Thilo Rusche
1162
+ * Andrew Stuntz
1163
+ * Lucas Uyezu
1164
+ * Bruno Sutic
1165
+ * Ryan Kerr
1166
+ * Adam Harwood
1167
+ * Ben Koshy
1168
+ * Jesse Bowes
1169
+ * Marek Kasztelnik
1170
+ * ce07c3
1171
+ * Jun Jiang
1172
+ * Oleksiy Kovyrin
1173
+ * Matt Larraz
1174
+ * Tony Schneider
1175
+ * Niklas Hösl
1176
+ * Johanna Hartmann
1177
+ * Alex Vondrak
1178
+ * Will Storey
1179
+ * Eduardo Hernandez
1180
+ * ojab
1181
+ * Giorgio Gambino
1182
+ * Timmitry
1183
+ * Michael Fairley
1184
+ * Ray Zane
1185
+ * Go Sueyoshi
1186
+ * Cedric Sohrauer
1187
+ * Akira Matsuda
1188
+ * Mark Spangler
1189
+ * Henrik Nyh
1190
+ * Yoann Lecuyer
1191
+ * Lucas Arnaud
1192
+ * Marc Rohloff
1193
+ * inkstak
1194
+ * Yuki Inoue
1195
+ * Brandon Weaver
1196
+ * Josh Nichols
1197
+ * Ricardo Trindade
1198
+ * Earlopain
1199
+ * James Brown
1200
+ * Kazuhiro NISHIYAMA
1201
+ * Étienne Barrié
1202
+ * Matt Brown
1203
+ * Victor Maslov
1204
+ * Gio Lodi
1205
+ * Ryan Brooks
1206
+ * Jacob Frautschi
1207
+ * Christian Schmidt
1208
+ * Rodrigo Argumedo
1209
+
1210
+ For a full list of contributors you can visit the
1211
+ [contributors](https://github.com/bblimke/webmock/contributors) page.
1212
+
1213
+ ## Background
1214
+
1215
+ Thank you Fakeweb! This library was inspired by [FakeWeb](https://github.com/chrisk/fakeweb).
1216
+ I imported some solutions from that project to WebMock. I also copied some code i.e Net:HTTP adapter.
1217
+ Fakeweb architecture unfortunately didn't allow me to extend it easily with the features I needed.
1218
+ I also preferred some things to work differently i.e request stub precedence.
1219
+
1220
+ ## Copyright
1221
+
1222
+ Copyright (c) 2009-2010 Bartosz Blimke. See LICENSE for details.