allegro_api_client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (296) hide show
  1. checksums.yaml +7 -0
  2. data/.bundle/config +3 -0
  3. data/Gemfile +3 -0
  4. data/Gemfile.lock +25 -0
  5. data/README.md +19 -0
  6. data/apiclient.gemspec +24 -0
  7. data/gems/ruby/2.1.0/bin/httparty +23 -0
  8. data/gems/ruby/2.1.0/bin/rake +23 -0
  9. data/gems/ruby/2.1.0/build_info/git_repository-0.0.11.info +1 -0
  10. data/gems/ruby/2.1.0/build_info/httparty-0.13.1.info +1 -0
  11. data/gems/ruby/2.1.0/build_info/multi_xml-0.5.5.info +1 -0
  12. data/gems/ruby/2.1.0/build_info/rake-10.3.2.info +1 -0
  13. data/gems/ruby/2.1.0/cache/git_repository-0.0.11.gem +0 -0
  14. data/gems/ruby/2.1.0/cache/httparty-0.13.1.gem +0 -0
  15. data/gems/ruby/2.1.0/cache/multi_xml-0.5.5.gem +0 -0
  16. data/gems/ruby/2.1.0/cache/rake-10.3.2.gem +0 -0
  17. data/gems/ruby/2.1.0/gems/git_repository-0.0.11/lib/git_repository.rb +62 -0
  18. data/gems/ruby/2.1.0/gems/httparty-0.13.1/.gitignore +10 -0
  19. data/gems/ruby/2.1.0/gems/httparty-0.13.1/.travis.yml +7 -0
  20. data/gems/ruby/2.1.0/gems/httparty-0.13.1/Gemfile +14 -0
  21. data/gems/ruby/2.1.0/gems/httparty-0.13.1/Guardfile +16 -0
  22. data/gems/ruby/2.1.0/gems/httparty-0.13.1/History +303 -0
  23. data/gems/ruby/2.1.0/gems/httparty-0.13.1/MIT-LICENSE +20 -0
  24. data/gems/ruby/2.1.0/gems/httparty-0.13.1/README.md +74 -0
  25. data/gems/ruby/2.1.0/gems/httparty-0.13.1/Rakefile +12 -0
  26. data/gems/ruby/2.1.0/gems/httparty-0.13.1/bin/httparty +117 -0
  27. data/gems/ruby/2.1.0/gems/httparty-0.13.1/cucumber.yml +1 -0
  28. data/gems/ruby/2.1.0/gems/httparty-0.13.1/examples/aaws.rb +32 -0
  29. data/gems/ruby/2.1.0/gems/httparty-0.13.1/examples/basic.rb +28 -0
  30. data/gems/ruby/2.1.0/gems/httparty-0.13.1/examples/crack.rb +19 -0
  31. data/gems/ruby/2.1.0/gems/httparty-0.13.1/examples/custom_parsers.rb +67 -0
  32. data/gems/ruby/2.1.0/gems/httparty-0.13.1/examples/delicious.rb +37 -0
  33. data/gems/ruby/2.1.0/gems/httparty-0.13.1/examples/google.rb +16 -0
  34. data/gems/ruby/2.1.0/gems/httparty-0.13.1/examples/headers_and_user_agents.rb +6 -0
  35. data/gems/ruby/2.1.0/gems/httparty-0.13.1/examples/nokogiri_html_parser.rb +22 -0
  36. data/gems/ruby/2.1.0/gems/httparty-0.13.1/examples/rubyurl.rb +14 -0
  37. data/gems/ruby/2.1.0/gems/httparty-0.13.1/examples/stackexchange.rb +24 -0
  38. data/gems/ruby/2.1.0/gems/httparty-0.13.1/examples/tripit_sign_in.rb +33 -0
  39. data/gems/ruby/2.1.0/gems/httparty-0.13.1/examples/twitter.rb +31 -0
  40. data/gems/ruby/2.1.0/gems/httparty-0.13.1/examples/whoismyrep.rb +10 -0
  41. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/basic_authentication.feature +20 -0
  42. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/command_line.feature +7 -0
  43. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/deals_with_http_error_codes.feature +26 -0
  44. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/digest_authentication.feature +20 -0
  45. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/handles_compressed_responses.feature +27 -0
  46. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/handles_multiple_formats.feature +57 -0
  47. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/steps/env.rb +22 -0
  48. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/steps/httparty_response_steps.rb +52 -0
  49. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/steps/httparty_steps.rb +43 -0
  50. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/steps/mongrel_helper.rb +94 -0
  51. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/steps/remote_service_steps.rb +74 -0
  52. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/supports_read_timeout_option.feature +13 -0
  53. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/supports_redirection.feature +22 -0
  54. data/gems/ruby/2.1.0/gems/httparty-0.13.1/features/supports_timeout_option.feature +13 -0
  55. data/gems/ruby/2.1.0/gems/httparty-0.13.1/httparty.gemspec +26 -0
  56. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty.rb +600 -0
  57. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/connection_adapter.rb +187 -0
  58. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/cookie_hash.rb +22 -0
  59. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/core_extensions.rb +32 -0
  60. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/exceptions.rb +29 -0
  61. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/hash_conversions.rb +51 -0
  62. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/logger/apache_logger.rb +22 -0
  63. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/logger/curl_logger.rb +48 -0
  64. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/logger/logger.rb +18 -0
  65. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/module_inheritable_attributes.rb +56 -0
  66. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/net_digest_auth.rb +84 -0
  67. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/parser.rb +141 -0
  68. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/request.rb +331 -0
  69. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/response.rb +72 -0
  70. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/response/headers.rb +31 -0
  71. data/gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/version.rb +3 -0
  72. data/gems/ruby/2.1.0/gems/httparty-0.13.1/script/release +42 -0
  73. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/delicious.xml +23 -0
  74. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/empty.xml +0 -0
  75. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/google.html +3 -0
  76. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/ssl/generate.sh +29 -0
  77. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/ssl/generated/1fe462c2.0 +16 -0
  78. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/ssl/generated/bogushost.crt +13 -0
  79. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/ssl/generated/ca.crt +16 -0
  80. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/ssl/generated/ca.key +15 -0
  81. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/ssl/generated/selfsigned.crt +14 -0
  82. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/ssl/generated/server.crt +13 -0
  83. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/ssl/generated/server.key +15 -0
  84. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/ssl/openssl-exts.cnf +9 -0
  85. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/twitter.csv +2 -0
  86. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/twitter.json +1 -0
  87. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/twitter.xml +403 -0
  88. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/fixtures/undefined_method_add_node_for_nil.xml +2 -0
  89. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/connection_adapter_spec.rb +354 -0
  90. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/cookie_hash_spec.rb +83 -0
  91. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/exception_spec.rb +23 -0
  92. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/logger/apache_logger_spec.rb +26 -0
  93. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/logger/curl_logger_spec.rb +18 -0
  94. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/logger/logger_spec.rb +22 -0
  95. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/net_digest_auth_spec.rb +152 -0
  96. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/parser_spec.rb +165 -0
  97. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/request_spec.rb +638 -0
  98. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/response_spec.rb +221 -0
  99. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/ssl_spec.rb +74 -0
  100. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty_spec.rb +764 -0
  101. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/spec.opts +2 -0
  102. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/spec_helper.rb +37 -0
  103. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/support/ssl_test_helper.rb +47 -0
  104. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/support/ssl_test_server.rb +80 -0
  105. data/gems/ruby/2.1.0/gems/httparty-0.13.1/spec/support/stub_response.rb +43 -0
  106. data/gems/ruby/2.1.0/gems/httparty-0.13.1/website/css/common.css +47 -0
  107. data/gems/ruby/2.1.0/gems/httparty-0.13.1/website/index.html +73 -0
  108. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/.yardopts +8 -0
  109. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/CHANGELOG.md +93 -0
  110. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/CONTRIBUTING.md +49 -0
  111. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/LICENSE.md +20 -0
  112. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/README.md +97 -0
  113. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/Rakefile +21 -0
  114. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/lib/multi_xml.rb +296 -0
  115. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/lib/multi_xml/parsers/libxml.rb +30 -0
  116. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/lib/multi_xml/parsers/libxml2_parser.rb +74 -0
  117. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/lib/multi_xml/parsers/nokogiri.rb +32 -0
  118. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/lib/multi_xml/parsers/ox.rb +97 -0
  119. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/lib/multi_xml/parsers/rexml.rb +113 -0
  120. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/lib/multi_xml/version.rb +3 -0
  121. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/multi_xml.gemspec +24 -0
  122. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/spec/helper.rb +17 -0
  123. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/spec/multi_xml_spec.rb +43 -0
  124. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/spec/parser_shared_example.rb +694 -0
  125. data/gems/ruby/2.1.0/gems/multi_xml-0.5.5/spec/speed.rb +63 -0
  126. data/gems/ruby/2.1.0/gems/rake-10.3.2/.autotest +7 -0
  127. data/gems/ruby/2.1.0/gems/rake-10.3.2/.gemtest +0 -0
  128. data/gems/ruby/2.1.0/gems/rake-10.3.2/.rubocop.yml +27 -0
  129. data/gems/ruby/2.1.0/gems/rake-10.3.2/.togglerc +7 -0
  130. data/gems/ruby/2.1.0/gems/rake-10.3.2/CONTRIBUTING.rdoc +34 -0
  131. data/gems/ruby/2.1.0/gems/rake-10.3.2/History.rdoc +609 -0
  132. data/gems/ruby/2.1.0/gems/rake-10.3.2/MIT-LICENSE +21 -0
  133. data/gems/ruby/2.1.0/gems/rake-10.3.2/Manifest.txt +162 -0
  134. data/gems/ruby/2.1.0/gems/rake-10.3.2/README.rdoc +137 -0
  135. data/gems/ruby/2.1.0/gems/rake-10.3.2/Rakefile +81 -0
  136. data/gems/ruby/2.1.0/gems/rake-10.3.2/bin/rake +33 -0
  137. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/command_line_usage.rdoc +158 -0
  138. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/example/Rakefile1 +38 -0
  139. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/example/Rakefile2 +35 -0
  140. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/example/a.c +6 -0
  141. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/example/b.c +6 -0
  142. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/example/main.c +11 -0
  143. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/glossary.rdoc +43 -0
  144. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/jamis.rb +591 -0
  145. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/proto_rake.rdoc +127 -0
  146. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/rake.1.gz +0 -0
  147. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/rakefile.rdoc +653 -0
  148. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/rational.rdoc +151 -0
  149. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.4.14.rdoc +23 -0
  150. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.4.15.rdoc +35 -0
  151. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.5.0.rdoc +53 -0
  152. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.5.3.rdoc +78 -0
  153. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.5.4.rdoc +46 -0
  154. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.6.0.rdoc +141 -0
  155. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.7.0.rdoc +119 -0
  156. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.7.1.rdoc +59 -0
  157. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.7.2.rdoc +121 -0
  158. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.7.3.rdoc +47 -0
  159. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.8.0.rdoc +114 -0
  160. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.8.2.rdoc +165 -0
  161. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.8.3.rdoc +112 -0
  162. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.8.4.rdoc +147 -0
  163. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.8.5.rdoc +53 -0
  164. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.8.6.rdoc +37 -0
  165. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.8.7.rdoc +55 -0
  166. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.9.0.rdoc +112 -0
  167. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.9.1.rdoc +52 -0
  168. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.9.2.2.rdoc +55 -0
  169. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.9.2.rdoc +49 -0
  170. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.9.3.rdoc +102 -0
  171. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.9.4.rdoc +60 -0
  172. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.9.5.rdoc +55 -0
  173. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-0.9.6.rdoc +64 -0
  174. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-10.0.0.rdoc +178 -0
  175. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-10.0.1.rdoc +58 -0
  176. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-10.0.2.rdoc +53 -0
  177. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-10.0.3.rdoc +191 -0
  178. data/gems/ruby/2.1.0/gems/rake-10.3.2/doc/release_notes/rake-10.1.0.rdoc +61 -0
  179. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake.rb +78 -0
  180. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/alt_system.rb +110 -0
  181. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb +783 -0
  182. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/backtrace.rb +23 -0
  183. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/clean.rb +76 -0
  184. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/cloneable.rb +16 -0
  185. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/.document +0 -0
  186. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/compositepublisher.rb +21 -0
  187. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/ftptools.rb +137 -0
  188. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/publisher.rb +81 -0
  189. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/rubyforgepublisher.rb +18 -0
  190. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/sshpublisher.rb +61 -0
  191. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/sys.rb +4 -0
  192. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/cpu_counter.rb +109 -0
  193. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/default_loader.rb +14 -0
  194. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/dsl_definition.rb +198 -0
  195. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/early_time.rb +21 -0
  196. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/ext/core.rb +25 -0
  197. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/ext/module.rb +1 -0
  198. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/ext/string.rb +173 -0
  199. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/ext/time.rb +15 -0
  200. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/file_creation_task.rb +24 -0
  201. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/file_list.rb +414 -0
  202. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/file_task.rb +46 -0
  203. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/file_utils.rb +116 -0
  204. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/file_utils_ext.rb +144 -0
  205. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/gempackagetask.rb +4 -0
  206. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb +56 -0
  207. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_exception_mixin.rb +16 -0
  208. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/linked_list.rb +103 -0
  209. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/loaders/makefile.rb +40 -0
  210. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/multi_task.rb +13 -0
  211. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/name_space.rb +38 -0
  212. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/packagetask.rb +202 -0
  213. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/pathmap.rb +3 -0
  214. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/phony.rb +15 -0
  215. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/private_reader.rb +20 -0
  216. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/promise.rb +99 -0
  217. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/pseudo_status.rb +29 -0
  218. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/rake_module.rb +38 -0
  219. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/rake_test_loader.rb +22 -0
  220. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/rdoctask.rb +4 -0
  221. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/ruby182_test_unit_fix.rb +29 -0
  222. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/rule_recursion_overflow_error.rb +20 -0
  223. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/runtest.rb +27 -0
  224. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/scope.rb +42 -0
  225. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb +383 -0
  226. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task_argument_error.rb +7 -0
  227. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task_arguments.rb +98 -0
  228. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task_manager.rb +310 -0
  229. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/tasklib.rb +24 -0
  230. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/testtask.rb +212 -0
  231. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/thread_history_display.rb +48 -0
  232. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/thread_pool.rb +164 -0
  233. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/trace_output.rb +22 -0
  234. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/version.rb +7 -0
  235. data/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/win32.rb +56 -0
  236. data/gems/ruby/2.1.0/gems/rake-10.3.2/rakelib/publish.rake +20 -0
  237. data/gems/ruby/2.1.0/gems/rake-10.3.2/rakelib/test_times.rake +25 -0
  238. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/file_creation.rb +34 -0
  239. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/helper.rb +127 -0
  240. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/support/rakefile_definitions.rb +478 -0
  241. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/support/ruby_runner.rb +33 -0
  242. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_private_reader.rb +42 -0
  243. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake.rb +40 -0
  244. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_application.rb +641 -0
  245. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_application_options.rb +466 -0
  246. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_backtrace.rb +119 -0
  247. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb +55 -0
  248. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_cpu_counter.rb +50 -0
  249. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_definitions.rb +79 -0
  250. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_directory_task.rb +63 -0
  251. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_dsl.rb +40 -0
  252. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_early_time.rb +31 -0
  253. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_extension.rb +59 -0
  254. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_file_creation_task.rb +56 -0
  255. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_file_list.rb +627 -0
  256. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_file_list_path_map.rb +8 -0
  257. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_file_task.rb +186 -0
  258. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_file_utils.rb +309 -0
  259. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_ftp_file.rb +74 -0
  260. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_functional.rb +482 -0
  261. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_invocation_chain.rb +64 -0
  262. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_linked_list.rb +84 -0
  263. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_makefile_loader.rb +46 -0
  264. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_multi_task.rb +58 -0
  265. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_name_space.rb +57 -0
  266. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_package_task.rb +79 -0
  267. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_path_map.rb +168 -0
  268. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_path_map_explode.rb +34 -0
  269. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_path_map_partial.rb +18 -0
  270. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_pseudo_status.rb +21 -0
  271. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_rake_test_loader.rb +20 -0
  272. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_reduce_compat.rb +26 -0
  273. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_require.rb +40 -0
  274. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_rules.rb +388 -0
  275. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_scope.rb +44 -0
  276. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task.rb +392 -0
  277. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task_argument_parsing.rb +109 -0
  278. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task_arguments.rb +127 -0
  279. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task_lib.rb +9 -0
  280. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task_manager.rb +178 -0
  281. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task_manager_argument_resolution.rb +19 -0
  282. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task_with_arguments.rb +171 -0
  283. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_test_task.rb +141 -0
  284. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_thread_pool.rb +142 -0
  285. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_top_level_functions.rb +71 -0
  286. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_win32.rb +72 -0
  287. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_thread_history_display.rb +101 -0
  288. data/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_trace_output.rb +52 -0
  289. data/gems/ruby/2.1.0/specifications/git_repository-0.0.11.gemspec +16 -0
  290. data/gems/ruby/2.1.0/specifications/httparty-0.13.1.gemspec +36 -0
  291. data/gems/ruby/2.1.0/specifications/multi_xml-0.5.5.gemspec +31 -0
  292. data/gems/ruby/2.1.0/specifications/rake-10.3.2.gemspec +43 -0
  293. data/rakefile.rb +33 -0
  294. data/src/APIClient.rb +23 -0
  295. data/test/test_git_repository_commit.rb +19 -0
  296. metadata +395 -0
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
2
+
3
+ describe HTTParty::Logger::ApacheLogger do
4
+ describe "#format" do
5
+ it "formats a response in a style that resembles apache's access log" do
6
+ request_time = Time.new.strftime("%Y-%m-%d %H:%M:%S %z")
7
+ log_message = "[HTTParty] [#{request_time}] 302 \"GET http://my.domain.com/my_path\" - "
8
+
9
+ request_double = double(
10
+ :http_method => Net::HTTP::Get,
11
+ :path => "http://my.domain.com/my_path"
12
+ )
13
+ response_double = double(
14
+ :code => 302,
15
+ :[] => nil
16
+ )
17
+
18
+ logger_double = double
19
+ logger_double.should_receive(:info).with(log_message)
20
+
21
+ subject = described_class.new(logger_double, :info)
22
+ subject.current_time = request_time
23
+ subject.format(request_double, response_double)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
2
+
3
+ describe HTTParty::Logger::CurlLogger do
4
+ describe "#format" do
5
+ it "formats a response in a style that resembles a -v curl" do
6
+ logger_double = double
7
+ logger_double.should_receive(:info).with(
8
+ /\[HTTParty\] \[\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\ [+-]\d{4}\] > GET http:\/\/localhost/)
9
+
10
+ subject = described_class.new(logger_double, :info)
11
+
12
+ stub_http_response_with("google.html")
13
+
14
+ response = HTTParty::Request.new.perform
15
+ subject.format(response.request, response)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
2
+
3
+ describe HTTParty::Logger do
4
+ describe ".build" do
5
+ subject { HTTParty::Logger }
6
+
7
+ it "defaults level to :info" do
8
+ logger_double = double()
9
+ subject.build(logger_double, nil, nil).level.should == :info
10
+ end
11
+
12
+ it "defaults format to :apache" do
13
+ logger_double = double()
14
+ subject.build(logger_double, nil, nil).should be_an_instance_of(HTTParty::Logger::ApacheLogger)
15
+ end
16
+
17
+ it "builds :curl style logger" do
18
+ logger_double = double()
19
+ subject.build(logger_double, nil, :curl).should be_an_instance_of(HTTParty::Logger::CurlLogger)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,152 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ describe Net::HTTPHeader::DigestAuthenticator do
4
+ def setup_digest(response)
5
+ digest = Net::HTTPHeader::DigestAuthenticator.new("Mufasa",
6
+ "Circle Of Life", "GET", "/dir/index.html", response)
7
+ digest.stub(:random).and_return("deadbeef")
8
+ Digest::MD5.stub(:hexdigest) { |str| "md5(#{str})" }
9
+ digest
10
+ end
11
+
12
+ def authorization_header
13
+ @digest.authorization_header.join(", ")
14
+ end
15
+
16
+
17
+ context "with an opaque value in the response header" do
18
+ before do
19
+ @digest = setup_digest({
20
+ 'www-authenticate' => 'Digest realm="myhost@testrealm.com", opaque="solid"'
21
+ })
22
+ end
23
+
24
+ it "should set opaque" do
25
+ authorization_header.should include(%Q(opaque="solid"))
26
+ end
27
+ end
28
+
29
+ context "without an opaque valid in the response header" do
30
+ before do
31
+ @digest = setup_digest({
32
+ 'www-authenticate' => 'Digest realm="myhost@testrealm.com"'
33
+ })
34
+ end
35
+
36
+ it "should not set opaque" do
37
+ authorization_header.should_not include(%Q(opaque=))
38
+ end
39
+ end
40
+
41
+ context "with specified quality of protection (qop)" do
42
+ before do
43
+ @digest = setup_digest({
44
+ 'www-authenticate' => 'Digest realm="myhost@testrealm.com", nonce="NONCE", qop="auth"',
45
+ })
46
+ end
47
+
48
+ it "should set prefix" do
49
+ authorization_header.should =~ /^Digest /
50
+ end
51
+
52
+ it "should set username" do
53
+ authorization_header.should include(%Q(username="Mufasa"))
54
+ end
55
+
56
+ it "should set digest-uri" do
57
+ authorization_header.should include(%Q(uri="/dir/index.html"))
58
+ end
59
+
60
+ it "should set qop" do
61
+ authorization_header.should include(%Q(qop="auth"))
62
+ end
63
+
64
+ it "should set cnonce" do
65
+ authorization_header.should include(%Q(cnonce="md5(deadbeef)"))
66
+ end
67
+
68
+ it "should set nonce-count" do
69
+ authorization_header.should include(%Q(nc=00000001))
70
+ end
71
+
72
+ it "should set response" do
73
+ request_digest = "md5(md5(Mufasa:myhost@testrealm.com:Circle Of Life):NONCE:00000001:md5(deadbeef):auth:md5(GET:/dir/index.html))"
74
+ authorization_header.should include(%Q(response="#{request_digest}"))
75
+ end
76
+ end
77
+
78
+
79
+ context "with unspecified quality of protection (qop)" do
80
+ before do
81
+ @digest = setup_digest({
82
+ 'www-authenticate' => 'Digest realm="myhost@testrealm.com", nonce="NONCE"',
83
+ })
84
+ end
85
+
86
+ it "should set prefix" do
87
+ authorization_header.should =~ /^Digest /
88
+ end
89
+
90
+ it "should set username" do
91
+ authorization_header.should include(%Q(username="Mufasa"))
92
+ end
93
+
94
+ it "should set digest-uri" do
95
+ authorization_header.should include(%Q(uri="/dir/index.html"))
96
+ end
97
+
98
+ it "should not set qop" do
99
+ authorization_header.should_not include(%Q(qop=))
100
+ end
101
+
102
+ it "should not set cnonce" do
103
+ authorization_header.should_not include(%Q(cnonce=))
104
+ end
105
+
106
+ it "should not set nonce-count" do
107
+ authorization_header.should_not include(%Q(nc=))
108
+ end
109
+
110
+ it "should set response" do
111
+ request_digest = "md5(md5(Mufasa:myhost@testrealm.com:Circle Of Life):NONCE:md5(GET:/dir/index.html))"
112
+ authorization_header.should include(%Q(response="#{request_digest}"))
113
+ end
114
+ end
115
+
116
+ context "with multiple authenticate headers" do
117
+ before do
118
+ @digest = setup_digest({
119
+ 'www-authenticate' => 'NTLM, Digest realm="myhost@testrealm.com", nonce="NONCE", qop="auth"',
120
+ })
121
+ end
122
+
123
+ it "should set prefix" do
124
+ authorization_header.should =~ /^Digest /
125
+ end
126
+
127
+ it "should set username" do
128
+ authorization_header.should include(%Q(username="Mufasa"))
129
+ end
130
+
131
+ it "should set digest-uri" do
132
+ authorization_header.should include(%Q(uri="/dir/index.html"))
133
+ end
134
+
135
+ it "should set qop" do
136
+ authorization_header.should include(%Q(qop="auth"))
137
+ end
138
+
139
+ it "should set cnonce" do
140
+ authorization_header.should include(%Q(cnonce="md5(deadbeef)"))
141
+ end
142
+
143
+ it "should set nonce-count" do
144
+ authorization_header.should include(%Q(nc=00000001))
145
+ end
146
+
147
+ it "should set response" do
148
+ request_digest = "md5(md5(Mufasa:myhost@testrealm.com:Circle Of Life):NONCE:00000001:md5(deadbeef):auth:md5(GET:/dir/index.html))"
149
+ authorization_header.should include(%Q(response="#{request_digest}"))
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,165 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ describe HTTParty::Parser do
4
+ describe ".SupportedFormats" do
5
+ it "returns a hash" do
6
+ HTTParty::Parser::SupportedFormats.should be_instance_of(Hash)
7
+ end
8
+ end
9
+
10
+ describe ".call" do
11
+ it "generates an HTTParty::Parser instance with the given body and format" do
12
+ HTTParty::Parser.should_receive(:new).with('body', :plain).and_return(stub(:parse => nil))
13
+ HTTParty::Parser.call('body', :plain)
14
+ end
15
+
16
+ it "calls #parse on the parser" do
17
+ parser = mock('Parser')
18
+ parser.should_receive(:parse)
19
+ HTTParty::Parser.stub(:new => parser)
20
+ parser = HTTParty::Parser.call('body', :plain)
21
+ end
22
+ end
23
+
24
+ describe ".formats" do
25
+ it "returns the SupportedFormats constant" do
26
+ HTTParty::Parser.formats.should == HTTParty::Parser::SupportedFormats
27
+ end
28
+
29
+ it "returns the SupportedFormats constant for subclasses" do
30
+ class MyParser < HTTParty::Parser
31
+ SupportedFormats = {"application/atom+xml" => :atom}
32
+ end
33
+ MyParser.formats.should == {"application/atom+xml" => :atom}
34
+ end
35
+ end
36
+
37
+ describe ".format_from_mimetype" do
38
+ it "returns a symbol representing the format mimetype" do
39
+ HTTParty::Parser.format_from_mimetype("text/plain").should == :plain
40
+ end
41
+
42
+ it "returns nil when the mimetype is not supported" do
43
+ HTTParty::Parser.format_from_mimetype("application/atom+xml").should be_nil
44
+ end
45
+ end
46
+
47
+ describe ".supported_formats" do
48
+ it "returns a unique set of supported formats represented by symbols" do
49
+ HTTParty::Parser.supported_formats.should == HTTParty::Parser::SupportedFormats.values.uniq
50
+ end
51
+ end
52
+
53
+ describe ".supports_format?" do
54
+ it "returns true for a supported format" do
55
+ HTTParty::Parser.stub(:supported_formats => [:json])
56
+ HTTParty::Parser.supports_format?(:json).should be_true
57
+ end
58
+
59
+ it "returns false for an unsupported format" do
60
+ HTTParty::Parser.stub(:supported_formats => [])
61
+ HTTParty::Parser.supports_format?(:json).should be_false
62
+ end
63
+ end
64
+
65
+ describe "#parse" do
66
+ before do
67
+ @parser = HTTParty::Parser.new('body', :json)
68
+ end
69
+
70
+ it "attempts to parse supported formats" do
71
+ @parser.stub(:supports_format? => true)
72
+ @parser.should_receive(:parse_supported_format)
73
+ @parser.parse
74
+ end
75
+
76
+ it "returns the unparsed body when the format is unsupported" do
77
+ @parser.stub(:supports_format? => false)
78
+ @parser.parse.should == @parser.body
79
+ end
80
+
81
+ it "returns nil for an empty body" do
82
+ @parser.stub(:body => '')
83
+ @parser.parse.should be_nil
84
+ end
85
+
86
+ it "returns nil for a nil body" do
87
+ @parser.stub(:body => nil)
88
+ @parser.parse.should be_nil
89
+ end
90
+
91
+ it "returns nil for a 'null' body" do
92
+ @parser.stub(:body => "null")
93
+ @parser.parse.should be_nil
94
+ end
95
+
96
+ it "returns nil for a body with spaces only" do
97
+ @parser.stub(:body => " ")
98
+ @parser.parse.should be_nil
99
+ end
100
+ end
101
+
102
+ describe "#supports_format?" do
103
+ it "utilizes the class method to determine if the format is supported" do
104
+ HTTParty::Parser.should_receive(:supports_format?).with(:json)
105
+ parser = HTTParty::Parser.new('body', :json)
106
+ parser.send(:supports_format?)
107
+ end
108
+ end
109
+
110
+ describe "#parse_supported_format" do
111
+ it "calls the parser for the given format" do
112
+ parser = HTTParty::Parser.new('body', :json)
113
+ parser.should_receive(:json)
114
+ parser.send(:parse_supported_format)
115
+ end
116
+
117
+ context "when a parsing method does not exist for the given format" do
118
+ it "raises an exception" do
119
+ parser = HTTParty::Parser.new('body', :atom)
120
+ expect do
121
+ parser.send(:parse_supported_format)
122
+ end.to raise_error(NotImplementedError, "HTTParty::Parser has not implemented a parsing method for the :atom format.")
123
+ end
124
+
125
+ it "raises a useful exception message for subclasses" do
126
+ atom_parser = Class.new(HTTParty::Parser) do
127
+ def self.name; 'AtomParser'; end
128
+ end
129
+ parser = atom_parser.new 'body', :atom
130
+ expect do
131
+ parser.send(:parse_supported_format)
132
+ end.to raise_error(NotImplementedError, "AtomParser has not implemented a parsing method for the :atom format.")
133
+ end
134
+ end
135
+ end
136
+
137
+ context "parsers" do
138
+ subject do
139
+ HTTParty::Parser.new('body', nil)
140
+ end
141
+
142
+ it "parses xml with MultiXml" do
143
+ MultiXml.should_receive(:parse).with('body')
144
+ subject.send(:xml)
145
+ end
146
+
147
+ it "parses json with JSON" do
148
+ JSON.should_receive(:load).with('body', nil)
149
+ subject.send(:json)
150
+ end
151
+
152
+ it "parses html by simply returning the body" do
153
+ subject.send(:html).should == 'body'
154
+ end
155
+
156
+ it "parses plain text by simply returning the body" do
157
+ subject.send(:plain).should == 'body'
158
+ end
159
+
160
+ it "parses csv with CSV" do
161
+ CSV.should_receive(:parse).with('body')
162
+ subject.send(:csv)
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,638 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ describe HTTParty::Request do
4
+ before do
5
+ @request = HTTParty::Request.new(Net::HTTP::Get, 'http://api.foo.com/v1', :format => :xml)
6
+ end
7
+
8
+ describe "::NON_RAILS_QUERY_STRING_NORMALIZER" do
9
+ let(:normalizer) { HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER }
10
+
11
+ it "doesn't modify strings" do
12
+ query_string = normalizer["foo=bar&foo=baz"]
13
+ URI.unescape(query_string).should == "foo=bar&foo=baz"
14
+ end
15
+
16
+ context "when the query is an array" do
17
+
18
+ it "doesn't include brackets" do
19
+ query_string = normalizer[{:page => 1, :foo => %w(bar baz)}]
20
+ URI.unescape(query_string).should == "foo=bar&foo=baz&page=1"
21
+ end
22
+
23
+ it "URI encodes array values" do
24
+ query_string = normalizer[{:people => ["Otis Redding", "Bob Marley", "Tim & Jon"], :page => 1, :xyzzy => 3}]
25
+ query_string.should == "page=1&people=Otis%20Redding&people=Bob%20Marley&people=Tim%20%26%20Jon&xyzzy=3"
26
+ end
27
+ end
28
+
29
+ context "when the query is a hash" do
30
+ it "correctly handles nil values" do
31
+ query_string = normalizer[{:page => 1, :per_page => nil}]
32
+ query_string.should == "page=1&per_page"
33
+ end
34
+ end
35
+ end
36
+
37
+ describe "initialization" do
38
+ it "sets parser to HTTParty::Parser" do
39
+ request = HTTParty::Request.new(Net::HTTP::Get, 'http://google.com')
40
+ request.parser.should == HTTParty::Parser
41
+ end
42
+
43
+ it "sets parser to the optional parser" do
44
+ my_parser = lambda {}
45
+ request = HTTParty::Request.new(Net::HTTP::Get, 'http://google.com', :parser => my_parser)
46
+ request.parser.should == my_parser
47
+ end
48
+
49
+ it "sets connection_adapter to HTTPParty::ConnectionAdapter" do
50
+ request = HTTParty::Request.new(Net::HTTP::Get, 'http://google.com')
51
+ request.connection_adapter.should == HTTParty::ConnectionAdapter
52
+ end
53
+
54
+ it "sets connection_adapter to the optional connection_adapter" do
55
+ my_adapter = lambda {}
56
+ request = HTTParty::Request.new(Net::HTTP::Get, 'http://google.com', :connection_adapter => my_adapter)
57
+ request.connection_adapter.should == my_adapter
58
+ end
59
+ end
60
+
61
+ describe "#format" do
62
+ context "request yet to be made" do
63
+ it "returns format option" do
64
+ request = HTTParty::Request.new 'get', '/', :format => :xml
65
+ request.format.should == :xml
66
+ end
67
+
68
+ it "returns nil format" do
69
+ request = HTTParty::Request.new 'get', '/'
70
+ request.format.should be_nil
71
+ end
72
+ end
73
+
74
+ context "request has been made" do
75
+ it "returns format option" do
76
+ request = HTTParty::Request.new 'get', '/', :format => :xml
77
+ request.last_response = stub
78
+ request.format.should == :xml
79
+ end
80
+
81
+ it "returns the content-type from the last response when the option is not set" do
82
+ request = HTTParty::Request.new 'get', '/'
83
+ response = stub
84
+ response.should_receive(:[]).with('content-type').and_return('text/json')
85
+ request.last_response = response
86
+ request.format.should == :json
87
+ end
88
+ end
89
+
90
+ end
91
+
92
+ context "options" do
93
+ it "should use basic auth when configured" do
94
+ @request.options[:basic_auth] = {:username => 'foobar', :password => 'secret'}
95
+ @request.send(:setup_raw_request)
96
+ @request.instance_variable_get(:@raw_request)['authorization'].should_not be_nil
97
+ end
98
+
99
+ it "should use digest auth when configured" do
100
+ FakeWeb.register_uri(:get, "http://api.foo.com/v1",
101
+ :www_authenticate => 'Digest realm="Log Viewer", qop="auth", nonce="2CA0EC6B0E126C4800E56BA0C0003D3C", opaque="5ccc069c403ebaf9f0171e9517f40e41", stale=false')
102
+
103
+ @request.options[:digest_auth] = {:username => 'foobar', :password => 'secret'}
104
+ @request.send(:setup_raw_request)
105
+
106
+ raw_request = @request.instance_variable_get(:@raw_request)
107
+ raw_request.instance_variable_get(:@header)['Authorization'].should_not be_nil
108
+ end
109
+
110
+ it "should use the right http method for digest authentication" do
111
+ @post_request = HTTParty::Request.new(Net::HTTP::Post, 'http://api.foo.com/v1', :format => :xml)
112
+ FakeWeb.register_uri(:post, "http://api.foo.com/v1", {})
113
+
114
+ http = @post_request.send(:http)
115
+ @post_request.should_receive(:http).and_return(http)
116
+ http.should_not_receive(:head).and_return({'www-authenticate' => nil})
117
+ @post_request.options[:digest_auth] = {:username => 'foobar', :password => 'secret'}
118
+ @post_request.send(:setup_raw_request)
119
+ end
120
+
121
+ it 'should use body_stream when configured' do
122
+ stream = StringIO.new('foo')
123
+ request = HTTParty::Request.new(Net::HTTP::Post, 'http://api.foo.com/v1', body_stream: stream)
124
+ request.send(:setup_raw_request)
125
+ request.instance_variable_get(:@raw_request).body_stream.should == stream
126
+ end
127
+ end
128
+
129
+ describe "#uri" do
130
+ context "query strings" do
131
+ it "does not add an empty query string when default_params are blank" do
132
+ @request.options[:default_params] = {}
133
+ @request.uri.query.should be_nil
134
+ end
135
+
136
+ it "respects the query string normalization proc" do
137
+ empty_proc = lambda {|qs| ""}
138
+ @request.options[:query_string_normalizer] = empty_proc
139
+ @request.options[:query] = {:foo => :bar}
140
+ URI.unescape(@request.uri.query).should == ""
141
+ end
142
+
143
+ it "does not append an ampersand when queries are embedded in paths" do
144
+ @request.path = "/path?a=1"
145
+ @request.options[:query] = {}
146
+ @request.uri.query.should == "a=1"
147
+ end
148
+
149
+ it "does not duplicate query string parameters when uri is called twice" do
150
+ @request.options[:query] = {:foo => :bar}
151
+ @request.uri
152
+ @request.uri.query.should == "foo=bar"
153
+ end
154
+
155
+ context "when representing an array" do
156
+ it "returns a Rails style query string" do
157
+ @request.options[:query] = {:foo => %w(bar baz)}
158
+ URI.unescape(@request.uri.query).should == "foo[]=bar&foo[]=baz"
159
+ end
160
+ end
161
+
162
+ end
163
+ end
164
+
165
+ describe "#setup_raw_request" do
166
+ context "when query_string_normalizer is set" do
167
+ it "sets the body to the return value of the proc" do
168
+ @request.options[:query_string_normalizer] = HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER
169
+ @request.options[:body] = {:page => 1, :foo => %w(bar baz)}
170
+ @request.send(:setup_raw_request)
171
+ body = @request.instance_variable_get(:@raw_request).body
172
+ URI.unescape(body).should == "foo=bar&foo=baz&page=1"
173
+ end
174
+ end
175
+ end
176
+
177
+ describe 'http' do
178
+ it "should get a connection from the connection_adapter" do
179
+ http = Net::HTTP.new('google.com')
180
+ adapter = mock('adapter')
181
+ request = HTTParty::Request.new(Net::HTTP::Get, 'https://api.foo.com/v1:443', :connection_adapter => adapter)
182
+ adapter.should_receive(:call).with(request.uri, request.options).and_return(http)
183
+ request.send(:http).should be http
184
+ end
185
+ end
186
+
187
+ describe '#format_from_mimetype' do
188
+ it 'should handle text/xml' do
189
+ ["text/xml", "text/xml; charset=iso8859-1"].each do |ct|
190
+ @request.send(:format_from_mimetype, ct).should == :xml
191
+ end
192
+ end
193
+
194
+ it 'should handle application/xml' do
195
+ ["application/xml", "application/xml; charset=iso8859-1"].each do |ct|
196
+ @request.send(:format_from_mimetype, ct).should == :xml
197
+ end
198
+ end
199
+
200
+ it 'should handle text/json' do
201
+ ["text/json", "text/json; charset=iso8859-1"].each do |ct|
202
+ @request.send(:format_from_mimetype, ct).should == :json
203
+ end
204
+ end
205
+
206
+ it 'should handle application/json' do
207
+ ["application/json", "application/json; charset=iso8859-1"].each do |ct|
208
+ @request.send(:format_from_mimetype, ct).should == :json
209
+ end
210
+ end
211
+
212
+ it 'should handle text/csv' do
213
+ ["text/csv", "text/csv; charset=iso8859-1"].each do |ct|
214
+ @request.send(:format_from_mimetype, ct).should == :csv
215
+ end
216
+ end
217
+
218
+ it 'should handle application/csv' do
219
+ ["application/csv", "application/csv; charset=iso8859-1"].each do |ct|
220
+ @request.send(:format_from_mimetype, ct).should == :csv
221
+ end
222
+ end
223
+
224
+ it 'should handle text/comma-separated-values' do
225
+ ["text/comma-separated-values", "text/comma-separated-values; charset=iso8859-1"].each do |ct|
226
+ @request.send(:format_from_mimetype, ct).should == :csv
227
+ end
228
+ end
229
+
230
+ it 'should handle text/javascript' do
231
+ ["text/javascript", "text/javascript; charset=iso8859-1"].each do |ct|
232
+ @request.send(:format_from_mimetype, ct).should == :plain
233
+ end
234
+ end
235
+
236
+ it 'should handle application/javascript' do
237
+ ["application/javascript", "application/javascript; charset=iso8859-1"].each do |ct|
238
+ @request.send(:format_from_mimetype, ct).should == :plain
239
+ end
240
+ end
241
+
242
+ it "returns nil for an unrecognized mimetype" do
243
+ @request.send(:format_from_mimetype, "application/atom+xml").should be_nil
244
+ end
245
+
246
+ it "returns nil when using a default parser" do
247
+ @request.options[:parser] = lambda {}
248
+ @request.send(:format_from_mimetype, "text/json").should be_nil
249
+ end
250
+ end
251
+
252
+ describe 'parsing responses' do
253
+ it 'should handle xml automatically' do
254
+ xml = %q[<books><book><id>1234</id><name>Foo Bar!</name></book></books>]
255
+ @request.options[:format] = :xml
256
+ @request.send(:parse_response, xml).should == {'books' => {'book' => {'id' => '1234', 'name' => 'Foo Bar!'}}}
257
+ end
258
+
259
+ it 'should handle csv automatically' do
260
+ csv=[%q["id","Name"],%q["1234","Foo Bar!"]].join("\n")
261
+ @request.options[:format] = :csv
262
+ @request.send(:parse_response, csv).should == [["id","Name"],["1234","Foo Bar!"]]
263
+ end
264
+
265
+ it 'should handle json automatically' do
266
+ json = %q[{"books": {"book": {"name": "Foo Bar!", "id": "1234"}}}]
267
+ @request.options[:format] = :json
268
+ @request.send(:parse_response, json).should == {'books' => {'book' => {'id' => '1234', 'name' => 'Foo Bar!'}}}
269
+ end
270
+
271
+ it "should include any HTTP headers in the returned response" do
272
+ @request.options[:format] = :html
273
+ response = stub_response "Content"
274
+ response.initialize_http_header("key" => "value")
275
+
276
+ @request.perform.headers.should == { "key" => ["value"] }
277
+ end
278
+
279
+ if "".respond_to?(:encoding)
280
+
281
+ it "should process charset in content type properly" do
282
+ response = stub_response "Content"
283
+ response.initialize_http_header("Content-Type" => "text/plain;charset = utf-8")
284
+ resp = @request.perform
285
+ resp.body.encoding.should == Encoding.find("UTF-8")
286
+ end
287
+
288
+ it "should process charset in content type properly if it has a different case" do
289
+ response = stub_response "Content"
290
+ response.initialize_http_header("Content-Type" => "text/plain;CHARSET = utf-8")
291
+ resp = @request.perform
292
+ resp.body.encoding.should == Encoding.find("UTF-8")
293
+ end
294
+
295
+ it "should process quoted charset in content type properly" do
296
+ response = stub_response "Content"
297
+ response.initialize_http_header("Content-Type" => "text/plain;charset = \"utf-8\"")
298
+ resp = @request.perform
299
+ resp.body.encoding.should == Encoding.find("UTF-8")
300
+ end
301
+
302
+ it "should process utf-16 charset with little endian bom correctly" do
303
+ @request.options[:assume_utf16_is_big_endian] = true
304
+
305
+ response = stub_response "\xFF\xFEC\x00o\x00n\x00t\x00e\x00n\x00t\x00"
306
+ response.initialize_http_header("Content-Type" => "text/plain;charset = utf-16")
307
+ resp = @request.perform
308
+ resp.body.encoding.should == Encoding.find("UTF-16LE")
309
+ end
310
+
311
+ it "should process utf-16 charset with big endian bom correctly" do
312
+ @request.options[:assume_utf16_is_big_endian] = false
313
+
314
+ response = stub_response "\xFE\xFF\x00C\x00o\x00n\x00t\x00e\x00n\x00t"
315
+ response.initialize_http_header("Content-Type" => "text/plain;charset = utf-16")
316
+ resp = @request.perform
317
+ resp.body.encoding.should == Encoding.find("UTF-16BE")
318
+ end
319
+
320
+ it "should assume utf-16 little endian if options has been chosen" do
321
+ @request.options[:assume_utf16_is_big_endian] = false
322
+
323
+ response = stub_response "C\x00o\x00n\x00t\x00e\x00n\x00t\x00"
324
+ response.initialize_http_header("Content-Type" => "text/plain;charset = utf-16")
325
+ resp = @request.perform
326
+ resp.body.encoding.should == Encoding.find("UTF-16LE")
327
+ end
328
+
329
+
330
+ it "should perform no encoding if the charset is not available" do
331
+
332
+ response = stub_response "Content"
333
+ response.initialize_http_header("Content-Type" => "text/plain;charset = utf-lols")
334
+ resp = @request.perform
335
+ resp.body.should == "Content"
336
+ resp.body.encoding.should == "Content".encoding
337
+ end
338
+
339
+ it "should perform no encoding if the content type is specified but no charset is specified" do
340
+
341
+ response = stub_response "Content"
342
+ response.initialize_http_header("Content-Type" => "text/plain")
343
+ resp = @request.perform
344
+ resp.body.should == "Content"
345
+ resp.body.encoding.should == "Content".encoding
346
+ end
347
+ end
348
+
349
+
350
+ describe 'with non-200 responses' do
351
+ context "3xx responses" do
352
+ it 'returns a valid object for 304 not modified' do
353
+ stub_response '', 304
354
+ resp = @request.perform
355
+ resp.code.should == 304
356
+ resp.body.should == ''
357
+ resp.should be_nil
358
+ end
359
+
360
+ it "redirects if a 300 contains a location header" do
361
+ redirect = stub_response '', 300
362
+ redirect['location'] = 'http://foo.com/foo'
363
+ ok = stub_response('<hash><foo>bar</foo></hash>', 200)
364
+ @http.stub!(:request).and_return(redirect, ok)
365
+ response = @request.perform
366
+ response.request.base_uri.to_s.should == "http://foo.com"
367
+ response.request.path.to_s.should == "http://foo.com/foo"
368
+ response.request.uri.request_uri.should == "/foo"
369
+ response.request.uri.to_s.should == "http://foo.com/foo"
370
+ response.should == {"hash" => {"foo" => "bar"}}
371
+ end
372
+
373
+ it "calls block given to perform with each redirect" do
374
+ @request = HTTParty::Request.new(Net::HTTP::Get, 'http://test.com/redirect', :format => :xml)
375
+ FakeWeb.register_uri(:get, "http://test.com/redirect", :status => [300, "REDIRECT"], :location => "http://api.foo.com/v2")
376
+ FakeWeb.register_uri(:get, "http://api.foo.com/v2", :body => "<hash><foo>bar</foo></hash>")
377
+ body = ""
378
+ response = @request.perform { |chunk| body += chunk }
379
+ body.length.should == 27
380
+ end
381
+
382
+ it "redirects if a 300 contains a relative location header" do
383
+ redirect = stub_response '', 300
384
+ redirect['location'] = '/foo/bar'
385
+ ok = stub_response('<hash><foo>bar</foo></hash>', 200)
386
+ @http.stub!(:request).and_return(redirect, ok)
387
+ response = @request.perform
388
+ response.request.base_uri.to_s.should == "http://api.foo.com"
389
+ response.request.path.to_s.should == "/foo/bar"
390
+ response.request.uri.request_uri.should == "/foo/bar"
391
+ response.request.uri.to_s.should == "http://api.foo.com/foo/bar"
392
+ response.should == {"hash" => {"foo" => "bar"}}
393
+ end
394
+
395
+ it "handles multiple redirects and relative location headers on different hosts" do
396
+ @request = HTTParty::Request.new(Net::HTTP::Get, 'http://test.com/redirect', :format => :xml)
397
+ FakeWeb.register_uri(:get, "http://test.com/redirect", :status => [300, "REDIRECT"], :location => "http://api.foo.com/v2")
398
+ FakeWeb.register_uri(:get, "http://api.foo.com/v2", :status => [300, "REDIRECT"], :location => "/v3")
399
+ FakeWeb.register_uri(:get, "http://api.foo.com/v3", :body => "<hash><foo>bar</foo></hash>")
400
+ response = @request.perform
401
+ response.request.base_uri.to_s.should == "http://api.foo.com"
402
+ response.request.path.to_s.should == "/v3"
403
+ response.request.uri.request_uri.should == "/v3"
404
+ response.request.uri.to_s.should == "http://api.foo.com/v3"
405
+ response.should == {"hash" => {"foo" => "bar"}}
406
+ end
407
+
408
+ it "returns the HTTParty::Response when the 300 does not contain a location header" do
409
+ stub_response '', 300
410
+ HTTParty::Response.should === @request.perform
411
+ end
412
+ end
413
+
414
+ it 'should return a valid object for 4xx response' do
415
+ stub_response '<foo><bar>yes</bar></foo>', 401
416
+ resp = @request.perform
417
+ resp.code.should == 401
418
+ resp.body.should == "<foo><bar>yes</bar></foo>"
419
+ resp['foo']['bar'].should == "yes"
420
+ end
421
+
422
+ it 'should return a valid object for 5xx response' do
423
+ stub_response '<foo><bar>error</bar></foo>', 500
424
+ resp = @request.perform
425
+ resp.code.should == 500
426
+ resp.body.should == "<foo><bar>error</bar></foo>"
427
+ resp['foo']['bar'].should == "error"
428
+ end
429
+
430
+ it "parses response lazily so codes can be checked prior" do
431
+ stub_response 'not xml', 500
432
+ @request.options[:format] = :xml
433
+ lambda {
434
+ response = @request.perform
435
+ response.code.should == 500
436
+ response.body.should == 'not xml'
437
+ }.should_not raise_error
438
+ end
439
+ end
440
+ end
441
+
442
+ it "should not attempt to parse empty responses" do
443
+ [204, 304].each do |code|
444
+ stub_response "", code
445
+
446
+ @request.options[:format] = :xml
447
+ @request.perform.should be_nil
448
+ end
449
+ end
450
+
451
+ it "should not fail for missing mime type" do
452
+ stub_response "Content for you"
453
+ @request.options[:format] = :html
454
+ @request.perform.should == 'Content for you'
455
+ end
456
+
457
+ describe "a request that redirects" do
458
+ before(:each) do
459
+ @redirect = stub_response("", 302)
460
+ @redirect['location'] = '/foo'
461
+
462
+ @ok = stub_response('<hash><foo>bar</foo></hash>', 200)
463
+ end
464
+
465
+ describe "once" do
466
+ before(:each) do
467
+ @http.stub!(:request).and_return(@redirect, @ok)
468
+ end
469
+
470
+ it "should be handled by GET transparently" do
471
+ @request.perform.should == {"hash" => {"foo" => "bar"}}
472
+ end
473
+
474
+ it "should be handled by POST transparently" do
475
+ @request.http_method = Net::HTTP::Post
476
+ @request.perform.should == {"hash" => {"foo" => "bar"}}
477
+ end
478
+
479
+ it "should be handled by DELETE transparently" do
480
+ @request.http_method = Net::HTTP::Delete
481
+ @request.perform.should == {"hash" => {"foo" => "bar"}}
482
+ end
483
+
484
+ it "should be handled by MOVE transparently" do
485
+ @request.http_method = Net::HTTP::Move
486
+ @request.perform.should == {"hash" => {"foo" => "bar"}}
487
+ end
488
+
489
+ it "should be handled by COPY transparently" do
490
+ @request.http_method = Net::HTTP::Copy
491
+ @request.perform.should == {"hash" => {"foo" => "bar"}}
492
+ end
493
+
494
+ it "should be handled by PATCH transparently" do
495
+ @request.http_method = Net::HTTP::Patch
496
+ @request.perform.should == {"hash" => {"foo" => "bar"}}
497
+ end
498
+
499
+ it "should be handled by PUT transparently" do
500
+ @request.http_method = Net::HTTP::Put
501
+ @request.perform.should == {"hash" => {"foo" => "bar"}}
502
+ end
503
+
504
+ it "should be handled by HEAD transparently" do
505
+ @request.http_method = Net::HTTP::Head
506
+ @request.perform.should == {"hash" => {"foo" => "bar"}}
507
+ end
508
+
509
+ it "should be handled by OPTIONS transparently" do
510
+ @request.http_method = Net::HTTP::Options
511
+ @request.perform.should == {"hash" => {"foo" => "bar"}}
512
+ end
513
+
514
+ it "should keep track of cookies between redirects" do
515
+ @redirect['Set-Cookie'] = 'foo=bar; name=value; HTTPOnly'
516
+ @request.perform
517
+ @request.options[:headers]['Cookie'].should match(/foo=bar/)
518
+ @request.options[:headers]['Cookie'].should match(/name=value/)
519
+ end
520
+
521
+ it 'should update cookies with rediects' do
522
+ @request.options[:headers] = {'Cookie'=> 'foo=bar;'}
523
+ @redirect['Set-Cookie'] = 'foo=tar;'
524
+ @request.perform
525
+ @request.options[:headers]['Cookie'].should match(/foo=tar/)
526
+ end
527
+
528
+ it 'should keep cookies between rediects' do
529
+ @request.options[:headers] = {'Cookie'=> 'keep=me'}
530
+ @redirect['Set-Cookie'] = 'foo=tar;'
531
+ @request.perform
532
+ @request.options[:headers]['Cookie'].should match(/keep=me/)
533
+ end
534
+
535
+ it "should handle multiple Set-Cookie headers between redirects" do
536
+ @redirect.add_field 'set-cookie', 'foo=bar; name=value; HTTPOnly'
537
+ @redirect.add_field 'set-cookie', 'one=1; two=2; HTTPOnly'
538
+ @request.perform
539
+ @request.options[:headers]['Cookie'].should match(/foo=bar/)
540
+ @request.options[:headers]['Cookie'].should match(/name=value/)
541
+ @request.options[:headers]['Cookie'].should match(/one=1/)
542
+ @request.options[:headers]['Cookie'].should match(/two=2/)
543
+ end
544
+
545
+ it 'should make resulting request a get request if it not already' do
546
+ @request.http_method = Net::HTTP::Delete
547
+ @request.perform.should == {"hash" => {"foo" => "bar"}}
548
+ @request.http_method.should == Net::HTTP::Get
549
+ end
550
+
551
+ it 'should not make resulting request a get request if options[:maintain_method_across_redirects] is true' do
552
+ @request.options[:maintain_method_across_redirects] = true
553
+ @request.http_method = Net::HTTP::Delete
554
+ @request.perform.should == {"hash" => {"foo" => "bar"}}
555
+ @request.http_method.should == Net::HTTP::Delete
556
+ end
557
+
558
+ it 'should log the redirection' do
559
+ logger_double = double
560
+ logger_double.should_receive(:info).twice
561
+ @request.options[:logger] = logger_double
562
+ @request.perform
563
+ end
564
+ end
565
+
566
+ describe "infinitely" do
567
+ before(:each) do
568
+ @http.stub!(:request).and_return(@redirect)
569
+ end
570
+
571
+ it "should raise an exception" do
572
+ lambda { @request.perform }.should raise_error(HTTParty::RedirectionTooDeep)
573
+ end
574
+ end
575
+ end
576
+
577
+ describe "#handle_deflation" do
578
+ context "context-encoding" do
579
+ before do
580
+ @request.options[:format] = :html
581
+ @last_response = mock()
582
+ @last_response.stub!(:body).and_return('')
583
+ end
584
+
585
+ it "should inflate the gzipped body with content-encoding: gzip" do
586
+ @last_response.stub!(:[]).with("content-encoding").and_return("gzip")
587
+ @request.stub!(:last_response).and_return(@last_response)
588
+ Zlib::GzipReader.should_receive(:new).and_return(StringIO.new(''))
589
+ @request.last_response.should_receive(:delete).with('content-encoding')
590
+ @request.send(:handle_deflation)
591
+ end
592
+
593
+ it "should inflate the gzipped body with content-encoding: x-gzip" do
594
+ @last_response.stub!(:[]).with("content-encoding").and_return("x-gzip")
595
+ @request.stub!(:last_response).and_return(@last_response)
596
+ Zlib::GzipReader.should_receive(:new).and_return(StringIO.new(''))
597
+ @request.last_response.should_receive(:delete).with('content-encoding')
598
+ @request.send(:handle_deflation)
599
+ end
600
+
601
+ it "should inflate the deflated body" do
602
+ @last_response.stub!(:[]).with("content-encoding").and_return("deflate")
603
+ @request.stub!(:last_response).and_return(@last_response)
604
+ Zlib::Inflate.should_receive(:inflate).and_return('')
605
+ @request.last_response.should_receive(:delete).with('content-encoding')
606
+ @request.send(:handle_deflation)
607
+ end
608
+ end
609
+ end
610
+
611
+ context "with POST http method" do
612
+ it "should raise argument error if query is not a hash" do
613
+ lambda {
614
+ HTTParty::Request.new(Net::HTTP::Post, 'http://api.foo.com/v1', :format => :xml, :query => 'astring').perform
615
+ }.should raise_error(ArgumentError)
616
+ end
617
+ end
618
+
619
+ describe "argument validation" do
620
+ it "should raise argument error if basic_auth and digest_auth are both present" do
621
+ lambda {
622
+ HTTParty::Request.new(Net::HTTP::Post, 'http://api.foo.com/v1', :basic_auth => {}, :digest_auth => {}).perform
623
+ }.should raise_error(ArgumentError, "only one authentication method, :basic_auth or :digest_auth may be used at a time")
624
+ end
625
+
626
+ it "should raise argument error if basic_auth is not a hash" do
627
+ lambda {
628
+ HTTParty::Request.new(Net::HTTP::Post, 'http://api.foo.com/v1', :basic_auth => ["foo", "bar"]).perform
629
+ }.should raise_error(ArgumentError, ":basic_auth must be a hash")
630
+ end
631
+
632
+ it "should raise argument error if digest_auth is not a hash" do
633
+ lambda {
634
+ HTTParty::Request.new(Net::HTTP::Post, 'http://api.foo.com/v1', :digest_auth => ["foo", "bar"]).perform
635
+ }.should raise_error(ArgumentError, ":digest_auth must be a hash")
636
+ end
637
+ end
638
+ end