simple-client 0.0.2

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 (297) hide show
  1. data/.bundle/config +4 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +23 -0
  4. data/bin/rake +16 -0
  5. data/lib/simple-client/simple-client.rb +229 -0
  6. data/lib/simple-client/version.rb +4 -0
  7. data/lib/simple-client.rb +1 -0
  8. data/test/test_simple-client.rb +236 -0
  9. data/vendor/bundle/ruby/1.8/bin/rake +19 -0
  10. data/vendor/bundle/ruby/1.8/cache/addressable-2.2.8.gem +0 -0
  11. data/vendor/bundle/ruby/1.8/cache/crack-0.3.1.gem +0 -0
  12. data/vendor/bundle/ruby/1.8/cache/rake-0.9.2.2.gem +0 -0
  13. data/vendor/bundle/ruby/1.8/cache/webmock-1.8.8.gem +0 -0
  14. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/CHANGELOG.md +126 -0
  15. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/Gemfile +17 -0
  16. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/Gemfile.lock +35 -0
  17. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/LICENSE.txt +202 -0
  18. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/README.md +83 -0
  19. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/Rakefile +37 -0
  20. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/lib/addressable/idna/native.rb +43 -0
  21. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/lib/addressable/idna/pure.rb +4886 -0
  22. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/lib/addressable/idna.rb +25 -0
  23. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/lib/addressable/template.rb +1047 -0
  24. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/lib/addressable/uri.rb +2288 -0
  25. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/lib/addressable/version.rb +30 -0
  26. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/spec/addressable/idna_spec.rb +216 -0
  27. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/spec/addressable/net_http_compat_spec.rb +26 -0
  28. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/spec/addressable/template_spec.rb +2144 -0
  29. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/spec/addressable/uri_spec.rb +4928 -0
  30. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/tasks/clobber.rake +2 -0
  31. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/tasks/gem.rake +85 -0
  32. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/tasks/git.rake +45 -0
  33. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/tasks/metrics.rake +22 -0
  34. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/tasks/rspec.rake +58 -0
  35. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/tasks/rubyforge.rake +89 -0
  36. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/tasks/yard.rake +27 -0
  37. data/vendor/bundle/ruby/1.8/gems/addressable-2.2.8/website/index.html +110 -0
  38. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/History +25 -0
  39. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/LICENSE +20 -0
  40. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/README.rdoc +42 -0
  41. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/Rakefile +32 -0
  42. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/crack.gemspec +53 -0
  43. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/lib/crack/json.rb +79 -0
  44. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/lib/crack/util.rb +17 -0
  45. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/lib/crack/xml.rb +232 -0
  46. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/lib/crack.rb +8 -0
  47. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/test/crack_test.rb +4 -0
  48. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/test/data/twittersearch-firefox.json +1 -0
  49. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/test/data/twittersearch-ie.json +1 -0
  50. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/test/hash_test.rb +28 -0
  51. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/test/json_test.rb +82 -0
  52. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/test/parser_test.rb +27 -0
  53. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/test/string_test.rb +31 -0
  54. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/test/test_helper.rb +12 -0
  55. data/vendor/bundle/ruby/1.8/gems/crack-0.3.1/test/xml_test.rb +499 -0
  56. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/CHANGES +522 -0
  57. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/MIT-LICENSE +21 -0
  58. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/README.rdoc +197 -0
  59. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/Rakefile +369 -0
  60. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/TODO +20 -0
  61. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/bin/rake +33 -0
  62. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/command_line_usage.rdoc +114 -0
  63. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/example/Rakefile1 +38 -0
  64. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/example/Rakefile2 +35 -0
  65. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/example/a.c +6 -0
  66. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/example/b.c +6 -0
  67. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/example/main.c +11 -0
  68. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/glossary.rdoc +51 -0
  69. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/jamis.rb +591 -0
  70. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/proto_rake.rdoc +127 -0
  71. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/rake.1.gz +0 -0
  72. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/rakefile.rdoc +557 -0
  73. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/rational.rdoc +151 -0
  74. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.4.14.rdoc +23 -0
  75. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.4.15.rdoc +35 -0
  76. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.5.0.rdoc +53 -0
  77. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.5.3.rdoc +78 -0
  78. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.5.4.rdoc +46 -0
  79. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.6.0.rdoc +141 -0
  80. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.7.0.rdoc +119 -0
  81. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.7.1.rdoc +59 -0
  82. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.7.2.rdoc +121 -0
  83. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.7.3.rdoc +47 -0
  84. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.8.0.rdoc +114 -0
  85. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.8.2.rdoc +165 -0
  86. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.8.3.rdoc +112 -0
  87. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.8.4.rdoc +147 -0
  88. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.8.5.rdoc +53 -0
  89. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.8.6.rdoc +55 -0
  90. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.8.7.rdoc +55 -0
  91. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.9.0.rdoc +112 -0
  92. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.9.1.rdoc +52 -0
  93. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/doc/release_notes/rake-0.9.2.rdoc +49 -0
  94. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/install.rb +90 -0
  95. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/alt_system.rb +109 -0
  96. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb +595 -0
  97. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/classic_namespace.rb +11 -0
  98. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/clean.rb +32 -0
  99. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/cloneable.rb +25 -0
  100. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/contrib/compositepublisher.rb +21 -0
  101. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/contrib/ftptools.rb +150 -0
  102. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/contrib/publisher.rb +73 -0
  103. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/contrib/rubyforgepublisher.rb +16 -0
  104. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/contrib/sshpublisher.rb +50 -0
  105. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/contrib/sys.rb +191 -0
  106. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/default_loader.rb +10 -0
  107. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/dsl_definition.rb +176 -0
  108. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/early_time.rb +18 -0
  109. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/ext/core.rb +27 -0
  110. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/ext/module.rb +39 -0
  111. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/ext/string.rb +167 -0
  112. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/ext/time.rb +14 -0
  113. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/file_creation_task.rb +24 -0
  114. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/file_list.rb +403 -0
  115. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/file_task.rb +47 -0
  116. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/file_utils.rb +114 -0
  117. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb +145 -0
  118. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/gempackagetask.rb +15 -0
  119. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/invocation_chain.rb +51 -0
  120. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/invocation_exception_mixin.rb +16 -0
  121. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/loaders/makefile.rb +40 -0
  122. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/multi_task.rb +16 -0
  123. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/name_space.rb +25 -0
  124. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/packagetask.rb +185 -0
  125. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/pathmap.rb +1 -0
  126. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/pseudo_status.rb +24 -0
  127. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/rake_module.rb +29 -0
  128. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb +22 -0
  129. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/rdoctask.rb +234 -0
  130. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/ruby182_test_unit_fix.rb +25 -0
  131. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/rule_recursion_overflow_error.rb +20 -0
  132. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/runtest.rb +21 -0
  133. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb +327 -0
  134. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task_argument_error.rb +7 -0
  135. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task_arguments.rb +78 -0
  136. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task_manager.rb +307 -0
  137. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/tasklib.rb +22 -0
  138. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/testtask.rb +191 -0
  139. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/version.rb +8 -0
  140. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/win32.rb +55 -0
  141. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake.rb +69 -0
  142. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/file_creation.rb +34 -0
  143. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/helper.rb +492 -0
  144. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake.rb +40 -0
  145. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_application.rb +489 -0
  146. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_application_options.rb +335 -0
  147. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_clean.rb +14 -0
  148. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_definitions.rb +80 -0
  149. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_directory_task.rb +46 -0
  150. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_dsl.rb +77 -0
  151. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_early_time.rb +31 -0
  152. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_extension.rb +59 -0
  153. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_file_creation_task.rb +56 -0
  154. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_file_list.rb +628 -0
  155. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_file_list_path_map.rb +8 -0
  156. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_file_task.rb +102 -0
  157. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_file_utils.rb +305 -0
  158. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_ftp_file.rb +59 -0
  159. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_functional.rb +450 -0
  160. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_invocation_chain.rb +52 -0
  161. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_makefile_loader.rb +44 -0
  162. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_multi_task.rb +51 -0
  163. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_name_space.rb +43 -0
  164. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_package_task.rb +79 -0
  165. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_path_map.rb +157 -0
  166. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_path_map_explode.rb +34 -0
  167. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_path_map_partial.rb +18 -0
  168. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_pseudo_status.rb +21 -0
  169. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_rake_test_loader.rb +21 -0
  170. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_rdoc_task.rb +83 -0
  171. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_require.rb +40 -0
  172. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_rules.rb +327 -0
  173. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_task.rb +267 -0
  174. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_task_argument_parsing.rb +103 -0
  175. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_task_arguments.rb +88 -0
  176. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_task_lib.rb +9 -0
  177. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_task_manager.rb +157 -0
  178. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_task_manager_argument_resolution.rb +36 -0
  179. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_task_with_arguments.rb +173 -0
  180. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_test_task.rb +120 -0
  181. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_top_level_functions.rb +111 -0
  182. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_win32.rb +72 -0
  183. data/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_sys.rb +20 -0
  184. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/CHANGELOG.md +749 -0
  185. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/Gemfile +21 -0
  186. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/Guardfile +24 -0
  187. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/LICENSE +20 -0
  188. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/README.md +728 -0
  189. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/Rakefile +65 -0
  190. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/api.rb +63 -0
  191. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/assertion_failure.rb +11 -0
  192. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/callback_registry.rb +35 -0
  193. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/config.rb +10 -0
  194. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/cucumber.rb +8 -0
  195. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/deprecation.rb +9 -0
  196. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/errors.rb +33 -0
  197. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/http_lib_adapters/curb_adapter.rb +287 -0
  198. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/http_lib_adapters/em_http_request/em_http_request_0_x.rb +151 -0
  199. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/http_lib_adapters/em_http_request/em_http_request_1_x.rb +212 -0
  200. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +11 -0
  201. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/http_lib_adapters/excon_adapter.rb +95 -0
  202. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/http_lib_adapters/http_lib_adapter.rb +7 -0
  203. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb +19 -0
  204. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/http_lib_adapters/httpclient_adapter.rb +193 -0
  205. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/http_lib_adapters/net_http.rb +279 -0
  206. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/http_lib_adapters/net_http_response.rb +34 -0
  207. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/http_lib_adapters/patron_adapter.rb +129 -0
  208. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +180 -0
  209. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/matchers/hash_including_matcher.rb +25 -0
  210. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/minitest.rb +15 -0
  211. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/rack_response.rb +63 -0
  212. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/request_execution_verifier.rb +56 -0
  213. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/request_pattern.rb +282 -0
  214. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/request_registry.rb +35 -0
  215. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/request_signature.rb +50 -0
  216. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/request_stub.rb +97 -0
  217. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/response.rb +144 -0
  218. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/responses_sequence.rb +40 -0
  219. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/rspec/matchers/request_pattern_matcher.rb +42 -0
  220. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/rspec/matchers/webmock_matcher.rb +46 -0
  221. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/rspec/matchers.rb +28 -0
  222. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/rspec.rb +33 -0
  223. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/stub_registry.rb +61 -0
  224. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/stub_request_snippet.rb +30 -0
  225. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/test_unit.rb +20 -0
  226. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/util/hash_counter.rb +25 -0
  227. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/util/hash_keys_stringifier.rb +23 -0
  228. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/util/headers.rb +43 -0
  229. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/util/json.rb +54 -0
  230. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/util/uri.rb +101 -0
  231. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/util/version_checker.rb +73 -0
  232. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/version.rb +3 -0
  233. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/webmock.rb +124 -0
  234. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock.rb +49 -0
  235. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/minitest/test_helper.rb +29 -0
  236. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/minitest/test_webmock.rb +6 -0
  237. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/minitest/webmock_spec.rb +50 -0
  238. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/curb/curb_spec.rb +340 -0
  239. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/curb/curb_spec_helper.rb +144 -0
  240. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/em_http_request/em_http_request_spec.rb +183 -0
  241. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +72 -0
  242. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/excon/excon_spec.rb +15 -0
  243. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/excon/excon_spec_helper.rb +38 -0
  244. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/httpclient/httpclient_spec.rb +76 -0
  245. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/httpclient/httpclient_spec_helper.rb +48 -0
  246. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/net_http/net_http_shared.rb +125 -0
  247. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/net_http/net_http_spec.rb +255 -0
  248. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/net_http/net_http_spec_helper.rb +55 -0
  249. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/net_http/real_net_http_spec.rb +20 -0
  250. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/patron/patron_spec.rb +136 -0
  251. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/patron/patron_spec_helper.rb +50 -0
  252. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +142 -0
  253. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/shared/callbacks.rb +146 -0
  254. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/shared/complex_cross_concern_behaviors.rb +36 -0
  255. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/shared/enabling_and_disabling_webmock.rb +95 -0
  256. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/shared/precedence_of_stubs.rb +15 -0
  257. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/shared/request_expectations.rb +666 -0
  258. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/shared/returning_declared_responses.rb +367 -0
  259. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/shared/stubbing_requests.rb +447 -0
  260. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +74 -0
  261. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb +56 -0
  262. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/acceptance/webmock_shared.rb +41 -0
  263. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/quality_spec.rb +60 -0
  264. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/spec_helper.rb +57 -0
  265. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/support/example_curl_output.txt +22 -0
  266. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/support/my_rack_app.rb +48 -0
  267. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/support/network_connection.rb +25 -0
  268. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/support/webmock_server.rb +65 -0
  269. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/errors_spec.rb +32 -0
  270. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/http_lib_adapters/http_lib_adapter_registry_spec.rb +17 -0
  271. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/http_lib_adapters/http_lib_adapter_spec.rb +12 -0
  272. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/rack_response_spec.rb +74 -0
  273. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/request_execution_verifier_spec.rb +100 -0
  274. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/request_pattern_spec.rb +479 -0
  275. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/request_registry_spec.rb +75 -0
  276. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/request_signature_spec.rb +113 -0
  277. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/request_stub_spec.rb +198 -0
  278. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/response_spec.rb +267 -0
  279. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/stub_registry_spec.rb +86 -0
  280. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/stub_request_snippet_spec.rb +95 -0
  281. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/util/hash_counter_spec.rb +39 -0
  282. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/util/hash_keys_stringifier_spec.rb +27 -0
  283. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/util/headers_spec.rb +28 -0
  284. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/util/json_spec.rb +7 -0
  285. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/util/uri_spec.rb +257 -0
  286. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/util/version_checker_spec.rb +59 -0
  287. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/webmock_spec.rb +7 -0
  288. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/test/http_request.rb +24 -0
  289. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/test/shared_test.rb +76 -0
  290. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/test/test_helper.rb +23 -0
  291. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/test/test_webmock.rb +6 -0
  292. data/vendor/bundle/ruby/1.8/gems/webmock-1.8.8/webmock.gemspec +35 -0
  293. data/vendor/bundle/ruby/1.8/specifications/addressable-2.2.8.gemspec +38 -0
  294. data/vendor/bundle/ruby/1.8/specifications/crack-0.3.1.gemspec +25 -0
  295. data/vendor/bundle/ruby/1.8/specifications/rake-0.9.2.2.gemspec +33 -0
  296. data/vendor/bundle/ruby/1.8/specifications/webmock-1.8.8.gemspec +61 -0
  297. metadata +390 -0
@@ -0,0 +1,728 @@
1
+ WebMock [![Build Status](https://secure.travis-ci.org/bblimke/webmock.png?branch=master)](http://travis-ci.org/bblimke/webmock) [![Dependency Status](https://gemnasium.com/bblimke/webmock.png)](http://gemnasium.com/bblimke/webmock)
2
+ =======
3
+
4
+ Library for stubbing and setting expectations on HTTP requests in Ruby.
5
+
6
+ Features
7
+ --------
8
+
9
+ * Stubbing HTTP requests at low http client lib level (no need to change tests when you change HTTP library)
10
+ * Setting and verifying expectations on HTTP requests
11
+ * Matching requests based on method, URI, headers and body
12
+ * Smart matching of the same URIs in different representations (also encoded and non encoded forms)
13
+ * Smart matching of the same headers in different representations.
14
+ * Support for Test::Unit
15
+ * Support for RSpec 1.x and RSpec 2.x
16
+ * Support for MiniTest
17
+
18
+ Supported HTTP libraries
19
+ ------------------------
20
+
21
+ * Net::HTTP and libraries based on Net::HTTP (i.e RightHttpConnection, REST Client, HTTParty)
22
+ * HTTPClient
23
+ * Patron
24
+ * EM-HTTP-Request
25
+ * Curb (currently only Curb::Easy)
26
+ * Typhoeus (currently only Typhoeus::Hydra)
27
+ * Excon
28
+
29
+ Supported Ruby Interpreters
30
+ ---------------------------
31
+
32
+ * MRI 1.8.6
33
+ * MRI 1.8.7
34
+ * MRI 1.9.1
35
+ * MRI 1.9.2
36
+ * MRI 1.9.3
37
+ * REE 1.8.7
38
+ * JRuby
39
+ * Rubinius
40
+
41
+ ##Installation
42
+
43
+ gem install webmock
44
+
45
+ ### or to install the latest development version from github master
46
+
47
+ git clone http://github.com/bblimke/webmock.git
48
+ cd webmock
49
+ rake install
50
+
51
+ ### Test::Unit
52
+
53
+ Add the following code to `test/test_helper.rb`
54
+
55
+ require 'webmock/test_unit'
56
+
57
+ ### RSpec
58
+
59
+ Add the following code to `spec/spec_helper`:
60
+
61
+ require 'webmock/rspec'
62
+
63
+ ### MiniTest
64
+
65
+ Add the following code to `test/test_helper`:
66
+
67
+ require 'webmock/minitest'
68
+
69
+ ### Cucumber
70
+
71
+ Add the following code to `features/support/env.rb`
72
+
73
+ require 'webmock/cucumber'
74
+
75
+ ### Outside a test framework
76
+
77
+ You can also use WebMock outside a test framework:
78
+
79
+ require 'webmock'
80
+ include WebMock::API
81
+
82
+ ## Examples
83
+
84
+
85
+
86
+ ## Stubbing
87
+
88
+
89
+ ### Stubbed request based on uri only and with the default response
90
+
91
+ stub_request(:any, "www.example.com")
92
+
93
+ Net::HTTP.get("www.example.com", "/") # ===> Success
94
+
95
+ ### Stubbing requests based on method, uri, body and headers
96
+
97
+ stub_request(:post, "www.example.com").with(:body => "abc", :headers => { 'Content-Length' => 3 })
98
+
99
+ uri = URI.parse("http://www.example.com/")
100
+ req = Net::HTTP::Post.new(uri.path)
101
+ req['Content-Length'] = 3
102
+ res = Net::HTTP.start(uri.host, uri.port) {|http|
103
+ http.request(req, "abc")
104
+ } # ===> Success
105
+
106
+ ### Matching request body and headers against regular expressions
107
+
108
+ stub_request(:post, "www.example.com").
109
+ with(:body => /^.*world$/, :headers => {"Content-Type" => /image\/.+/}).to_return(:body => "abc")
110
+
111
+ uri = URI.parse('http://www.example.com/')
112
+ req = Net::HTTP::Post.new(uri.path)
113
+ req['Content-Type'] = 'image/png'
114
+ res = Net::HTTP.start(uri.host, uri.port) {|http|
115
+ http.request(req, 'hello world')
116
+ } # ===> Success
117
+
118
+ ### Matching request body against a hash. Body can be URL-Encoded, JSON or XML.
119
+
120
+ stub_http_request(:post, "www.example.com").
121
+ with(:body => {:data => {:a => '1', :b => 'five'}})
122
+
123
+ RestClient.post('www.example.com', "data[a]=1&data[b]=five",
124
+ :content_type => 'application/x-www-form-urlencoded') # ===> Success
125
+
126
+ RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
127
+ :content_type => 'application/json') # ===> Success
128
+
129
+ RestClient.post('www.example.com', '<data a="1" b="five" />',
130
+ :content_type => 'application/xml' ) # ===> Success
131
+
132
+ ### Matching request body against partial hash.
133
+
134
+ stub_http_request(:post, "www.example.com").
135
+ with(:body => hash_including({:data => {:a => '1', :b => 'five'}}))
136
+
137
+ RestClient.post('www.example.com', "data[a]=1&data[b]=five&x=1",
138
+ :content_type => 'application/x-www-form-urlencoded') # ===> Success
139
+
140
+ ### Matching custom request headers
141
+
142
+ stub_request(:any, "www.example.com").with(:headers=>{ 'Header-Name' => 'Header-Value' })
143
+
144
+ uri = URI.parse('http://www.example.com/')
145
+ req = Net::HTTP::Post.new(uri.path)
146
+ req['Header-Name'] = 'Header-Value'
147
+ res = Net::HTTP.start(uri.host, uri.port) {|http|
148
+ http.request(req, 'abc')
149
+ } # ===> Success
150
+
151
+ ### Matching multiple headers with the same name
152
+
153
+ stub_http_request(:get, 'www.example.com').with(:headers => {'Accept' => ['image/jpeg', 'image/png'] })
154
+
155
+ req = Net::HTTP::Get.new("/")
156
+ req['Accept'] = ['image/png']
157
+ req.add_field('Accept', 'image/jpeg')
158
+ Net::HTTP.start("www.example.com") {|http| http.request(req) } # ===> Success
159
+
160
+ ### Matching requests against provided block
161
+
162
+ stub_request(:post, "www.example.com").with { |request| request.body == "abc" }
163
+ RestClient.post('www.example.com', 'abc') # ===> Success
164
+
165
+ ### Request with basic authentication
166
+
167
+ stub_request(:get, "user:pass@www.example.com")
168
+
169
+ Net::HTTP.start('www.example.com') {|http|
170
+ req = Net::HTTP::Get.new('/')
171
+ req.basic_auth 'user', 'pass'
172
+ http.request(req)
173
+ } # ===> Success
174
+
175
+ ### Matching uris using regular expressions
176
+
177
+ stub_request(:any, /.*example.*/)
178
+
179
+ Net::HTTP.get('www.example.com', '/') # ===> Success
180
+
181
+ ### Matching query params using hash
182
+
183
+ stub_http_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
184
+
185
+ RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
186
+
187
+ ### Matching partial query params using hash
188
+
189
+ stub_http_request(:get, "www.example.com").with(:query => hash_including({"a" => ["b", "c"]}))
190
+
191
+ RestClient.get("http://www.example.com/?a[]=b&a[]=c&x=1") # ===> Success
192
+
193
+ ### Stubbing with custom response
194
+
195
+ stub_request(:any, "www.example.com").to_return(:body => "abc", :status => 200, :headers => { 'Content-Length' => 3 } )
196
+
197
+ Net::HTTP.get("www.example.com", '/') # ===> "abc"
198
+
199
+ ### Response with body specified as IO object
200
+
201
+ File.open('/tmp/response_body.txt', 'w') { |f| f.puts 'abc' }
202
+
203
+ stub_request(:any, "www.example.com").to_return(:body => File.new('/tmp/response_body.txt'), :status => 200)
204
+
205
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
206
+
207
+ ### Response with custom status message
208
+
209
+ stub_request(:any, "www.example.com").to_return(:status => [500, "Internal Server Error"])
210
+
211
+ req = Net::HTTP::Get.new("/")
212
+ Net::HTTP.start("www.example.com") { |http| http.request(req) }.message # ===> "Internal Server Error"
213
+
214
+ ### Replaying raw responses recorded with `curl -is`
215
+
216
+ `curl -is www.example.com > /tmp/example_curl_-is_output.txt`
217
+ raw_response_file = File.new("/tmp/example_curl_-is_output.txt")
218
+
219
+ from file
220
+
221
+ stub_request(:get, "www.example.com").to_return(raw_response_file)
222
+
223
+ or string
224
+
225
+ stub_request(:get, "www.example.com").to_return(raw_response_file.read)
226
+
227
+ ### Responses dynamically evaluated from block
228
+
229
+ stub_request(:any, 'www.example.net').
230
+ to_return { |request| {:body => request.body} }
231
+
232
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
233
+
234
+ ### Responses dynamically evaluated from lambda
235
+
236
+ stub_request(:any, 'www.example.net').
237
+ to_return(lambda { |request| {:body => request.body} })
238
+
239
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
240
+
241
+ ### Dynamically evaluated raw responses recorded with `curl -is`
242
+
243
+ `curl -is www.example.com > /tmp/www.example.com.txt`
244
+ stub_request(:get, "www.example.com").to_return(lambda { |request| File.new("/tmp/#{request.uri.host.to_s}.txt" }))
245
+
246
+ ### Responses with dynamically evaluated parts
247
+
248
+ stub_request(:any, 'www.example.net').
249
+ to_return(:body => lambda { |request| request.body })
250
+
251
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
252
+
253
+ ### Rack responses
254
+
255
+ class MyRackApp
256
+ def self.call(env)
257
+ [200, {}, ["Hello"]]
258
+ end
259
+ end
260
+
261
+ stub_request(:get, "www.example.com").to_rack(MyRackApp)
262
+
263
+ RestClient.post('www.example.com') # ===> "Hello"
264
+
265
+ ### Raising errors
266
+
267
+ #### Exception declared by class
268
+
269
+ stub_request(:any, 'www.example.net').to_raise(StandardError)
270
+
271
+ RestClient.post('www.example.net', 'abc') # ===> StandardError
272
+
273
+ #### or by exception instance
274
+
275
+ stub_request(:any, 'www.example.net').to_raise(StandardError.new("some error"))
276
+
277
+ #### or by string
278
+
279
+ stub_request(:any, 'www.example.net').to_raise("some error")
280
+
281
+ ### Raising timeout errors
282
+
283
+ stub_request(:any, 'www.example.net').to_timeout
284
+
285
+ RestClient.post('www.example.net', 'abc') # ===> RestClient::RequestTimeout
286
+
287
+ ### Multiple responses for repeated requests
288
+
289
+ stub_request(:get, "www.example.com").to_return({:body => "abc"}, {:body => "def"})
290
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
291
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
292
+
293
+ #after all responses are used the last response will be returned infinitely
294
+
295
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
296
+
297
+ ### Multiple responses using chained `to_return()`, `to_raise()` or `to_timeout` declarations
298
+
299
+ stub_request(:get, "www.example.com").
300
+ to_return({:body => "abc"}).then. #then() is just a syntactic sugar
301
+ to_return({:body => "def"}).then.
302
+ to_raise(MyException)
303
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
304
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
305
+ Net::HTTP.get('www.example.com', '/') # ===> MyException raised
306
+
307
+ ### Specifying number of times given response should be returned
308
+
309
+ stub_request(:get, "www.example.com").
310
+ to_return({:body => "abc"}).times(2).then.
311
+ to_return({:body => "def"})
312
+
313
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
314
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
315
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
316
+
317
+
318
+ ### Real requests to network can be allowed or disabled
319
+
320
+ WebMock.allow_net_connect!
321
+
322
+ stub_request(:any, "www.example.com").to_return(:body => "abc")
323
+
324
+ Net::HTTP.get('www.example.com', '/') # ===> "abc"
325
+
326
+ Net::HTTP.get('www.something.com', '/') # ===> /.+Something.+/
327
+
328
+ WebMock.disable_net_connect!
329
+
330
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
331
+
332
+ ### External requests can be disabled while allowing localhost
333
+
334
+ WebMock.disable_net_connect!(:allow_localhost => true)
335
+
336
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
337
+
338
+ Net::HTTP.get('localhost:9887', '/') # ===> Allowed. Perhaps to Selenium?
339
+
340
+ ### External requests can be disabled while allowing any hostname or port or parts thereof
341
+
342
+ WebMock.disable_net_connect!(:allow => "www.example.org:8080")
343
+
344
+ RestClient.get('www.something.com', '/') # ===> Failure
345
+
346
+ RestClient.get('www.example.org', '/') # ===> Failure.
347
+
348
+ RestClient.get('www.example.org:8080', '/') # ===> Allowed
349
+
350
+ WebMock.disable_net_connect!(:allow => /ample.org/)
351
+
352
+ RestClient.get('www.example.org', '/') # ===> Allowed
353
+
354
+ ## Connecting on Net::HTTP.start
355
+
356
+ HTTP protocol has 3 steps: connect, request and response (or 4 with close). Most Ruby HTTP client libraries
357
+ treat connect as a part of request step, with the exception of `Net::HTTP` which
358
+ allows opening connection to the server separately to the request, by using `Net::HTTP.start`.
359
+
360
+ WebMock API was also designed with connect being part of request step, and it only allows stubbing
361
+ requests, not connections. When `Net::HTTP.start` is called, WebMock doesn't know yet whether
362
+ a request is stubbed or not. WebMock by default delays a connection until the request is invoked,
363
+ so when there is no request, `Net::HTTP.start` doesn't do anything.
364
+ **This means that WebMock breaks the Net::HTTP behaviour by default!**
365
+
366
+ To workaround this issue, WebMock offers `:net_http_connect_on_start` option,
367
+ which can be passed to `WebMock.allow_net_connect!` and `WebMock#disable_net_connect!` methods, i.e.
368
+
369
+ WebMock.allow_net_connect!(:net_http_connect_on_start => true)
370
+
371
+ This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`.
372
+
373
+ ## Setting Expectations
374
+
375
+ ### Setting expectations in Test::Unit
376
+ require 'webmock/test_unit'
377
+
378
+ stub_request(:any, "www.example.com")
379
+
380
+ uri = URI.parse('http://www.example.com/')
381
+ req = Net::HTTP::Post.new(uri.path)
382
+ req['Content-Length'] = 3
383
+ res = Net::HTTP.start(uri.host, uri.port) {|http|
384
+ http.request(req, 'abc')
385
+ }
386
+
387
+ assert_requested :post, "http://www.example.com",
388
+ :headers => {'Content-Length' => 3}, :body => "abc", :times => 1 # ===> Success
389
+
390
+ assert_not_requested :get, "http://www.something.com" # ===> Success
391
+
392
+ assert_requested(:post, "http://www.example.com", :times => 1) { |req| req.body == "abc" }
393
+
394
+ ### Expecting real (not stubbed) requests
395
+
396
+ WebMock.allow_net_connect!
397
+
398
+ Net::HTTP.get('www.example.com', '/') # ===> Success
399
+
400
+ assert_requested :get, "http://www.example.com" # ===> Success
401
+
402
+ ### Setting expectations in Test::Unit on the stub
403
+
404
+ stub_get = stub_request(:get, "www.example.com")
405
+ stub_post = stub_request(:post, "www.example.com")
406
+
407
+ Net::HTTP.get('www.example.com', '/')
408
+
409
+ assert_requested(stub_get)
410
+ assert_not_requested(stub_post)
411
+
412
+
413
+ ### Setting expectations in RSpec on `WebMock` module
414
+ This style is borrowed from [fakeweb-matcher](http://github.com/freelancing-god/fakeweb-matcher)
415
+
416
+ require 'webmock/rspec'
417
+
418
+ WebMock.should have_requested(:get, "www.example.com").with(:body => "abc", :headers => {'Content-Length' => 3}).twice
419
+
420
+ WebMock.should_not have_requested(:get, "www.something.com")
421
+
422
+ WebMock.should have_requested(:post, "www.example.com").with { |req| req.body == "abc" }
423
+
424
+ WebMock.should have_requested(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
425
+
426
+ WebMock.should have_requested(:get, "www.example.com").with(:query => hash_including({"a" => ["b", "c"]}))
427
+
428
+ WebMock.should have_requested(:get, "www.example.com").
429
+ with(:body => {"a" => ["b", "c"]}, :headers => {'Content-Type' => 'application/json'})
430
+
431
+ ### Setting expectations in RSpec with `a_request`
432
+
433
+ a_request(:post, "www.example.com").with(:body => "abc", :headers => {'Content-Length' => 3}).should have_been_made.once
434
+
435
+ a_request(:post, "www.something.com").should have_been_made.times(3)
436
+
437
+ a_request(:any, "www.example.com").should_not have_been_made
438
+
439
+ a_request(:post, "www.example.com").with { |req| req.body == "abc" }.should have_been_made
440
+
441
+ a_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]}).should have_been_made
442
+
443
+ a_request(:get, "www.example.com").with(:query => hash_including({"a" => ["b", "c"]})).should have_been_made
444
+
445
+ a_request(:post, "www.example.com").
446
+ with(:body => {"a" => ["b", "c"]}, :headers => {'Content-Type' => 'application/json'}).should have_been_made
447
+
448
+ ### Setting expectations in RSpec on the stub
449
+
450
+ stub = stub_request(:get, "www.example.com")
451
+ # ... make requests ...
452
+ stub.should have_been_requested
453
+
454
+ ## Clearing stubs and request history
455
+
456
+ If you want to reset all current stubs and history of requests use `WebMock.reset!`
457
+
458
+ stub_request(:any, "www.example.com")
459
+
460
+ Net::HTTP.get('www.example.com', '/') # ===> Success
461
+
462
+ WebMock.reset!
463
+
464
+ Net::HTTP.get('www.example.com', '/') # ===> Failure
465
+
466
+ assert_not_requested :get, "www.example.com" # ===> Success
467
+
468
+ ## Disabling and enabling WebMock or only some http client adapters
469
+
470
+ WebMock.disable! #disable WebMock (all adapters)
471
+ WebMock.disable!(:except => [:net_http]) #disable WebMock for all libs except Net::HTTP
472
+ WebMock.enable! #enable WebMock (all adapters)
473
+ WebMock.enable!(:except => [:patron]) #enable WebMock for all libs except Patron
474
+
475
+
476
+ ## Matching requests
477
+
478
+ An executed request matches stubbed request if it passes following criteria:
479
+
480
+ When request URI matches stubbed request URI string or Regexp pattern<br/>
481
+ And request method is the same as stubbed request method or stubbed request method is :any<br/>
482
+ And request body is the same as stubbed request body or stubbed request body is not specified<br/>
483
+ And request headers match stubbed request headers, or stubbed request headers match a subset of request headers, or stubbed request headers are not specified<br/>
484
+ And request matches provided block or block is not provided
485
+
486
+ ## Precedence of stubs
487
+
488
+ Always the last declared stub matching the request will be applied i.e:
489
+
490
+ stub_request(:get, "www.example.com").to_return(:body => "abc")
491
+ stub_request(:get, "www.example.com").to_return(:body => "def")
492
+
493
+ Net::HTTP.get('www.example.com', '/') # ====> "def"
494
+
495
+ ## Matching URIs
496
+
497
+ WebMock will match all different representations of the same URI.
498
+
499
+ I.e all the following representations of the URI are equal:
500
+
501
+ "www.example.com"
502
+ "www.example.com/"
503
+ "www.example.com:80"
504
+ "www.example.com:80/"
505
+ "http://www.example.com"
506
+ "http://www.example.com/"
507
+ "http://www.example.com:80"
508
+ "http://www.example.com:80/"
509
+
510
+ The following URIs with basic authentication are also equal for WebMock
511
+
512
+ "a b:pass@www.example.com"
513
+ "a b:pass@www.example.com/"
514
+ "a b:pass@www.example.com:80"
515
+ "a b:pass@www.example.com:80/"
516
+ "http://a b:pass@www.example.com"
517
+ "http://a b:pass@www.example.com/"
518
+ "http://a b:pass@www.example.com:80"
519
+ "http://a b:pass@www.example.com:80/"
520
+ "a%20b:pass@www.example.com"
521
+ "a%20b:pass@www.example.com/"
522
+ "a%20b:pass@www.example.com:80"
523
+ "a%20b:pass@www.example.com:80/"
524
+ "http://a%20b:pass@www.example.com"
525
+ "http://a%20b:pass@www.example.com/"
526
+ "http://a%20b:pass@www.example.com:80"
527
+ "http://a%20b:pass@www.example.com:80/"
528
+
529
+ or these
530
+
531
+ "www.example.com/my path/?a=my param&b=c"
532
+ "www.example.com/my%20path/?a=my%20param&b=c"
533
+ "www.example.com:80/my path/?a=my param&b=c"
534
+ "www.example.com:80/my%20path/?a=my%20param&b=c"
535
+ "http://www.example.com/my path/?a=my param&b=c"
536
+ "http://www.example.com/my%20path/?a=my%20param&b=c"
537
+ "http://www.example.com:80/my path/?a=my param&b=c"
538
+ "http://www.example.com:80/my%20path/?a=my%20param&b=c"
539
+
540
+
541
+ If you provide Regexp to match URI, WebMock will try to match it against every valid form of the same url.
542
+
543
+ I.e `/.*my param.*/` will match `www.example.com/my%20path` because it is equivalent of `www.example.com/my path`
544
+
545
+
546
+ ## Matching headers
547
+
548
+ WebMock will match request headers against stubbed request headers in the following situations:
549
+
550
+ 1. Stubbed request has headers specified and request headers are the same as stubbed headers <br/>
551
+ i.e stubbed headers: `{ 'Header1' => 'Value1', 'Header1' => 'Value1' }`, requested: `{ 'Header1' => 'Value1', 'Header1' => 'Value1' }`
552
+
553
+ 2. Stubbed request has headers specified and stubbed request headers are a subset of request headers <br/>
554
+ i.e stubbed headers: `{ 'Header1' => 'Value1' }`, requested: `{ 'Header1' => 'Value1', 'Header1' => 'Value1' }`
555
+
556
+ 3. Stubbed request has no headers <br/>
557
+ i.e stubbed headers: `nil`, requested: `{ 'Header1' => 'Value1', 'Header1' => 'Value1' }`
558
+
559
+ WebMock normalises headers and treats all forms of same headers as equal:
560
+ i.e the following two sets of headers are equal:
561
+
562
+ `{ "Header1" => "value1", :content_length => 123, :X_CuStOm_hEAder => :value }`
563
+
564
+ `{ :header1 => "value1", "Content-Length" => 123, "x-cuSTOM-HeAder" => "value" }`
565
+
566
+ ## Recording real requests and responses and replaying them later
567
+
568
+ To record your application's real HTTP interactions and replay them later in tests you can use [VCR](http://github.com/myronmarston/vcr) with WebMock.
569
+
570
+ ## Request callbacks
571
+
572
+ ####WebMock can invoke callbacks stubbed or real requests:
573
+
574
+ WebMock.after_request do |request_signature, response|
575
+ puts "Request #{request_signature} was made and #{response} was returned"
576
+ end
577
+
578
+ #### invoke callbacks for real requests only and except requests made with Patron
579
+
580
+ WebMock.after_request(:except => [:patron], :real_requests_only => true) do |request_signature, response|
581
+ puts "Request #{request_signature} was made and #{response} was returned"
582
+ end
583
+
584
+ ## Bugs and Issues
585
+
586
+ Please submit them here [http://github.com/bblimke/webmock/issues](http://github.com/bblimke/webmock/issues)
587
+
588
+ ## Suggestions
589
+
590
+ 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)
591
+
592
+ I'm particularly interested in how the DSL could be improved.
593
+
594
+ ## Development
595
+
596
+ In order to work on Webmock you first need to fork and clone the repo.
597
+ Please do any work on a dedicated branch and rebase against master
598
+ before sending a pull request.
599
+
600
+ #### Running Tests
601
+
602
+ We use RVM in order to test WebMock against 1.8.6, REE, 1.8.7, 1.9.2 and
603
+ jRuby. You can get RVM setup for WebMock development using the
604
+ following commands (if you don't have these version of Ruby installed
605
+ use `rvm install` to install each of them).
606
+
607
+ rvm use --create 1.8.6@webmock
608
+ gem install jeweler bundler
609
+ bundle install
610
+
611
+ rvm use --create ree@webmock
612
+ gem install jeweler bundler
613
+ bundle install
614
+
615
+ rvm use --create 1.8.7@webmock
616
+ gem install jeweler bundler
617
+ bundle install
618
+
619
+ rvm use --create 1.9.2@webmock
620
+ gem install jeweler bundler
621
+ bundle install
622
+
623
+ rvm use --create jruby@webmock
624
+ gem install jeweler bundler
625
+ bundle install
626
+
627
+ These commands will create a gemset named WebMock for each of the
628
+ supported versions of Ruby and `bundle install` all dependencies.
629
+
630
+ With the supported versions of Ruby installed RVM will run specs across
631
+ all version with just one command.
632
+
633
+ bundle exec rvm 1.8.6@webmock,ree@webmock,1.8.7@webmock,1.9.2@webmock,jruby@webmock rspec spec/**/*_spec.rb
634
+
635
+ This command is wrapped up in to a rake task and can be invoked like so:
636
+
637
+ rake spec:rubies
638
+
639
+ ## Credits
640
+
641
+ The initial lines of this project were written during New Bamboo [Hack Day](http://blog.new-bamboo.co.uk/2009/11/13/hackday-results)
642
+ Thanks to my fellow [Bambinos](http://new-bamboo.co.uk/) for all the great suggestions!
643
+
644
+ People who submitted patches and new features or suggested improvements. Many thanks to these people:
645
+
646
+ * Ben Pickles
647
+ * Mark Evans
648
+ * Ivan Vega
649
+ * Piotr Usewicz
650
+ * Nick Plante
651
+ * Nick Quaranto
652
+ * Diego E. "Flameeyes" Pettenò
653
+ * Niels Meersschaert
654
+ * Mack Earnhardt
655
+ * Arvicco
656
+ * Sergio Gil
657
+ * Jeffrey Jones
658
+ * Tekin Suleyman
659
+ * Tom Ward
660
+ * Nadim Bitar
661
+ * Myron Marston
662
+ * Sam Phillips
663
+ * Jose Angel Cortinas
664
+ * Razic
665
+ * Steve Tooke
666
+ * Nathaniel Bibler
667
+ * Martyn Loughran
668
+ * Muness Alrubaie
669
+ * Charles Li
670
+ * Ryan Bigg
671
+ * Pete Higgins
672
+ * Hans de Graaff
673
+ * Alastair Brunton
674
+ * Sam Stokes
675
+ * Eugene Bolshakov
676
+ * James Conroy-Finn
677
+ * Salvador Fuentes Jr
678
+ * Alex Rothenberg
679
+ * Aidan Feldman
680
+ * Steve Hull
681
+ * Jay Adkisson
682
+ * Zach Dennis
683
+ * Nikita Fedyashev
684
+ * Lin Jen-Shin
685
+ * David Yeu
686
+ * Andreas Garnæs
687
+ * Roman Shterenzon
688
+ * Chris McGrath
689
+ * Stephen Celis
690
+ * Eugene Pimenov
691
+ * Albert Llop
692
+ * Christopher Pickslay
693
+ * Tammer Saleh
694
+ * Nicolas Fouché
695
+ * Joe Van Dyk
696
+ * Mark Abramov
697
+ * Frank Schumacher
698
+ * Dimitrij Denissenko
699
+ * Marnen Laibow-Koser
700
+ * Evgeniy Dolzhenko
701
+ * Nick Recobra
702
+ * Jordan Elver
703
+ * Joe Karayusuf
704
+ * Paul Cortens
705
+ * jugyo
706
+ * aindustries
707
+ * Eric Oestrich
708
+ * erwanlr
709
+ * Ben Bleything
710
+ * Jon Leighton
711
+ * Ryan Schlesinger
712
+ * Julien Boyer
713
+ * Kevin Glowacz
714
+ * Hans Hasselberg
715
+
716
+ For a full list of contributors you can visit the
717
+ [contributors](https://github.com/bblimke/webmock/contributors) page.
718
+
719
+ ## Background
720
+
721
+ Thank you Fakeweb! This library was inspired by [FakeWeb](http://fakeweb.rubyforge.org).
722
+ I imported some solutions from that project to WebMock. I also copied some code i.e Net:HTTP adapter.
723
+ Fakeweb architecture unfortunately didn't allow me to extend it easily with the features I needed.
724
+ I also preferred some things to work differently i.e request stub precedence.
725
+
726
+ ## Copyright
727
+
728
+ Copyright (c) 2009-2010 Bartosz Blimke. See LICENSE for details.