restify 2.0.2 → 2.1.0

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