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,2144 @@
1
+ # coding: utf-8
2
+ # Copyright (C) 2006-2011 Bob Aman
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ require "addressable/template"
18
+
19
+ if !"".respond_to?("force_encoding")
20
+ class String
21
+ def force_encoding(encoding)
22
+ @encoding = encoding
23
+ end
24
+
25
+ def encoding
26
+ @encoding ||= Encoding::ASCII_8BIT
27
+ end
28
+ end
29
+
30
+ class Encoding
31
+ def initialize(name)
32
+ @name = name
33
+ end
34
+
35
+ def to_s
36
+ return @name
37
+ end
38
+
39
+ UTF_8 = Encoding.new("UTF-8")
40
+ ASCII_8BIT = Encoding.new("US-ASCII")
41
+ end
42
+ end
43
+
44
+ class ExampleProcessor
45
+ def self.validate(name, value)
46
+ return !!(value =~ /^[\w ]+$/) if name == "query"
47
+ return true
48
+ end
49
+
50
+ def self.transform(name, value)
51
+ return value.gsub(/ /, "+") if name == "query"
52
+ return value
53
+ end
54
+
55
+ def self.restore(name, value)
56
+ return value.gsub(/\+/, " ") if name == "query"
57
+ return value.tr("A-Za-z", "N-ZA-Mn-za-m") if name == "rot13"
58
+ return value
59
+ end
60
+
61
+ def self.match(name)
62
+ return ".*?" if name == "first"
63
+ return ".*"
64
+ end
65
+ end
66
+
67
+ class SlashlessProcessor
68
+ def self.match(name)
69
+ return "[^/\\n]*"
70
+ end
71
+ end
72
+
73
+ class NoOpProcessor
74
+ def self.transform(name, value)
75
+ value
76
+ end
77
+ end
78
+
79
+ describe Addressable::Template do
80
+ it "should raise a TypeError for invalid patterns" do
81
+ (lambda do
82
+ Addressable::Template.new(42)
83
+ end).should raise_error(TypeError, "Can't convert Fixnum into String.")
84
+ end
85
+ end
86
+
87
+ describe Addressable::Template, "created with the pattern '/'" do
88
+ before do
89
+ @template = Addressable::Template.new("/")
90
+ end
91
+
92
+ it "should have no variables" do
93
+ @template.variables.should be_empty
94
+ end
95
+
96
+ it "should have the correct mapping when extracting from '/'" do
97
+ @template.extract("/").should == {}
98
+ end
99
+ end
100
+
101
+ describe Addressable::URI, "when parsed from '/one/'" do
102
+ before do
103
+ @uri = Addressable::URI.parse("/one/")
104
+ end
105
+
106
+ it "should not match the pattern '/two/'" do
107
+ Addressable::Template.new("/two/").extract(@uri).should == nil
108
+ end
109
+
110
+ it "should have the correct mapping when extracting values " +
111
+ "using the pattern '/{number}/'" do
112
+ Addressable::Template.new(
113
+ "/{number}/"
114
+ ).extract(@uri).should == {"number" => "one"}
115
+ end
116
+ end
117
+
118
+ describe Addressable::Template, "created with the pattern '/{number}/'" do
119
+ before do
120
+ @template = Addressable::Template.new("/{number}/")
121
+ end
122
+
123
+ it "should have the variables ['number']" do
124
+ @template.variables.should == ["number"]
125
+ end
126
+
127
+ it "should not match the pattern '/'" do
128
+ @template.match("/").should == nil
129
+ end
130
+
131
+ it "should match the pattern '/two/'" do
132
+ @template.match("/two/").mapping.should == {"number" => "two"}
133
+ end
134
+ end
135
+
136
+ describe Addressable::Template,
137
+ "created with the pattern '/{number}/{number}/'" do
138
+ before do
139
+ @template = Addressable::Template.new("/{number}/{number}/")
140
+ end
141
+
142
+ it "should have one variable" do
143
+ @template.variables.should == ["number"]
144
+ end
145
+
146
+ it "should have the correct mapping when extracting from '/1/1/'" do
147
+ @template.extract("/1/1/").should == {"number" => "1"}
148
+ end
149
+
150
+ it "should not match '/1/2/'" do
151
+ @template.match("/1/2/").should == nil
152
+ end
153
+
154
+ it "should not match '/2/1/'" do
155
+ @template.match("/2/1/").should == nil
156
+ end
157
+
158
+ it "should not match '/1/'" do
159
+ @template.match("/1/").should == nil
160
+ end
161
+
162
+ it "should not match '/1/1/1/'" do
163
+ @template.match("/1/1/1/").should == nil
164
+ end
165
+
166
+ it "should not match '/1/2/3/'" do
167
+ @template.match("/1/2/3/").should == nil
168
+ end
169
+ end
170
+
171
+ describe Addressable::Template,
172
+ "created with the pattern '/{number}{-prefix|.|number}'" do
173
+ before do
174
+ @template = Addressable::Template.new("/{number}{-prefix|.|number}")
175
+ end
176
+
177
+ it "should have one variable" do
178
+ @template.variables.should == ["number"]
179
+ end
180
+
181
+ it "should have the correct mapping when extracting from '/1.1'" do
182
+ @template.extract("/1.1").should == {"number" => "1"}
183
+ end
184
+
185
+ it "should have the correct mapping when extracting from '/99.99'" do
186
+ @template.extract("/99.99").should == {"number" => "99"}
187
+ end
188
+
189
+ it "should not match '/1.2'" do
190
+ @template.match("/1.2").should == nil
191
+ end
192
+
193
+ it "should not match '/2.1'" do
194
+ @template.match("/2.1").should == nil
195
+ end
196
+
197
+ it "should not match '/1'" do
198
+ @template.match("/1").should == nil
199
+ end
200
+
201
+ it "should not match '/1.1.1'" do
202
+ @template.match("/1.1.1").should == nil
203
+ end
204
+
205
+ it "should not match '/1.23'" do
206
+ @template.match("/1.23").should == nil
207
+ end
208
+ end
209
+
210
+ describe Addressable::Template,
211
+ "created with the pattern '/{number}/{-suffix|/|number}'" do
212
+ before do
213
+ @template = Addressable::Template.new("/{number}/{-suffix|/|number}")
214
+ end
215
+
216
+ it "should have one variable" do
217
+ @template.variables.should == ["number"]
218
+ end
219
+
220
+ it "should have the correct mapping when extracting from '/1/1/'" do
221
+ @template.extract("/1/1/").should == {"number" => "1"}
222
+ end
223
+
224
+ it "should have the correct mapping when extracting from '/99/99/'" do
225
+ @template.extract("/99/99/").should == {"number" => "99"}
226
+ end
227
+
228
+ it "should not match '/1/1'" do
229
+ @template.match("/1/1").should == nil
230
+ end
231
+
232
+ it "should not match '/11/'" do
233
+ @template.match("/11/").should == nil
234
+ end
235
+
236
+ it "should not match '/1/2/'" do
237
+ @template.match("/1/2/").should == nil
238
+ end
239
+
240
+ it "should not match '/2/1/'" do
241
+ @template.match("/2/1/").should == nil
242
+ end
243
+
244
+ it "should not match '/1/'" do
245
+ @template.match("/1/").should == nil
246
+ end
247
+
248
+ it "should not match '/1/1/1/'" do
249
+ @template.match("/1/1/1/").should == nil
250
+ end
251
+
252
+ it "should not match '/1/23/'" do
253
+ @template.match("/1/23/").should == nil
254
+ end
255
+ end
256
+
257
+ describe Addressable::Template,
258
+ "created with the pattern '/{number}/?{-join|&|number}'" do
259
+ before do
260
+ @template = Addressable::Template.new(
261
+ "/{number}/?{-join|&|number,letter}"
262
+ )
263
+ end
264
+
265
+ it "should have one variable" do
266
+ @template.variables.should == ["number", "letter"]
267
+ end
268
+
269
+ it "should have the correct mapping when extracting from '/1/?number=1'" do
270
+ @template.extract("/1/?number=1").should == {"number" => "1"}
271
+ end
272
+
273
+ it "should have the correct mapping when extracting " +
274
+ "from '/99/?number=99'" do
275
+ @template.extract("/99/?number=99").should == {"number" => "99"}
276
+ end
277
+
278
+ it "should have the correct mapping when extracting " +
279
+ "from '/1/?number=1&letter=a'" do
280
+ @template.extract("/1/?number=1&letter=a").should == {
281
+ "number" => "1", "letter" => "a"
282
+ }
283
+ end
284
+
285
+ it "should not match '/1/?number=1&bogus=foo'" do
286
+ @template.match("/1/?number=1&bogus=foo").should == nil
287
+ end
288
+
289
+ it "should not match '/1/?number=2'" do
290
+ @template.match("/1/?number=2").should == nil
291
+ end
292
+
293
+ it "should not match '/2/?number=1'" do
294
+ @template.match("/2/?number=1").should == nil
295
+ end
296
+
297
+ it "should not match '/1/?'" do
298
+ @template.match("/1/?").should == nil
299
+ end
300
+ end
301
+
302
+ describe Addressable::Template,
303
+ "created with the pattern '/{number}/{-list|/|number}/'" do
304
+ before do
305
+ @template = Addressable::Template.new("/{number}/{-list|/|number}/")
306
+ end
307
+
308
+ it "should have one variable" do
309
+ @template.variables.should == ["number"]
310
+ end
311
+
312
+ it "should not match '/1/1/'" do
313
+ @template.match("/1/1/").should == nil
314
+ end
315
+
316
+ it "should not match '/1/2/'" do
317
+ @template.match("/1/2/").should == nil
318
+ end
319
+
320
+ it "should not match '/2/1/'" do
321
+ @template.match("/2/1/").should == nil
322
+ end
323
+
324
+ it "should not match '/1/1/1/'" do
325
+ @template.match("/1/1/1/").should == nil
326
+ end
327
+
328
+ it "should not match '/1/1/1/1/'" do
329
+ @template.match("/1/1/1/1/").should == nil
330
+ end
331
+ end
332
+
333
+ describe Addressable::Template, "created with the pattern " +
334
+ "'http://www.example.com/?{-join|&|query,number}'" do
335
+ before do
336
+ @template = Addressable::Template.new(
337
+ "http://www.example.com/?{-join|&|query,number}"
338
+ )
339
+ end
340
+
341
+ it "when inspected, should have the correct class name" do
342
+ @template.inspect.should include("Addressable::Template")
343
+ end
344
+
345
+ it "when inspected, should have the correct object id" do
346
+ @template.inspect.should include("%#0x" % @template.object_id)
347
+ end
348
+
349
+ it "should have the variables ['query', 'number']" do
350
+ @template.variables.should == ["query", "number"]
351
+ end
352
+
353
+ it "should not match the pattern 'http://www.example.com/'" do
354
+ @template.match("http://www.example.com/").should == nil
355
+ end
356
+
357
+ it "should match the pattern 'http://www.example.com/?'" do
358
+ @template.match("http://www.example.com/?").mapping.should == {}
359
+ end
360
+
361
+ it "should match the pattern " +
362
+ "'http://www.example.com/?query=mycelium'" do
363
+ match = @template.match(
364
+ "http://www.example.com/?query=mycelium"
365
+ )
366
+ match.variables.should == ["query", "number"]
367
+ match.values.should == ["mycelium", nil]
368
+ match.mapping.should == {"query" => "mycelium"}
369
+ match.inspect.should =~ /MatchData/
370
+ end
371
+
372
+ it "should match the pattern " +
373
+ "'http://www.example.com/?query=mycelium&number=100'" do
374
+ @template.match(
375
+ "http://www.example.com/?query=mycelium&number=100"
376
+ ).mapping.should == {"query" => "mycelium", "number" => "100"}
377
+ end
378
+ end
379
+
380
+ describe Addressable::URI, "when parsed from '/one/two/'" do
381
+ before do
382
+ @uri = Addressable::URI.parse("/one/two/")
383
+ end
384
+
385
+ it "should not match the pattern '/{number}/' " +
386
+ "with the SlashlessProcessor" do
387
+ Addressable::Template.new(
388
+ "/{number}/"
389
+ ).extract(@uri, SlashlessProcessor).should == nil
390
+ end
391
+
392
+ it "should have the correct mapping when extracting values " +
393
+ "using the pattern '/{number}/' without a processor" do
394
+ Addressable::Template.new("/{number}/").extract(@uri).should == {
395
+ "number" => "one/two"
396
+ }
397
+ end
398
+
399
+ it "should have the correct mapping when extracting values " +
400
+ "using the pattern '/{first}/{second}/' with the SlashlessProcessor" do
401
+ Addressable::Template.new(
402
+ "/{first}/{second}/"
403
+ ).extract(@uri, SlashlessProcessor).should == {
404
+ "first" => "one",
405
+ "second" => "two"
406
+ }
407
+ end
408
+ end
409
+
410
+ describe Addressable::URI, "when parsed from " +
411
+ "'http://example.com/search/an+example+search+query/'" do
412
+ before do
413
+ @uri = Addressable::URI.parse(
414
+ "http://example.com/search/an+example+search+query/")
415
+ end
416
+
417
+ it "should have the correct mapping when extracting values using " +
418
+ "the pattern 'http://example.com/search/{query}/' with the " +
419
+ "ExampleProcessor" do
420
+ Addressable::Template.new(
421
+ "http://example.com/search/{query}/"
422
+ ).extract(@uri, ExampleProcessor).should == {
423
+ "query" => "an example search query"
424
+ }
425
+ end
426
+
427
+ it "should have the correct mapping when extracting values " +
428
+ "using the pattern " +
429
+ "'http://example.com/search/{-list|+|query}/'" do
430
+ Addressable::Template.new(
431
+ "http://example.com/search/{-list|+|query}/"
432
+ ).extract(@uri).should == {
433
+ "query" => ["an", "example", "search", "query"]
434
+ }
435
+ end
436
+
437
+ it "should return nil when extracting values using " +
438
+ "a non-matching pattern" do
439
+ Addressable::Template.new(
440
+ "http://bogus.com/{thingy}/"
441
+ ).extract(@uri).should == nil
442
+ end
443
+ end
444
+
445
+ describe Addressable::URI, "when parsed from " +
446
+ "'http://example.com/a/b/c/'" do
447
+ before do
448
+ @uri = Addressable::URI.parse(
449
+ "http://example.com/a/b/c/")
450
+ end
451
+
452
+ it "should have the correct mapping when extracting values " +
453
+ "using the pattern " +
454
+ "'http://example.com/{first}/{second}/' with the ExampleProcessor" do
455
+ Addressable::Template.new(
456
+ "http://example.com/{first}/{second}/"
457
+ ).extract(@uri, ExampleProcessor).should == {
458
+ "first" => "a",
459
+ "second" => "b/c"
460
+ }
461
+ end
462
+
463
+ it "should have the correct mapping when extracting values " +
464
+ "using the pattern " +
465
+ "'http://example.com/{first}/{-list|/|second}/'" do
466
+ Addressable::Template.new(
467
+ "http://example.com/{first}/{-list|/|second}/"
468
+ ).extract(@uri).should == {
469
+ "first" => "a",
470
+ "second" => ["b", "c"]
471
+ }
472
+ end
473
+
474
+ it "should have the correct mapping when extracting values " +
475
+ "using the pattern " +
476
+ "'http://example.com/{first}/{-list|/|rot13}/' " +
477
+ "with the ExampleProcessor" do
478
+ Addressable::Template.new(
479
+ "http://example.com/{first}/{-list|/|rot13}/"
480
+ ).extract(@uri, ExampleProcessor).should == {
481
+ "first" => "a",
482
+ "rot13" => ["o", "p"]
483
+ }
484
+ end
485
+
486
+ it "should have the correct mapping when extracting values " +
487
+ "using the pattern " +
488
+ "'http://example.com/{-list|/|rot13}/' " +
489
+ "with the ExampleProcessor" do
490
+ Addressable::Template.new(
491
+ "http://example.com/{-list|/|rot13}/"
492
+ ).extract(@uri, ExampleProcessor).should == {
493
+ "rot13" => ["n", "o", "p"]
494
+ }
495
+ end
496
+
497
+ it "should not map to anything when extracting values " +
498
+ "using the pattern " +
499
+ "'http://example.com/{-list|/|rot13}/'" do
500
+ Addressable::Template.new(
501
+ "http://example.com/{-join|/|a,b,c}/"
502
+ ).extract(@uri).should == nil
503
+ end
504
+ end
505
+
506
+ describe Addressable::URI, "when parsed from " +
507
+ "'http://example.com/?a=one&b=two&c=three'" do
508
+ before do
509
+ @uri = Addressable::URI.parse("http://example.com/?a=one&b=two&c=three")
510
+ end
511
+
512
+ it "should have the correct mapping when extracting values " +
513
+ "using the pattern " +
514
+ "'http://example.com/?{-join|&|a,b,c}'" do
515
+ Addressable::Template.new(
516
+ "http://example.com/?{-join|&|a,b,c}"
517
+ ).extract(@uri).should == {
518
+ "a" => "one",
519
+ "b" => "two",
520
+ "c" => "three"
521
+ }
522
+ end
523
+ end
524
+
525
+ describe Addressable::URI, "when parsed from " +
526
+ "'http://example.com/?rot13=frperg'" do
527
+ before do
528
+ @uri = Addressable::URI.parse("http://example.com/?rot13=frperg")
529
+ end
530
+
531
+ it "should have the correct mapping when extracting values " +
532
+ "using the pattern " +
533
+ "'http://example.com/?{-join|&|rot13}' with the ExampleProcessor" do
534
+ Addressable::Template.new(
535
+ "http://example.com/?{-join|&|rot13}"
536
+ ).extract(@uri, ExampleProcessor).should == {
537
+ "rot13" => "secret"
538
+ }
539
+ end
540
+ end
541
+
542
+ describe Addressable::URI, "when parsed from " +
543
+ "'http://example.org///something///'" do
544
+ before do
545
+ @uri = Addressable::URI.parse("http://example.org///something///")
546
+ end
547
+
548
+ it "should have the correct mapping when extracting values " +
549
+ "using the pattern 'http://example.org{-prefix|/|parts}/'" do
550
+ Addressable::Template.new(
551
+ "http://example.org{-prefix|/|parts}/"
552
+ ).extract(@uri).should == {
553
+ "parts" => ["", "", "something", "", ""]
554
+ }
555
+ end
556
+
557
+ it "should have the correct mapping when extracting values " +
558
+ "using the pattern 'http://example.org/{-suffix|/|parts}'" do
559
+ Addressable::Template.new(
560
+ "http://example.org/{-suffix|/|parts}"
561
+ ).extract(@uri).should == {
562
+ "parts" => ["", "", "something", "", ""]
563
+ }
564
+ end
565
+
566
+ it "should have the correct mapping when extracting values " +
567
+ "using the pattern 'http://example.org/{-list|/|parts}'" do
568
+ Addressable::Template.new(
569
+ "http://example.org/{-list|/|parts}"
570
+ ).extract(@uri).should == {
571
+ "parts" => ["", "", "something", "", ""]
572
+ }
573
+ end
574
+ end
575
+
576
+ describe Addressable::URI, "when parsed from " +
577
+ "'http://example.com/one/spacer/two/'" do
578
+ before do
579
+ @uri = Addressable::URI.parse("http://example.com/one/spacer/two/")
580
+ end
581
+
582
+ it "should have the correct mapping when extracting values " +
583
+ "using the pattern " +
584
+ "'http://example.com/{first}/spacer/{second}/'" do
585
+ Addressable::Template.new(
586
+ "http://example.com/{first}/spacer/{second}/"
587
+ ).extract(@uri).should == {
588
+ "first" => "one",
589
+ "second" => "two"
590
+ }
591
+ end
592
+
593
+ it "should have the correct mapping when extracting values " +
594
+ "using the pattern " +
595
+ "'http://example.com{-prefix|/|stuff}/'" do
596
+ Addressable::Template.new(
597
+ "http://example.com{-prefix|/|stuff}/"
598
+ ).extract(@uri).should == {
599
+ "stuff" => ["one", "spacer", "two"]
600
+ }
601
+ end
602
+
603
+ it "should have the correct mapping when extracting values " +
604
+ "using the pattern " +
605
+ "'http://example.com/o{-prefix|/|stuff}/'" do
606
+ Addressable::Template.new(
607
+ "http://example.com/o{-prefix|/|stuff}/"
608
+ ).extract(@uri).should == nil
609
+ end
610
+
611
+ it "should have the correct mapping when extracting values " +
612
+ "using the pattern " +
613
+ "'http://example.com/{first}/spacer{-prefix|/|stuff}/'" do
614
+ Addressable::Template.new(
615
+ "http://example.com/{first}/spacer{-prefix|/|stuff}/"
616
+ ).extract(@uri).should == {
617
+ "first" => "one",
618
+ "stuff" => "two"
619
+ }
620
+ end
621
+
622
+ it "should not match anything when extracting values " +
623
+ "using the incorrect suffix pattern " +
624
+ "'http://example.com/{-prefix|/|stuff}/'" do
625
+ Addressable::Template.new(
626
+ "http://example.com/{-prefix|/|stuff}/"
627
+ ).extract(@uri).should == nil
628
+ end
629
+
630
+ it "should have the correct mapping when extracting values " +
631
+ "using the pattern " +
632
+ "'http://example.com{-prefix|/|rot13}/' with the ExampleProcessor" do
633
+ Addressable::Template.new(
634
+ "http://example.com{-prefix|/|rot13}/"
635
+ ).extract(@uri, ExampleProcessor).should == {
636
+ "rot13" => ["bar", "fcnpre", "gjb"]
637
+ }
638
+ end
639
+
640
+ it "should have the correct mapping when extracting values " +
641
+ "using the pattern " +
642
+ "'http://example.com{-prefix|/|rot13}' with the ExampleProcessor" do
643
+ Addressable::Template.new(
644
+ "http://example.com{-prefix|/|rot13}"
645
+ ).extract(@uri, ExampleProcessor).should == {
646
+ "rot13" => ["bar", "fcnpre", "gjb", ""]
647
+ }
648
+ end
649
+
650
+ it "should not match anything when extracting values " +
651
+ "using the incorrect suffix pattern " +
652
+ "'http://example.com/{-prefix|/|rot13}' with the ExampleProcessor" do
653
+ Addressable::Template.new(
654
+ "http://example.com/{-prefix|/|rot13}"
655
+ ).extract(@uri, ExampleProcessor).should == nil
656
+ end
657
+
658
+ it "should have the correct mapping when extracting values " +
659
+ "using the pattern " +
660
+ "'http://example.com/{-suffix|/|stuff}'" do
661
+ Addressable::Template.new(
662
+ "http://example.com/{-suffix|/|stuff}"
663
+ ).extract(@uri).should == {
664
+ "stuff" => ["one", "spacer", "two"]
665
+ }
666
+ end
667
+
668
+ it "should have the correct mapping when extracting values " +
669
+ "using the pattern " +
670
+ "'http://example.com/{-suffix|/|stuff}o'" do
671
+ Addressable::Template.new(
672
+ "http://example.com/{-suffix|/|stuff}o"
673
+ ).extract(@uri).should == nil
674
+ end
675
+
676
+ it "should have the correct mapping when extracting values " +
677
+ "using the pattern " +
678
+ "'http://example.com/o{-suffix|/|stuff}'" do
679
+ Addressable::Template.new(
680
+ "http://example.com/o{-suffix|/|stuff}"
681
+ ).extract(@uri).should == {"stuff"=>["ne", "spacer", "two"]}
682
+ end
683
+
684
+ it "should have the correct mapping when extracting values " +
685
+ "using the pattern " +
686
+ "'http://example.com/{first}/spacer/{-suffix|/|stuff}'" do
687
+ Addressable::Template.new(
688
+ "http://example.com/{first}/spacer/{-suffix|/|stuff}"
689
+ ).extract(@uri).should == {
690
+ "first" => "one",
691
+ "stuff" => "two"
692
+ }
693
+ end
694
+
695
+ it "should not match anything when extracting values " +
696
+ "using the incorrect suffix pattern " +
697
+ "'http://example.com/{-suffix|/|stuff}/'" do
698
+ Addressable::Template.new(
699
+ "http://example.com/{-suffix|/|stuff}/"
700
+ ).extract(@uri).should == nil
701
+ end
702
+
703
+ it "should have the correct mapping when extracting values " +
704
+ "using the pattern " +
705
+ "'http://example.com/{-suffix|/|rot13}' with the ExampleProcessor" do
706
+ Addressable::Template.new(
707
+ "http://example.com/{-suffix|/|rot13}"
708
+ ).extract(@uri, ExampleProcessor).should == {
709
+ "rot13" => ["bar", "fcnpre", "gjb"]
710
+ }
711
+ end
712
+
713
+ it "should have the correct mapping when extracting values " +
714
+ "using the pattern " +
715
+ "'http://example.com{-suffix|/|rot13}' with the ExampleProcessor" do
716
+ Addressable::Template.new(
717
+ "http://example.com{-suffix|/|rot13}"
718
+ ).extract(@uri, ExampleProcessor).should == {
719
+ "rot13" => ["", "bar", "fcnpre", "gjb"]
720
+ }
721
+ end
722
+
723
+ it "should not match anything when extracting values " +
724
+ "using the incorrect suffix pattern " +
725
+ "'http://example.com/{-suffix|/|rot13}/' with the ExampleProcessor" do
726
+ Addressable::Template.new(
727
+ "http://example.com/{-suffix|/|rot13}/"
728
+ ).extract(@uri, ExampleProcessor).should == nil
729
+ end
730
+ end
731
+
732
+ describe Addressable::URI, "when parsed from " +
733
+ "'http://example.com/?email=bob@sporkmonger.com'" do
734
+ before do
735
+ @uri = Addressable::URI.parse(
736
+ "http://example.com/?email=bob@sporkmonger.com"
737
+ )
738
+ end
739
+
740
+ it "should not match anything when extracting values " +
741
+ "using the incorrect opt pattern " +
742
+ "'http://example.com/?email={-opt|bogus@bogus.com|test}'" do
743
+ Addressable::Template.new(
744
+ "http://example.com/?email={-opt|bogus@bogus.com|test}"
745
+ ).extract(@uri).should == nil
746
+ end
747
+
748
+ it "should not match anything when extracting values " +
749
+ "using the incorrect neg pattern " +
750
+ "'http://example.com/?email={-neg|bogus@bogus.com|test}'" do
751
+ Addressable::Template.new(
752
+ "http://example.com/?email={-neg|bogus@bogus.com|test}"
753
+ ).extract(@uri).should == nil
754
+ end
755
+
756
+ it "should indicate a match when extracting values " +
757
+ "using the opt pattern " +
758
+ "'http://example.com/?email={-opt|bob@sporkmonger.com|test}'" do
759
+ Addressable::Template.new(
760
+ "http://example.com/?email={-opt|bob@sporkmonger.com|test}"
761
+ ).extract(@uri).should == {}
762
+ end
763
+
764
+ it "should indicate a match when extracting values " +
765
+ "using the neg pattern " +
766
+ "'http://example.com/?email={-neg|bob@sporkmonger.com|test}'" do
767
+ Addressable::Template.new(
768
+ "http://example.com/?email={-neg|bob@sporkmonger.com|test}"
769
+ ).extract(@uri).should == {}
770
+ end
771
+ end
772
+
773
+ describe Addressable::URI, "when parsed from " +
774
+ "'http://example.com/?email='" do
775
+ before do
776
+ @uri = Addressable::URI.parse(
777
+ "http://example.com/?email="
778
+ )
779
+ end
780
+
781
+ it "should indicate a match when extracting values " +
782
+ "using the opt pattern " +
783
+ "'http://example.com/?email={-opt|bob@sporkmonger.com|test}'" do
784
+ Addressable::Template.new(
785
+ "http://example.com/?email={-opt|bob@sporkmonger.com|test}"
786
+ ).extract(@uri).should == {}
787
+ end
788
+
789
+ it "should indicate a match when extracting values " +
790
+ "using the neg pattern " +
791
+ "'http://example.com/?email={-neg|bob@sporkmonger.com|test}'" do
792
+ Addressable::Template.new(
793
+ "http://example.com/?email={-neg|bob@sporkmonger.com|test}"
794
+ ).extract(@uri).should == {}
795
+ end
796
+ end
797
+
798
+ describe Addressable::URI, "when parsed from " +
799
+ "'http://example.com/a/b/c/?one=1&two=2#foo'" do
800
+ before do
801
+ @uri = Addressable::URI.parse(
802
+ "http://example.com/a/b/c/?one=1&two=2#foo"
803
+ )
804
+ end
805
+
806
+ it "should have the correct mapping when extracting values " +
807
+ "using the pattern " +
808
+ "'http://{host}/{-suffix|/|segments}?{-join|&|one,two}\#{fragment}'" do
809
+ Addressable::Template.new(
810
+ "http://{host}/{-suffix|/|segments}?{-join|&|one,two}\#{fragment}"
811
+ ).extract(@uri).should == {
812
+ "host" => "example.com",
813
+ "segments" => ["a", "b", "c"],
814
+ "one" => "1",
815
+ "two" => "2",
816
+ "fragment" => "foo"
817
+ }
818
+ end
819
+
820
+ it "should not match when extracting values " +
821
+ "using the pattern " +
822
+ "'http://{host}/{-suffix|/|segments}?{-join|&|one}\#{fragment}'" do
823
+ Addressable::Template.new(
824
+ "http://{host}/{-suffix|/|segments}?{-join|&|one}\#{fragment}"
825
+ ).extract(@uri).should == nil
826
+ end
827
+
828
+ it "should not match when extracting values " +
829
+ "using the pattern " +
830
+ "'http://{host}/{-suffix|/|segments}?{-join|&|bogus}\#{fragment}'" do
831
+ Addressable::Template.new(
832
+ "http://{host}/{-suffix|/|segments}?{-join|&|bogus}\#{fragment}"
833
+ ).extract(@uri).should == nil
834
+ end
835
+
836
+ it "should not match when extracting values " +
837
+ "using the pattern " +
838
+ "'http://{host}/{-suffix|/|segments}?" +
839
+ "{-join|&|one,bogus}\#{fragment}'" do
840
+ Addressable::Template.new(
841
+ "http://{host}/{-suffix|/|segments}?{-join|&|one,bogus}\#{fragment}"
842
+ ).extract(@uri).should == nil
843
+ end
844
+
845
+ it "should not match when extracting values " +
846
+ "using the pattern " +
847
+ "'http://{host}/{-suffix|/|segments}?" +
848
+ "{-join|&|one,two,bogus}\#{fragment}'" do
849
+ Addressable::Template.new(
850
+ "http://{host}/{-suffix|/|segments}?{-join|&|one,two,bogus}\#{fragment}"
851
+ ).extract(@uri).should == {
852
+ "host" => "example.com",
853
+ "segments" => ["a", "b", "c"],
854
+ "one" => "1",
855
+ "two" => "2",
856
+ "fragment" => "foo"
857
+ }
858
+ end
859
+ end
860
+
861
+ describe Addressable::URI, "when given a pattern with bogus operators" do
862
+ before do
863
+ @uri = Addressable::URI.parse("http://example.com/a/b/c/")
864
+ end
865
+
866
+ it "should raise an InvalidTemplateOperatorError" do
867
+ (lambda do
868
+ Addressable::Template.new(
869
+ "http://example.com/{-bogus|/|a,b,c}/"
870
+ ).extract(@uri)
871
+ end).should raise_error(
872
+ Addressable::Template::InvalidTemplateOperatorError
873
+ )
874
+ end
875
+
876
+ it "should raise an InvalidTemplateOperatorError" do
877
+ (lambda do
878
+ Addressable::Template.new(
879
+ "http://example.com{-prefix|/|a,b,c}/"
880
+ ).extract(@uri)
881
+ end).should raise_error(
882
+ Addressable::Template::InvalidTemplateOperatorError
883
+ )
884
+ end
885
+
886
+ it "should raise an InvalidTemplateOperatorError" do
887
+ (lambda do
888
+ Addressable::Template.new(
889
+ "http://example.com/{-suffix|/|a,b,c}"
890
+ ).extract(@uri)
891
+ end).should raise_error(
892
+ Addressable::Template::InvalidTemplateOperatorError
893
+ )
894
+ end
895
+
896
+ it "should raise an InvalidTemplateOperatorError" do
897
+ (lambda do
898
+ Addressable::Template.new(
899
+ "http://example.com/{-list|/|a,b,c}/"
900
+ ).extract(@uri)
901
+ end).should raise_error(
902
+ Addressable::Template::InvalidTemplateOperatorError
903
+ )
904
+ end
905
+ end
906
+
907
+ describe Addressable::URI, "when given a mapping that contains an Array" do
908
+ before do
909
+ @mapping = {"query" => "an example search query".split(" ")}
910
+ end
911
+
912
+ it "should result in 'http://example.com/search/an+example+search+query/'" +
913
+ " when used to expand 'http://example.com/search/{-list|+|query}/'" do
914
+ Addressable::Template.new(
915
+ "http://example.com/search/{-list|+|query}/"
916
+ ).expand(@mapping).to_str.should ==
917
+ "http://example.com/search/an+example+search+query/"
918
+ end
919
+
920
+ it "should result in 'http://example.com/search/an+example+search+query/'" +
921
+ " when used to expand 'http://example.com/search/{-list|+|query}/'" +
922
+ " with a NoOpProcessor" do
923
+ Addressable::Template.new(
924
+ "http://example.com/search/{-list|+|query}/"
925
+ ).expand(@mapping, NoOpProcessor).to_str.should ==
926
+ "http://example.com/search/an+example+search+query/"
927
+ end
928
+ end
929
+
930
+ describe Addressable::URI, "when given an empty mapping" do
931
+ before do
932
+ @mapping = {}
933
+ end
934
+
935
+ it "should result in 'http://example.com/search/'" +
936
+ " when used to expand 'http://example.com/search/{-list|+|query}'" do
937
+ Addressable::Template.new(
938
+ "http://example.com/search/{-list|+|query}"
939
+ ).expand(@mapping).to_str.should == "http://example.com/search/"
940
+ end
941
+
942
+ it "should result in 'http://example.com'" +
943
+ " when used to expand 'http://example.com{-prefix|/|foo}'" do
944
+ Addressable::Template.new(
945
+ "http://example.com{-prefix|/|foo}"
946
+ ).expand(@mapping).to_str.should == "http://example.com"
947
+ end
948
+
949
+ it "should result in 'http://example.com'" +
950
+ " when used to expand 'http://example.com{-suffix|/|foo}'" do
951
+ Addressable::Template.new(
952
+ "http://example.com{-suffix|/|foo}"
953
+ ).expand(@mapping).to_str.should == "http://example.com"
954
+ end
955
+ end
956
+
957
+ describe Addressable::URI, "when given the template pattern " +
958
+ "'http://example.com/search/{query}/' " +
959
+ "to be processed with the ExampleProcessor" do
960
+ before do
961
+ @pattern = "http://example.com/search/{query}/"
962
+ end
963
+
964
+ it "should expand to " +
965
+ "'http://example.com/search/an+example+search+query/' " +
966
+ "with a mapping of {\"query\" => \"an example search query\"} " do
967
+ Addressable::Template.new(
968
+ "http://example.com/search/{query}/"
969
+ ).expand({
970
+ "query" => "an example search query"
971
+ }, ExampleProcessor).to_s.should ==
972
+ "http://example.com/search/an+example+search+query/"
973
+ end
974
+
975
+ it "should raise an error " +
976
+ "with a mapping of {\"query\" => \"invalid!\"}" do
977
+ (lambda do
978
+ Addressable::Template.new(
979
+ "http://example.com/search/{query}/"
980
+ ).expand({"query" => "invalid!"}, ExampleProcessor).to_s
981
+ end).should raise_error(Addressable::Template::InvalidTemplateValueError)
982
+ end
983
+ end
984
+
985
+ # Section 3.3.1 of the URI Template draft v 01
986
+ describe Addressable::URI, "when given the mapping supplied in " +
987
+ "Section 3.3.1 of the URI Template draft v 01" do
988
+ before do
989
+ @mapping = {
990
+ "a" => "fred",
991
+ "b" => "barney",
992
+ "c" => "cheeseburger",
993
+ "d" => "one two three",
994
+ "e" => "20% tricky",
995
+ "f" => "",
996
+ "20" => "this-is-spinal-tap",
997
+ "scheme" => "https",
998
+ "p" => "quote=to+be+or+not+to+be",
999
+ "q" => "hullo#world"
1000
+ }
1001
+ end
1002
+
1003
+ it "should result in 'http://example.org/page1#fred' " +
1004
+ "when used to expand 'http://example.org/page1\#{a}'" do
1005
+ Addressable::Template.new(
1006
+ "http://example.org/page1\#{a}"
1007
+ ).expand(@mapping).to_s.should == "http://example.org/page1#fred"
1008
+ end
1009
+
1010
+ it "should result in 'http://example.org/fred/barney/' " +
1011
+ "when used to expand 'http://example.org/{a}/{b}/'" do
1012
+ Addressable::Template.new(
1013
+ "http://example.org/{a}/{b}/"
1014
+ ).expand(@mapping).to_s.should == "http://example.org/fred/barney/"
1015
+ end
1016
+
1017
+ it "should result in 'http://example.org/fredbarney/' " +
1018
+ "when used to expand 'http://example.org/{a}{b}/'" do
1019
+ Addressable::Template.new(
1020
+ "http://example.org/{a}{b}/"
1021
+ ).expand(@mapping).to_s.should == "http://example.org/fredbarney/"
1022
+ end
1023
+
1024
+ it "should result in " +
1025
+ "'http://example.com/order/cheeseburger/cheeseburger/cheeseburger/' " +
1026
+ "when used to expand 'http://example.com/order/{c}/{c}/{c}/'" do
1027
+ Addressable::Template.new(
1028
+ "http://example.com/order/{c}/{c}/{c}/"
1029
+ ).expand(@mapping).to_s.should ==
1030
+ "http://example.com/order/cheeseburger/cheeseburger/cheeseburger/"
1031
+ end
1032
+
1033
+ it "should result in 'http://example.org/one%20two%20three' " +
1034
+ "when used to expand 'http://example.org/{d}'" do
1035
+ Addressable::Template.new(
1036
+ "http://example.org/{d}"
1037
+ ).expand(@mapping).to_s.should ==
1038
+ "http://example.org/one%20two%20three"
1039
+ end
1040
+
1041
+ it "should result in 'http://example.org/20%25%20tricky' " +
1042
+ "when used to expand 'http://example.org/{e}'" do
1043
+ Addressable::Template.new(
1044
+ "http://example.org/{e}"
1045
+ ).expand(@mapping).to_s.should ==
1046
+ "http://example.org/20%25%20tricky"
1047
+ end
1048
+
1049
+ it "should result in 'http://example.com//' " +
1050
+ "when used to expand 'http://example.com/{f}/'" do
1051
+ Addressable::Template.new(
1052
+ "http://example.com/{f}/"
1053
+ ).expand(@mapping).to_s.should ==
1054
+ "http://example.com//"
1055
+ end
1056
+
1057
+ it "should result in " +
1058
+ "'https://this-is-spinal-tap.example.org?date=&option=fred' " +
1059
+ "when used to expand " +
1060
+ "'{scheme}://{20}.example.org?date={wilma}&option={a}'" do
1061
+ Addressable::Template.new(
1062
+ "{scheme}://{20}.example.org?date={wilma}&option={a}"
1063
+ ).expand(@mapping).to_s.should ==
1064
+ "https://this-is-spinal-tap.example.org?date=&option=fred"
1065
+ end
1066
+
1067
+ # The v 01 draft conflicts with the v 03 draft here.
1068
+ # The Addressable implementation uses v 03.
1069
+ it "should result in " +
1070
+ "'http://example.org?quote%3Dto%2Bbe%2Bor%2Bnot%2Bto%2Bbe' " +
1071
+ "when used to expand 'http://example.org?{p}'" do
1072
+ Addressable::Template.new(
1073
+ "http://example.org?{p}"
1074
+ ).expand(@mapping).to_s.should ==
1075
+ "http://example.org?quote%3Dto%2Bbe%2Bor%2Bnot%2Bto%2Bbe"
1076
+ end
1077
+
1078
+ # The v 01 draft conflicts with the v 03 draft here.
1079
+ # The Addressable implementation uses v 03.
1080
+ it "should result in 'http://example.com/hullo%23world' " +
1081
+ "when used to expand 'http://example.com/{q}'" do
1082
+ Addressable::Template.new(
1083
+ "http://example.com/{q}"
1084
+ ).expand(@mapping).to_s.should == "http://example.com/hullo%23world"
1085
+ end
1086
+ end
1087
+
1088
+ # Section 4.5 of the URI Template draft v 03
1089
+ describe Addressable::URI, "when given the mapping supplied in " +
1090
+ "Section 4.5 of the URI Template draft v 03" do
1091
+ before do
1092
+ @mapping = {
1093
+ "foo" => "ϓ",
1094
+ "bar" => "fred",
1095
+ "baz" => "10,20,30",
1096
+ "qux" => ["10","20","30"],
1097
+ "corge" => [],
1098
+ "grault" => "",
1099
+ "garply" => "a/b/c",
1100
+ "waldo" => "ben & jerrys",
1101
+ "fred" => ["fred", "", "wilma"],
1102
+ "plugh" => ["ẛ", "ṡ"],
1103
+ "1-a_b.c" => "200"
1104
+ }
1105
+ end
1106
+
1107
+ it "should result in 'http://example.org/?q=fred' " +
1108
+ "when used to expand 'http://example.org/?q={bar}'" do
1109
+ Addressable::Template.new(
1110
+ "http://example.org/?q={bar}"
1111
+ ).expand(@mapping).to_s.should == "http://example.org/?q=fred"
1112
+ end
1113
+
1114
+ it "should result in '/' " +
1115
+ "when used to expand '/{xyzzy}'" do
1116
+ Addressable::Template.new(
1117
+ "/{xyzzy}"
1118
+ ).expand(@mapping).to_s.should == "/"
1119
+ end
1120
+
1121
+ it "should result in " +
1122
+ "'http://example.org/?foo=%CE%8E&bar=fred&baz=10%2C20%2C30' " +
1123
+ "when used to expand " +
1124
+ "'http://example.org/?{-join|&|foo,bar,xyzzy,baz}'" do
1125
+ Addressable::Template.new(
1126
+ "http://example.org/?{-join|&|foo,bar,xyzzy,baz}"
1127
+ ).expand(@mapping).to_s.should ==
1128
+ "http://example.org/?foo=%CE%8E&bar=fred&baz=10%2C20%2C30"
1129
+ end
1130
+
1131
+ it "should result in 'http://example.org/?d=10,20,30' " +
1132
+ "when used to expand 'http://example.org/?d={-list|,|qux}'" do
1133
+ Addressable::Template.new(
1134
+ "http://example.org/?d={-list|,|qux}"
1135
+ ).expand(
1136
+ @mapping
1137
+ ).to_s.should == "http://example.org/?d=10,20,30"
1138
+ end
1139
+
1140
+ it "should result in 'http://example.org/?d=10&d=20&d=30' " +
1141
+ "when used to expand 'http://example.org/?d={-list|&d=|qux}'" do
1142
+ Addressable::Template.new(
1143
+ "http://example.org/?d={-list|&d=|qux}"
1144
+ ).expand(
1145
+ @mapping
1146
+ ).to_s.should == "http://example.org/?d=10&d=20&d=30"
1147
+ end
1148
+
1149
+ it "should result in 'http://example.org/fredfred/a%2Fb%2Fc' " +
1150
+ "when used to expand 'http://example.org/{bar}{bar}/{garply}'" do
1151
+ Addressable::Template.new(
1152
+ "http://example.org/{bar}{bar}/{garply}"
1153
+ ).expand(
1154
+ @mapping
1155
+ ).to_s.should == "http://example.org/fredfred/a%2Fb%2Fc"
1156
+ end
1157
+
1158
+ it "should result in 'http://example.org/fred/fred//wilma' " +
1159
+ "when used to expand 'http://example.org/{bar}{-prefix|/|fred}'" do
1160
+ Addressable::Template.new(
1161
+ "http://example.org/{bar}{-prefix|/|fred}"
1162
+ ).expand(
1163
+ @mapping
1164
+ ).to_s.should == "http://example.org/fred/fred//wilma"
1165
+ end
1166
+
1167
+ it "should result in ':%E1%B9%A1:%E1%B9%A1:' " +
1168
+ "when used to expand '{-neg|:|corge}{-suffix|:|plugh}'" do
1169
+ # Note: We need to check the path, because technically, this is an
1170
+ # invalid URI.
1171
+ Addressable::Template.new(
1172
+ "{-neg|:|corge}{-suffix|:|plugh}"
1173
+ ).expand(@mapping).path.should == ":%E1%B9%A1:%E1%B9%A1:"
1174
+ end
1175
+
1176
+ it "should result in '../ben%20%26%20jerrys/' " +
1177
+ "when used to expand '../{waldo}/'" do
1178
+ Addressable::Template.new(
1179
+ "../{waldo}/"
1180
+ ).expand(
1181
+ @mapping
1182
+ ).to_s.should == "../ben%20%26%20jerrys/"
1183
+ end
1184
+
1185
+ it "should result in 'telnet:192.0.2.16:80' " +
1186
+ "when used to expand 'telnet:192.0.2.16{-opt|:80|grault}'" do
1187
+ Addressable::Template.new(
1188
+ "telnet:192.0.2.16{-opt|:80|grault}"
1189
+ ).expand(
1190
+ @mapping
1191
+ ).to_s.should == "telnet:192.0.2.16:80"
1192
+ end
1193
+
1194
+ it "should result in ':200:' " +
1195
+ "when used to expand ':{1-a_b.c}:'" do
1196
+ # Note: We need to check the path, because technically, this is an
1197
+ # invalid URI.
1198
+ Addressable::Template.new(
1199
+ ":{1-a_b.c}:"
1200
+ ).expand(@mapping).path.should == ":200:"
1201
+ end
1202
+ end
1203
+
1204
+ describe Addressable::URI, "when given a mapping that contains a " +
1205
+ "template-var within a value" do
1206
+ before do
1207
+ @mapping = {
1208
+ "a" => "{b}",
1209
+ "b" => "barney",
1210
+ }
1211
+ end
1212
+
1213
+ it "should result in 'http://example.com/%7Bb%7D/barney/' " +
1214
+ "when used to expand 'http://example.com/{a}/{b}/'" do
1215
+ Addressable::Template.new(
1216
+ "http://example.com/{a}/{b}/"
1217
+ ).expand(
1218
+ @mapping
1219
+ ).to_s.should == "http://example.com/%7Bb%7D/barney/"
1220
+ end
1221
+
1222
+ it "should result in 'http://example.com//%7Bb%7D/' " +
1223
+ "when used to expand 'http://example.com/{-opt|foo|foo}/{a}/'" do
1224
+ Addressable::Template.new(
1225
+ "http://example.com/{-opt|foo|foo}/{a}/"
1226
+ ).expand(
1227
+ @mapping
1228
+ ).to_s.should == "http://example.com//%7Bb%7D/"
1229
+ end
1230
+
1231
+ it "should result in 'http://example.com//%7Bb%7D/' " +
1232
+ "when used to expand 'http://example.com/{-neg|foo|b}/{a}/'" do
1233
+ Addressable::Template.new(
1234
+ "http://example.com/{-neg|foo|b}/{a}/"
1235
+ ).expand(
1236
+ @mapping
1237
+ ).to_s.should == "http://example.com//%7Bb%7D/"
1238
+ end
1239
+
1240
+ it "should result in 'http://example.com//barney/%7Bb%7D/' " +
1241
+ "when used to expand 'http://example.com/{-prefix|/|b}/{a}/'" do
1242
+ Addressable::Template.new(
1243
+ "http://example.com/{-prefix|/|b}/{a}/"
1244
+ ).expand(
1245
+ @mapping
1246
+ ).to_s.should == "http://example.com//barney/%7Bb%7D/"
1247
+ end
1248
+
1249
+ it "should result in 'http://example.com/barney//%7Bb%7D/' " +
1250
+ "when used to expand 'http://example.com/{-suffix|/|b}/{a}/'" do
1251
+ Addressable::Template.new(
1252
+ "http://example.com/{-suffix|/|b}/{a}/"
1253
+ ).expand(
1254
+ @mapping
1255
+ ).to_s.should == "http://example.com/barney//%7Bb%7D/"
1256
+ end
1257
+
1258
+ it "should result in 'http://example.com/%7Bb%7D/?b=barney&c=42' " +
1259
+ "when used to expand 'http://example.com/{a}/?{-join|&|b,c=42}'" do
1260
+ Addressable::Template.new(
1261
+ "http://example.com/{a}/?{-join|&|b,c=42}"
1262
+ ).expand(
1263
+ @mapping
1264
+ ).to_s.should == "http://example.com/%7Bb%7D/?b=barney&c=42"
1265
+ end
1266
+
1267
+ it "should result in 'http://example.com/42/?b=barney' " +
1268
+ "when used to expand 'http://example.com/{c=42}/?{-join|&|b}'" do
1269
+ Addressable::Template.new(
1270
+ "http://example.com/{c=42}/?{-join|&|b}"
1271
+ ).expand(@mapping).to_s.should == "http://example.com/42/?b=barney"
1272
+ end
1273
+ end
1274
+
1275
+ describe Addressable::URI, "when given a single variable mapping" do
1276
+ before do
1277
+ @mapping = {
1278
+ "foo" => "fred"
1279
+ }
1280
+ end
1281
+
1282
+ it "should result in 'fred' when used to expand '{foo}'" do
1283
+ Addressable::Template.new(
1284
+ "{foo}"
1285
+ ).expand(@mapping).to_s.should == "fred"
1286
+ end
1287
+
1288
+ it "should result in 'wilma' when used to expand '{bar=wilma}'" do
1289
+ Addressable::Template.new(
1290
+ "{bar=wilma}"
1291
+ ).expand(@mapping).to_s.should == "wilma"
1292
+ end
1293
+
1294
+ it "should result in '' when used to expand '{baz}'" do
1295
+ Addressable::Template.new(
1296
+ "{baz}"
1297
+ ).expand(@mapping).to_s.should == ""
1298
+ end
1299
+ end
1300
+
1301
+ describe Addressable::URI, "when given a simple mapping" do
1302
+ before do
1303
+ @mapping = {
1304
+ "foo" => "fred",
1305
+ "bar" => "barney",
1306
+ "baz" => ""
1307
+ }
1308
+ end
1309
+
1310
+ it "should result in 'foo=fred&bar=barney&baz=' when used to expand " +
1311
+ "'{-join|&|foo,bar,baz,qux}'" do
1312
+ Addressable::Template.new(
1313
+ "{-join|&|foo,bar,baz,qux}"
1314
+ ).expand(@mapping).to_s.should == "foo=fred&bar=barney&baz="
1315
+ end
1316
+
1317
+ it "should result in 'bar=barney' when used to expand " +
1318
+ "'{-join|&|bar}'" do
1319
+ Addressable::Template.new(
1320
+ "{-join|&|bar}"
1321
+ ).expand(@mapping).to_s.should == "bar=barney"
1322
+ end
1323
+
1324
+ it "should result in '' when used to expand " +
1325
+ "'{-join|&|qux}'" do
1326
+ Addressable::Template.new(
1327
+ "{-join|&|qux}"
1328
+ ).expand(@mapping).to_s.should == ""
1329
+ end
1330
+ end
1331
+
1332
+ describe Addressable::URI, "extracting defaults from a pattern" do
1333
+ before do
1334
+ @template = Addressable::Template.new("{foo}{bar=baz}{-opt|found|cond}")
1335
+ end
1336
+
1337
+ it "should extract default value" do
1338
+ @template.variable_defaults.should == {"bar" => "baz"}
1339
+ end
1340
+ end
1341
+
1342
+ describe Addressable::URI, "when given a mapping with symbol keys" do
1343
+ before do
1344
+ @mapping = { :name => "fred" }
1345
+ end
1346
+
1347
+ it "should result in 'fred' when used to expand '{foo}'" do
1348
+ Addressable::Template.new(
1349
+ "{name}"
1350
+ ).expand(@mapping).to_s.should == "fred"
1351
+ end
1352
+ end
1353
+
1354
+ describe Addressable::URI, "when given a mapping with bogus keys" do
1355
+ before do
1356
+ @mapping = { Object.new => "fred" }
1357
+ end
1358
+
1359
+ it "should raise an error" do
1360
+ (lambda do
1361
+ Addressable::Template.new(
1362
+ "{name}"
1363
+ ).expand(@mapping)
1364
+ end).should raise_error(TypeError)
1365
+ end
1366
+ end
1367
+
1368
+ describe Addressable::URI, "when given a mapping with numeric values" do
1369
+ before do
1370
+ @mapping = { :id => 123 }
1371
+ end
1372
+
1373
+ it "should result in 'fred' when used to expand '{foo}'" do
1374
+ Addressable::Template.new(
1375
+ "{id}"
1376
+ ).expand(@mapping).to_s.should == "123"
1377
+ end
1378
+ end
1379
+
1380
+ describe Addressable::URI, "when given a mapping containing values " +
1381
+ "that are already percent-encoded" do
1382
+ before do
1383
+ @mapping = {
1384
+ "a" => "%7Bb%7D"
1385
+ }
1386
+ end
1387
+
1388
+ it "should result in 'http://example.com/%257Bb%257D/' " +
1389
+ "when used to expand 'http://example.com/{a}/'" do
1390
+ Addressable::Template.new(
1391
+ "http://example.com/{a}/"
1392
+ ).expand(@mapping).to_s.should == "http://example.com/%257Bb%257D/"
1393
+ end
1394
+ end
1395
+
1396
+ describe Addressable::URI, "when given a pattern with bogus operators" do
1397
+ it "should raise an InvalidTemplateOperatorError" do
1398
+ (lambda do
1399
+ Addressable::Template.new(
1400
+ "http://example.com/{-bogus|/|a,b,c}/"
1401
+ ).expand({
1402
+ "a" => "a", "b" => "b", "c" => "c"
1403
+ })
1404
+ end).should raise_error(
1405
+ Addressable::Template::InvalidTemplateOperatorError
1406
+ )
1407
+ end
1408
+
1409
+ it "should raise an InvalidTemplateOperatorError" do
1410
+ (lambda do
1411
+ Addressable::Template.new(
1412
+ "http://example.com/{-prefix|/|a,b,c}/"
1413
+ ).expand({
1414
+ "a" => "a", "b" => "b", "c" => "c"
1415
+ })
1416
+ end).should raise_error(
1417
+ Addressable::Template::InvalidTemplateOperatorError
1418
+ )
1419
+ end
1420
+
1421
+ it "should raise an InvalidTemplateOperatorError" do
1422
+ (lambda do
1423
+ Addressable::Template.new(
1424
+ "http://example.com/{-suffix|/|a,b,c}/"
1425
+ ).expand({
1426
+ "a" => "a", "b" => "b", "c" => "c"
1427
+ })
1428
+ end).should raise_error(
1429
+ Addressable::Template::InvalidTemplateOperatorError
1430
+ )
1431
+ end
1432
+
1433
+ it "should raise an InvalidTemplateOperatorError" do
1434
+ (lambda do
1435
+ Addressable::Template.new(
1436
+ "http://example.com/{-join|/|a,b,c}/"
1437
+ ).expand({
1438
+ "a" => ["a"], "b" => ["b"], "c" => "c"
1439
+ })
1440
+ end).should raise_error(
1441
+ Addressable::Template::InvalidTemplateOperatorError
1442
+ )
1443
+ end
1444
+
1445
+ it "should raise an InvalidTemplateOperatorError" do
1446
+ (lambda do
1447
+ Addressable::Template.new(
1448
+ "http://example.com/{-list|/|a,b,c}/"
1449
+ ).expand({
1450
+ "a" => ["a"], "b" => ["b"], "c" => "c"
1451
+ })
1452
+ end).should raise_error(
1453
+ Addressable::Template::InvalidTemplateOperatorError
1454
+ )
1455
+ end
1456
+ end
1457
+
1458
+ describe Addressable::Template, "with a partially expanded template" do
1459
+ before do
1460
+ @initial_template = Addressable::Template.new(
1461
+ "http://example.com/{one}/{two}/"
1462
+ )
1463
+ @partial_template = @initial_template.partial_expand({"one" => "1"})
1464
+ end
1465
+
1466
+ it "should produce the same result when fully expanded" do
1467
+ @initial_template.expand({"one" => "1", "two" => "2"}).should ==
1468
+ @partial_template.expand({"two" => "2"})
1469
+ end
1470
+
1471
+ it "should raise an error if the template is expanded with bogus values" do
1472
+ (lambda do
1473
+ @initial_template.expand({"one" => Object.new, "two" => Object.new})
1474
+ end).should raise_error(TypeError)
1475
+ (lambda do
1476
+ @partial_template.expand({"two" => Object.new})
1477
+ end).should raise_error(TypeError)
1478
+ end
1479
+ end
1480
+
1481
+ describe Addressable::Template, "with a partially expanded template" do
1482
+ before do
1483
+ @initial_template = Addressable::Template.new(
1484
+ "http://example.com/{one}/{two}/"
1485
+ )
1486
+ @partial_template = @initial_template.partial_expand({"two" => "2"})
1487
+ end
1488
+
1489
+ it "should produce the same result when fully expanded" do
1490
+ @initial_template.expand({"one" => "1", "two" => "2"}).should ==
1491
+ @partial_template.expand({"one" => "1"})
1492
+ end
1493
+ end
1494
+
1495
+ describe Addressable::Template, "with a partially expanded template" do
1496
+ before do
1497
+ @initial_template = Addressable::Template.new(
1498
+ "http://example.com/{one}/{two}/"
1499
+ )
1500
+ @partial_template = @initial_template.partial_expand({"two" => "2"})
1501
+ end
1502
+
1503
+ it "should produce the same result when fully expanded" do
1504
+ @initial_template.expand({"one" => "1", "two" => "2"}).should ==
1505
+ @partial_template.expand({"one" => "1"})
1506
+ end
1507
+ end
1508
+
1509
+ describe Addressable::Template, "with a partially expanded template" do
1510
+ before do
1511
+ @initial_template = Addressable::Template.new(
1512
+ "http://example.com/{one=1}/{two=2}/"
1513
+ )
1514
+ @partial_template = @initial_template.partial_expand({"one" => "3"})
1515
+ end
1516
+
1517
+ it "should produce the same result when fully expanded" do
1518
+ @initial_template.expand({"one" => "3", "two" => "4"}).should ==
1519
+ @partial_template.expand({"two" => "4"})
1520
+ end
1521
+
1522
+ it "should produce the correct result when fully expanded" do
1523
+ @partial_template.expand({}).should === "http://example.com/3/2/"
1524
+ end
1525
+ end
1526
+
1527
+ describe Addressable::Template, "with a partially expanded template" do
1528
+ before do
1529
+ @initial_template = Addressable::Template.new(
1530
+ "http://example.com/{one=1}/{two=2}/"
1531
+ )
1532
+ @partial_template = @initial_template.partial_expand({"two" => "4"})
1533
+ end
1534
+
1535
+ it "should produce the same result when fully expanded" do
1536
+ @initial_template.expand({"one" => "3", "two" => "4"}).should ==
1537
+ @partial_template.expand({"one" => "3"})
1538
+ end
1539
+
1540
+ it "should produce the correct result when fully expanded" do
1541
+ @partial_template.expand({}).should === "http://example.com/1/4/"
1542
+ end
1543
+ end
1544
+
1545
+ describe Addressable::Template, "with a partially expanded template" do
1546
+ before do
1547
+ @initial_template = Addressable::Template.new(
1548
+ "http://example.com/{-opt|found|one,two,three}"
1549
+ )
1550
+ @partial_template = @initial_template.partial_expand({})
1551
+ end
1552
+
1553
+ it "should produce the same result when fully expanded" do
1554
+ @initial_template.expand({"one" => "1"}).to_str.should ==
1555
+ @partial_template.expand({"two" => "2"}).to_str
1556
+ end
1557
+
1558
+ it "should produce the correct result when fully expanded" do
1559
+ @partial_template.expand({}).to_str.should == "http://example.com/"
1560
+ end
1561
+
1562
+ it "should produce the correct result when fully expanded" do
1563
+ @partial_template.expand({"one" => "1"}).to_str.should ==
1564
+ "http://example.com/found"
1565
+ end
1566
+
1567
+ it "should produce the correct result when fully expanded" do
1568
+ @partial_template.expand({"two" => "2"}).to_str.should ==
1569
+ "http://example.com/found"
1570
+ end
1571
+
1572
+ it "should produce the correct result when fully expanded" do
1573
+ @partial_template.expand({"three" => "3"}).to_str.should ==
1574
+ "http://example.com/found"
1575
+ end
1576
+
1577
+ it "should produce the correct result when fully expanded" do
1578
+ @partial_template.expand({"four" => "4"}).to_str.should ==
1579
+ "http://example.com/"
1580
+ end
1581
+
1582
+ it "should produce the correct result when fully expanded" do
1583
+ @partial_template.expand({"one" => "1", "two" => "2"}).to_str.should ==
1584
+ "http://example.com/found"
1585
+ end
1586
+ end
1587
+
1588
+ describe Addressable::Template, "with a partially expanded template" do
1589
+ before do
1590
+ @initial_template = Addressable::Template.new(
1591
+ "http://example.com/{-opt|found|one,two,three}"
1592
+ )
1593
+ @partial_template = @initial_template.partial_expand({"one" => "1"})
1594
+ end
1595
+
1596
+ it "should produce the same result when fully expanded" do
1597
+ @initial_template.expand({"one" => "1"}).to_str.should ==
1598
+ @partial_template.expand({"two" => "2"}).to_str
1599
+ end
1600
+
1601
+ it "should produce the correct result when fully expanded" do
1602
+ @partial_template.expand({}).to_str.should == "http://example.com/found"
1603
+ end
1604
+
1605
+ it "should produce the correct pattern" do
1606
+ @partial_template.pattern.should == "http://example.com/found"
1607
+ end
1608
+ end
1609
+
1610
+ describe Addressable::Template, "with a partially expanded template" do
1611
+ before do
1612
+ @initial_template = Addressable::Template.new(
1613
+ "http://example.com/{-neg|notfound|one,two,three}"
1614
+ )
1615
+ @partial_template = @initial_template.partial_expand({})
1616
+ end
1617
+
1618
+ it "should produce the same result when fully expanded" do
1619
+ @initial_template.expand({"one" => "1"}).to_str.should ==
1620
+ @partial_template.expand({"two" => "2"}).to_str
1621
+ end
1622
+
1623
+ it "should produce the correct result when fully expanded" do
1624
+ @partial_template.expand({}).to_str.should == "http://example.com/notfound"
1625
+ end
1626
+
1627
+ it "should produce the correct result when fully expanded" do
1628
+ @partial_template.expand({"one" => "1"}).to_str.should ==
1629
+ "http://example.com/"
1630
+ end
1631
+
1632
+ it "should produce the correct result when fully expanded" do
1633
+ @partial_template.expand({"two" => "2"}).to_str.should ==
1634
+ "http://example.com/"
1635
+ end
1636
+
1637
+ it "should produce the correct result when fully expanded" do
1638
+ @partial_template.expand({"three" => "3"}).to_str.should ==
1639
+ "http://example.com/"
1640
+ end
1641
+
1642
+ it "should produce the correct result when fully expanded" do
1643
+ @partial_template.expand({"four" => "4"}).to_str.should ==
1644
+ "http://example.com/notfound"
1645
+ end
1646
+
1647
+ it "should produce the correct result when fully expanded" do
1648
+ @partial_template.expand({"one" => "1", "two" => "2"}).to_str.should ==
1649
+ "http://example.com/"
1650
+ end
1651
+ end
1652
+
1653
+ describe Addressable::Template, "with a partially expanded template" do
1654
+ before do
1655
+ @initial_template = Addressable::Template.new(
1656
+ "http://example.com/{-neg|notfound|one,two,three}"
1657
+ )
1658
+ @partial_template = @initial_template.partial_expand({"one" => "1"})
1659
+ end
1660
+
1661
+ it "should produce the same result when fully expanded" do
1662
+ @initial_template.expand({"one" => "1"}).to_str.should ==
1663
+ @partial_template.expand({"two" => "2"}).to_str
1664
+ end
1665
+
1666
+ it "should produce the correct result when fully expanded" do
1667
+ @partial_template.expand({}).to_str.should == "http://example.com/"
1668
+ end
1669
+
1670
+ it "should produce the correct pattern" do
1671
+ @partial_template.pattern.should == "http://example.com/"
1672
+ end
1673
+ end
1674
+
1675
+ describe Addressable::Template, "with a partially expanded template" do
1676
+ before do
1677
+ @initial_template = Addressable::Template.new(
1678
+ "http://example.com/?{-prefix|x=|one}"
1679
+ )
1680
+ @partial_template = @initial_template.partial_expand({})
1681
+ end
1682
+
1683
+ it "should produce the same result when fully expanded" do
1684
+ @initial_template.expand({"one" => "1"}).to_str.should ==
1685
+ @partial_template.expand({"one" => "1"}).to_str
1686
+ end
1687
+
1688
+ it "should produce the correct result when fully expanded" do
1689
+ @partial_template.expand({}).to_str.should == "http://example.com/?"
1690
+ end
1691
+
1692
+ it "should produce the correct result when fully expanded" do
1693
+ @partial_template.expand({"one" => "1"}).to_str.should ==
1694
+ "http://example.com/?x=1"
1695
+ end
1696
+
1697
+ it "should produce the correct result when fully expanded" do
1698
+ @partial_template.expand({"two" => "2"}).to_str.should ==
1699
+ "http://example.com/?"
1700
+ end
1701
+
1702
+ it "should produce the correct result when fully expanded" do
1703
+ @partial_template.expand({"one" => "1", "two" => "2"}).to_str.should ==
1704
+ "http://example.com/?x=1"
1705
+ end
1706
+ end
1707
+
1708
+ describe Addressable::Template, "with a partially expanded template" do
1709
+ before do
1710
+ @initial_template = Addressable::Template.new(
1711
+ "http://example.com/?{-prefix|x=|one}"
1712
+ )
1713
+ @partial_template = @initial_template.partial_expand({"one" => "1"})
1714
+ end
1715
+
1716
+ it "should produce the same result when fully expanded" do
1717
+ @initial_template.expand({"one" => "1"}).to_str.should ==
1718
+ @partial_template.expand({}).to_str
1719
+ end
1720
+
1721
+ it "should produce the correct result when fully expanded" do
1722
+ @partial_template.expand({}).to_str.should == "http://example.com/?x=1"
1723
+ end
1724
+
1725
+ it "should produce the correct pattern" do
1726
+ @partial_template.pattern.should == "http://example.com/?x=1"
1727
+ end
1728
+ end
1729
+
1730
+ describe Addressable::Template, "with a partially expanded template" do
1731
+ before do
1732
+ @initial_template = Addressable::Template.new(
1733
+ "http://example.com/?{-suffix|=x|one}"
1734
+ )
1735
+ @partial_template = @initial_template.partial_expand({})
1736
+ end
1737
+
1738
+ it "should produce the same result when fully expanded" do
1739
+ @initial_template.expand({"one" => "1"}).to_str.should ==
1740
+ @partial_template.expand({"one" => "1"}).to_str
1741
+ end
1742
+
1743
+ it "should produce the correct result when fully expanded" do
1744
+ @partial_template.expand({}).to_str.should == "http://example.com/?"
1745
+ end
1746
+
1747
+ it "should produce the correct result when fully expanded" do
1748
+ @partial_template.expand({"one" => "1"}).to_str.should ==
1749
+ "http://example.com/?1=x"
1750
+ end
1751
+
1752
+ it "should produce the correct result when fully expanded" do
1753
+ @partial_template.expand({"two" => "2"}).to_str.should ==
1754
+ "http://example.com/?"
1755
+ end
1756
+
1757
+ it "should produce the correct result when fully expanded" do
1758
+ @partial_template.expand({"one" => "1", "two" => "2"}).to_str.should ==
1759
+ "http://example.com/?1=x"
1760
+ end
1761
+ end
1762
+
1763
+ describe Addressable::Template, "with a partially expanded template" do
1764
+ before do
1765
+ @initial_template = Addressable::Template.new(
1766
+ "http://example.com/?{-suffix|=x|one}"
1767
+ )
1768
+ @partial_template = @initial_template.partial_expand({"one" => "1"})
1769
+ end
1770
+
1771
+ it "should produce the same result when fully expanded" do
1772
+ @initial_template.expand({"one" => "1"}).to_str.should ==
1773
+ @partial_template.expand({}).to_str
1774
+ end
1775
+
1776
+ it "should produce the correct result when fully expanded" do
1777
+ @partial_template.expand({}).to_str.should == "http://example.com/?1=x"
1778
+ end
1779
+
1780
+ it "should produce the correct pattern" do
1781
+ @partial_template.pattern.should == "http://example.com/?1=x"
1782
+ end
1783
+ end
1784
+
1785
+ describe Addressable::Template, "with a partially expanded template" do
1786
+ before do
1787
+ @initial_template = Addressable::Template.new(
1788
+ "http://example.com/?{-join|&|one}"
1789
+ )
1790
+ @partial_template = @initial_template.partial_expand({})
1791
+ end
1792
+
1793
+ it "should produce the same result when fully expanded" do
1794
+ @initial_template.expand({"one" => "1"}).to_str.should ==
1795
+ @partial_template.expand({"one" => "1"}).to_str
1796
+ end
1797
+
1798
+ it "should produce the correct result when fully expanded" do
1799
+ @partial_template.expand({}).to_str.should == "http://example.com/?"
1800
+ end
1801
+
1802
+ it "should produce the correct result when fully expanded" do
1803
+ @partial_template.pattern.should == @initial_template.pattern
1804
+ end
1805
+ end
1806
+
1807
+ describe Addressable::Template, "with a partially expanded template" do
1808
+ before do
1809
+ @initial_template = Addressable::Template.new(
1810
+ "http://example.com/?{-join|&|one,two}"
1811
+ )
1812
+ @partial_template = @initial_template.partial_expand({"one" => "1"})
1813
+ end
1814
+
1815
+ it "should produce the same result when fully expanded" do
1816
+ @initial_template.expand({"one" => "1", "two" => "2"}).to_str.should ==
1817
+ @partial_template.expand({"two" => "2"}).to_str
1818
+ end
1819
+
1820
+ it "should produce the correct result when fully expanded" do
1821
+ @partial_template.expand({}).to_str.should == "http://example.com/?one=1"
1822
+ end
1823
+ end
1824
+
1825
+ describe Addressable::Template, "with a partially expanded template" do
1826
+ before do
1827
+ @initial_template = Addressable::Template.new(
1828
+ "http://example.com/?{-join|&|one,two}"
1829
+ )
1830
+ @partial_template = @initial_template.partial_expand({"two" => "2"})
1831
+ end
1832
+
1833
+ it "should produce the same result when fully expanded" do
1834
+ @initial_template.expand({"one" => "1", "two" => "2"}).to_str.should ==
1835
+ @partial_template.expand({"one" => "1"}).to_str
1836
+ end
1837
+
1838
+ it "should produce the correct result when fully expanded" do
1839
+ @partial_template.expand({}).to_str.should == "http://example.com/?two=2"
1840
+ end
1841
+ end
1842
+
1843
+ describe Addressable::Template, "with a partially expanded template" do
1844
+ before do
1845
+ @initial_template = Addressable::Template.new(
1846
+ "http://example.com/?{-join|&|one,two,three}"
1847
+ )
1848
+ @partial_template = @initial_template.partial_expand({"one" => "1"})
1849
+ end
1850
+
1851
+ it "should produce the same result when fully expanded" do
1852
+ @initial_template.expand({
1853
+ "one" => "1", "two" => "2", "three" => "3"
1854
+ }).to_str.should ==
1855
+ @partial_template.expand({"two" => "2", "three" => "3"}).to_str
1856
+ end
1857
+
1858
+ it "should produce the correct result when fully expanded" do
1859
+ @partial_template.expand({}).to_str.should == "http://example.com/?one=1"
1860
+ end
1861
+
1862
+ it "should produce the correct result when fully expanded" do
1863
+ @partial_template.expand({"two" => "2"}).to_str.should ==
1864
+ "http://example.com/?one=1&two=2"
1865
+ end
1866
+
1867
+ it "should produce the correct result when fully expanded" do
1868
+ @partial_template.expand({"three" => "3"}).to_str.should ==
1869
+ "http://example.com/?one=1&three=3"
1870
+ end
1871
+ end
1872
+
1873
+ describe Addressable::Template, "with a partially expanded template" do
1874
+ before do
1875
+ @initial_template = Addressable::Template.new(
1876
+ "http://example.com/?{-join|&|one,two,three}"
1877
+ )
1878
+ @partial_template = @initial_template.partial_expand({"two" => "2"})
1879
+ end
1880
+
1881
+ it "should produce the same result when fully expanded" do
1882
+ @initial_template.expand({
1883
+ "one" => "1", "two" => "2", "three" => "3"
1884
+ }).to_str.should ==
1885
+ @partial_template.expand({"one" => "1", "three" => "3"}).to_str
1886
+ end
1887
+
1888
+ it "should produce the correct result when fully expanded" do
1889
+ @partial_template.expand({}).to_str.should == "http://example.com/?two=2"
1890
+ end
1891
+
1892
+ it "should produce the correct result when fully expanded" do
1893
+ @partial_template.expand({"one" => "1"}).to_str.should ==
1894
+ "http://example.com/?one=1&two=2"
1895
+ end
1896
+
1897
+ it "should produce the correct result when fully expanded" do
1898
+ @partial_template.expand({"three" => "3"}).to_str.should ==
1899
+ "http://example.com/?two=2&three=3"
1900
+ end
1901
+ end
1902
+
1903
+ describe Addressable::Template, "with a partially expanded template" do
1904
+ before do
1905
+ @initial_template = Addressable::Template.new(
1906
+ "http://example.com/?{-join|&|one,two,three}"
1907
+ )
1908
+ @partial_template = @initial_template.partial_expand({"three" => "3"})
1909
+ end
1910
+
1911
+ it "should produce the same result when fully expanded" do
1912
+ @initial_template.expand({
1913
+ "one" => "1", "two" => "2", "three" => "3"
1914
+ }).to_str.should ==
1915
+ @partial_template.expand({"one" => "1", "two" => "2"}).to_str
1916
+ end
1917
+
1918
+ it "should produce the correct result when fully expanded" do
1919
+ @partial_template.expand({}).to_str.should == "http://example.com/?three=3"
1920
+ end
1921
+
1922
+ it "should produce the correct result when fully expanded" do
1923
+ @partial_template.expand({"one" => "1"}).to_str.should ==
1924
+ "http://example.com/?one=1&three=3"
1925
+ end
1926
+
1927
+ it "should produce the correct result when fully expanded" do
1928
+ @partial_template.expand({"two" => "2"}).to_str.should ==
1929
+ "http://example.com/?two=2&three=3"
1930
+ end
1931
+ end
1932
+
1933
+ describe Addressable::Template, "with a partially expanded template" do
1934
+ before do
1935
+ @initial_template = Addressable::Template.new(
1936
+ "http://example.com/?{-join|&|one,two,three}"
1937
+ )
1938
+ @partial_template = @initial_template.partial_expand({
1939
+ "one" => "1", "two" => "2"
1940
+ })
1941
+ end
1942
+
1943
+ it "should produce the same result when fully expanded" do
1944
+ @initial_template.expand({
1945
+ "one" => "1", "two" => "2", "three" => "3"
1946
+ }).to_str.should ==
1947
+ @partial_template.expand({"three" => "3"}).to_str
1948
+ end
1949
+
1950
+ it "should produce the correct result when fully expanded" do
1951
+ @partial_template.expand({}).to_str.should ==
1952
+ "http://example.com/?one=1&two=2"
1953
+ end
1954
+
1955
+ it "should produce the correct result when fully expanded" do
1956
+ @partial_template.expand({"three" => "3"}).to_str.should ==
1957
+ "http://example.com/?one=1&two=2&three=3"
1958
+ end
1959
+ end
1960
+
1961
+ describe Addressable::Template, "with a partially expanded template" do
1962
+ before do
1963
+ @initial_template = Addressable::Template.new(
1964
+ "http://example.com/?{-join|&|one,two,three}"
1965
+ )
1966
+ @partial_template = @initial_template.partial_expand({
1967
+ "one" => "1", "three" => "3"
1968
+ })
1969
+ end
1970
+
1971
+ it "should produce the same result when fully expanded" do
1972
+ @initial_template.expand({
1973
+ "one" => "1", "two" => "2", "three" => "3"
1974
+ }).to_str.should ==
1975
+ @partial_template.expand({"two" => "2"}).to_str
1976
+ end
1977
+
1978
+ it "should produce the correct result when fully expanded" do
1979
+ @partial_template.expand({}).to_str.should ==
1980
+ "http://example.com/?one=1&three=3"
1981
+ end
1982
+
1983
+ it "should produce the correct result when fully expanded" do
1984
+ @partial_template.expand({"two" => "2"}).to_str.should ==
1985
+ "http://example.com/?one=1&two=2&three=3"
1986
+ end
1987
+ end
1988
+
1989
+ describe Addressable::Template, "with a partially expanded template" do
1990
+ before do
1991
+ @initial_template = Addressable::Template.new(
1992
+ "http://example.com/?{-join|&|one,two,three}"
1993
+ )
1994
+ @partial_template = @initial_template.partial_expand({
1995
+ "two" => "2", "three" => "3"
1996
+ })
1997
+ end
1998
+
1999
+ it "should produce the same result when fully expanded" do
2000
+ @initial_template.expand({
2001
+ "one" => "1", "two" => "2", "three" => "3"
2002
+ }).to_str.should ==
2003
+ @partial_template.expand({"one" => "1"}).to_str
2004
+ end
2005
+
2006
+ it "should produce the correct result when fully expanded" do
2007
+ @partial_template.expand({}).to_str.should ==
2008
+ "http://example.com/?two=2&three=3"
2009
+ end
2010
+
2011
+ it "should produce the correct result when fully expanded" do
2012
+ @partial_template.expand({"one" => "1"}).to_str.should ==
2013
+ "http://example.com/?one=1&two=2&three=3"
2014
+ end
2015
+ end
2016
+
2017
+ describe Addressable::Template, "with a partially expanded template" do
2018
+ before do
2019
+ @initial_template = Addressable::Template.new(
2020
+ "http://example.com/?{-join|&|one,two,three}"
2021
+ )
2022
+ end
2023
+
2024
+ it "should raise an error when partially expanding a bogus operator" do
2025
+ (lambda do
2026
+ @initial_template.partial_expand({"one" => ["1"]})
2027
+ end).should raise_error(
2028
+ Addressable::Template::InvalidTemplateOperatorError
2029
+ )
2030
+ (lambda do
2031
+ @initial_template.partial_expand({"two" => "2", "three" => ["3"]})
2032
+ end).should raise_error(
2033
+ Addressable::Template::InvalidTemplateOperatorError
2034
+ )
2035
+ end
2036
+ end
2037
+
2038
+ describe Addressable::Template, "with a partially expanded template" do
2039
+ before do
2040
+ @initial_template = Addressable::Template.new(
2041
+ "http://example.com/{-list|/|numbers}/{-list|/|letters}/"
2042
+ )
2043
+ @partial_template = @initial_template.partial_expand({})
2044
+ end
2045
+
2046
+ it "should produce the same result when fully expanded" do
2047
+ @initial_template.expand({
2048
+ "numbers" => ["1", "2", "3"], "letters" => ["a", "b", "c"]
2049
+ }).to_str.should == @partial_template.expand({
2050
+ "numbers" => ["1", "2", "3"], "letters" => ["a", "b", "c"]
2051
+ }).to_str
2052
+ end
2053
+
2054
+ it "should produce the correct result when fully expanded" do
2055
+ @partial_template.expand({}).to_str.should == "http://example.com///"
2056
+ end
2057
+
2058
+ it "should produce the correct result when fully expanded" do
2059
+ @partial_template.pattern.should == @initial_template.pattern
2060
+ end
2061
+ end
2062
+
2063
+ describe Addressable::Template, "with a partially expanded template" do
2064
+ before do
2065
+ @initial_template = Addressable::Template.new(
2066
+ "http://example.com/{-list|/|numbers}/{-list|/|letters}/"
2067
+ )
2068
+ @partial_template = @initial_template.partial_expand({
2069
+ "numbers" => ["1", "2", "3"]
2070
+ })
2071
+ end
2072
+
2073
+ it "should produce the same result when fully expanded" do
2074
+ @initial_template.expand({
2075
+ "numbers" => ["1", "2", "3"], "letters" => ["a", "b", "c"]
2076
+ }).to_str.should == @partial_template.expand({
2077
+ "letters" => ["a", "b", "c"]
2078
+ }).to_str
2079
+ end
2080
+
2081
+ it "should produce the correct result when fully expanded" do
2082
+ @partial_template.expand({}).to_str.should == "http://example.com/1/2/3//"
2083
+ end
2084
+ end
2085
+
2086
+ describe Addressable::Template, "with a partially expanded template" do
2087
+ before do
2088
+ @initial_template = Addressable::Template.new(
2089
+ "http://example.com/{-list|/|numbers}/{-list|/|letters}/"
2090
+ )
2091
+ @partial_template = @initial_template.partial_expand({
2092
+ "letters" => ["a", "b", "c"]
2093
+ })
2094
+ end
2095
+
2096
+ it "should produce the same result when fully expanded" do
2097
+ @initial_template.expand({
2098
+ "numbers" => ["1", "2", "3"], "letters" => ["a", "b", "c"]
2099
+ }).to_str.should == @partial_template.expand({
2100
+ "numbers" => ["1", "2", "3"]
2101
+ }).to_str
2102
+ end
2103
+
2104
+ it "should produce the correct result when fully expanded" do
2105
+ @partial_template.expand({}).to_str.should == "http://example.com//a/b/c/"
2106
+ end
2107
+ end
2108
+
2109
+ describe Addressable::Template, "with a partially expanded template" do
2110
+ before do
2111
+ @initial_template = Addressable::Template.new(
2112
+ "http://example.com/{-list|/|numbers}/{-list|/|letters}/"
2113
+ )
2114
+ end
2115
+
2116
+ it "should raise an error when partially expanding a bogus operator" do
2117
+ (lambda do
2118
+ @initial_template.partial_expand({"numbers" => "1"})
2119
+ end).should raise_error(
2120
+ Addressable::Template::InvalidTemplateOperatorError
2121
+ )
2122
+ (lambda do
2123
+ @initial_template.partial_expand({"letters" => "a"})
2124
+ end).should raise_error(
2125
+ Addressable::Template::InvalidTemplateOperatorError
2126
+ )
2127
+ end
2128
+ end
2129
+
2130
+ describe Addressable::Template, "with a partially expanded template" do
2131
+ before do
2132
+ @initial_template = Addressable::Template.new(
2133
+ "http://example.com/{-bogus|/|one,two}/"
2134
+ )
2135
+ end
2136
+
2137
+ it "should raise an error when partially expanding a bogus operator" do
2138
+ (lambda do
2139
+ @initial_template.partial_expand({"one" => "1"})
2140
+ end).should raise_error(
2141
+ Addressable::Template::InvalidTemplateOperatorError
2142
+ )
2143
+ end
2144
+ end