abiquo-etk 0.4.13

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 (530) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +87 -0
  6. data/TODO +6 -0
  7. data/VERSION +1 -0
  8. data/abiquo-etk.gemspec +577 -0
  9. data/abiquo-etk.spec +125 -0
  10. data/bin/abicli +90 -0
  11. data/bin/abiquo-check-16-install +129 -0
  12. data/bin/aetk-setup-rs +36 -0
  13. data/bin/aetk-setup-server +77 -0
  14. data/bin/aetk-setup-v2v +33 -0
  15. data/lib/abicli/commands/remote-services-settings.rb +24 -0
  16. data/lib/abicli/commands/server-settings.rb +22 -0
  17. data/lib/abicli/commands/set.rb +133 -0
  18. data/lib/abicli/commands/smoketest.rb +93 -0
  19. data/lib/abicli/commands/upload-template.rb +272 -0
  20. data/lib/abicli/commands/version.rb +5 -0
  21. data/lib/abiquo-etk.rb +191 -0
  22. data/lib/checks/01detect_abiquo.rb +4 -0
  23. data/lib/checks/abiquo_service.rb +34 -0
  24. data/lib/checks/abiquo_version.rb +24 -0
  25. data/lib/checks/components_installed.rb +6 -0
  26. data/lib/checks/firewall.rb +10 -0
  27. data/lib/checks/hv_passwords.rb +51 -0
  28. data/lib/checks/install_type.rb +8 -0
  29. data/lib/checks/java.rb +19 -0
  30. data/lib/checks/mysql.rb +33 -0
  31. data/lib/checks/nfs.rb +18 -0
  32. data/lib/checks/os_version.rb +5 -0
  33. data/lib/checks/virtualbox.rb +11 -0
  34. data/scripts/setup_rs +44 -0
  35. data/scripts/setup_v2v +1 -0
  36. data/vendor/activesupport-2.3.8/CHANGELOG +1367 -0
  37. data/vendor/activesupport-2.3.8/README +43 -0
  38. data/vendor/activesupport-2.3.8/lib/active_support/all.rb +8 -0
  39. data/vendor/activesupport-2.3.8/lib/active_support/backtrace_cleaner.rb +72 -0
  40. data/vendor/activesupport-2.3.8/lib/active_support/base64.rb +33 -0
  41. data/vendor/activesupport-2.3.8/lib/active_support/basic_object.rb +24 -0
  42. data/vendor/activesupport-2.3.8/lib/active_support/buffered_logger.rb +127 -0
  43. data/vendor/activesupport-2.3.8/lib/active_support/cache/compressed_mem_cache_store.rb +20 -0
  44. data/vendor/activesupport-2.3.8/lib/active_support/cache/drb_store.rb +14 -0
  45. data/vendor/activesupport-2.3.8/lib/active_support/cache/file_store.rb +72 -0
  46. data/vendor/activesupport-2.3.8/lib/active_support/cache/mem_cache_store.rb +143 -0
  47. data/vendor/activesupport-2.3.8/lib/active_support/cache/memory_store.rb +58 -0
  48. data/vendor/activesupport-2.3.8/lib/active_support/cache/strategy/local_cache.rb +104 -0
  49. data/vendor/activesupport-2.3.8/lib/active_support/cache/synchronized_memory_store.rb +47 -0
  50. data/vendor/activesupport-2.3.8/lib/active_support/cache.rb +248 -0
  51. data/vendor/activesupport-2.3.8/lib/active_support/callbacks.rb +279 -0
  52. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array/access.rb +53 -0
  53. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array/conversions.rb +197 -0
  54. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array/extract_options.rb +20 -0
  55. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array/grouping.rb +106 -0
  56. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array/random_access.rb +22 -0
  57. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array/wrapper.rb +24 -0
  58. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array.rb +15 -0
  59. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/base64/encoding.rb +16 -0
  60. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/base64.rb +4 -0
  61. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/benchmark.rb +19 -0
  62. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/bigdecimal/conversions.rb +37 -0
  63. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/bigdecimal.rb +6 -0
  64. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/blank.rb +2 -0
  65. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +23 -0
  66. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/cgi.rb +5 -0
  67. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/class/attribute_accessors.rb +61 -0
  68. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/class/delegating_attributes.rb +47 -0
  69. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/class/inheritable_attributes.rb +140 -0
  70. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/class/removal.rb +50 -0
  71. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/class.rb +4 -0
  72. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date/behavior.rb +42 -0
  73. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date/calculations.rb +241 -0
  74. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date/conversions.rb +107 -0
  75. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date.rb +10 -0
  76. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date_time/calculations.rb +126 -0
  77. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date_time/conversions.rb +107 -0
  78. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date_time.rb +12 -0
  79. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/duplicable.rb +43 -0
  80. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/enumerable.rb +120 -0
  81. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/exception.rb +45 -0
  82. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/file/atomic.rb +47 -0
  83. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/file.rb +5 -0
  84. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/float/rounding.rb +24 -0
  85. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/float/time.rb +27 -0
  86. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/float.rb +7 -0
  87. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/conversions.rb +247 -0
  88. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/deep_merge.rb +23 -0
  89. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/diff.rb +19 -0
  90. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/except.rb +25 -0
  91. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/indifferent_access.rb +143 -0
  92. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/keys.rb +52 -0
  93. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/reverse_merge.rb +35 -0
  94. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/slice.rb +40 -0
  95. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash.rb +14 -0
  96. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/integer/even_odd.rb +29 -0
  97. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/integer/inflections.rb +20 -0
  98. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/integer/time.rb +45 -0
  99. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/integer.rb +9 -0
  100. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/kernel/agnostics.rb +11 -0
  101. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
  102. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/kernel/debugger.rb +16 -0
  103. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/kernel/reporting.rb +59 -0
  104. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb +24 -0
  105. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/kernel.rb +5 -0
  106. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb +38 -0
  107. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/logger.rb +145 -0
  108. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/aliasing.rb +74 -0
  109. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
  110. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb +32 -0
  111. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/attribute_accessors.rb +67 -0
  112. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/delegation.rb +135 -0
  113. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/inclusion.rb +30 -0
  114. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/introspection.rb +90 -0
  115. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/loading.rb +23 -0
  116. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/model_naming.rb +25 -0
  117. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/synchronization.rb +39 -0
  118. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module.rb +23 -0
  119. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/name_error.rb +19 -0
  120. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/numeric/bytes.rb +50 -0
  121. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/numeric/conversions.rb +19 -0
  122. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/numeric/time.rb +81 -0
  123. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/numeric.rb +9 -0
  124. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/blank.rb +76 -0
  125. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/conversions.rb +15 -0
  126. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/extending.rb +80 -0
  127. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/instance_variables.rb +74 -0
  128. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/metaclass.rb +14 -0
  129. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/misc.rb +90 -0
  130. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/singleton_class.rb +13 -0
  131. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object.rb +7 -0
  132. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/pathname/clean_within.rb +14 -0
  133. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/pathname.rb +7 -0
  134. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/proc.rb +12 -0
  135. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/process/daemon.rb +25 -0
  136. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/process.rb +1 -0
  137. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/range/blockless_step.rb +32 -0
  138. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/range/conversions.rb +27 -0
  139. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/range/include_range.rb +30 -0
  140. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/range/overlaps.rb +15 -0
  141. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/range.rb +11 -0
  142. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb +41 -0
  143. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/access.rb +106 -0
  144. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/behavior.rb +13 -0
  145. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/bytesize.rb +5 -0
  146. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/conversions.rb +28 -0
  147. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/filters.rb +26 -0
  148. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/inflections.rb +167 -0
  149. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/iterators.rb +23 -0
  150. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/multibyte.rb +81 -0
  151. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/output_safety.rb +112 -0
  152. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/starts_ends_with.rb +33 -0
  153. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/xchar.rb +11 -0
  154. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string.rb +24 -0
  155. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb +14 -0
  156. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/time/behavior.rb +13 -0
  157. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/time/calculations.rb +313 -0
  158. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/time/conversions.rb +90 -0
  159. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/time/zones.rb +86 -0
  160. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/time.rb +46 -0
  161. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/try.rb +36 -0
  162. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/uri.rb +16 -0
  163. data/vendor/activesupport-2.3.8/lib/active_support/core_ext.rb +8 -0
  164. data/vendor/activesupport-2.3.8/lib/active_support/dependencies.rb +625 -0
  165. data/vendor/activesupport-2.3.8/lib/active_support/deprecation.rb +197 -0
  166. data/vendor/activesupport-2.3.8/lib/active_support/duration.rb +100 -0
  167. data/vendor/activesupport-2.3.8/lib/active_support/gzip.rb +25 -0
  168. data/vendor/activesupport-2.3.8/lib/active_support/inflections.rb +56 -0
  169. data/vendor/activesupport-2.3.8/lib/active_support/inflector.rb +409 -0
  170. data/vendor/activesupport-2.3.8/lib/active_support/json/backends/jsongem.rb +37 -0
  171. data/vendor/activesupport-2.3.8/lib/active_support/json/backends/yajl.rb +40 -0
  172. data/vendor/activesupport-2.3.8/lib/active_support/json/backends/yaml.rb +87 -0
  173. data/vendor/activesupport-2.3.8/lib/active_support/json/decoding.rb +50 -0
  174. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/date.rb +22 -0
  175. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/date_time.rb +22 -0
  176. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/enumerable.rb +17 -0
  177. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/false_class.rb +7 -0
  178. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/hash.rb +56 -0
  179. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/nil_class.rb +7 -0
  180. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/numeric.rb +21 -0
  181. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/object.rb +10 -0
  182. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/regexp.rb +9 -0
  183. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/string.rb +9 -0
  184. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/symbol.rb +5 -0
  185. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/time.rb +22 -0
  186. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/true_class.rb +7 -0
  187. data/vendor/activesupport-2.3.8/lib/active_support/json/encoding.rb +111 -0
  188. data/vendor/activesupport-2.3.8/lib/active_support/json/variable.rb +10 -0
  189. data/vendor/activesupport-2.3.8/lib/active_support/json.rb +2 -0
  190. data/vendor/activesupport-2.3.8/lib/active_support/locale/en.yml +33 -0
  191. data/vendor/activesupport-2.3.8/lib/active_support/memoizable.rb +100 -0
  192. data/vendor/activesupport-2.3.8/lib/active_support/message_encryptor.rb +70 -0
  193. data/vendor/activesupport-2.3.8/lib/active_support/message_verifier.rb +79 -0
  194. data/vendor/activesupport-2.3.8/lib/active_support/multibyte/chars.rb +707 -0
  195. data/vendor/activesupport-2.3.8/lib/active_support/multibyte/exceptions.rb +8 -0
  196. data/vendor/activesupport-2.3.8/lib/active_support/multibyte/unicode_database.rb +71 -0
  197. data/vendor/activesupport-2.3.8/lib/active_support/multibyte/utils.rb +60 -0
  198. data/vendor/activesupport-2.3.8/lib/active_support/multibyte.rb +57 -0
  199. data/vendor/activesupport-2.3.8/lib/active_support/option_merger.rb +23 -0
  200. data/vendor/activesupport-2.3.8/lib/active_support/ordered_hash.rb +158 -0
  201. data/vendor/activesupport-2.3.8/lib/active_support/ordered_options.rb +19 -0
  202. data/vendor/activesupport-2.3.8/lib/active_support/rescuable.rb +108 -0
  203. data/vendor/activesupport-2.3.8/lib/active_support/secure_random.rb +199 -0
  204. data/vendor/activesupport-2.3.8/lib/active_support/string_inquirer.rb +21 -0
  205. data/vendor/activesupport-2.3.8/lib/active_support/test_case.rb +40 -0
  206. data/vendor/activesupport-2.3.8/lib/active_support/testing/assertions.rb +79 -0
  207. data/vendor/activesupport-2.3.8/lib/active_support/testing/declarative.rb +21 -0
  208. data/vendor/activesupport-2.3.8/lib/active_support/testing/default.rb +9 -0
  209. data/vendor/activesupport-2.3.8/lib/active_support/testing/deprecation.rb +57 -0
  210. data/vendor/activesupport-2.3.8/lib/active_support/testing/performance.rb +452 -0
  211. data/vendor/activesupport-2.3.8/lib/active_support/testing/setup_and_teardown.rb +91 -0
  212. data/vendor/activesupport-2.3.8/lib/active_support/time_with_zone.rb +335 -0
  213. data/vendor/activesupport-2.3.8/lib/active_support/values/time_zone.rb +412 -0
  214. data/vendor/activesupport-2.3.8/lib/active_support/values/unicode_tables.dat +0 -0
  215. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
  216. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
  217. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
  218. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +115 -0
  219. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +139 -0
  220. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +63 -0
  221. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +328 -0
  222. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder.rb +13 -0
  223. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/active_record/missing.rb +67 -0
  224. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/active_record/store_procs.rb +38 -0
  225. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/active_record/translation.rb +88 -0
  226. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/active_record.rb +66 -0
  227. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/base.rb +266 -0
  228. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/cache.rb +76 -0
  229. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/cascade.rb +58 -0
  230. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/chain.rb +75 -0
  231. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb +100 -0
  232. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/fallbacks.rb +69 -0
  233. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/fast.rb +69 -0
  234. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/gettext.rb +75 -0
  235. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/helpers.rb +68 -0
  236. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/interpolation_compiler.rb +119 -0
  237. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/links.rb +34 -0
  238. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/metadata.rb +73 -0
  239. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/pluralization.rb +57 -0
  240. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/simple.rb +22 -0
  241. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend.rb +19 -0
  242. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/hash/except.rb +8 -0
  243. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/hash/slice.rb +8 -0
  244. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/object/meta_class.rb +5 -0
  245. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/string/interpolate.rb +99 -0
  246. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/exceptions.rb +61 -0
  247. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/gettext/po_parser.rb +329 -0
  248. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/gettext.rb +25 -0
  249. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/helpers/gettext.rb +65 -0
  250. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/helpers.rb +5 -0
  251. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/locale/fallbacks.rb +98 -0
  252. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/locale/tag/parents.rb +24 -0
  253. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/locale/tag/rfc4646.rb +76 -0
  254. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/locale/tag/simple.rb +41 -0
  255. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/locale/tag.rb +28 -0
  256. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/locale.rb +6 -0
  257. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/version.rb +3 -0
  258. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n.rb +335 -0
  259. data/vendor/activesupport-2.3.8/lib/active_support/vendor/memcache-client-1.7.4/memcache.rb +1107 -0
  260. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb +47 -0
  261. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb +228 -0
  262. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb +55 -0
  263. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb +219 -0
  264. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb +40 -0
  265. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb +18 -0
  266. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
  267. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb +22 -0
  268. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb +23 -0
  269. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
  270. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
  271. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb +23 -0
  272. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb +23 -0
  273. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb +283 -0
  274. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb +136 -0
  275. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb +204 -0
  276. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb +161 -0
  277. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb +27 -0
  278. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb +274 -0
  279. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
  280. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb +194 -0
  281. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb +22 -0
  282. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb +35 -0
  283. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb +232 -0
  284. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb +139 -0
  285. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb +144 -0
  286. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb +131 -0
  287. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb +282 -0
  288. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb +30 -0
  289. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb +74 -0
  290. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb +205 -0
  291. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
  292. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb +288 -0
  293. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb +196 -0
  294. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb +67 -0
  295. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb +73 -0
  296. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb +161 -0
  297. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb +20 -0
  298. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb +33 -0
  299. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +30 -0
  300. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb +27 -0
  301. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
  302. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
  303. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb +30 -0
  304. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
  305. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb +20 -0
  306. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
  307. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb +30 -0
  308. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb +20 -0
  309. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb +25 -0
  310. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
  311. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
  312. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb +18 -0
  313. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb +163 -0
  314. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb +18 -0
  315. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
  316. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb +24 -0
  317. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb +18 -0
  318. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb +34 -0
  319. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb +35 -0
  320. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb +33 -0
  321. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb +59 -0
  322. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb +47 -0
  323. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
  324. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb +121 -0
  325. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb +30 -0
  326. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
  327. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb +33 -0
  328. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
  329. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
  330. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
  331. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb +165 -0
  332. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb +270 -0
  333. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
  334. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
  335. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb +187 -0
  336. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb +35 -0
  337. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb +29 -0
  338. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb +193 -0
  339. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb +185 -0
  340. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb +37 -0
  341. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb +185 -0
  342. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb +16 -0
  343. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
  344. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb +185 -0
  345. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb +163 -0
  346. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb +188 -0
  347. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb +13 -0
  348. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb +232 -0
  349. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb +181 -0
  350. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb +197 -0
  351. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
  352. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb +276 -0
  353. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb +163 -0
  354. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb +218 -0
  355. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb +168 -0
  356. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb +268 -0
  357. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
  358. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb +288 -0
  359. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb +211 -0
  360. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb +170 -0
  361. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb +181 -0
  362. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb +232 -0
  363. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb +187 -0
  364. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb +176 -0
  365. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb +215 -0
  366. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
  367. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb +13 -0
  368. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb +173 -0
  369. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb +165 -0
  370. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb +172 -0
  371. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb +183 -0
  372. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb +170 -0
  373. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb +212 -0
  374. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb +13 -0
  375. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb +202 -0
  376. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb +23 -0
  377. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb +22 -0
  378. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
  379. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb +20 -0
  380. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb +25 -0
  381. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb +25 -0
  382. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
  383. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
  384. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
  385. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb +52 -0
  386. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb +51 -0
  387. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb +44 -0
  388. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb +98 -0
  389. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb +56 -0
  390. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb +292 -0
  391. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb +508 -0
  392. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb +56 -0
  393. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb +40 -0
  394. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb +94 -0
  395. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb +198 -0
  396. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb +129 -0
  397. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb +33 -0
  398. data/vendor/activesupport-2.3.8/lib/active_support/vendor.rb +36 -0
  399. data/vendor/activesupport-2.3.8/lib/active_support/version.rb +9 -0
  400. data/vendor/activesupport-2.3.8/lib/active_support/whiny_nil.rb +64 -0
  401. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini/jdom.rb +162 -0
  402. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini/libxml.rb +73 -0
  403. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini/libxmlsax.rb +74 -0
  404. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini/nokogiri.rb +72 -0
  405. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini/nokogirisax.rb +73 -0
  406. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini/rexml.rb +108 -0
  407. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini.rb +31 -0
  408. data/vendor/activesupport-2.3.8/lib/active_support.rb +60 -0
  409. data/vendor/activesupport-2.3.8/lib/activesupport.rb +2 -0
  410. data/vendor/addressable-2.2.1/CHANGELOG +95 -0
  411. data/vendor/addressable-2.2.1/LICENSE +20 -0
  412. data/vendor/addressable-2.2.1/README +60 -0
  413. data/vendor/addressable-2.2.1/Rakefile +42 -0
  414. data/vendor/addressable-2.2.1/lib/addressable/idna.rb +4871 -0
  415. data/vendor/addressable-2.2.1/lib/addressable/template.rb +1049 -0
  416. data/vendor/addressable-2.2.1/lib/addressable/uri.rb +2250 -0
  417. data/vendor/addressable-2.2.1/lib/addressable/version.rb +36 -0
  418. data/vendor/addressable-2.2.1/spec/addressable/idna_spec.rb +194 -0
  419. data/vendor/addressable-2.2.1/spec/addressable/template_spec.rb +2152 -0
  420. data/vendor/addressable-2.2.1/spec/addressable/uri_spec.rb +4203 -0
  421. data/vendor/addressable-2.2.1/spec/data/rfc3986.txt +3419 -0
  422. data/vendor/addressable-2.2.1/tasks/clobber.rake +2 -0
  423. data/vendor/addressable-2.2.1/tasks/gem.rake +84 -0
  424. data/vendor/addressable-2.2.1/tasks/git.rake +40 -0
  425. data/vendor/addressable-2.2.1/tasks/metrics.rake +22 -0
  426. data/vendor/addressable-2.2.1/tasks/rdoc.rake +26 -0
  427. data/vendor/addressable-2.2.1/tasks/rubyforge.rake +89 -0
  428. data/vendor/addressable-2.2.1/tasks/spec.rake +47 -0
  429. data/vendor/addressable-2.2.1/tasks/yard.rake +26 -0
  430. data/vendor/addressable-2.2.1/website/index.html +110 -0
  431. data/vendor/api_ruby_client/Gemfile +10 -0
  432. data/vendor/api_ruby_client/LICENSE +20 -0
  433. data/vendor/api_ruby_client/README +39 -0
  434. data/vendor/api_ruby_client/Rakefile +89 -0
  435. data/vendor/api_ruby_client/abiquo.gemspec +43 -0
  436. data/vendor/api_ruby_client/examples/create_dc_and_hv.rb +38 -0
  437. data/vendor/api_ruby_client/examples/hypervisor_resource.rb +16 -0
  438. data/vendor/api_ruby_client/examples/rack_resource.rb +38 -0
  439. data/vendor/api_ruby_client/lib/abiquo.rb +201 -0
  440. data/vendor/api_ruby_client/lib/core_ext.rb +28 -0
  441. data/vendor/api_ruby_client/lib/to_xml.rb +22 -0
  442. data/vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb +43 -0
  443. data/vendor/api_ruby_client/spec/acceptance/delete_resource_spec.rb +27 -0
  444. data/vendor/api_ruby_client/spec/acceptance/fetch_resource_collections_spec.rb +55 -0
  445. data/vendor/api_ruby_client/spec/acceptance/fetch_single_resources_spec.rb +47 -0
  446. data/vendor/api_ruby_client/spec/acceptance/from_xml_spec.rb +15 -0
  447. data/vendor/api_ruby_client/spec/acceptance/navigate_linked_resources_spec.rb +61 -0
  448. data/vendor/api_ruby_client/spec/acceptance/update_resource_spec.rb +26 -0
  449. data/vendor/api_ruby_client/spec/spec_helper.rb +32 -0
  450. data/vendor/api_ruby_client/spec/unit/to_xml_spec.rb +56 -0
  451. data/vendor/fattr-2.1.0/README +347 -0
  452. data/vendor/fattr-2.1.0/README.erb +82 -0
  453. data/vendor/fattr-2.1.0/Rakefile +242 -0
  454. data/vendor/fattr-2.1.0/a.rb +42 -0
  455. data/vendor/fattr-2.1.0/fattr.gemspec +29 -0
  456. data/vendor/fattr-2.1.0/lib/fattr.rb +193 -0
  457. data/vendor/fattr-2.1.0/samples/a.rb +21 -0
  458. data/vendor/fattr-2.1.0/samples/b.rb +22 -0
  459. data/vendor/fattr-2.1.0/samples/c.rb +12 -0
  460. data/vendor/fattr-2.1.0/samples/d.rb +34 -0
  461. data/vendor/fattr-2.1.0/samples/e.rb +17 -0
  462. data/vendor/fattr-2.1.0/samples/f.rb +21 -0
  463. data/vendor/fattr-2.1.0/samples/g.rb +15 -0
  464. data/vendor/fattr-2.1.0/samples/h.rb +29 -0
  465. data/vendor/fattr-2.1.0/test/fattr.rb +166 -0
  466. data/vendor/httpauth-0.1/LICENSE +16 -0
  467. data/vendor/httpauth-0.1/README +39 -0
  468. data/vendor/httpauth-0.1/Rakefile +76 -0
  469. data/vendor/httpauth-0.1/examples/client_digest_secure +132 -0
  470. data/vendor/httpauth-0.1/examples/server_digest_secure +47 -0
  471. data/vendor/httpauth-0.1/lib/httpauth/basic.rb +114 -0
  472. data/vendor/httpauth-0.1/lib/httpauth/constants.rb +14 -0
  473. data/vendor/httpauth-0.1/lib/httpauth/digest.rb +583 -0
  474. data/vendor/httpauth-0.1/lib/httpauth/exceptions.rb +6 -0
  475. data/vendor/httpauth-0.1/lib/httpauth.rb +4 -0
  476. data/vendor/options-2.3.0/README +186 -0
  477. data/vendor/options-2.3.0/README.erb +35 -0
  478. data/vendor/options-2.3.0/Rakefile +371 -0
  479. data/vendor/options-2.3.0/lib/options.rb +220 -0
  480. data/vendor/options-2.3.0/options.gemspec +26 -0
  481. data/vendor/options-2.3.0/samples/a.rb +15 -0
  482. data/vendor/options-2.3.0/samples/b.rb +50 -0
  483. data/vendor/options-2.3.0/samples/c.rb +20 -0
  484. data/vendor/options-2.3.0/samples/d.rb +17 -0
  485. data/vendor/options-2.3.0/spec/options_spec.rb +38 -0
  486. data/vendor/options-2.3.0/spec/spec_helper.rb +7 -0
  487. data/vendor/resourceful-1.0.1/History.txt +39 -0
  488. data/vendor/resourceful-1.0.1/MIT-LICENSE +21 -0
  489. data/vendor/resourceful-1.0.1/Manifest +43 -0
  490. data/vendor/resourceful-1.0.1/README.markdown +92 -0
  491. data/vendor/resourceful-1.0.1/Rakefile +91 -0
  492. data/vendor/resourceful-1.0.1/lib/resourceful/abstract_form_data.rb +18 -0
  493. data/vendor/resourceful-1.0.1/lib/resourceful/authentication_manager.rb +108 -0
  494. data/vendor/resourceful-1.0.1/lib/resourceful/cache_manager.rb +242 -0
  495. data/vendor/resourceful-1.0.1/lib/resourceful/exceptions.rb +34 -0
  496. data/vendor/resourceful-1.0.1/lib/resourceful/header.rb +355 -0
  497. data/vendor/resourceful-1.0.1/lib/resourceful/http_accessor.rb +103 -0
  498. data/vendor/resourceful-1.0.1/lib/resourceful/memcache_cache_manager.rb +75 -0
  499. data/vendor/resourceful-1.0.1/lib/resourceful/multipart_form_data.rb +46 -0
  500. data/vendor/resourceful-1.0.1/lib/resourceful/net_http_adapter.rb +84 -0
  501. data/vendor/resourceful-1.0.1/lib/resourceful/request.rb +235 -0
  502. data/vendor/resourceful-1.0.1/lib/resourceful/resource.rb +179 -0
  503. data/vendor/resourceful-1.0.1/lib/resourceful/response.rb +221 -0
  504. data/vendor/resourceful-1.0.1/lib/resourceful/simple.rb +36 -0
  505. data/vendor/resourceful-1.0.1/lib/resourceful/stubbed_resource_proxy.rb +47 -0
  506. data/vendor/resourceful-1.0.1/lib/resourceful/urlencoded_form_data.rb +17 -0
  507. data/vendor/resourceful-1.0.1/lib/resourceful/util.rb +6 -0
  508. data/vendor/resourceful-1.0.1/lib/resourceful.rb +26 -0
  509. data/vendor/resourceful-1.0.1/resourceful.gemspec +51 -0
  510. data/vendor/resourceful-1.0.1/spec/acceptance/authorization_spec.rb +16 -0
  511. data/vendor/resourceful-1.0.1/spec/acceptance/caching_spec.rb +190 -0
  512. data/vendor/resourceful-1.0.1/spec/acceptance/header_spec.rb +24 -0
  513. data/vendor/resourceful-1.0.1/spec/acceptance/redirecting_spec.rb +12 -0
  514. data/vendor/resourceful-1.0.1/spec/acceptance/resource_spec.rb +84 -0
  515. data/vendor/resourceful-1.0.1/spec/acceptance/resourceful_spec.rb +56 -0
  516. data/vendor/resourceful-1.0.1/spec/acceptance_shared_specs.rb +44 -0
  517. data/vendor/resourceful-1.0.1/spec/caching_spec.rb +89 -0
  518. data/vendor/resourceful-1.0.1/spec/old_acceptance_specs.rb +378 -0
  519. data/vendor/resourceful-1.0.1/spec/resourceful/header_spec.rb +153 -0
  520. data/vendor/resourceful-1.0.1/spec/resourceful/http_accessor_spec.rb +56 -0
  521. data/vendor/resourceful-1.0.1/spec/resourceful/multipart_form_data_spec.rb +77 -0
  522. data/vendor/resourceful-1.0.1/spec/resourceful/resource_spec.rb +20 -0
  523. data/vendor/resourceful-1.0.1/spec/resourceful/response_spec.rb +51 -0
  524. data/vendor/resourceful-1.0.1/spec/resourceful/urlencoded_form_data_spec.rb +44 -0
  525. data/vendor/resourceful-1.0.1/spec/resourceful_spec.rb +79 -0
  526. data/vendor/resourceful-1.0.1/spec/simple_sinatra_server.rb +74 -0
  527. data/vendor/resourceful-1.0.1/spec/simple_sinatra_server_spec.rb +98 -0
  528. data/vendor/resourceful-1.0.1/spec/spec.opts +3 -0
  529. data/vendor/resourceful-1.0.1/spec/spec_helper.rb +31 -0
  530. metadata +645 -0
@@ -0,0 +1,4203 @@
1
+ # encoding: utf-8
2
+ #--
3
+ # Addressable, Copyright (c) 2006-2007 Bob Aman
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ #++
24
+
25
+ require "addressable/uri"
26
+
27
+ if !"".respond_to?("force_encoding")
28
+ class String
29
+ def force_encoding(encoding)
30
+ @encoding = encoding
31
+ end
32
+
33
+ def encoding
34
+ @encoding ||= Encoding::ASCII_8BIT
35
+ end
36
+ end
37
+
38
+ class Encoding
39
+ def initialize(name)
40
+ @name = name
41
+ end
42
+
43
+ def to_s
44
+ return @name
45
+ end
46
+
47
+ UTF_8 = Encoding.new("UTF-8")
48
+ ASCII_8BIT = Encoding.new("US-ASCII")
49
+ end
50
+ end
51
+
52
+ module URI
53
+ class HTTP
54
+ def initialize(uri)
55
+ @uri = uri
56
+ end
57
+
58
+ def to_s
59
+ return @uri.to_s
60
+ end
61
+ end
62
+ end
63
+
64
+ describe Addressable::URI, "when created with a non-numeric port number" do
65
+ it "should raise an error" do
66
+ (lambda do
67
+ Addressable::URI.new(:port => "bogus")
68
+ end).should raise_error(Addressable::URI::InvalidURIError)
69
+ end
70
+ end
71
+
72
+ describe Addressable::URI, "when created with a non-string scheme" do
73
+ it "should raise an error" do
74
+ (lambda do
75
+ Addressable::URI.new(:scheme => :bogus)
76
+ end).should raise_error(TypeError)
77
+ end
78
+ end
79
+
80
+ describe Addressable::URI, "when created with a non-string user" do
81
+ it "should raise an error" do
82
+ (lambda do
83
+ Addressable::URI.new(:user => :bogus)
84
+ end).should raise_error(TypeError)
85
+ end
86
+ end
87
+
88
+ describe Addressable::URI, "when created with a non-string password" do
89
+ it "should raise an error" do
90
+ (lambda do
91
+ Addressable::URI.new(:password => :bogus)
92
+ end).should raise_error(TypeError)
93
+ end
94
+ end
95
+
96
+ describe Addressable::URI, "when created with a non-string userinfo" do
97
+ it "should raise an error" do
98
+ (lambda do
99
+ Addressable::URI.new(:userinfo => :bogus)
100
+ end).should raise_error(TypeError)
101
+ end
102
+ end
103
+
104
+ describe Addressable::URI, "when created with a non-string host" do
105
+ it "should raise an error" do
106
+ (lambda do
107
+ Addressable::URI.new(:host => :bogus)
108
+ end).should raise_error(TypeError)
109
+ end
110
+ end
111
+
112
+ describe Addressable::URI, "when created with a non-string authority" do
113
+ it "should raise an error" do
114
+ (lambda do
115
+ Addressable::URI.new(:authority => :bogus)
116
+ end).should raise_error(TypeError)
117
+ end
118
+ end
119
+
120
+ describe Addressable::URI, "when created with a non-string authority" do
121
+ it "should raise an error" do
122
+ (lambda do
123
+ Addressable::URI.new(:authority => :bogus)
124
+ end).should raise_error(TypeError)
125
+ end
126
+ end
127
+
128
+ describe Addressable::URI, "when created with a non-string path" do
129
+ it "should raise an error" do
130
+ (lambda do
131
+ Addressable::URI.new(:path => :bogus)
132
+ end).should raise_error(TypeError)
133
+ end
134
+ end
135
+
136
+ describe Addressable::URI, "when created with a non-string query" do
137
+ it "should raise an error" do
138
+ (lambda do
139
+ Addressable::URI.new(:query => :bogus)
140
+ end).should raise_error(TypeError)
141
+ end
142
+ end
143
+
144
+ describe Addressable::URI, "when created with a non-string fragment" do
145
+ it "should raise an error" do
146
+ (lambda do
147
+ Addressable::URI.new(:fragment => :bogus)
148
+ end).should raise_error(TypeError)
149
+ end
150
+ end
151
+
152
+ describe Addressable::URI, "when created with a scheme but no hierarchical " +
153
+ "segment" do
154
+ it "should raise an error" do
155
+ (lambda do
156
+ Addressable::URI.parse("http:")
157
+ end).should raise_error(Addressable::URI::InvalidURIError)
158
+ end
159
+ end
160
+
161
+ describe Addressable::URI, "when created from nil components" do
162
+ before do
163
+ @uri = Addressable::URI.new
164
+ end
165
+
166
+ it "should have a nil site value" do
167
+ @uri.site.should == nil
168
+ end
169
+
170
+ it "should have an empty path" do
171
+ @uri.path.should == ""
172
+ end
173
+
174
+ it "should be an empty uri" do
175
+ @uri.to_s.should == ""
176
+ end
177
+
178
+ it "should raise an error if the scheme is set to whitespace" do
179
+ (lambda do
180
+ @uri.scheme = "\t \n"
181
+ end).should raise_error(Addressable::URI::InvalidURIError)
182
+ end
183
+
184
+ it "should raise an error if the scheme is set to all digits" do
185
+ (lambda do
186
+ @uri.scheme = "123"
187
+ end).should raise_error(Addressable::URI::InvalidURIError)
188
+ end
189
+
190
+ it "should raise an error if set into an invalid state" do
191
+ (lambda do
192
+ @uri.user = "user"
193
+ end).should raise_error(Addressable::URI::InvalidURIError)
194
+ end
195
+
196
+ it "should raise an error if set into an invalid state" do
197
+ (lambda do
198
+ @uri.password = "pass"
199
+ end).should raise_error(Addressable::URI::InvalidURIError)
200
+ end
201
+
202
+ it "should raise an error if set into an invalid state" do
203
+ (lambda do
204
+ @uri.scheme = "http"
205
+ @uri.fragment = "fragment"
206
+ end).should raise_error(Addressable::URI::InvalidURIError)
207
+ end
208
+
209
+ it "should raise an error if set into an invalid state" do
210
+ (lambda do
211
+ @uri.fragment = "fragment"
212
+ @uri.scheme = "http"
213
+ end).should raise_error(Addressable::URI::InvalidURIError)
214
+ end
215
+ end
216
+
217
+ describe Addressable::URI, "when created from string components" do
218
+ before do
219
+ @uri = Addressable::URI.new(
220
+ :scheme => "http", :host => "example.com"
221
+ )
222
+ end
223
+
224
+ it "should have a site value of 'http://example.com'" do
225
+ @uri.site.should == "http://example.com"
226
+ end
227
+
228
+ it "should be equal to the equivalent parsed URI" do
229
+ @uri.should == Addressable::URI.parse("http://example.com")
230
+ end
231
+
232
+ it "should raise an error if invalid components omitted" do
233
+ (lambda do
234
+ @uri.omit(:bogus)
235
+ end).should raise_error(ArgumentError)
236
+ (lambda do
237
+ @uri.omit(:scheme, :bogus, :path)
238
+ end).should raise_error(ArgumentError)
239
+ end
240
+ end
241
+
242
+ describe Addressable::URI, "when created with a nil host but " +
243
+ "non-nil authority components" do
244
+ it "should raise an error" do
245
+ (lambda do
246
+ Addressable::URI.new(:user => "user", :password => "pass", :port => 80)
247
+ end).should raise_error(Addressable::URI::InvalidURIError)
248
+ end
249
+ end
250
+
251
+ describe Addressable::URI, "when created with both an authority and a user" do
252
+ it "should raise an error" do
253
+ (lambda do
254
+ Addressable::URI.new(
255
+ :user => "user", :authority => "user@example.com:80"
256
+ )
257
+ end).should raise_error(ArgumentError)
258
+ end
259
+ end
260
+
261
+ describe Addressable::URI, "when created with an authority and no port" do
262
+ before do
263
+ @uri = Addressable::URI.new(:authority => "user@example.com")
264
+ end
265
+
266
+ it "should not infer a port" do
267
+ @uri.port.should == nil
268
+ @uri.inferred_port.should == nil
269
+ end
270
+
271
+ it "should have a site value of '//user@example.com'" do
272
+ @uri.site.should == "//user@example.com"
273
+ end
274
+ end
275
+
276
+ describe Addressable::URI, "when created with both a userinfo and a user" do
277
+ it "should raise an error" do
278
+ (lambda do
279
+ Addressable::URI.new(:user => "user", :userinfo => "user:pass")
280
+ end).should raise_error(ArgumentError)
281
+ end
282
+ end
283
+
284
+ describe Addressable::URI, "when created with a path that hasn't been " +
285
+ "prefixed with a '/' but a host specified" do
286
+ before do
287
+ @uri = Addressable::URI.new(
288
+ :scheme => "http", :host => "example.com", :path => "path"
289
+ )
290
+ end
291
+
292
+ it "should prefix a '/' to the path" do
293
+ @uri.should == Addressable::URI.parse("http://example.com/path")
294
+ end
295
+
296
+ it "should have a site value of 'http://example.com'" do
297
+ @uri.site.should == "http://example.com"
298
+ end
299
+ end
300
+
301
+ describe Addressable::URI, "when created with a path that hasn't been " +
302
+ "prefixed with a '/' but no host specified" do
303
+ before do
304
+ @uri = Addressable::URI.new(
305
+ :scheme => "http", :path => "path"
306
+ )
307
+ end
308
+
309
+ it "should not prefix a '/' to the path" do
310
+ @uri.should == Addressable::URI.parse("http:path")
311
+ end
312
+
313
+ it "should have a site value of 'http:'" do
314
+ @uri.site.should == "http:"
315
+ end
316
+ end
317
+
318
+ describe Addressable::URI, "when parsed from an Addressable::URI object" do
319
+ it "should return the object" do
320
+ uri = Addressable::URI.parse("http://example.com/")
321
+ (lambda do
322
+ Addressable::URI.parse(uri).object_id.should == uri.object_id
323
+ end).should_not raise_error
324
+ end
325
+
326
+ it "should return the object" do
327
+ uri = Addressable::URI.parse("http://example.com/")
328
+ (lambda do
329
+ Addressable::URI.heuristic_parse(uri).object_id.should == uri.object_id
330
+ end).should_not raise_error
331
+ end
332
+ end
333
+
334
+ describe Addressable::URI, "when parsed from something that looks " +
335
+ "like a URI object" do
336
+ it "should parse without error" do
337
+ uri = Addressable::URI.parse(URI::HTTP.new("http://example.com/"))
338
+ (lambda do
339
+ Addressable::URI.parse(uri)
340
+ end).should_not raise_error
341
+ end
342
+ end
343
+
344
+ describe Addressable::URI, "when parsed from ''" do
345
+ before do
346
+ @uri = Addressable::URI.parse("")
347
+ end
348
+
349
+ it "should have no scheme" do
350
+ @uri.scheme.should == nil
351
+ end
352
+
353
+ it "should not be considered to be ip-based" do
354
+ @uri.should_not be_ip_based
355
+ end
356
+
357
+ it "should have a path of ''" do
358
+ @uri.path.should == ""
359
+ end
360
+
361
+ it "should have a request URI of '/'" do
362
+ @uri.request_uri.should == "/"
363
+ end
364
+
365
+ it "should be considered relative" do
366
+ @uri.should be_relative
367
+ end
368
+
369
+ it "should be considered to be in normal form" do
370
+ @uri.normalize.should be_eql(@uri)
371
+ end
372
+ end
373
+
374
+ # Section 1.1.2 of RFC 3986
375
+ describe Addressable::URI, "when parsed from " +
376
+ "'ftp://ftp.is.co.za/rfc/rfc1808.txt'" do
377
+ before do
378
+ @uri = Addressable::URI.parse("ftp://ftp.is.co.za/rfc/rfc1808.txt")
379
+ end
380
+
381
+ it "should use the 'ftp' scheme" do
382
+ @uri.scheme.should == "ftp"
383
+ end
384
+
385
+ it "should be considered to be ip-based" do
386
+ @uri.should be_ip_based
387
+ end
388
+
389
+ it "should have a host of 'ftp.is.co.za'" do
390
+ @uri.host.should == "ftp.is.co.za"
391
+ end
392
+
393
+ it "should have a path of '/rfc/rfc1808.txt'" do
394
+ @uri.path.should == "/rfc/rfc1808.txt"
395
+ end
396
+
397
+ it "should not have a request URI" do
398
+ @uri.request_uri.should == nil
399
+ end
400
+
401
+ it "should be considered to be in normal form" do
402
+ @uri.normalize.should be_eql(@uri)
403
+ end
404
+ end
405
+
406
+ # Section 1.1.2 of RFC 3986
407
+ describe Addressable::URI, "when parsed from " +
408
+ "'http://www.ietf.org/rfc/rfc2396.txt'" do
409
+ before do
410
+ @uri = Addressable::URI.parse("http://www.ietf.org/rfc/rfc2396.txt")
411
+ end
412
+
413
+ it "should use the 'http' scheme" do
414
+ @uri.scheme.should == "http"
415
+ end
416
+
417
+ it "should be considered to be ip-based" do
418
+ @uri.should be_ip_based
419
+ end
420
+
421
+ it "should have a host of 'www.ietf.org'" do
422
+ @uri.host.should == "www.ietf.org"
423
+ end
424
+
425
+ it "should have a path of '/rfc/rfc2396.txt'" do
426
+ @uri.path.should == "/rfc/rfc2396.txt"
427
+ end
428
+
429
+ it "should have a request URI of '/rfc/rfc2396.txt'" do
430
+ @uri.request_uri.should == "/rfc/rfc2396.txt"
431
+ end
432
+
433
+ it "should be considered to be in normal form" do
434
+ @uri.normalize.should be_eql(@uri)
435
+ end
436
+
437
+ it "should correctly omit components" do
438
+ @uri.omit(:scheme).to_s.should == "//www.ietf.org/rfc/rfc2396.txt"
439
+ @uri.omit(:path).to_s.should == "http://www.ietf.org"
440
+ end
441
+
442
+ it "should correctly omit components destructively" do
443
+ @uri.omit!(:scheme)
444
+ @uri.to_s.should == "//www.ietf.org/rfc/rfc2396.txt"
445
+ end
446
+ end
447
+
448
+ # Section 1.1.2 of RFC 3986
449
+ describe Addressable::URI, "when parsed from " +
450
+ "'ldap://[2001:db8::7]/c=GB?objectClass?one'" do
451
+ before do
452
+ @uri = Addressable::URI.parse("ldap://[2001:db8::7]/c=GB?objectClass?one")
453
+ end
454
+
455
+ it "should use the 'ldap' scheme" do
456
+ @uri.scheme.should == "ldap"
457
+ end
458
+
459
+ it "should be considered to be ip-based" do
460
+ @uri.should be_ip_based
461
+ end
462
+
463
+ it "should have a host of '[2001:db8::7]'" do
464
+ @uri.host.should == "[2001:db8::7]"
465
+ end
466
+
467
+ it "should have a path of '/c=GB'" do
468
+ @uri.path.should == "/c=GB"
469
+ end
470
+
471
+ it "should not have a request URI" do
472
+ @uri.request_uri.should == nil
473
+ end
474
+
475
+ it "should not allow request URI assignment" do
476
+ (lambda do
477
+ @uri.request_uri = "/"
478
+ end).should raise_error(Addressable::URI::InvalidURIError)
479
+ end
480
+
481
+ it "should have a query of 'objectClass?one'" do
482
+ @uri.query.should == "objectClass?one"
483
+ end
484
+
485
+ it "should be considered to be in normal form" do
486
+ @uri.normalize.should be_eql(@uri)
487
+ end
488
+
489
+ it "should correctly omit components" do
490
+ @uri.omit(:scheme, :authority).to_s.should == "/c=GB?objectClass?one"
491
+ @uri.omit(:path).to_s.should == "ldap://[2001:db8::7]?objectClass?one"
492
+ end
493
+
494
+ it "should correctly omit components destructively" do
495
+ @uri.omit!(:scheme, :authority)
496
+ @uri.to_s.should == "/c=GB?objectClass?one"
497
+ end
498
+
499
+ it "should raise an error if omission would create an invalid URI" do
500
+ (lambda do
501
+ @uri.omit(:authority, :path)
502
+ end).should raise_error(Addressable::URI::InvalidURIError)
503
+ end
504
+ end
505
+
506
+ # Section 1.1.2 of RFC 3986
507
+ describe Addressable::URI, "when parsed from " +
508
+ "'mailto:John.Doe@example.com'" do
509
+ before do
510
+ @uri = Addressable::URI.parse("mailto:John.Doe@example.com")
511
+ end
512
+
513
+ it "should use the 'mailto' scheme" do
514
+ @uri.scheme.should == "mailto"
515
+ end
516
+
517
+ it "should not be considered to be ip-based" do
518
+ @uri.should_not be_ip_based
519
+ end
520
+
521
+ it "should have a path of 'John.Doe@example.com'" do
522
+ @uri.path.should == "John.Doe@example.com"
523
+ end
524
+
525
+ it "should not have a request URI" do
526
+ @uri.request_uri.should == nil
527
+ end
528
+
529
+ it "should be considered to be in normal form" do
530
+ @uri.normalize.should be_eql(@uri)
531
+ end
532
+ end
533
+
534
+ # Section 1.1.2 of RFC 3986
535
+ describe Addressable::URI, "when parsed from " +
536
+ "'news:comp.infosystems.www.servers.unix'" do
537
+ before do
538
+ @uri = Addressable::URI.parse("news:comp.infosystems.www.servers.unix")
539
+ end
540
+
541
+ it "should use the 'news' scheme" do
542
+ @uri.scheme.should == "news"
543
+ end
544
+
545
+ it "should not be considered to be ip-based" do
546
+ @uri.should_not be_ip_based
547
+ end
548
+
549
+ it "should have a path of 'comp.infosystems.www.servers.unix'" do
550
+ @uri.path.should == "comp.infosystems.www.servers.unix"
551
+ end
552
+
553
+ it "should not have a request URI" do
554
+ @uri.request_uri.should == nil
555
+ end
556
+
557
+ it "should be considered to be in normal form" do
558
+ @uri.normalize.should be_eql(@uri)
559
+ end
560
+ end
561
+
562
+ # Section 1.1.2 of RFC 3986
563
+ describe Addressable::URI, "when parsed from " +
564
+ "'tel:+1-816-555-1212'" do
565
+ before do
566
+ @uri = Addressable::URI.parse("tel:+1-816-555-1212")
567
+ end
568
+
569
+ it "should use the 'tel' scheme" do
570
+ @uri.scheme.should == "tel"
571
+ end
572
+
573
+ it "should not be considered to be ip-based" do
574
+ @uri.should_not be_ip_based
575
+ end
576
+
577
+ it "should have a path of '+1-816-555-1212'" do
578
+ @uri.path.should == "+1-816-555-1212"
579
+ end
580
+
581
+ it "should not have a request URI" do
582
+ @uri.request_uri.should == nil
583
+ end
584
+
585
+ it "should be considered to be in normal form" do
586
+ @uri.normalize.should be_eql(@uri)
587
+ end
588
+ end
589
+
590
+ # Section 1.1.2 of RFC 3986
591
+ describe Addressable::URI, "when parsed from " +
592
+ "'telnet://192.0.2.16:80/'" do
593
+ before do
594
+ @uri = Addressable::URI.parse("telnet://192.0.2.16:80/")
595
+ end
596
+
597
+ it "should use the 'telnet' scheme" do
598
+ @uri.scheme.should == "telnet"
599
+ end
600
+
601
+ it "should have a host of '192.0.2.16'" do
602
+ @uri.host.should == "192.0.2.16"
603
+ end
604
+
605
+ it "should have a port of '80'" do
606
+ @uri.port.should == 80
607
+ end
608
+
609
+ it "should be considered to be ip-based" do
610
+ @uri.should be_ip_based
611
+ end
612
+
613
+ it "should have a path of '/'" do
614
+ @uri.path.should == "/"
615
+ end
616
+
617
+ it "should not have a request URI" do
618
+ @uri.request_uri.should == nil
619
+ end
620
+
621
+ it "should be considered to be in normal form" do
622
+ @uri.normalize.should be_eql(@uri)
623
+ end
624
+ end
625
+
626
+ # Section 1.1.2 of RFC 3986
627
+ describe Addressable::URI, "when parsed from " +
628
+ "'urn:oasis:names:specification:docbook:dtd:xml:4.1.2'" do
629
+ before do
630
+ @uri = Addressable::URI.parse(
631
+ "urn:oasis:names:specification:docbook:dtd:xml:4.1.2")
632
+ end
633
+
634
+ it "should use the 'urn' scheme" do
635
+ @uri.scheme.should == "urn"
636
+ end
637
+
638
+ it "should not be considered to be ip-based" do
639
+ @uri.should_not be_ip_based
640
+ end
641
+
642
+ it "should have a path of " +
643
+ "'oasis:names:specification:docbook:dtd:xml:4.1.2'" do
644
+ @uri.path.should == "oasis:names:specification:docbook:dtd:xml:4.1.2"
645
+ end
646
+
647
+ it "should not have a request URI" do
648
+ @uri.request_uri.should == nil
649
+ end
650
+
651
+ it "should be considered to be in normal form" do
652
+ @uri.normalize.should be_eql(@uri)
653
+ end
654
+ end
655
+
656
+ describe Addressable::URI, "when parsed from " +
657
+ "'http://example.com'" do
658
+ before do
659
+ @uri = Addressable::URI.parse("http://example.com")
660
+ end
661
+
662
+ it "when inspected, should have the correct URI" do
663
+ @uri.inspect.should include("http://example.com")
664
+ end
665
+
666
+ it "when inspected, should have the correct class name" do
667
+ @uri.inspect.should include("Addressable::URI")
668
+ end
669
+
670
+ it "when inspected, should have the correct object id" do
671
+ @uri.inspect.should include("%#0x" % @uri.object_id)
672
+ end
673
+
674
+ it "should use the 'http' scheme" do
675
+ @uri.scheme.should == "http"
676
+ end
677
+
678
+ it "should be considered to be ip-based" do
679
+ @uri.should be_ip_based
680
+ end
681
+
682
+ it "should have an authority segment of 'example.com'" do
683
+ @uri.authority.should == "example.com"
684
+ end
685
+
686
+ it "should have a host of 'example.com'" do
687
+ @uri.host.should == "example.com"
688
+ end
689
+
690
+ it "should be considered ip-based" do
691
+ @uri.should be_ip_based
692
+ end
693
+
694
+ it "should have no username" do
695
+ @uri.user.should == nil
696
+ end
697
+
698
+ it "should have no password" do
699
+ @uri.password.should == nil
700
+ end
701
+
702
+ it "should use port 80" do
703
+ @uri.inferred_port.should == 80
704
+ end
705
+
706
+ it "should not have a specified port" do
707
+ @uri.port.should == nil
708
+ end
709
+
710
+ it "should have an empty path" do
711
+ @uri.path.should == ""
712
+ end
713
+
714
+ it "should have no query string" do
715
+ @uri.query.should == nil
716
+ @uri.query_values.should == nil
717
+ end
718
+
719
+ it "should have a request URI of '/'" do
720
+ @uri.request_uri.should == "/"
721
+ end
722
+
723
+ it "should have no fragment" do
724
+ @uri.fragment.should == nil
725
+ end
726
+
727
+ it "should be considered absolute" do
728
+ @uri.should be_absolute
729
+ end
730
+
731
+ it "should not be considered relative" do
732
+ @uri.should_not be_relative
733
+ end
734
+
735
+ it "should not be exactly equal to 42" do
736
+ @uri.eql?(42).should == false
737
+ end
738
+
739
+ it "should not be equal to 42" do
740
+ (@uri == 42).should == false
741
+ end
742
+
743
+ it "should not be roughly equal to 42" do
744
+ (@uri === 42).should == false
745
+ end
746
+
747
+ it "should be exactly equal to http://example.com" do
748
+ @uri.eql?(Addressable::URI.parse("http://example.com")).should == true
749
+ end
750
+
751
+ it "should be roughly equal to http://example.com/" do
752
+ (@uri === Addressable::URI.parse("http://example.com/")).should == true
753
+ end
754
+
755
+ it "should be roughly equal to the string 'http://example.com/'" do
756
+ (@uri === "http://example.com/").should == true
757
+ end
758
+
759
+ it "should not be roughly equal to the string " +
760
+ "'http://example.com:bogus/'" do
761
+ (lambda do
762
+ (@uri === "http://example.com:bogus/").should == false
763
+ end).should_not raise_error
764
+ end
765
+
766
+ it "should result in itself when joined with itself" do
767
+ @uri.join(@uri).to_s.should == "http://example.com"
768
+ @uri.join!(@uri).to_s.should == "http://example.com"
769
+ end
770
+
771
+ it "should be equivalent to http://EXAMPLE.com" do
772
+ @uri.should == Addressable::URI.parse("http://EXAMPLE.com")
773
+ end
774
+
775
+ it "should be equivalent to http://EXAMPLE.com:80/" do
776
+ @uri.should == Addressable::URI.parse("http://EXAMPLE.com:80/")
777
+ end
778
+
779
+ it "should have the same hash as http://example.com" do
780
+ @uri.hash.should == Addressable::URI.parse("http://example.com").hash
781
+ end
782
+
783
+ it "should have the same hash as http://EXAMPLE.com after assignment" do
784
+ @uri.host = "EXAMPLE.com"
785
+ @uri.hash.should == Addressable::URI.parse("http://EXAMPLE.com").hash
786
+ end
787
+
788
+ it "should have a different hash from http://EXAMPLE.com" do
789
+ @uri.hash.should_not == Addressable::URI.parse("http://EXAMPLE.com").hash
790
+ end
791
+
792
+ # Section 6.2.3 of RFC 3986
793
+ it "should be equivalent to http://example.com/" do
794
+ @uri.should == Addressable::URI.parse("http://example.com/")
795
+ end
796
+
797
+ # Section 6.2.3 of RFC 3986
798
+ it "should be equivalent to http://example.com:/" do
799
+ @uri.should == Addressable::URI.parse("http://example.com:/")
800
+ end
801
+
802
+ # Section 6.2.3 of RFC 3986
803
+ it "should be equivalent to http://example.com:80/" do
804
+ @uri.should == Addressable::URI.parse("http://example.com:80/")
805
+ end
806
+
807
+ # Section 6.2.2.1 of RFC 3986
808
+ it "should be equivalent to http://EXAMPLE.COM/" do
809
+ @uri.should == Addressable::URI.parse("http://EXAMPLE.COM/")
810
+ end
811
+
812
+ it "should have a route of '/path/' to 'http://example.com/path/'" do
813
+ @uri.route_to("http://example.com/path/").should ==
814
+ Addressable::URI.parse("/path/")
815
+ end
816
+
817
+ it "should have a route of '/' from 'http://example.com/path/'" do
818
+ @uri.route_from("http://example.com/path/").should ==
819
+ Addressable::URI.parse("/")
820
+ end
821
+
822
+ it "should have a route of '#' to 'http://example.com/'" do
823
+ @uri.route_to("http://example.com/").should ==
824
+ Addressable::URI.parse("#")
825
+ end
826
+
827
+ it "should have a route of 'http://elsewhere.com/' to " +
828
+ "'http://elsewhere.com/'" do
829
+ @uri.route_to("http://elsewhere.com/").should ==
830
+ Addressable::URI.parse("http://elsewhere.com/")
831
+ end
832
+
833
+ it "when joined with 'relative/path' should be " +
834
+ "'http://example.com/relative/path'" do
835
+ @uri.join('relative/path').should ==
836
+ Addressable::URI.parse("http://example.com/relative/path")
837
+ end
838
+
839
+ it "when joined with a bogus object a TypeError should be raised" do
840
+ (lambda do
841
+ @uri.join(42)
842
+ end).should raise_error(TypeError)
843
+ end
844
+
845
+ it "should have the correct username after assignment" do
846
+ @uri.user = "newuser"
847
+ @uri.user.should == "newuser"
848
+ @uri.password.should == nil
849
+ @uri.to_s.should == "http://newuser@example.com"
850
+ end
851
+
852
+ it "should have the correct username after assignment" do
853
+ @uri.user = "user@123!"
854
+ @uri.user.should == "user@123!"
855
+ @uri.normalized_user.should == "user%40123%21"
856
+ @uri.password.should == nil
857
+ @uri.normalize.to_s.should == "http://user%40123%21@example.com/"
858
+ end
859
+
860
+ it "should have the correct password after assignment" do
861
+ @uri.password = "newpass"
862
+ @uri.password.should == "newpass"
863
+ @uri.user.should == ""
864
+ @uri.to_s.should == "http://:newpass@example.com"
865
+ end
866
+
867
+ it "should have the correct password after assignment" do
868
+ @uri.password = "secret@123!"
869
+ @uri.password.should == "secret@123!"
870
+ @uri.normalized_password.should == "secret%40123%21"
871
+ @uri.user.should == ""
872
+ @uri.normalize.to_s.should == "http://:secret%40123%21@example.com/"
873
+ @uri.omit(:password).to_s.should == "http://example.com"
874
+ end
875
+
876
+ it "should have the correct user/pass after repeated assignment" do
877
+ @uri.user = nil
878
+ @uri.user.should == nil
879
+ @uri.password = "newpass"
880
+ @uri.password.should == "newpass"
881
+ # Username cannot be nil if the password is set
882
+ @uri.user.should == ""
883
+ @uri.to_s.should == "http://:newpass@example.com"
884
+ @uri.user = "newuser"
885
+ @uri.user.should == "newuser"
886
+ @uri.password = nil
887
+ @uri.password.should == nil
888
+ @uri.to_s.should == "http://newuser@example.com"
889
+ @uri.user = "newuser"
890
+ @uri.user.should == "newuser"
891
+ @uri.password = ""
892
+ @uri.password.should == ""
893
+ @uri.to_s.should == "http://newuser:@example.com"
894
+ @uri.password = "newpass"
895
+ @uri.password.should == "newpass"
896
+ @uri.user = nil
897
+ # Username cannot be nil if the password is set
898
+ @uri.user.should == ""
899
+ @uri.to_s.should == "http://:newpass@example.com"
900
+ end
901
+
902
+ it "should have the correct user/pass after userinfo assignment" do
903
+ @uri.user = "newuser"
904
+ @uri.user.should == "newuser"
905
+ @uri.password = "newpass"
906
+ @uri.password.should == "newpass"
907
+ @uri.userinfo = nil
908
+ @uri.userinfo.should == nil
909
+ @uri.user.should == nil
910
+ @uri.password.should == nil
911
+ end
912
+
913
+ it "should correctly convert to a hash" do
914
+ @uri.to_hash.should == {
915
+ :scheme => "http",
916
+ :user => nil,
917
+ :password => nil,
918
+ :host => "example.com",
919
+ :port => nil,
920
+ :path => "",
921
+ :query => nil,
922
+ :fragment => nil
923
+ }
924
+ end
925
+
926
+ it "should be identical to its duplicate" do
927
+ @uri.should == @uri.dup
928
+ end
929
+ end
930
+
931
+ # Section 5.1.2 of RFC 2616
932
+ describe Addressable::URI, "when parsed from " +
933
+ "'http://www.w3.org/pub/WWW/TheProject.html'" do
934
+ before do
935
+ @uri = Addressable::URI.parse("http://www.w3.org/pub/WWW/TheProject.html")
936
+ end
937
+
938
+ it "should have the correct request URI" do
939
+ @uri.request_uri.should == "/pub/WWW/TheProject.html"
940
+ end
941
+
942
+ it "should have the correct request URI after assignment" do
943
+ @uri.request_uri = "/some/where/else.html?query?string"
944
+ @uri.request_uri.should == "/some/where/else.html?query?string"
945
+ @uri.path.should == "/some/where/else.html"
946
+ @uri.query.should == "query?string"
947
+ end
948
+
949
+ it "should have the correct request URI after assignment" do
950
+ @uri.request_uri = "?x=y"
951
+ @uri.request_uri.should == "/?x=y"
952
+ @uri.path.should == "/"
953
+ @uri.query.should == "x=y"
954
+ end
955
+
956
+ it "should raise an error if the site value is set to something bogus" do
957
+ (lambda do
958
+ @uri.site = 42
959
+ end).should raise_error(TypeError)
960
+ end
961
+
962
+ it "should raise an error if the request URI is set to something bogus" do
963
+ (lambda do
964
+ @uri.request_uri = 42
965
+ end).should raise_error(TypeError)
966
+ end
967
+
968
+ it "should correctly convert to a hash" do
969
+ @uri.to_hash.should == {
970
+ :scheme => "http",
971
+ :user => nil,
972
+ :password => nil,
973
+ :host => "www.w3.org",
974
+ :port => nil,
975
+ :path => "/pub/WWW/TheProject.html",
976
+ :query => nil,
977
+ :fragment => nil
978
+ }
979
+ end
980
+ end
981
+
982
+ describe Addressable::URI, "when parsed from " +
983
+ "'http://example.com/'" do
984
+ before do
985
+ @uri = Addressable::URI.parse("http://example.com/")
986
+ end
987
+
988
+ # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
989
+ it "should be equivalent to http://example.com" do
990
+ @uri.should == Addressable::URI.parse("http://example.com")
991
+ end
992
+
993
+ # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
994
+ it "should be equivalent to HTTP://example.com/" do
995
+ @uri.should == Addressable::URI.parse("HTTP://example.com/")
996
+ end
997
+
998
+ # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
999
+ it "should be equivalent to http://example.com:/" do
1000
+ @uri.should == Addressable::URI.parse("http://example.com:/")
1001
+ end
1002
+
1003
+ # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
1004
+ it "should be equivalent to http://example.com:80/" do
1005
+ @uri.should == Addressable::URI.parse("http://example.com:80/")
1006
+ end
1007
+
1008
+ # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
1009
+ it "should be equivalent to http://Example.com/" do
1010
+ @uri.should == Addressable::URI.parse("http://Example.com/")
1011
+ end
1012
+
1013
+ it "should have the correct username after assignment" do
1014
+ @uri.user = nil
1015
+ @uri.user.should == nil
1016
+ @uri.password.should == nil
1017
+ @uri.to_s.should == "http://example.com/"
1018
+ end
1019
+
1020
+ it "should have the correct password after assignment" do
1021
+ @uri.password = nil
1022
+ @uri.password.should == nil
1023
+ @uri.user.should == nil
1024
+ @uri.to_s.should == "http://example.com/"
1025
+ end
1026
+
1027
+ it "should have a request URI of '/'" do
1028
+ @uri.request_uri.should == "/"
1029
+ end
1030
+
1031
+ it "should correctly convert to a hash" do
1032
+ @uri.to_hash.should == {
1033
+ :scheme => "http",
1034
+ :user => nil,
1035
+ :password => nil,
1036
+ :host => "example.com",
1037
+ :port => nil,
1038
+ :path => "/",
1039
+ :query => nil,
1040
+ :fragment => nil
1041
+ }
1042
+ end
1043
+
1044
+ it "should be identical to its duplicate" do
1045
+ @uri.should == @uri.dup
1046
+ end
1047
+
1048
+ it "should have the same hash as its duplicate" do
1049
+ @uri.hash.should == @uri.dup.hash
1050
+ end
1051
+
1052
+ it "should have a different hash from its equivalent String value" do
1053
+ @uri.hash.should_not == @uri.to_s.hash
1054
+ end
1055
+
1056
+ it "should have the same hash as an equal URI" do
1057
+ @uri.hash.should == Addressable::URI.parse("http://example.com/").hash
1058
+ end
1059
+
1060
+ it "should be equivalent to http://EXAMPLE.com" do
1061
+ @uri.should == Addressable::URI.parse("http://EXAMPLE.com")
1062
+ end
1063
+
1064
+ it "should be equivalent to http://EXAMPLE.com:80/" do
1065
+ @uri.should == Addressable::URI.parse("http://EXAMPLE.com:80/")
1066
+ end
1067
+
1068
+ it "should have the same hash as http://example.com/" do
1069
+ @uri.hash.should == Addressable::URI.parse("http://example.com/").hash
1070
+ end
1071
+
1072
+ it "should have the same hash as http://example.com after assignment" do
1073
+ @uri.path = ""
1074
+ @uri.hash.should == Addressable::URI.parse("http://example.com").hash
1075
+ end
1076
+
1077
+ it "should have the same hash as http://example.com/? after assignment" do
1078
+ @uri.query = ""
1079
+ @uri.hash.should == Addressable::URI.parse("http://example.com/?").hash
1080
+ end
1081
+
1082
+ it "should have the same hash as http://example.com/? after assignment" do
1083
+ @uri.query_values = {}
1084
+ @uri.hash.should == Addressable::URI.parse("http://example.com/?").hash
1085
+ end
1086
+
1087
+ it "should have the same hash as http://example.com/# after assignment" do
1088
+ @uri.fragment = ""
1089
+ @uri.hash.should == Addressable::URI.parse("http://example.com/#").hash
1090
+ end
1091
+
1092
+ it "should have a different hash from http://example.com" do
1093
+ @uri.hash.should_not == Addressable::URI.parse("http://example.com").hash
1094
+ end
1095
+ end
1096
+
1097
+ describe Addressable::URI, "when parsed from " +
1098
+ "'http://@example.com/'" do
1099
+ before do
1100
+ @uri = Addressable::URI.parse("http://@example.com/")
1101
+ end
1102
+
1103
+ it "should be equivalent to http://example.com" do
1104
+ @uri.should == Addressable::URI.parse("http://example.com")
1105
+ end
1106
+
1107
+ it "should correctly convert to a hash" do
1108
+ @uri.to_hash.should == {
1109
+ :scheme => "http",
1110
+ :user => "",
1111
+ :password => nil,
1112
+ :host => "example.com",
1113
+ :port => nil,
1114
+ :path => "/",
1115
+ :query => nil,
1116
+ :fragment => nil
1117
+ }
1118
+ end
1119
+
1120
+ it "should be identical to its duplicate" do
1121
+ @uri.should == @uri.dup
1122
+ end
1123
+ end
1124
+
1125
+ describe Addressable::URI, "when parsed from " +
1126
+ "'http://example.com./'" do
1127
+ before do
1128
+ @uri = Addressable::URI.parse("http://example.com./")
1129
+ end
1130
+
1131
+ it "should be equivalent to http://example.com" do
1132
+ @uri.should == Addressable::URI.parse("http://example.com")
1133
+ end
1134
+
1135
+ it "should not be considered to be in normal form" do
1136
+ @uri.normalize.should_not be_eql(@uri)
1137
+ end
1138
+
1139
+ it "should be identical to its duplicate" do
1140
+ @uri.should == @uri.dup
1141
+ end
1142
+ end
1143
+
1144
+ describe Addressable::URI, "when parsed from " +
1145
+ "'http://:@example.com/'" do
1146
+ before do
1147
+ @uri = Addressable::URI.parse("http://:@example.com/")
1148
+ end
1149
+
1150
+ it "should be equivalent to http://example.com" do
1151
+ @uri.should == Addressable::URI.parse("http://example.com")
1152
+ end
1153
+
1154
+ it "should correctly convert to a hash" do
1155
+ @uri.to_hash.should == {
1156
+ :scheme => "http",
1157
+ :user => "",
1158
+ :password => "",
1159
+ :host => "example.com",
1160
+ :port => nil,
1161
+ :path => "/",
1162
+ :query => nil,
1163
+ :fragment => nil
1164
+ }
1165
+ end
1166
+
1167
+ it "should be identical to its duplicate" do
1168
+ @uri.should == @uri.dup
1169
+ end
1170
+ end
1171
+
1172
+ describe Addressable::URI, "when parsed from " +
1173
+ "'http://example.com/~smith/'" do
1174
+ before do
1175
+ @uri = Addressable::URI.parse("http://example.com/~smith/")
1176
+ end
1177
+
1178
+ # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
1179
+ it "should be equivalent to http://example.com/%7Esmith/" do
1180
+ @uri.should == Addressable::URI.parse("http://example.com/%7Esmith/")
1181
+ end
1182
+
1183
+ # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
1184
+ it "should be equivalent to http://example.com/%7esmith/" do
1185
+ @uri.should == Addressable::URI.parse("http://example.com/%7esmith/")
1186
+ end
1187
+
1188
+ it "should be identical to its duplicate" do
1189
+ @uri.should == @uri.dup
1190
+ end
1191
+ end
1192
+
1193
+ describe Addressable::URI, "when parsed from " +
1194
+ "'http://example.com/%E8'" do
1195
+ before do
1196
+ @uri = Addressable::URI.parse("http://example.com/%E8")
1197
+ end
1198
+
1199
+ it "should not raise an exception when normalized" do
1200
+ (lambda do
1201
+ @uri.normalize
1202
+ end).should_not raise_error(ArgumentError)
1203
+ end
1204
+
1205
+ it "should be considered to be in normal form" do
1206
+ @uri.normalize.should be_eql(@uri)
1207
+ end
1208
+
1209
+ it "should not change if encoded with the normalizing algorithm" do
1210
+ Addressable::URI.normalized_encode(@uri).to_s.should ==
1211
+ "http://example.com/%E8"
1212
+ Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s.should ===
1213
+ "http://example.com/%E8"
1214
+ end
1215
+ end
1216
+
1217
+ describe Addressable::URI, "when parsed from " +
1218
+ "'http://example.com/path%2Fsegment/'" do
1219
+ before do
1220
+ @uri = Addressable::URI.parse("http://example.com/path%2Fsegment/")
1221
+ end
1222
+
1223
+ it "should be considered to be in normal form" do
1224
+ @uri.normalize.should be_eql(@uri)
1225
+ end
1226
+
1227
+ it "should be equal to 'http://example.com/path%2Fsegment/'" do
1228
+ @uri.normalize.should be_eql(
1229
+ Addressable::URI.parse("http://example.com/path%2Fsegment/")
1230
+ )
1231
+ end
1232
+
1233
+ it "should not be equal to 'http://example.com/path/segment/'" do
1234
+ @uri.should_not ==
1235
+ Addressable::URI.parse("http://example.com/path/segment/")
1236
+ end
1237
+
1238
+ it "should not be equal to 'http://example.com/path/segment/'" do
1239
+ @uri.normalize.should_not be_eql(
1240
+ Addressable::URI.parse("http://example.com/path/segment/")
1241
+ )
1242
+ end
1243
+ end
1244
+
1245
+ describe Addressable::URI, "when parsed from " +
1246
+ "'http://example.com/?%F6'" do
1247
+ before do
1248
+ @uri = Addressable::URI.parse("http://example.com/?%F6")
1249
+ end
1250
+
1251
+ it "should not raise an exception when normalized" do
1252
+ (lambda do
1253
+ @uri.normalize
1254
+ end).should_not raise_error(ArgumentError)
1255
+ end
1256
+
1257
+ it "should be considered to be in normal form" do
1258
+ @uri.normalize.should be_eql(@uri)
1259
+ end
1260
+
1261
+ it "should not change if encoded with the normalizing algorithm" do
1262
+ Addressable::URI.normalized_encode(@uri).to_s.should ==
1263
+ "http://example.com/?%F6"
1264
+ Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s.should ===
1265
+ "http://example.com/?%F6"
1266
+ end
1267
+ end
1268
+
1269
+ describe Addressable::URI, "when parsed from " +
1270
+ "'http://example.com/#%F6'" do
1271
+ before do
1272
+ @uri = Addressable::URI.parse("http://example.com/#%F6")
1273
+ end
1274
+
1275
+ it "should not raise an exception when normalized" do
1276
+ (lambda do
1277
+ @uri.normalize
1278
+ end).should_not raise_error(ArgumentError)
1279
+ end
1280
+
1281
+ it "should be considered to be in normal form" do
1282
+ @uri.normalize.should be_eql(@uri)
1283
+ end
1284
+
1285
+ it "should not change if encoded with the normalizing algorithm" do
1286
+ Addressable::URI.normalized_encode(@uri).to_s.should ==
1287
+ "http://example.com/#%F6"
1288
+ Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s.should ===
1289
+ "http://example.com/#%F6"
1290
+ end
1291
+ end
1292
+
1293
+ describe Addressable::URI, "when parsed from " +
1294
+ "'http://example.com/%C3%87'" do
1295
+ before do
1296
+ @uri = Addressable::URI.parse("http://example.com/%C3%87")
1297
+ end
1298
+
1299
+ # Based on http://intertwingly.net/blog/2004/07/31/URI-Equivalence
1300
+ it "should be equivalent to 'http://example.com/C%CC%A7'" do
1301
+ @uri.should == Addressable::URI.parse("http://example.com/C%CC%A7")
1302
+ end
1303
+
1304
+ it "should not change if encoded with the normalizing algorithm" do
1305
+ Addressable::URI.normalized_encode(@uri).to_s.should ==
1306
+ "http://example.com/%C3%87"
1307
+ Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s.should ===
1308
+ "http://example.com/%C3%87"
1309
+ end
1310
+
1311
+ it "should raise an error if encoding with an unexpected return type" do
1312
+ (lambda do
1313
+ Addressable::URI.normalized_encode(@uri, Integer)
1314
+ end).should raise_error(TypeError)
1315
+ end
1316
+
1317
+ it "if percent encoded should be 'http://example.com/C%25CC%25A7'" do
1318
+ Addressable::URI.encode(@uri).to_s.should ==
1319
+ "http://example.com/%25C3%2587"
1320
+ end
1321
+
1322
+ it "if percent encoded should be 'http://example.com/C%25CC%25A7'" do
1323
+ Addressable::URI.encode(@uri, Addressable::URI).should ==
1324
+ Addressable::URI.parse("http://example.com/%25C3%2587")
1325
+ end
1326
+
1327
+ it "should raise an error if encoding with an unexpected return type" do
1328
+ (lambda do
1329
+ Addressable::URI.encode(@uri, Integer)
1330
+ end).should raise_error(TypeError)
1331
+ end
1332
+
1333
+ it "should be identical to its duplicate" do
1334
+ @uri.should == @uri.dup
1335
+ end
1336
+ end
1337
+
1338
+ describe Addressable::URI, "when parsed from " +
1339
+ "'http://example.com/?q=string'" do
1340
+ before do
1341
+ @uri = Addressable::URI.parse("http://example.com/?q=string")
1342
+ end
1343
+
1344
+ it "should use the 'http' scheme" do
1345
+ @uri.scheme.should == "http"
1346
+ end
1347
+
1348
+ it "should have an authority segment of 'example.com'" do
1349
+ @uri.authority.should == "example.com"
1350
+ end
1351
+
1352
+ it "should have a host of 'example.com'" do
1353
+ @uri.host.should == "example.com"
1354
+ end
1355
+
1356
+ it "should have no username" do
1357
+ @uri.user.should == nil
1358
+ end
1359
+
1360
+ it "should have no password" do
1361
+ @uri.password.should == nil
1362
+ end
1363
+
1364
+ it "should use port 80" do
1365
+ @uri.inferred_port.should == 80
1366
+ end
1367
+
1368
+ it "should have a path of '/'" do
1369
+ @uri.path.should == "/"
1370
+ end
1371
+
1372
+ it "should have a query string of 'q=string'" do
1373
+ @uri.query.should == "q=string"
1374
+ end
1375
+
1376
+ it "should have no fragment" do
1377
+ @uri.fragment.should == nil
1378
+ end
1379
+
1380
+ it "should be considered absolute" do
1381
+ @uri.should be_absolute
1382
+ end
1383
+
1384
+ it "should not be considered relative" do
1385
+ @uri.should_not be_relative
1386
+ end
1387
+
1388
+ it "should be considered to be in normal form" do
1389
+ @uri.normalize.should be_eql(@uri)
1390
+ end
1391
+
1392
+ it "should be identical to its duplicate" do
1393
+ @uri.should == @uri.dup
1394
+ end
1395
+ end
1396
+
1397
+ describe Addressable::URI, "when parsed from " +
1398
+ "'http://example.com:80/'" do
1399
+ before do
1400
+ @uri = Addressable::URI.parse("http://example.com:80/")
1401
+ end
1402
+
1403
+ it "should use the 'http' scheme" do
1404
+ @uri.scheme.should == "http"
1405
+ end
1406
+
1407
+ it "should have an authority segment of 'example.com:80'" do
1408
+ @uri.authority.should == "example.com:80"
1409
+ end
1410
+
1411
+ it "should have a host of 'example.com'" do
1412
+ @uri.host.should == "example.com"
1413
+ end
1414
+
1415
+ it "should have no username" do
1416
+ @uri.user.should == nil
1417
+ end
1418
+
1419
+ it "should have no password" do
1420
+ @uri.password.should == nil
1421
+ end
1422
+
1423
+ it "should use port 80" do
1424
+ @uri.port.should == 80
1425
+ end
1426
+
1427
+ it "should have a path of '/'" do
1428
+ @uri.path.should == "/"
1429
+ end
1430
+
1431
+ it "should have no query string" do
1432
+ @uri.query.should == nil
1433
+ end
1434
+
1435
+ it "should have no fragment" do
1436
+ @uri.fragment.should == nil
1437
+ end
1438
+
1439
+ it "should be considered absolute" do
1440
+ @uri.should be_absolute
1441
+ end
1442
+
1443
+ it "should not be considered relative" do
1444
+ @uri.should_not be_relative
1445
+ end
1446
+
1447
+ it "should be exactly equal to http://example.com:80/" do
1448
+ @uri.eql?(Addressable::URI.parse("http://example.com:80/")).should == true
1449
+ end
1450
+
1451
+ it "should be roughly equal to http://example.com/" do
1452
+ (@uri === Addressable::URI.parse("http://example.com/")).should == true
1453
+ end
1454
+
1455
+ it "should be roughly equal to the string 'http://example.com/'" do
1456
+ (@uri === "http://example.com/").should == true
1457
+ end
1458
+
1459
+ it "should not be roughly equal to the string " +
1460
+ "'http://example.com:bogus/'" do
1461
+ (lambda do
1462
+ (@uri === "http://example.com:bogus/").should == false
1463
+ end).should_not raise_error
1464
+ end
1465
+
1466
+ it "should result in itself when joined with itself" do
1467
+ @uri.join(@uri).to_s.should == "http://example.com:80/"
1468
+ @uri.join!(@uri).to_s.should == "http://example.com:80/"
1469
+ end
1470
+
1471
+ # Section 6.2.3 of RFC 3986
1472
+ it "should be equal to http://example.com/" do
1473
+ @uri.should == Addressable::URI.parse("http://example.com/")
1474
+ end
1475
+
1476
+ # Section 6.2.3 of RFC 3986
1477
+ it "should be equal to http://example.com:/" do
1478
+ @uri.should == Addressable::URI.parse("http://example.com:/")
1479
+ end
1480
+
1481
+ # Section 6.2.3 of RFC 3986
1482
+ it "should be equal to http://example.com:80/" do
1483
+ @uri.should == Addressable::URI.parse("http://example.com:80/")
1484
+ end
1485
+
1486
+ # Section 6.2.2.1 of RFC 3986
1487
+ it "should be equal to http://EXAMPLE.COM/" do
1488
+ @uri.should == Addressable::URI.parse("http://EXAMPLE.COM/")
1489
+ end
1490
+
1491
+ it "should correctly convert to a hash" do
1492
+ @uri.to_hash.should == {
1493
+ :scheme => "http",
1494
+ :user => nil,
1495
+ :password => nil,
1496
+ :host => "example.com",
1497
+ :port => 80,
1498
+ :path => "/",
1499
+ :query => nil,
1500
+ :fragment => nil
1501
+ }
1502
+ end
1503
+
1504
+ it "should be identical to its duplicate" do
1505
+ @uri.should == @uri.dup
1506
+ end
1507
+ end
1508
+
1509
+ describe Addressable::URI, "when parsed from " +
1510
+ "'http://example.com:8080/'" do
1511
+ before do
1512
+ @uri = Addressable::URI.parse("http://example.com:8080/")
1513
+ end
1514
+
1515
+ it "should use the 'http' scheme" do
1516
+ @uri.scheme.should == "http"
1517
+ end
1518
+
1519
+ it "should have an authority segment of 'example.com:8080'" do
1520
+ @uri.authority.should == "example.com:8080"
1521
+ end
1522
+
1523
+ it "should have a host of 'example.com'" do
1524
+ @uri.host.should == "example.com"
1525
+ end
1526
+
1527
+ it "should have no username" do
1528
+ @uri.user.should == nil
1529
+ end
1530
+
1531
+ it "should have no password" do
1532
+ @uri.password.should == nil
1533
+ end
1534
+
1535
+ it "should use port 8080" do
1536
+ @uri.port.should == 8080
1537
+ end
1538
+
1539
+ it "should have a path of '/'" do
1540
+ @uri.path.should == "/"
1541
+ end
1542
+
1543
+ it "should have no query string" do
1544
+ @uri.query.should == nil
1545
+ end
1546
+
1547
+ it "should have no fragment" do
1548
+ @uri.fragment.should == nil
1549
+ end
1550
+
1551
+ it "should be considered absolute" do
1552
+ @uri.should be_absolute
1553
+ end
1554
+
1555
+ it "should not be considered relative" do
1556
+ @uri.should_not be_relative
1557
+ end
1558
+
1559
+ it "should be exactly equal to http://example.com:8080/" do
1560
+ @uri.eql?(Addressable::URI.parse(
1561
+ "http://example.com:8080/")).should == true
1562
+ end
1563
+
1564
+ it "should have a route of 'http://example.com:8080/' from " +
1565
+ "'http://example.com/path/to/'" do
1566
+ @uri.route_from("http://example.com/path/to/").should ==
1567
+ Addressable::URI.parse("http://example.com:8080/")
1568
+ end
1569
+
1570
+ it "should have a route of 'http://example.com:8080/' from " +
1571
+ "'http://example.com:80/path/to/'" do
1572
+ @uri.route_from("http://example.com:80/path/to/").should ==
1573
+ Addressable::URI.parse("http://example.com:8080/")
1574
+ end
1575
+
1576
+ it "should have a route of '/' from " +
1577
+ "'http://example.com:8080/path/to/'" do
1578
+ @uri.route_from("http://example.com:8080/path/to/").should ==
1579
+ Addressable::URI.parse("/")
1580
+ end
1581
+
1582
+ it "should have a route of 'http://example.com:8080/' from " +
1583
+ "'http://user:pass@example.com/path/to/'" do
1584
+ @uri.route_from("http://user:pass@example.com/path/to/").should ==
1585
+ Addressable::URI.parse("http://example.com:8080/")
1586
+ end
1587
+
1588
+ it "should correctly convert to a hash" do
1589
+ @uri.to_hash.should == {
1590
+ :scheme => "http",
1591
+ :user => nil,
1592
+ :password => nil,
1593
+ :host => "example.com",
1594
+ :port => 8080,
1595
+ :path => "/",
1596
+ :query => nil,
1597
+ :fragment => nil
1598
+ }
1599
+ end
1600
+
1601
+ it "should be identical to its duplicate" do
1602
+ @uri.should == @uri.dup
1603
+ end
1604
+ end
1605
+
1606
+ describe Addressable::URI, "when parsed from " +
1607
+ "'http://example.com:%38%30/'" do
1608
+ before do
1609
+ @uri = Addressable::URI.parse("http://example.com:%38%30/")
1610
+ end
1611
+
1612
+ it "should have the correct port" do
1613
+ @uri.port.should == 80
1614
+ end
1615
+
1616
+ it "should not be considered to be in normal form" do
1617
+ @uri.normalize.should_not be_eql(@uri)
1618
+ end
1619
+
1620
+ it "should normalize to 'http://example.com/'" do
1621
+ @uri.normalize.should === "http://example.com/"
1622
+ end
1623
+ end
1624
+
1625
+ describe Addressable::URI, "when parsed from " +
1626
+ "'http://example.com/path/to/resource/'" do
1627
+ before do
1628
+ @uri = Addressable::URI.parse("http://example.com/path/to/resource/")
1629
+ end
1630
+
1631
+ it "should use the 'http' scheme" do
1632
+ @uri.scheme.should == "http"
1633
+ end
1634
+
1635
+ it "should have an authority segment of 'example.com'" do
1636
+ @uri.authority.should == "example.com"
1637
+ end
1638
+
1639
+ it "should have a host of 'example.com'" do
1640
+ @uri.host.should == "example.com"
1641
+ end
1642
+
1643
+ it "should have no username" do
1644
+ @uri.user.should == nil
1645
+ end
1646
+
1647
+ it "should have no password" do
1648
+ @uri.password.should == nil
1649
+ end
1650
+
1651
+ it "should use port 80" do
1652
+ @uri.inferred_port.should == 80
1653
+ end
1654
+
1655
+ it "should have a path of '/path/to/resource/'" do
1656
+ @uri.path.should == "/path/to/resource/"
1657
+ end
1658
+
1659
+ it "should have no query string" do
1660
+ @uri.query.should == nil
1661
+ end
1662
+
1663
+ it "should have no fragment" do
1664
+ @uri.fragment.should == nil
1665
+ end
1666
+
1667
+ it "should be considered absolute" do
1668
+ @uri.should be_absolute
1669
+ end
1670
+
1671
+ it "should not be considered relative" do
1672
+ @uri.should_not be_relative
1673
+ end
1674
+
1675
+ it "should be exactly equal to http://example.com:8080/" do
1676
+ @uri.eql?(Addressable::URI.parse(
1677
+ "http://example.com/path/to/resource/")).should == true
1678
+ end
1679
+
1680
+ it "should have a route of 'resource/' from " +
1681
+ "'http://example.com/path/to/'" do
1682
+ @uri.route_from("http://example.com/path/to/").should ==
1683
+ Addressable::URI.parse("resource/")
1684
+ end
1685
+
1686
+ it "should have a route of 'resource/' from " +
1687
+ "'http://example.com:80/path/to/'" do
1688
+ @uri.route_from("http://example.com:80/path/to/").should ==
1689
+ Addressable::URI.parse("resource/")
1690
+ end
1691
+
1692
+ it "should have a route of 'http://example.com/path/to/' from " +
1693
+ "'http://example.com:8080/path/to/'" do
1694
+ @uri.route_from("http://example.com:8080/path/to/").should ==
1695
+ Addressable::URI.parse("http://example.com/path/to/resource/")
1696
+ end
1697
+
1698
+ it "should have a route of 'http://example.com/path/to/' from " +
1699
+ "'http://user:pass@example.com/path/to/'" do
1700
+ @uri.route_from("http://user:pass@example.com/path/to/").should ==
1701
+ Addressable::URI.parse("http://example.com/path/to/resource/")
1702
+ end
1703
+
1704
+ it "should have a route of '/path/to/resource/' from " +
1705
+ "'http://example.com/to/resource/'" do
1706
+ @uri.route_from("http://example.com/to/resource/").should ==
1707
+ Addressable::URI.parse("/path/to/resource/")
1708
+ end
1709
+
1710
+ it "should correctly convert to a hash" do
1711
+ @uri.to_hash.should == {
1712
+ :scheme => "http",
1713
+ :user => nil,
1714
+ :password => nil,
1715
+ :host => "example.com",
1716
+ :port => nil,
1717
+ :path => "/path/to/resource/",
1718
+ :query => nil,
1719
+ :fragment => nil
1720
+ }
1721
+ end
1722
+
1723
+ it "should be identical to its duplicate" do
1724
+ @uri.should == @uri.dup
1725
+ end
1726
+ end
1727
+
1728
+ describe Addressable::URI, "when parsed from " +
1729
+ "'relative/path/to/resource'" do
1730
+ before do
1731
+ @uri = Addressable::URI.parse("relative/path/to/resource")
1732
+ end
1733
+
1734
+ it "should not have a scheme" do
1735
+ @uri.scheme.should == nil
1736
+ end
1737
+
1738
+ it "should not be considered ip-based" do
1739
+ @uri.should_not be_ip_based
1740
+ end
1741
+
1742
+ it "should not have an authority segment" do
1743
+ @uri.authority.should == nil
1744
+ end
1745
+
1746
+ it "should not have a host" do
1747
+ @uri.host.should == nil
1748
+ end
1749
+
1750
+ it "should have no username" do
1751
+ @uri.user.should == nil
1752
+ end
1753
+
1754
+ it "should have no password" do
1755
+ @uri.password.should == nil
1756
+ end
1757
+
1758
+ it "should not have a port" do
1759
+ @uri.port.should == nil
1760
+ end
1761
+
1762
+ it "should have a path of 'relative/path/to/resource'" do
1763
+ @uri.path.should == "relative/path/to/resource"
1764
+ end
1765
+
1766
+ it "should have no query string" do
1767
+ @uri.query.should == nil
1768
+ end
1769
+
1770
+ it "should have no fragment" do
1771
+ @uri.fragment.should == nil
1772
+ end
1773
+
1774
+ it "should not be considered absolute" do
1775
+ @uri.should_not be_absolute
1776
+ end
1777
+
1778
+ it "should be considered relative" do
1779
+ @uri.should be_relative
1780
+ end
1781
+
1782
+ it "should raise an error if routing is attempted" do
1783
+ (lambda do
1784
+ @uri.route_to("http://example.com/")
1785
+ end).should raise_error(ArgumentError, /relative\/path\/to\/resource/)
1786
+ (lambda do
1787
+ @uri.route_from("http://example.com/")
1788
+ end).should raise_error(ArgumentError, /relative\/path\/to\/resource/)
1789
+ end
1790
+
1791
+ it "when joined with 'another/relative/path' should be " +
1792
+ "'relative/path/to/another/relative/path'" do
1793
+ @uri.join('another/relative/path').should ==
1794
+ Addressable::URI.parse("relative/path/to/another/relative/path")
1795
+ end
1796
+
1797
+ it "should be identical to its duplicate" do
1798
+ @uri.should == @uri.dup
1799
+ end
1800
+ end
1801
+
1802
+ describe Addressable::URI, "when parsed from " +
1803
+ "'relative_path_with_no_slashes'" do
1804
+ before do
1805
+ @uri = Addressable::URI.parse("relative_path_with_no_slashes")
1806
+ end
1807
+
1808
+ it "should not have a scheme" do
1809
+ @uri.scheme.should == nil
1810
+ end
1811
+
1812
+ it "should not be considered ip-based" do
1813
+ @uri.should_not be_ip_based
1814
+ end
1815
+
1816
+ it "should not have an authority segment" do
1817
+ @uri.authority.should == nil
1818
+ end
1819
+
1820
+ it "should not have a host" do
1821
+ @uri.host.should == nil
1822
+ end
1823
+
1824
+ it "should have no username" do
1825
+ @uri.user.should == nil
1826
+ end
1827
+
1828
+ it "should have no password" do
1829
+ @uri.password.should == nil
1830
+ end
1831
+
1832
+ it "should not have a port" do
1833
+ @uri.port.should == nil
1834
+ end
1835
+
1836
+ it "should have a path of 'relative_path_with_no_slashes'" do
1837
+ @uri.path.should == "relative_path_with_no_slashes"
1838
+ end
1839
+
1840
+ it "should have no query string" do
1841
+ @uri.query.should == nil
1842
+ end
1843
+
1844
+ it "should have no fragment" do
1845
+ @uri.fragment.should == nil
1846
+ end
1847
+
1848
+ it "should not be considered absolute" do
1849
+ @uri.should_not be_absolute
1850
+ end
1851
+
1852
+ it "should be considered relative" do
1853
+ @uri.should be_relative
1854
+ end
1855
+
1856
+ it "when joined with 'another_relative_path' should be " +
1857
+ "'another_relative_path'" do
1858
+ @uri.join('another_relative_path').should ==
1859
+ Addressable::URI.parse("another_relative_path")
1860
+ end
1861
+ end
1862
+
1863
+ describe Addressable::URI, "when parsed from " +
1864
+ "'http://example.com/file.txt'" do
1865
+ before do
1866
+ @uri = Addressable::URI.parse("http://example.com/file.txt")
1867
+ end
1868
+
1869
+ it "should have a scheme of 'http'" do
1870
+ @uri.scheme.should == "http"
1871
+ end
1872
+
1873
+ it "should have an authority segment of 'example.com'" do
1874
+ @uri.authority.should == "example.com"
1875
+ end
1876
+
1877
+ it "should have a host of 'example.com'" do
1878
+ @uri.host.should == "example.com"
1879
+ end
1880
+
1881
+ it "should have no username" do
1882
+ @uri.user.should == nil
1883
+ end
1884
+
1885
+ it "should have no password" do
1886
+ @uri.password.should == nil
1887
+ end
1888
+
1889
+ it "should use port 80" do
1890
+ @uri.inferred_port.should == 80
1891
+ end
1892
+
1893
+ it "should have a path of '/file.txt'" do
1894
+ @uri.path.should == "/file.txt"
1895
+ end
1896
+
1897
+ it "should have a basename of 'file.txt'" do
1898
+ @uri.basename.should == "file.txt"
1899
+ end
1900
+
1901
+ it "should have an extname of '.txt'" do
1902
+ @uri.extname.should == ".txt"
1903
+ end
1904
+
1905
+ it "should have no query string" do
1906
+ @uri.query.should == nil
1907
+ end
1908
+
1909
+ it "should have no fragment" do
1910
+ @uri.fragment.should == nil
1911
+ end
1912
+ end
1913
+
1914
+ describe Addressable::URI, "when parsed from " +
1915
+ "'http://example.com/file.txt;parameter'" do
1916
+ before do
1917
+ @uri = Addressable::URI.parse("http://example.com/file.txt;parameter")
1918
+ end
1919
+
1920
+ it "should have a scheme of 'http'" do
1921
+ @uri.scheme.should == "http"
1922
+ end
1923
+
1924
+ it "should have an authority segment of 'example.com'" do
1925
+ @uri.authority.should == "example.com"
1926
+ end
1927
+
1928
+ it "should have a host of 'example.com'" do
1929
+ @uri.host.should == "example.com"
1930
+ end
1931
+
1932
+ it "should have no username" do
1933
+ @uri.user.should == nil
1934
+ end
1935
+
1936
+ it "should have no password" do
1937
+ @uri.password.should == nil
1938
+ end
1939
+
1940
+ it "should use port 80" do
1941
+ @uri.inferred_port.should == 80
1942
+ end
1943
+
1944
+ it "should have a path of '/file.txt;parameter'" do
1945
+ @uri.path.should == "/file.txt;parameter"
1946
+ end
1947
+
1948
+ it "should have a basename of 'file.txt'" do
1949
+ @uri.basename.should == "file.txt"
1950
+ end
1951
+
1952
+ it "should have an extname of '.txt'" do
1953
+ @uri.extname.should == ".txt"
1954
+ end
1955
+
1956
+ it "should have no query string" do
1957
+ @uri.query.should == nil
1958
+ end
1959
+
1960
+ it "should have no fragment" do
1961
+ @uri.fragment.should == nil
1962
+ end
1963
+ end
1964
+
1965
+ describe Addressable::URI, "when parsed from " +
1966
+ "'http://example.com/file.txt;x=y'" do
1967
+ before do
1968
+ @uri = Addressable::URI.parse("http://example.com/file.txt;x=y")
1969
+ end
1970
+
1971
+ it "should have a scheme of 'http'" do
1972
+ @uri.scheme.should == "http"
1973
+ end
1974
+
1975
+ it "should have a scheme of 'http'" do
1976
+ @uri.scheme.should == "http"
1977
+ end
1978
+
1979
+ it "should have an authority segment of 'example.com'" do
1980
+ @uri.authority.should == "example.com"
1981
+ end
1982
+
1983
+ it "should have a host of 'example.com'" do
1984
+ @uri.host.should == "example.com"
1985
+ end
1986
+
1987
+ it "should have no username" do
1988
+ @uri.user.should == nil
1989
+ end
1990
+
1991
+ it "should have no password" do
1992
+ @uri.password.should == nil
1993
+ end
1994
+
1995
+ it "should use port 80" do
1996
+ @uri.inferred_port.should == 80
1997
+ end
1998
+
1999
+ it "should have a path of '/file.txt;x=y'" do
2000
+ @uri.path.should == "/file.txt;x=y"
2001
+ end
2002
+
2003
+ it "should have an extname of '.txt'" do
2004
+ @uri.extname.should == ".txt"
2005
+ end
2006
+
2007
+ it "should have no query string" do
2008
+ @uri.query.should == nil
2009
+ end
2010
+
2011
+ it "should have no fragment" do
2012
+ @uri.fragment.should == nil
2013
+ end
2014
+
2015
+ it "should be considered to be in normal form" do
2016
+ @uri.normalize.should be_eql(@uri)
2017
+ end
2018
+ end
2019
+
2020
+ describe Addressable::URI, "when parsed from " +
2021
+ "'svn+ssh://developername@rubyforge.org/var/svn/project'" do
2022
+ before do
2023
+ @uri = Addressable::URI.parse(
2024
+ "svn+ssh://developername@rubyforge.org/var/svn/project"
2025
+ )
2026
+ end
2027
+
2028
+ it "should have a scheme of 'svn+ssh'" do
2029
+ @uri.scheme.should == "svn+ssh"
2030
+ end
2031
+
2032
+ it "should be considered to be ip-based" do
2033
+ @uri.should be_ip_based
2034
+ end
2035
+
2036
+ it "should have a path of '/var/svn/project'" do
2037
+ @uri.path.should == "/var/svn/project"
2038
+ end
2039
+
2040
+ it "should have a username of 'developername'" do
2041
+ @uri.user.should == "developername"
2042
+ end
2043
+
2044
+ it "should have no password" do
2045
+ @uri.password.should == nil
2046
+ end
2047
+
2048
+ it "should be considered to be in normal form" do
2049
+ @uri.normalize.should be_eql(@uri)
2050
+ end
2051
+ end
2052
+
2053
+ describe Addressable::URI, "when parsed from " +
2054
+ "'ssh+svn://developername@RUBYFORGE.ORG/var/svn/project'" do
2055
+ before do
2056
+ @uri = Addressable::URI.parse(
2057
+ "ssh+svn://developername@RUBYFORGE.ORG/var/svn/project"
2058
+ )
2059
+ end
2060
+
2061
+ it "should have a scheme of 'ssh+svn'" do
2062
+ @uri.scheme.should == "ssh+svn"
2063
+ end
2064
+
2065
+ it "should have a normalized scheme of 'svn+ssh'" do
2066
+ @uri.normalized_scheme.should == "svn+ssh"
2067
+ end
2068
+
2069
+ it "should have a normalized site of 'svn+ssh'" do
2070
+ @uri.normalized_site.should == "svn+ssh://developername@rubyforge.org"
2071
+ end
2072
+
2073
+ it "should not be considered to be ip-based" do
2074
+ @uri.should_not be_ip_based
2075
+ end
2076
+
2077
+ it "should have a path of '/var/svn/project'" do
2078
+ @uri.path.should == "/var/svn/project"
2079
+ end
2080
+
2081
+ it "should have a username of 'developername'" do
2082
+ @uri.user.should == "developername"
2083
+ end
2084
+
2085
+ it "should have no password" do
2086
+ @uri.password.should == nil
2087
+ end
2088
+
2089
+ it "should not be considered to be in normal form" do
2090
+ @uri.normalize.should_not be_eql(@uri)
2091
+ end
2092
+ end
2093
+
2094
+ describe Addressable::URI, "when parsed from " +
2095
+ "'mailto:user@example.com'" do
2096
+ before do
2097
+ @uri = Addressable::URI.parse("mailto:user@example.com")
2098
+ end
2099
+
2100
+ it "should have a scheme of 'mailto'" do
2101
+ @uri.scheme.should == "mailto"
2102
+ end
2103
+
2104
+ it "should not be considered to be ip-based" do
2105
+ @uri.should_not be_ip_based
2106
+ end
2107
+
2108
+ it "should have a path of 'user@example.com'" do
2109
+ @uri.path.should == "user@example.com"
2110
+ end
2111
+
2112
+ it "should have no user" do
2113
+ @uri.user.should == nil
2114
+ end
2115
+
2116
+ it "should be considered to be in normal form" do
2117
+ @uri.normalize.should be_eql(@uri)
2118
+ end
2119
+ end
2120
+
2121
+ describe Addressable::URI, "when parsed from " +
2122
+ "'tag:example.com,2006-08-18:/path/to/something'" do
2123
+ before do
2124
+ @uri = Addressable::URI.parse(
2125
+ "tag:example.com,2006-08-18:/path/to/something")
2126
+ end
2127
+
2128
+ it "should have a scheme of 'tag'" do
2129
+ @uri.scheme.should == "tag"
2130
+ end
2131
+
2132
+ it "should be considered to be ip-based" do
2133
+ @uri.should_not be_ip_based
2134
+ end
2135
+
2136
+ it "should have a path of " +
2137
+ "'example.com,2006-08-18:/path/to/something'" do
2138
+ @uri.path.should == "example.com,2006-08-18:/path/to/something"
2139
+ end
2140
+
2141
+ it "should have no user" do
2142
+ @uri.user.should == nil
2143
+ end
2144
+
2145
+ it "should be considered to be in normal form" do
2146
+ @uri.normalize.should be_eql(@uri)
2147
+ end
2148
+ end
2149
+
2150
+ describe Addressable::URI, "when parsed from " +
2151
+ "'http://example.com/x;y/'" do
2152
+ before do
2153
+ @uri = Addressable::URI.parse("http://example.com/x;y/")
2154
+ end
2155
+
2156
+ it "should be considered to be in normal form" do
2157
+ @uri.normalize.should be_eql(@uri)
2158
+ end
2159
+ end
2160
+
2161
+ describe Addressable::URI, "when parsed from " +
2162
+ "'http://example.com/?x=1&y=2'" do
2163
+ before do
2164
+ @uri = Addressable::URI.parse("http://example.com/?x=1&y=2")
2165
+ end
2166
+
2167
+ it "should be considered to be in normal form" do
2168
+ @uri.normalize.should be_eql(@uri)
2169
+ end
2170
+ end
2171
+
2172
+ describe Addressable::URI, "when parsed from " +
2173
+ "'view-source:http://example.com/'" do
2174
+ before do
2175
+ @uri = Addressable::URI.parse("view-source:http://example.com/")
2176
+ end
2177
+
2178
+ it "should have a scheme of 'view-source'" do
2179
+ @uri.scheme.should == "view-source"
2180
+ end
2181
+
2182
+ it "should have a path of 'http://example.com/'" do
2183
+ @uri.path.should == "http://example.com/"
2184
+ end
2185
+
2186
+ it "should be considered to be in normal form" do
2187
+ @uri.normalize.should be_eql(@uri)
2188
+ end
2189
+ end
2190
+
2191
+ describe Addressable::URI, "when parsed from " +
2192
+ "'http://user:pass@example.com/path/to/resource?query=x#fragment'" do
2193
+ before do
2194
+ @uri = Addressable::URI.parse(
2195
+ "http://user:pass@example.com/path/to/resource?query=x#fragment")
2196
+ end
2197
+
2198
+ it "should use the 'http' scheme" do
2199
+ @uri.scheme.should == "http"
2200
+ end
2201
+
2202
+ it "should have an authority segment of 'user:pass@example.com'" do
2203
+ @uri.authority.should == "user:pass@example.com"
2204
+ end
2205
+
2206
+ it "should have a username of 'user'" do
2207
+ @uri.user.should == "user"
2208
+ end
2209
+
2210
+ it "should have a password of 'pass'" do
2211
+ @uri.password.should == "pass"
2212
+ end
2213
+
2214
+ it "should have a host of 'example.com'" do
2215
+ @uri.host.should == "example.com"
2216
+ end
2217
+
2218
+ it "should use port 80" do
2219
+ @uri.inferred_port.should == 80
2220
+ end
2221
+
2222
+ it "should have a path of '/path/to/resource'" do
2223
+ @uri.path.should == "/path/to/resource"
2224
+ end
2225
+
2226
+ it "should have a query string of 'query=x'" do
2227
+ @uri.query.should == "query=x"
2228
+ end
2229
+
2230
+ it "should have a fragment of 'fragment'" do
2231
+ @uri.fragment.should == "fragment"
2232
+ end
2233
+
2234
+ it "should be considered to be in normal form" do
2235
+ @uri.normalize.should be_eql(@uri)
2236
+ end
2237
+
2238
+ it "should have a route of '/path/' to " +
2239
+ "'http://user:pass@example.com/path/'" do
2240
+ @uri.route_to("http://user:pass@example.com/path/").should ==
2241
+ Addressable::URI.parse("/path/")
2242
+ end
2243
+
2244
+ it "should have a route of '/path/to/resource?query=x#fragment' " +
2245
+ "from 'http://user:pass@example.com/path/'" do
2246
+ @uri.route_from("http://user:pass@example.com/path/").should ==
2247
+ Addressable::URI.parse("to/resource?query=x#fragment")
2248
+ end
2249
+
2250
+ it "should have a route of '?query=x#fragment' " +
2251
+ "from 'http://user:pass@example.com/path/to/resource'" do
2252
+ @uri.route_from("http://user:pass@example.com/path/to/resource").should ==
2253
+ Addressable::URI.parse("?query=x#fragment")
2254
+ end
2255
+
2256
+ it "should have a route of '#fragment' " +
2257
+ "from 'http://user:pass@example.com/path/to/resource?query=x'" do
2258
+ @uri.route_from(
2259
+ "http://user:pass@example.com/path/to/resource?query=x").should ==
2260
+ Addressable::URI.parse("#fragment")
2261
+ end
2262
+
2263
+ it "should have a route of '#fragment' from " +
2264
+ "'http://user:pass@example.com/path/to/resource?query=x#fragment'" do
2265
+ @uri.route_from(
2266
+ "http://user:pass@example.com/path/to/resource?query=x#fragment"
2267
+ ).should == Addressable::URI.parse("#fragment")
2268
+ end
2269
+
2270
+ it "should have a route of 'http://elsewhere.com/' to " +
2271
+ "'http://elsewhere.com/'" do
2272
+ @uri.route_to("http://elsewhere.com/").should ==
2273
+ Addressable::URI.parse("http://elsewhere.com/")
2274
+ end
2275
+
2276
+ it "should have a route of " +
2277
+ "'http://user:pass@example.com/path/to/resource?query=x#fragment' " +
2278
+ "from 'http://example.com/path/to/'" do
2279
+ @uri.route_from("http://elsewhere.com/path/to/").should ==
2280
+ Addressable::URI.parse(
2281
+ "http://user:pass@example.com/path/to/resource?query=x#fragment")
2282
+ end
2283
+
2284
+ it "should have the correct scheme after assignment" do
2285
+ @uri.scheme = "ftp"
2286
+ @uri.scheme.should == "ftp"
2287
+ @uri.to_s.should ==
2288
+ "ftp://user:pass@example.com/path/to/resource?query=x#fragment"
2289
+ @uri.to_str.should ==
2290
+ "ftp://user:pass@example.com/path/to/resource?query=x#fragment"
2291
+ @uri.scheme = "bogus!"
2292
+ @uri.scheme.should == "bogus!"
2293
+ @uri.normalized_scheme.should == "bogus%21"
2294
+ @uri.normalize.to_s.should ==
2295
+ "bogus%21://user:pass@example.com/path/to/resource?query=x#fragment"
2296
+ @uri.normalize.to_str.should ==
2297
+ "bogus%21://user:pass@example.com/path/to/resource?query=x#fragment"
2298
+ end
2299
+
2300
+ it "should have the correct site segment after assignment" do
2301
+ @uri.site = "https://newuser:newpass@example.com:443"
2302
+ @uri.scheme.should == "https"
2303
+ @uri.authority.should == "newuser:newpass@example.com:443"
2304
+ @uri.user.should == "newuser"
2305
+ @uri.password.should == "newpass"
2306
+ @uri.userinfo.should == "newuser:newpass"
2307
+ @uri.normalized_userinfo.should == "newuser:newpass"
2308
+ @uri.host.should == "example.com"
2309
+ @uri.port.should == 443
2310
+ @uri.inferred_port.should == 443
2311
+ @uri.to_s.should ==
2312
+ "https://newuser:newpass@example.com:443" +
2313
+ "/path/to/resource?query=x#fragment"
2314
+ end
2315
+
2316
+ it "should have the correct authority segment after assignment" do
2317
+ @uri.authority = "newuser:newpass@example.com:80"
2318
+ @uri.authority.should == "newuser:newpass@example.com:80"
2319
+ @uri.user.should == "newuser"
2320
+ @uri.password.should == "newpass"
2321
+ @uri.userinfo.should == "newuser:newpass"
2322
+ @uri.normalized_userinfo.should == "newuser:newpass"
2323
+ @uri.host.should == "example.com"
2324
+ @uri.port.should == 80
2325
+ @uri.inferred_port.should == 80
2326
+ @uri.to_s.should ==
2327
+ "http://newuser:newpass@example.com:80" +
2328
+ "/path/to/resource?query=x#fragment"
2329
+ end
2330
+
2331
+ it "should have the correct userinfo segment after assignment" do
2332
+ @uri.userinfo = "newuser:newpass"
2333
+ @uri.userinfo.should == "newuser:newpass"
2334
+ @uri.authority.should == "newuser:newpass@example.com"
2335
+ @uri.user.should == "newuser"
2336
+ @uri.password.should == "newpass"
2337
+ @uri.host.should == "example.com"
2338
+ @uri.port.should == nil
2339
+ @uri.inferred_port.should == 80
2340
+ @uri.to_s.should ==
2341
+ "http://newuser:newpass@example.com" +
2342
+ "/path/to/resource?query=x#fragment"
2343
+ end
2344
+
2345
+ it "should have the correct username after assignment" do
2346
+ @uri.user = "newuser"
2347
+ @uri.user.should == "newuser"
2348
+ @uri.authority.should == "newuser:pass@example.com"
2349
+ end
2350
+
2351
+ it "should have the correct password after assignment" do
2352
+ @uri.password = "newpass"
2353
+ @uri.password.should == "newpass"
2354
+ @uri.authority.should == "user:newpass@example.com"
2355
+ end
2356
+
2357
+ it "should have the correct host after assignment" do
2358
+ @uri.host = "newexample.com"
2359
+ @uri.host.should == "newexample.com"
2360
+ @uri.authority.should == "user:pass@newexample.com"
2361
+ end
2362
+
2363
+ it "should have the correct port after assignment" do
2364
+ @uri.port = 8080
2365
+ @uri.port.should == 8080
2366
+ @uri.authority.should == "user:pass@example.com:8080"
2367
+ end
2368
+
2369
+ it "should have the correct path after assignment" do
2370
+ @uri.path = "/newpath/to/resource"
2371
+ @uri.path.should == "/newpath/to/resource"
2372
+ @uri.to_s.should ==
2373
+ "http://user:pass@example.com/newpath/to/resource?query=x#fragment"
2374
+ end
2375
+
2376
+ it "should have the correct scheme and authority after nil assignment" do
2377
+ @uri.site = nil
2378
+ @uri.scheme.should == nil
2379
+ @uri.authority.should == nil
2380
+ @uri.to_s.should == "/path/to/resource?query=x#fragment"
2381
+ end
2382
+
2383
+ it "should have the correct scheme and authority after assignment" do
2384
+ @uri.site = "file://"
2385
+ @uri.scheme.should == "file"
2386
+ @uri.authority.should == ""
2387
+ @uri.to_s.should == "file:///path/to/resource?query=x#fragment"
2388
+ end
2389
+
2390
+ it "should have the correct path after nil assignment" do
2391
+ @uri.path = nil
2392
+ @uri.path.should == ""
2393
+ @uri.to_s.should ==
2394
+ "http://user:pass@example.com?query=x#fragment"
2395
+ end
2396
+
2397
+ it "should have the correct query string after assignment" do
2398
+ @uri.query = "newquery=x"
2399
+ @uri.query.should == "newquery=x"
2400
+ @uri.to_s.should ==
2401
+ "http://user:pass@example.com/path/to/resource?newquery=x#fragment"
2402
+ @uri.query = nil
2403
+ @uri.query.should == nil
2404
+ @uri.to_s.should ==
2405
+ "http://user:pass@example.com/path/to/resource#fragment"
2406
+ end
2407
+
2408
+ it "should have the correct query string after hash assignment" do
2409
+ @uri.query_values = {"?uestion mark"=>"=sign", "hello"=>"g\xC3\xBCnther"}
2410
+ @uri.query.split("&").should include("%3Fuestion%20mark=%3Dsign")
2411
+ @uri.query.split("&").should include("hello=g%C3%BCnther")
2412
+ @uri.query_values.should == {
2413
+ "?uestion mark"=>"=sign", "hello"=>"g\xC3\xBCnther"
2414
+ }
2415
+ end
2416
+
2417
+ it "should have the correct query string after flag hash assignment" do
2418
+ @uri.query_values = {'flag?1' => true, 'fl=ag2' => true, 'flag3' => true}
2419
+ @uri.query.split("&").should include("flag%3F1")
2420
+ @uri.query.split("&").should include("fl%3Dag2")
2421
+ @uri.query.split("&").should include("flag3")
2422
+ @uri.query_values.should == {
2423
+ 'flag?1' => true, 'fl=ag2' => true, 'flag3' => true
2424
+ }
2425
+ end
2426
+
2427
+ it "should raise an error if query values are set to a bogus type" do
2428
+ (lambda do
2429
+ @uri.query_values = "bogus"
2430
+ end).should raise_error(TypeError)
2431
+ end
2432
+
2433
+ it "should have the correct fragment after assignment" do
2434
+ @uri.fragment = "newfragment"
2435
+ @uri.fragment.should == "newfragment"
2436
+ @uri.to_s.should ==
2437
+ "http://user:pass@example.com/path/to/resource?query=x#newfragment"
2438
+
2439
+ @uri.fragment = nil
2440
+ @uri.fragment.should == nil
2441
+ @uri.to_s.should ==
2442
+ "http://user:pass@example.com/path/to/resource?query=x"
2443
+ end
2444
+
2445
+ it "should have the correct values after a merge" do
2446
+ @uri.merge(:fragment => "newfragment").to_s.should ==
2447
+ "http://user:pass@example.com/path/to/resource?query=x#newfragment"
2448
+ end
2449
+
2450
+ it "should have the correct values after a merge" do
2451
+ @uri.merge(:fragment => nil).to_s.should ==
2452
+ "http://user:pass@example.com/path/to/resource?query=x"
2453
+ end
2454
+
2455
+ it "should have the correct values after a merge" do
2456
+ @uri.merge(:userinfo => "newuser:newpass").to_s.should ==
2457
+ "http://newuser:newpass@example.com/path/to/resource?query=x#fragment"
2458
+ end
2459
+
2460
+ it "should have the correct values after a merge" do
2461
+ @uri.merge(:userinfo => nil).to_s.should ==
2462
+ "http://example.com/path/to/resource?query=x#fragment"
2463
+ end
2464
+
2465
+ it "should have the correct values after a merge" do
2466
+ @uri.merge(:path => "newpath").to_s.should ==
2467
+ "http://user:pass@example.com/newpath?query=x#fragment"
2468
+ end
2469
+
2470
+ it "should have the correct values after a merge" do
2471
+ @uri.merge(:port => "42", :path => "newpath", :query => "").to_s.should ==
2472
+ "http://user:pass@example.com:42/newpath?#fragment"
2473
+ end
2474
+
2475
+ it "should have the correct values after a merge" do
2476
+ @uri.merge(:authority => "foo:bar@baz:42").to_s.should ==
2477
+ "http://foo:bar@baz:42/path/to/resource?query=x#fragment"
2478
+ # Ensure the operation was not destructive
2479
+ @uri.to_s.should ==
2480
+ "http://user:pass@example.com/path/to/resource?query=x#fragment"
2481
+ end
2482
+
2483
+ it "should have the correct values after a destructive merge" do
2484
+ @uri.merge!(:authority => "foo:bar@baz:42")
2485
+ # Ensure the operation was destructive
2486
+ @uri.to_s.should ==
2487
+ "http://foo:bar@baz:42/path/to/resource?query=x#fragment"
2488
+ end
2489
+
2490
+ it "should fail to merge with bogus values" do
2491
+ (lambda do
2492
+ @uri.merge(:port => "bogus")
2493
+ end).should raise_error(Addressable::URI::InvalidURIError)
2494
+ end
2495
+
2496
+ it "should fail to merge with bogus values" do
2497
+ (lambda do
2498
+ @uri.merge(:authority => "bar@baz:bogus")
2499
+ end).should raise_error(Addressable::URI::InvalidURIError)
2500
+ end
2501
+
2502
+ it "should fail to merge with bogus parameters" do
2503
+ (lambda do
2504
+ @uri.merge(42)
2505
+ end).should raise_error(TypeError)
2506
+ end
2507
+
2508
+ it "should fail to merge with bogus parameters" do
2509
+ (lambda do
2510
+ @uri.merge("http://example.com/")
2511
+ end).should raise_error(TypeError)
2512
+ end
2513
+
2514
+ it "should fail to merge with both authority and subcomponents" do
2515
+ (lambda do
2516
+ @uri.merge(:authority => "foo:bar@baz:42", :port => "42")
2517
+ end).should raise_error(ArgumentError)
2518
+ end
2519
+
2520
+ it "should fail to merge with both userinfo and subcomponents" do
2521
+ (lambda do
2522
+ @uri.merge(:userinfo => "foo:bar", :user => "foo")
2523
+ end).should raise_error(ArgumentError)
2524
+ end
2525
+
2526
+ it "should be identical to its duplicate" do
2527
+ @uri.should == @uri.dup
2528
+ end
2529
+ end
2530
+
2531
+ describe Addressable::URI, "when parsed from " +
2532
+ "'http://example.com/?q&&x=b'" do
2533
+ before do
2534
+ @uri = Addressable::URI.parse("http://example.com/?q&&x=b")
2535
+ end
2536
+
2537
+ it "should have a query of 'q&&x=b'" do
2538
+ @uri.query.should == "q&&x=b"
2539
+ end
2540
+
2541
+ it "should have query_values of {'q' => true, 'x' => 'b'}" do
2542
+ @uri.query_values.should == {'q' => true, 'x' => 'b'}
2543
+ end
2544
+ end
2545
+
2546
+ describe Addressable::URI, "when parsed from " +
2547
+ "'http://example.com/?q='" do
2548
+ before do
2549
+ @uri = Addressable::URI.parse("http://example.com/?q=")
2550
+ end
2551
+
2552
+ it "should have a query of 'q='" do
2553
+ @uri.query.should == "q="
2554
+ end
2555
+
2556
+ it "should have query_values of {'q' => ''}" do
2557
+ @uri.query_values.should == {'q' => ''}
2558
+ end
2559
+ end
2560
+
2561
+ describe Addressable::URI, "when parsed from " +
2562
+ "'http://user@example.com'" do
2563
+ before do
2564
+ @uri = Addressable::URI.parse("http://user@example.com")
2565
+ end
2566
+
2567
+ it "should use the 'http' scheme" do
2568
+ @uri.scheme.should == "http"
2569
+ end
2570
+
2571
+ it "should have a username of 'user'" do
2572
+ @uri.user.should == "user"
2573
+ end
2574
+
2575
+ it "should have no password" do
2576
+ @uri.password.should == nil
2577
+ end
2578
+
2579
+ it "should have a userinfo of 'user'" do
2580
+ @uri.userinfo.should == "user"
2581
+ end
2582
+
2583
+ it "should have a normalized userinfo of 'user'" do
2584
+ @uri.normalized_userinfo.should == "user"
2585
+ end
2586
+
2587
+ it "should have a host of 'example.com'" do
2588
+ @uri.host.should == "example.com"
2589
+ end
2590
+
2591
+ it "should use port 80" do
2592
+ @uri.inferred_port.should == 80
2593
+ end
2594
+
2595
+ it "should have the correct username after assignment" do
2596
+ @uri.user = "newuser"
2597
+ @uri.user.should == "newuser"
2598
+ @uri.password.should == nil
2599
+ @uri.to_s.should == "http://newuser@example.com"
2600
+ end
2601
+
2602
+ it "should have the correct password after assignment" do
2603
+ @uri.password = "newpass"
2604
+ @uri.password.should == "newpass"
2605
+ @uri.to_s.should == "http://user:newpass@example.com"
2606
+ end
2607
+
2608
+ it "should have the correct userinfo segment after assignment" do
2609
+ @uri.userinfo = "newuser:newpass"
2610
+ @uri.userinfo.should == "newuser:newpass"
2611
+ @uri.user.should == "newuser"
2612
+ @uri.password.should == "newpass"
2613
+ @uri.host.should == "example.com"
2614
+ @uri.port.should == nil
2615
+ @uri.inferred_port.should == 80
2616
+ @uri.to_s.should == "http://newuser:newpass@example.com"
2617
+ end
2618
+
2619
+ it "should have the correct userinfo segment after nil assignment" do
2620
+ @uri.userinfo = nil
2621
+ @uri.userinfo.should == nil
2622
+ @uri.user.should == nil
2623
+ @uri.password.should == nil
2624
+ @uri.host.should == "example.com"
2625
+ @uri.port.should == nil
2626
+ @uri.inferred_port.should == 80
2627
+ @uri.to_s.should == "http://example.com"
2628
+ end
2629
+
2630
+ it "should have the correct authority segment after assignment" do
2631
+ @uri.authority = "newuser@example.com"
2632
+ @uri.authority.should == "newuser@example.com"
2633
+ @uri.user.should == "newuser"
2634
+ @uri.password.should == nil
2635
+ @uri.host.should == "example.com"
2636
+ @uri.port.should == nil
2637
+ @uri.inferred_port.should == 80
2638
+ @uri.to_s.should == "http://newuser@example.com"
2639
+ end
2640
+
2641
+ it "should raise an error after nil assignment of authority segment" do
2642
+ (lambda do
2643
+ # This would create an invalid URI
2644
+ @uri.authority = nil
2645
+ end).should raise_error
2646
+ end
2647
+ end
2648
+
2649
+ describe Addressable::URI, "when parsed from " +
2650
+ "'http://user:@example.com'" do
2651
+ before do
2652
+ @uri = Addressable::URI.parse("http://user:@example.com")
2653
+ end
2654
+
2655
+ it "should use the 'http' scheme" do
2656
+ @uri.scheme.should == "http"
2657
+ end
2658
+
2659
+ it "should have a username of 'user'" do
2660
+ @uri.user.should == "user"
2661
+ end
2662
+
2663
+ it "should have a password of ''" do
2664
+ @uri.password.should == ""
2665
+ end
2666
+
2667
+ it "should have a normalized userinfo of 'user:'" do
2668
+ @uri.normalized_userinfo.should == "user:"
2669
+ end
2670
+
2671
+ it "should have a host of 'example.com'" do
2672
+ @uri.host.should == "example.com"
2673
+ end
2674
+
2675
+ it "should use port 80" do
2676
+ @uri.inferred_port.should == 80
2677
+ end
2678
+
2679
+ it "should have the correct username after assignment" do
2680
+ @uri.user = "newuser"
2681
+ @uri.user.should == "newuser"
2682
+ @uri.password.should == ""
2683
+ @uri.to_s.should == "http://newuser:@example.com"
2684
+ end
2685
+
2686
+ it "should have the correct password after assignment" do
2687
+ @uri.password = "newpass"
2688
+ @uri.password.should == "newpass"
2689
+ @uri.to_s.should == "http://user:newpass@example.com"
2690
+ end
2691
+
2692
+ it "should have the correct authority segment after assignment" do
2693
+ @uri.authority = "newuser:@example.com"
2694
+ @uri.authority.should == "newuser:@example.com"
2695
+ @uri.user.should == "newuser"
2696
+ @uri.password.should == ""
2697
+ @uri.host.should == "example.com"
2698
+ @uri.port.should == nil
2699
+ @uri.inferred_port.should == 80
2700
+ @uri.to_s.should == "http://newuser:@example.com"
2701
+ end
2702
+ end
2703
+
2704
+ describe Addressable::URI, "when parsed from " +
2705
+ "'http://:pass@example.com'" do
2706
+ before do
2707
+ @uri = Addressable::URI.parse("http://:pass@example.com")
2708
+ end
2709
+
2710
+ it "should use the 'http' scheme" do
2711
+ @uri.scheme.should == "http"
2712
+ end
2713
+
2714
+ it "should have a username of ''" do
2715
+ @uri.user.should == ""
2716
+ end
2717
+
2718
+ it "should have a password of 'pass'" do
2719
+ @uri.password.should == "pass"
2720
+ end
2721
+
2722
+ it "should have a userinfo of ':pass'" do
2723
+ @uri.userinfo.should == ":pass"
2724
+ end
2725
+
2726
+ it "should have a normalized userinfo of ':pass'" do
2727
+ @uri.normalized_userinfo.should == ":pass"
2728
+ end
2729
+
2730
+ it "should have a host of 'example.com'" do
2731
+ @uri.host.should == "example.com"
2732
+ end
2733
+
2734
+ it "should use port 80" do
2735
+ @uri.inferred_port.should == 80
2736
+ end
2737
+
2738
+ it "should have the correct username after assignment" do
2739
+ @uri.user = "newuser"
2740
+ @uri.user.should == "newuser"
2741
+ @uri.password.should == "pass"
2742
+ @uri.to_s.should == "http://newuser:pass@example.com"
2743
+ end
2744
+
2745
+ it "should have the correct password after assignment" do
2746
+ @uri.password = "newpass"
2747
+ @uri.password.should == "newpass"
2748
+ @uri.user.should == ""
2749
+ @uri.to_s.should == "http://:newpass@example.com"
2750
+ end
2751
+
2752
+ it "should have the correct authority segment after assignment" do
2753
+ @uri.authority = ":newpass@example.com"
2754
+ @uri.authority.should == ":newpass@example.com"
2755
+ @uri.user.should == ""
2756
+ @uri.password.should == "newpass"
2757
+ @uri.host.should == "example.com"
2758
+ @uri.port.should == nil
2759
+ @uri.inferred_port.should == 80
2760
+ @uri.to_s.should == "http://:newpass@example.com"
2761
+ end
2762
+ end
2763
+
2764
+ describe Addressable::URI, "when parsed from " +
2765
+ "'http://:@example.com'" do
2766
+ before do
2767
+ @uri = Addressable::URI.parse("http://:@example.com")
2768
+ end
2769
+
2770
+ it "should use the 'http' scheme" do
2771
+ @uri.scheme.should == "http"
2772
+ end
2773
+
2774
+ it "should have a username of ''" do
2775
+ @uri.user.should == ""
2776
+ end
2777
+
2778
+ it "should have a password of ''" do
2779
+ @uri.password.should == ""
2780
+ end
2781
+
2782
+ it "should have a normalized userinfo of nil" do
2783
+ @uri.normalized_userinfo.should == nil
2784
+ end
2785
+
2786
+ it "should have a host of 'example.com'" do
2787
+ @uri.host.should == "example.com"
2788
+ end
2789
+
2790
+ it "should use port 80" do
2791
+ @uri.inferred_port.should == 80
2792
+ end
2793
+
2794
+ it "should have the correct username after assignment" do
2795
+ @uri.user = "newuser"
2796
+ @uri.user.should == "newuser"
2797
+ @uri.password.should == ""
2798
+ @uri.to_s.should == "http://newuser:@example.com"
2799
+ end
2800
+
2801
+ it "should have the correct password after assignment" do
2802
+ @uri.password = "newpass"
2803
+ @uri.password.should == "newpass"
2804
+ @uri.user.should == ""
2805
+ @uri.to_s.should == "http://:newpass@example.com"
2806
+ end
2807
+
2808
+ it "should have the correct authority segment after assignment" do
2809
+ @uri.authority = ":@newexample.com"
2810
+ @uri.authority.should == ":@newexample.com"
2811
+ @uri.user.should == ""
2812
+ @uri.password.should == ""
2813
+ @uri.host.should == "newexample.com"
2814
+ @uri.port.should == nil
2815
+ @uri.inferred_port.should == 80
2816
+ @uri.to_s.should == "http://:@newexample.com"
2817
+ end
2818
+ end
2819
+
2820
+ describe Addressable::URI, "when parsed from " +
2821
+ "'#example'" do
2822
+ before do
2823
+ @uri = Addressable::URI.parse("#example")
2824
+ end
2825
+
2826
+ it "should be considered relative" do
2827
+ @uri.should be_relative
2828
+ end
2829
+
2830
+ it "should have a host of nil" do
2831
+ @uri.host.should == nil
2832
+ end
2833
+
2834
+ it "should have a site of nil" do
2835
+ @uri.site.should == nil
2836
+ end
2837
+
2838
+ it "should have a normalized_site of nil" do
2839
+ @uri.normalized_site.should == nil
2840
+ end
2841
+
2842
+ it "should have a path of ''" do
2843
+ @uri.path.should == ""
2844
+ end
2845
+
2846
+ it "should have a query string of nil" do
2847
+ @uri.query.should == nil
2848
+ end
2849
+
2850
+ it "should have a fragment of 'example'" do
2851
+ @uri.fragment.should == "example"
2852
+ end
2853
+ end
2854
+
2855
+ describe Addressable::URI, "when parsed from " +
2856
+ "the network-path reference '//example.com/'" do
2857
+ before do
2858
+ @uri = Addressable::URI.parse("//example.com/")
2859
+ end
2860
+
2861
+ it "should be considered relative" do
2862
+ @uri.should be_relative
2863
+ end
2864
+
2865
+ it "should have a host of 'example.com'" do
2866
+ @uri.host.should == "example.com"
2867
+ end
2868
+
2869
+ it "should have a path of '/'" do
2870
+ @uri.path.should == "/"
2871
+ end
2872
+
2873
+ it "should raise an error if routing is attempted" do
2874
+ (lambda do
2875
+ @uri.route_to("http://example.com/")
2876
+ end).should raise_error(ArgumentError, /\/\/example.com\//)
2877
+ (lambda do
2878
+ @uri.route_from("http://example.com/")
2879
+ end).should raise_error(ArgumentError, /\/\/example.com\//)
2880
+ end
2881
+ end
2882
+
2883
+ describe Addressable::URI, "when parsed from " +
2884
+ "'feed://http://example.com/'" do
2885
+ before do
2886
+ @uri = Addressable::URI.parse("feed://http://example.com/")
2887
+ end
2888
+
2889
+ it "should have a host of 'http'" do
2890
+ @uri.host.should == "http"
2891
+ end
2892
+
2893
+ it "should have a path of '//example.com/'" do
2894
+ @uri.path.should == "//example.com/"
2895
+ end
2896
+ end
2897
+
2898
+ describe Addressable::URI, "when parsed from " +
2899
+ "'feed:http://example.com/'" do
2900
+ before do
2901
+ @uri = Addressable::URI.parse("feed:http://example.com/")
2902
+ end
2903
+
2904
+ it "should have a path of 'http://example.com/'" do
2905
+ @uri.path.should == "http://example.com/"
2906
+ end
2907
+
2908
+ it "should normalize to 'http://example.com/'" do
2909
+ @uri.normalize.to_s.should == "http://example.com/"
2910
+ @uri.normalize!.to_s.should == "http://example.com/"
2911
+ end
2912
+ end
2913
+
2914
+ describe Addressable::URI, "when parsed from " +
2915
+ "'example://a/b/c/%7Bfoo%7D'" do
2916
+ before do
2917
+ @uri = Addressable::URI.parse("example://a/b/c/%7Bfoo%7D")
2918
+ end
2919
+
2920
+ # Section 6.2.2 of RFC 3986
2921
+ it "should be equivalent to eXAMPLE://a/./b/../b/%63/%7bfoo%7d" do
2922
+ @uri.should ==
2923
+ Addressable::URI.parse("eXAMPLE://a/./b/../b/%63/%7bfoo%7d")
2924
+ end
2925
+ end
2926
+
2927
+ describe Addressable::URI, "when parsed from " +
2928
+ "'http://example.com/indirect/path/./to/../resource/'" do
2929
+ before do
2930
+ @uri = Addressable::URI.parse(
2931
+ "http://example.com/indirect/path/./to/../resource/")
2932
+ end
2933
+
2934
+ it "should use the 'http' scheme" do
2935
+ @uri.scheme.should == "http"
2936
+ end
2937
+
2938
+ it "should have a host of 'example.com'" do
2939
+ @uri.host.should == "example.com"
2940
+ end
2941
+
2942
+ it "should use port 80" do
2943
+ @uri.inferred_port.should == 80
2944
+ end
2945
+
2946
+ it "should have a path of '/indirect/path/./to/../resource/'" do
2947
+ @uri.path.should == "/indirect/path/./to/../resource/"
2948
+ end
2949
+
2950
+ # Section 6.2.2.3 of RFC 3986
2951
+ it "should have a normalized path of '/indirect/path/resource/'" do
2952
+ @uri.normalize.path.should == "/indirect/path/resource/"
2953
+ @uri.normalize!.path.should == "/indirect/path/resource/"
2954
+ end
2955
+ end
2956
+
2957
+ describe Addressable::URI, "when parsed from " +
2958
+ "'http://under_score.example.com/'" do
2959
+ it "should not cause an error" do
2960
+ (lambda do
2961
+ Addressable::URI.parse("http://under_score.example.com/")
2962
+ end).should_not raise_error
2963
+ end
2964
+ end
2965
+
2966
+ describe Addressable::URI, "when parsed from " +
2967
+ "'./this:that'" do
2968
+ before do
2969
+ @uri = Addressable::URI.parse("./this:that")
2970
+ end
2971
+
2972
+ it "should be considered relative" do
2973
+ @uri.should be_relative
2974
+ end
2975
+
2976
+ it "should have no scheme" do
2977
+ @uri.scheme.should == nil
2978
+ end
2979
+ end
2980
+
2981
+ describe Addressable::URI, "when parsed from " +
2982
+ "'this:that'" do
2983
+ before do
2984
+ @uri = Addressable::URI.parse("this:that")
2985
+ end
2986
+
2987
+ it "should be considered absolute" do
2988
+ @uri.should be_absolute
2989
+ end
2990
+
2991
+ it "should have a scheme of 'this'" do
2992
+ @uri.scheme.should == "this"
2993
+ end
2994
+ end
2995
+
2996
+ describe Addressable::URI, "when parsed from '?'" do
2997
+ before do
2998
+ @uri = Addressable::URI.parse("?")
2999
+ end
3000
+
3001
+ it "should have the correct subscript notation query values" do
3002
+ @uri.query_values.should == {}
3003
+ @uri.query_values(:notation => :subscript).should == {}
3004
+ end
3005
+
3006
+ it "should have the correct dot notation query values" do
3007
+ @uri.query_values(:notation => :dot).should == {}
3008
+ end
3009
+
3010
+ it "should have the correct flat notation query values" do
3011
+ @uri.query_values(:notation => :flat).should == {}
3012
+ end
3013
+ end
3014
+
3015
+ describe Addressable::URI, "when parsed from '?one=1&two=2&three=3'" do
3016
+ before do
3017
+ @uri = Addressable::URI.parse("?one=1&two=2&three=3")
3018
+ end
3019
+
3020
+ it "should have the correct query values" do
3021
+ @uri.query_values.should == {"one" => "1", "two" => "2", "three" => "3"}
3022
+ end
3023
+
3024
+ it "should raise an error for invalid query value notations" do
3025
+ (lambda do
3026
+ @uri.query_values(:notation => :bogus)
3027
+ end).should raise_error(ArgumentError)
3028
+ end
3029
+ end
3030
+
3031
+ describe Addressable::URI, "when parsed from '?one[two][three]=four'" do
3032
+ before do
3033
+ @uri = Addressable::URI.parse("?one[two][three]=four")
3034
+ end
3035
+
3036
+ it "should have the correct query values" do
3037
+ @uri.query_values.should == {"one" => {"two" => {"three" => "four"}}}
3038
+ end
3039
+
3040
+ it "should have the correct flat notation query values" do
3041
+ @uri.query_values(:notation => :flat).should == {
3042
+ "one[two][three]" => "four"
3043
+ }
3044
+ end
3045
+ end
3046
+
3047
+ describe Addressable::URI, "when parsed from '?one.two.three=four'" do
3048
+ before do
3049
+ @uri = Addressable::URI.parse("?one.two.three=four")
3050
+ end
3051
+
3052
+ it "should have the correct dot notation query values" do
3053
+ @uri.query_values(:notation => :dot).should == {
3054
+ "one" => {"two" => {"three" => "four"}}
3055
+ }
3056
+ end
3057
+
3058
+ it "should have the correct flat notation query values" do
3059
+ @uri.query_values(:notation => :flat).should == {
3060
+ "one.two.three" => "four"
3061
+ }
3062
+ end
3063
+ end
3064
+
3065
+ describe Addressable::URI, "when parsed from " +
3066
+ "'?one[two][three]=four&one[two][five]=six'" do
3067
+ before do
3068
+ @uri = Addressable::URI.parse("?one[two][three]=four&one[two][five]=six")
3069
+ end
3070
+
3071
+ it "should have the correct dot notation query values" do
3072
+ @uri.query_values(:notation => :subscript).should == {
3073
+ "one" => {"two" => {"three" => "four", "five" => "six"}}
3074
+ }
3075
+ end
3076
+
3077
+ it "should have the correct flat notation query values" do
3078
+ @uri.query_values(:notation => :flat).should == {
3079
+ "one[two][three]" => "four",
3080
+ "one[two][five]" => "six"
3081
+ }
3082
+ end
3083
+ end
3084
+
3085
+ describe Addressable::URI, "when parsed from " +
3086
+ "'?one.two.three=four&one.two.five=six'" do
3087
+ before do
3088
+ @uri = Addressable::URI.parse("?one.two.three=four&one.two.five=six")
3089
+ end
3090
+
3091
+ it "should have the correct dot notation query values" do
3092
+ @uri.query_values(:notation => :dot).should == {
3093
+ "one" => {"two" => {"three" => "four", "five" => "six"}}
3094
+ }
3095
+ end
3096
+
3097
+ it "should have the correct flat notation query values" do
3098
+ @uri.query_values(:notation => :flat).should == {
3099
+ "one.two.three" => "four",
3100
+ "one.two.five" => "six"
3101
+ }
3102
+ end
3103
+ end
3104
+
3105
+ describe Addressable::URI, "when parsed from " +
3106
+ "'?one[two][three][]=four&one[two][three][]=five'" do
3107
+ before do
3108
+ @uri = Addressable::URI.parse(
3109
+ "?one[two][three][]=four&one[two][three][]=five"
3110
+ )
3111
+ end
3112
+
3113
+ it "should have the correct subscript notation query values" do
3114
+ @uri.query_values(:notation => :subscript).should == {
3115
+ "one" => {"two" => {"three" => ["four", "five"]}}
3116
+ }
3117
+ end
3118
+
3119
+ it "should raise an error if a key is repeated in the flat notation" do
3120
+ (lambda do
3121
+ @uri.query_values(:notation => :flat)
3122
+ end).should raise_error(ArgumentError)
3123
+ end
3124
+ end
3125
+
3126
+ describe Addressable::URI, "when parsed from " +
3127
+ "'?one[two][three][0]=four&one[two][three][1]=five'" do
3128
+ before do
3129
+ @uri = Addressable::URI.parse(
3130
+ "?one[two][three][0]=four&one[two][three][1]=five"
3131
+ )
3132
+ end
3133
+
3134
+ it "should have the correct subscript notation query values" do
3135
+ @uri.query_values(:notation => :subscript).should == {
3136
+ "one" => {"two" => {"three" => ["four", "five"]}}
3137
+ }
3138
+ end
3139
+ end
3140
+
3141
+ describe Addressable::URI, "when parsed from " +
3142
+ "'http://www.詹姆斯.com/'" do
3143
+ before do
3144
+ @uri = Addressable::URI.parse("http://www.詹姆斯.com/")
3145
+ end
3146
+
3147
+ it "should be equivalent to 'http://www.xn--8ws00zhy3a.com/'" do
3148
+ @uri.should ==
3149
+ Addressable::URI.parse("http://www.xn--8ws00zhy3a.com/")
3150
+ end
3151
+
3152
+ it "should not have domain name encoded during normalization" do
3153
+ Addressable::URI.normalized_encode(@uri.to_s).should ==
3154
+ "http://www.詹姆斯.com/"
3155
+ end
3156
+ end
3157
+
3158
+ describe Addressable::URI, "when parsed from " +
3159
+ "'http://www.詹姆斯.com/ some spaces /'" do
3160
+ before do
3161
+ @uri = Addressable::URI.parse("http://www.詹姆斯.com/ some spaces /")
3162
+ end
3163
+
3164
+ it "should be equivalent to " +
3165
+ "'http://www.xn--8ws00zhy3a.com/%20some%20spaces%20/'" do
3166
+ @uri.should ==
3167
+ Addressable::URI.parse(
3168
+ "http://www.xn--8ws00zhy3a.com/%20some%20spaces%20/")
3169
+ end
3170
+
3171
+ it "should not have domain name encoded during normalization" do
3172
+ Addressable::URI.normalized_encode(@uri.to_s).should ==
3173
+ "http://www.詹姆斯.com/%20some%20spaces%20/"
3174
+ end
3175
+ end
3176
+
3177
+ describe Addressable::URI, "when parsed from " +
3178
+ "'http://www.xn--8ws00zhy3a.com/'" do
3179
+ before do
3180
+ @uri = Addressable::URI.parse("http://www.xn--8ws00zhy3a.com/")
3181
+ end
3182
+
3183
+ it "should be displayed as http://www.詹姆斯.com/" do
3184
+ @uri.display_uri.to_s.should == "http://www.詹姆斯.com/"
3185
+ end
3186
+
3187
+ it "should properly force the encoding" do
3188
+ display_string = @uri.display_uri.to_str
3189
+ display_string.should == "http://www.詹姆斯.com/"
3190
+ if display_string.respond_to?(:encoding)
3191
+ display_string.encoding.to_s.should == Encoding::UTF_8.to_s
3192
+ end
3193
+ end
3194
+ end
3195
+
3196
+ describe Addressable::URI, "when parsed from " +
3197
+ "'http://www.詹姆斯.com/atomtests/iri/詹.html'" do
3198
+ before do
3199
+ @uri = Addressable::URI.parse("http://www.詹姆斯.com/atomtests/iri/詹.html")
3200
+ end
3201
+
3202
+ it "should normalize to " +
3203
+ "http://www.xn--8ws00zhy3a.com/atomtests/iri/%E8%A9%B9.html" do
3204
+ @uri.normalize.to_s.should ==
3205
+ "http://www.xn--8ws00zhy3a.com/atomtests/iri/%E8%A9%B9.html"
3206
+ @uri.normalize!.to_s.should ==
3207
+ "http://www.xn--8ws00zhy3a.com/atomtests/iri/%E8%A9%B9.html"
3208
+ end
3209
+ end
3210
+
3211
+ describe Addressable::URI, "when parsed from a percent-encoded IRI" do
3212
+ before do
3213
+ @uri = Addressable::URI.parse(
3214
+ "http://www.%E3%81%BB%E3%82%93%E3%81%A8%E3%81%86%E3%81%AB%E3%81%AA" +
3215
+ "%E3%81%8C%E3%81%84%E3%82%8F%E3%81%91%E3%81%AE%E3%82%8F%E3%81%8B%E3" +
3216
+ "%82%89%E3%81%AA%E3%81%84%E3%81%A9%E3%82%81%E3%81%84%E3%82%93%E3%82" +
3217
+ "%81%E3%81%84%E3%81%AE%E3%82%89%E3%81%B9%E3%82%8B%E3%81%BE%E3%81%A0" +
3218
+ "%E3%81%AA%E3%81%8C%E3%81%8F%E3%81%97%E3%81%AA%E3%81%84%E3%81%A8%E3" +
3219
+ "%81%9F%E3%82%8A%E3%81%AA%E3%81%84.w3.mag.keio.ac.jp"
3220
+ )
3221
+ end
3222
+
3223
+ it "should normalize to something sane" do
3224
+ @uri.normalize.to_s.should ==
3225
+ "http://www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3f" +
3226
+ "g11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp/"
3227
+ @uri.normalize!.to_s.should ==
3228
+ "http://www.xn--n8jaaaaai5bhf7as8fsfk3jnknefdde3f" +
3229
+ "g11amb5gzdb4wi9bya3kc6lra.w3.mag.keio.ac.jp/"
3230
+ end
3231
+ end
3232
+
3233
+ describe Addressable::URI, "with a base uri of 'http://a/b/c/d;p?q'" do
3234
+ before do
3235
+ @uri = Addressable::URI.parse("http://a/b/c/d;p?q")
3236
+ end
3237
+
3238
+ # Section 5.4.1 of RFC 3986
3239
+ it "when joined with 'g:h' should resolve to g:h" do
3240
+ (@uri + "g:h").to_s.should == "g:h"
3241
+ Addressable::URI.join(@uri, "g:h").to_s.should == "g:h"
3242
+ end
3243
+
3244
+ # Section 5.4.1 of RFC 3986
3245
+ it "when joined with 'g' should resolve to http://a/b/c/g" do
3246
+ (@uri + "g").to_s.should == "http://a/b/c/g"
3247
+ Addressable::URI.join(@uri.to_s, "g").to_s.should == "http://a/b/c/g"
3248
+ end
3249
+
3250
+ # Section 5.4.1 of RFC 3986
3251
+ it "when joined with './g' should resolve to http://a/b/c/g" do
3252
+ (@uri + "./g").to_s.should == "http://a/b/c/g"
3253
+ Addressable::URI.join(@uri.to_s, "./g").to_s.should == "http://a/b/c/g"
3254
+ end
3255
+
3256
+ # Section 5.4.1 of RFC 3986
3257
+ it "when joined with 'g/' should resolve to http://a/b/c/g/" do
3258
+ (@uri + "g/").to_s.should == "http://a/b/c/g/"
3259
+ Addressable::URI.join(@uri.to_s, "g/").to_s.should == "http://a/b/c/g/"
3260
+ end
3261
+
3262
+ # Section 5.4.1 of RFC 3986
3263
+ it "when joined with '/g' should resolve to http://a/g" do
3264
+ (@uri + "/g").to_s.should == "http://a/g"
3265
+ Addressable::URI.join(@uri.to_s, "/g").to_s.should == "http://a/g"
3266
+ end
3267
+
3268
+ # Section 5.4.1 of RFC 3986
3269
+ it "when joined with '//g' should resolve to http://g" do
3270
+ (@uri + "//g").to_s.should == "http://g"
3271
+ Addressable::URI.join(@uri.to_s, "//g").to_s.should == "http://g"
3272
+ end
3273
+
3274
+ # Section 5.4.1 of RFC 3986
3275
+ it "when joined with '?y' should resolve to http://a/b/c/d;p?y" do
3276
+ (@uri + "?y").to_s.should == "http://a/b/c/d;p?y"
3277
+ Addressable::URI.join(@uri.to_s, "?y").to_s.should == "http://a/b/c/d;p?y"
3278
+ end
3279
+
3280
+ # Section 5.4.1 of RFC 3986
3281
+ it "when joined with 'g?y' should resolve to http://a/b/c/g?y" do
3282
+ (@uri + "g?y").to_s.should == "http://a/b/c/g?y"
3283
+ Addressable::URI.join(@uri.to_s, "g?y").to_s.should == "http://a/b/c/g?y"
3284
+ end
3285
+
3286
+ # Section 5.4.1 of RFC 3986
3287
+ it "when joined with '#s' should resolve to http://a/b/c/d;p?q#s" do
3288
+ (@uri + "#s").to_s.should == "http://a/b/c/d;p?q#s"
3289
+ Addressable::URI.join(@uri.to_s, "#s").to_s.should ==
3290
+ "http://a/b/c/d;p?q#s"
3291
+ end
3292
+
3293
+ # Section 5.4.1 of RFC 3986
3294
+ it "when joined with 'g#s' should resolve to http://a/b/c/g#s" do
3295
+ (@uri + "g#s").to_s.should == "http://a/b/c/g#s"
3296
+ Addressable::URI.join(@uri.to_s, "g#s").to_s.should == "http://a/b/c/g#s"
3297
+ end
3298
+
3299
+ # Section 5.4.1 of RFC 3986
3300
+ it "when joined with 'g?y#s' should resolve to http://a/b/c/g?y#s" do
3301
+ (@uri + "g?y#s").to_s.should == "http://a/b/c/g?y#s"
3302
+ Addressable::URI.join(
3303
+ @uri.to_s, "g?y#s").to_s.should == "http://a/b/c/g?y#s"
3304
+ end
3305
+
3306
+ # Section 5.4.1 of RFC 3986
3307
+ it "when joined with ';x' should resolve to http://a/b/c/;x" do
3308
+ (@uri + ";x").to_s.should == "http://a/b/c/;x"
3309
+ Addressable::URI.join(@uri.to_s, ";x").to_s.should == "http://a/b/c/;x"
3310
+ end
3311
+
3312
+ # Section 5.4.1 of RFC 3986
3313
+ it "when joined with 'g;x' should resolve to http://a/b/c/g;x" do
3314
+ (@uri + "g;x").to_s.should == "http://a/b/c/g;x"
3315
+ Addressable::URI.join(@uri.to_s, "g;x").to_s.should == "http://a/b/c/g;x"
3316
+ end
3317
+
3318
+ # Section 5.4.1 of RFC 3986
3319
+ it "when joined with 'g;x?y#s' should resolve to http://a/b/c/g;x?y#s" do
3320
+ (@uri + "g;x?y#s").to_s.should == "http://a/b/c/g;x?y#s"
3321
+ Addressable::URI.join(
3322
+ @uri.to_s, "g;x?y#s").to_s.should == "http://a/b/c/g;x?y#s"
3323
+ end
3324
+
3325
+ # Section 5.4.1 of RFC 3986
3326
+ it "when joined with '' should resolve to http://a/b/c/d;p?q" do
3327
+ (@uri + "").to_s.should == "http://a/b/c/d;p?q"
3328
+ Addressable::URI.join(@uri.to_s, "").to_s.should == "http://a/b/c/d;p?q"
3329
+ end
3330
+
3331
+ # Section 5.4.1 of RFC 3986
3332
+ it "when joined with '.' should resolve to http://a/b/c/" do
3333
+ (@uri + ".").to_s.should == "http://a/b/c/"
3334
+ Addressable::URI.join(@uri.to_s, ".").to_s.should == "http://a/b/c/"
3335
+ end
3336
+
3337
+ # Section 5.4.1 of RFC 3986
3338
+ it "when joined with './' should resolve to http://a/b/c/" do
3339
+ (@uri + "./").to_s.should == "http://a/b/c/"
3340
+ Addressable::URI.join(@uri.to_s, "./").to_s.should == "http://a/b/c/"
3341
+ end
3342
+
3343
+ # Section 5.4.1 of RFC 3986
3344
+ it "when joined with '..' should resolve to http://a/b/" do
3345
+ (@uri + "..").to_s.should == "http://a/b/"
3346
+ Addressable::URI.join(@uri.to_s, "..").to_s.should == "http://a/b/"
3347
+ end
3348
+
3349
+ # Section 5.4.1 of RFC 3986
3350
+ it "when joined with '../' should resolve to http://a/b/" do
3351
+ (@uri + "../").to_s.should == "http://a/b/"
3352
+ Addressable::URI.join(@uri.to_s, "../").to_s.should == "http://a/b/"
3353
+ end
3354
+
3355
+ # Section 5.4.1 of RFC 3986
3356
+ it "when joined with '../g' should resolve to http://a/b/g" do
3357
+ (@uri + "../g").to_s.should == "http://a/b/g"
3358
+ Addressable::URI.join(@uri.to_s, "../g").to_s.should == "http://a/b/g"
3359
+ end
3360
+
3361
+ # Section 5.4.1 of RFC 3986
3362
+ it "when joined with '../..' should resolve to http://a/" do
3363
+ (@uri + "../..").to_s.should == "http://a/"
3364
+ Addressable::URI.join(@uri.to_s, "../..").to_s.should == "http://a/"
3365
+ end
3366
+
3367
+ # Section 5.4.1 of RFC 3986
3368
+ it "when joined with '../../' should resolve to http://a/" do
3369
+ (@uri + "../../").to_s.should == "http://a/"
3370
+ Addressable::URI.join(@uri.to_s, "../../").to_s.should == "http://a/"
3371
+ end
3372
+
3373
+ # Section 5.4.1 of RFC 3986
3374
+ it "when joined with '../../g' should resolve to http://a/g" do
3375
+ (@uri + "../../g").to_s.should == "http://a/g"
3376
+ Addressable::URI.join(@uri.to_s, "../../g").to_s.should == "http://a/g"
3377
+ end
3378
+
3379
+ # Section 5.4.2 of RFC 3986
3380
+ it "when joined with '../../../g' should resolve to http://a/g" do
3381
+ (@uri + "../../../g").to_s.should == "http://a/g"
3382
+ Addressable::URI.join(@uri.to_s, "../../../g").to_s.should == "http://a/g"
3383
+ end
3384
+
3385
+ it "when joined with '../.././../g' should resolve to http://a/g" do
3386
+ (@uri + "../.././../g").to_s.should == "http://a/g"
3387
+ Addressable::URI.join(@uri.to_s, "../.././../g").to_s.should ==
3388
+ "http://a/g"
3389
+ end
3390
+
3391
+ # Section 5.4.2 of RFC 3986
3392
+ it "when joined with '../../../../g' should resolve to http://a/g" do
3393
+ (@uri + "../../../../g").to_s.should == "http://a/g"
3394
+ Addressable::URI.join(
3395
+ @uri.to_s, "../../../../g").to_s.should == "http://a/g"
3396
+ end
3397
+
3398
+ # Section 5.4.2 of RFC 3986
3399
+ it "when joined with '/./g' should resolve to http://a/g" do
3400
+ (@uri + "/./g").to_s.should == "http://a/g"
3401
+ Addressable::URI.join(@uri.to_s, "/./g").to_s.should == "http://a/g"
3402
+ end
3403
+
3404
+ # Section 5.4.2 of RFC 3986
3405
+ it "when joined with '/../g' should resolve to http://a/g" do
3406
+ (@uri + "/../g").to_s.should == "http://a/g"
3407
+ Addressable::URI.join(@uri.to_s, "/../g").to_s.should == "http://a/g"
3408
+ end
3409
+
3410
+ # Section 5.4.2 of RFC 3986
3411
+ it "when joined with 'g.' should resolve to http://a/b/c/g." do
3412
+ (@uri + "g.").to_s.should == "http://a/b/c/g."
3413
+ Addressable::URI.join(@uri.to_s, "g.").to_s.should == "http://a/b/c/g."
3414
+ end
3415
+
3416
+ # Section 5.4.2 of RFC 3986
3417
+ it "when joined with '.g' should resolve to http://a/b/c/.g" do
3418
+ (@uri + ".g").to_s.should == "http://a/b/c/.g"
3419
+ Addressable::URI.join(@uri.to_s, ".g").to_s.should == "http://a/b/c/.g"
3420
+ end
3421
+
3422
+ # Section 5.4.2 of RFC 3986
3423
+ it "when joined with 'g..' should resolve to http://a/b/c/g.." do
3424
+ (@uri + "g..").to_s.should == "http://a/b/c/g.."
3425
+ Addressable::URI.join(@uri.to_s, "g..").to_s.should == "http://a/b/c/g.."
3426
+ end
3427
+
3428
+ # Section 5.4.2 of RFC 3986
3429
+ it "when joined with '..g' should resolve to http://a/b/c/..g" do
3430
+ (@uri + "..g").to_s.should == "http://a/b/c/..g"
3431
+ Addressable::URI.join(@uri.to_s, "..g").to_s.should == "http://a/b/c/..g"
3432
+ end
3433
+
3434
+ # Section 5.4.2 of RFC 3986
3435
+ it "when joined with './../g' should resolve to http://a/b/g" do
3436
+ (@uri + "./../g").to_s.should == "http://a/b/g"
3437
+ Addressable::URI.join(@uri.to_s, "./../g").to_s.should == "http://a/b/g"
3438
+ end
3439
+
3440
+ # Section 5.4.2 of RFC 3986
3441
+ it "when joined with './g/.' should resolve to http://a/b/c/g/" do
3442
+ (@uri + "./g/.").to_s.should == "http://a/b/c/g/"
3443
+ Addressable::URI.join(@uri.to_s, "./g/.").to_s.should == "http://a/b/c/g/"
3444
+ end
3445
+
3446
+ # Section 5.4.2 of RFC 3986
3447
+ it "when joined with 'g/./h' should resolve to http://a/b/c/g/h" do
3448
+ (@uri + "g/./h").to_s.should == "http://a/b/c/g/h"
3449
+ Addressable::URI.join(@uri.to_s, "g/./h").to_s.should == "http://a/b/c/g/h"
3450
+ end
3451
+
3452
+ # Section 5.4.2 of RFC 3986
3453
+ it "when joined with 'g/../h' should resolve to http://a/b/c/h" do
3454
+ (@uri + "g/../h").to_s.should == "http://a/b/c/h"
3455
+ Addressable::URI.join(@uri.to_s, "g/../h").to_s.should == "http://a/b/c/h"
3456
+ end
3457
+
3458
+ # Section 5.4.2 of RFC 3986
3459
+ it "when joined with 'g;x=1/./y' " +
3460
+ "should resolve to http://a/b/c/g;x=1/y" do
3461
+ (@uri + "g;x=1/./y").to_s.should == "http://a/b/c/g;x=1/y"
3462
+ Addressable::URI.join(
3463
+ @uri.to_s, "g;x=1/./y").to_s.should == "http://a/b/c/g;x=1/y"
3464
+ end
3465
+
3466
+ # Section 5.4.2 of RFC 3986
3467
+ it "when joined with 'g;x=1/../y' should resolve to http://a/b/c/y" do
3468
+ (@uri + "g;x=1/../y").to_s.should == "http://a/b/c/y"
3469
+ Addressable::URI.join(
3470
+ @uri.to_s, "g;x=1/../y").to_s.should == "http://a/b/c/y"
3471
+ end
3472
+
3473
+ # Section 5.4.2 of RFC 3986
3474
+ it "when joined with 'g?y/./x' " +
3475
+ "should resolve to http://a/b/c/g?y/./x" do
3476
+ (@uri + "g?y/./x").to_s.should == "http://a/b/c/g?y/./x"
3477
+ Addressable::URI.join(
3478
+ @uri.to_s, "g?y/./x").to_s.should == "http://a/b/c/g?y/./x"
3479
+ end
3480
+
3481
+ # Section 5.4.2 of RFC 3986
3482
+ it "when joined with 'g?y/../x' " +
3483
+ "should resolve to http://a/b/c/g?y/../x" do
3484
+ (@uri + "g?y/../x").to_s.should == "http://a/b/c/g?y/../x"
3485
+ Addressable::URI.join(
3486
+ @uri.to_s, "g?y/../x").to_s.should == "http://a/b/c/g?y/../x"
3487
+ end
3488
+
3489
+ # Section 5.4.2 of RFC 3986
3490
+ it "when joined with 'g#s/./x' " +
3491
+ "should resolve to http://a/b/c/g#s/./x" do
3492
+ (@uri + "g#s/./x").to_s.should == "http://a/b/c/g#s/./x"
3493
+ Addressable::URI.join(
3494
+ @uri.to_s, "g#s/./x").to_s.should == "http://a/b/c/g#s/./x"
3495
+ end
3496
+
3497
+ # Section 5.4.2 of RFC 3986
3498
+ it "when joined with 'g#s/../x' " +
3499
+ "should resolve to http://a/b/c/g#s/../x" do
3500
+ (@uri + "g#s/../x").to_s.should == "http://a/b/c/g#s/../x"
3501
+ Addressable::URI.join(
3502
+ @uri.to_s, "g#s/../x").to_s.should == "http://a/b/c/g#s/../x"
3503
+ end
3504
+
3505
+ # Section 5.4.2 of RFC 3986
3506
+ it "when joined with 'http:g' should resolve to http:g" do
3507
+ (@uri + "http:g").to_s.should == "http:g"
3508
+ Addressable::URI.join(@uri.to_s, "http:g").to_s.should == "http:g"
3509
+ end
3510
+
3511
+ # Edge case to be sure
3512
+ it "when joined with '//example.com/' should " +
3513
+ "resolve to http://example.com/" do
3514
+ (@uri + "//example.com/").to_s.should == "http://example.com/"
3515
+ Addressable::URI.join(
3516
+ @uri.to_s, "//example.com/").to_s.should == "http://example.com/"
3517
+ end
3518
+
3519
+ it "when joined with a bogus object a TypeError should be raised" do
3520
+ (lambda do
3521
+ Addressable::URI.join(@uri, 42)
3522
+ end).should raise_error(TypeError)
3523
+ end
3524
+ end
3525
+
3526
+ describe Addressable::URI, "when converting the path " +
3527
+ "'relative/path/to/something'" do
3528
+ before do
3529
+ @path = 'relative/path/to/something'
3530
+ end
3531
+
3532
+ it "should convert to " +
3533
+ "\'relative/path/to/something\'" do
3534
+ @uri = Addressable::URI.convert_path(@path)
3535
+ @uri.to_str.should == "relative/path/to/something"
3536
+ end
3537
+
3538
+ it "should join with an absolute file path correctly" do
3539
+ @base = Addressable::URI.convert_path("/absolute/path/")
3540
+ @uri = Addressable::URI.convert_path(@path)
3541
+ (@base + @uri).to_str.should ==
3542
+ "file:///absolute/path/relative/path/to/something"
3543
+ end
3544
+ end
3545
+
3546
+ describe Addressable::URI, "when converting a bogus path" do
3547
+ it "should raise a TypeError" do
3548
+ (lambda do
3549
+ Addressable::URI.convert_path(42)
3550
+ end).should raise_error(TypeError)
3551
+ end
3552
+ end
3553
+
3554
+ describe Addressable::URI, "when given a UNIX root directory" do
3555
+ before do
3556
+ @path = "/"
3557
+ end
3558
+
3559
+ it "should convert to \'file:///\'" do
3560
+ @uri = Addressable::URI.convert_path(@path)
3561
+ @uri.to_str.should == "file:///"
3562
+ end
3563
+ end
3564
+
3565
+ describe Addressable::URI, "when given a Windows root directory" do
3566
+ before do
3567
+ @path = "C:\\"
3568
+ end
3569
+
3570
+ it "should convert to \'file:///c:/\'" do
3571
+ @uri = Addressable::URI.convert_path(@path)
3572
+ @uri.to_str.should == "file:///c:/"
3573
+ end
3574
+ end
3575
+
3576
+ describe Addressable::URI, "when given the path '/home/user/'" do
3577
+ before do
3578
+ @path = '/home/user/'
3579
+ end
3580
+
3581
+ it "should convert to " +
3582
+ "\'file:///home/user/\'" do
3583
+ @uri = Addressable::URI.convert_path(@path)
3584
+ @uri.to_str.should == "file:///home/user/"
3585
+ end
3586
+ end
3587
+
3588
+ describe Addressable::URI, "when given the path " +
3589
+ "'c:\\windows\\My Documents 100%20\\foo.txt'" do
3590
+ before do
3591
+ @path = "c:\\windows\\My Documents 100%20\\foo.txt"
3592
+ end
3593
+
3594
+ it "should convert to " +
3595
+ "\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do
3596
+ @uri = Addressable::URI.convert_path(@path)
3597
+ @uri.to_str.should == "file:///c:/windows/My%20Documents%20100%20/foo.txt"
3598
+ end
3599
+ end
3600
+
3601
+ describe Addressable::URI, "when given the path " +
3602
+ "'file://c:\\windows\\My Documents 100%20\\foo.txt'" do
3603
+ before do
3604
+ @path = "file://c:\\windows\\My Documents 100%20\\foo.txt"
3605
+ end
3606
+
3607
+ it "should convert to " +
3608
+ "\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do
3609
+ @uri = Addressable::URI.convert_path(@path)
3610
+ @uri.to_str.should == "file:///c:/windows/My%20Documents%20100%20/foo.txt"
3611
+ end
3612
+ end
3613
+
3614
+ describe Addressable::URI, "when given the path " +
3615
+ "'file:c:\\windows\\My Documents 100%20\\foo.txt'" do
3616
+ before do
3617
+ @path = "file:c:\\windows\\My Documents 100%20\\foo.txt"
3618
+ end
3619
+
3620
+ it "should convert to " +
3621
+ "\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do
3622
+ @uri = Addressable::URI.convert_path(@path)
3623
+ @uri.to_str.should == "file:///c:/windows/My%20Documents%20100%20/foo.txt"
3624
+ end
3625
+ end
3626
+
3627
+ describe Addressable::URI, "when given the path " +
3628
+ "'file:/c:\\windows\\My Documents 100%20\\foo.txt'" do
3629
+ before do
3630
+ @path = "file:/c:\\windows\\My Documents 100%20\\foo.txt"
3631
+ end
3632
+
3633
+ it "should convert to " +
3634
+ "\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do
3635
+ @uri = Addressable::URI.convert_path(@path)
3636
+ @uri.to_str.should == "file:///c:/windows/My%20Documents%20100%20/foo.txt"
3637
+ end
3638
+ end
3639
+
3640
+ describe Addressable::URI, "when given the path " +
3641
+ "'file:///c|/windows/My%20Documents%20100%20/foo.txt'" do
3642
+ before do
3643
+ @path = "file:///c|/windows/My%20Documents%20100%20/foo.txt"
3644
+ end
3645
+
3646
+ it "should convert to " +
3647
+ "\'file:///c:/windows/My%20Documents%20100%20/foo.txt\'" do
3648
+ @uri = Addressable::URI.convert_path(@path)
3649
+ @uri.to_str.should == "file:///c:/windows/My%20Documents%20100%20/foo.txt"
3650
+ end
3651
+ end
3652
+
3653
+ describe Addressable::URI, "when given an http protocol URI" do
3654
+ before do
3655
+ @path = "http://example.com/"
3656
+ end
3657
+
3658
+ it "should not do any conversion at all" do
3659
+ @uri = Addressable::URI.convert_path(@path)
3660
+ @uri.to_str.should == "http://example.com/"
3661
+ end
3662
+ end
3663
+
3664
+ class SuperString
3665
+ def initialize(string)
3666
+ @string = string.to_s
3667
+ end
3668
+
3669
+ def to_str
3670
+ return @string
3671
+ end
3672
+ end
3673
+
3674
+ describe Addressable::URI, "when parsing a non-String object" do
3675
+ it "should correctly parse anything with a 'to_str' method" do
3676
+ Addressable::URI.parse(SuperString.new(42))
3677
+ end
3678
+
3679
+ it "should raise a TypeError for objects than cannot be converted" do
3680
+ (lambda do
3681
+ Addressable::URI.parse(42)
3682
+ end).should raise_error(TypeError, "Can't convert Fixnum into String.")
3683
+ end
3684
+
3685
+ it "should correctly parse heuristically anything with a 'to_str' method" do
3686
+ Addressable::URI.heuristic_parse(SuperString.new(42))
3687
+ end
3688
+
3689
+ it "should raise a TypeError for objects than cannot be converted" do
3690
+ (lambda do
3691
+ Addressable::URI.heuristic_parse(42)
3692
+ end).should raise_error(TypeError, "Can't convert Fixnum into String.")
3693
+ end
3694
+ end
3695
+
3696
+ describe Addressable::URI, "when form encoding a hash" do
3697
+ it "should result in correct percent encoded sequence" do
3698
+ Addressable::URI.form_encode(
3699
+ {"&one" => "/1", "=two" => "?2", ":three" => "#3"}
3700
+ ).should == "%26one=%2F1&%3Dtwo=%3F2&%3Athree=%233"
3701
+ end
3702
+
3703
+ it "should result in correct percent encoded sequence" do
3704
+ Addressable::URI.form_encode(
3705
+ {"q" => "one two three"}
3706
+ ).should == "q=one+two+three"
3707
+ end
3708
+
3709
+ it "should result in correct percent encoded sequence" do
3710
+ Addressable::URI.form_encode(
3711
+ {"key" => nil}
3712
+ ).should == "key="
3713
+ end
3714
+
3715
+ it "should result in correctly encoded newlines" do
3716
+ Addressable::URI.form_encode(
3717
+ {"text" => "one\ntwo\rthree\r\nfour\n\r"}
3718
+ ).should == "text=one%0D%0Atwo%0D%0Athree%0D%0Afour%0D%0A%0D%0A"
3719
+ end
3720
+
3721
+ it "should result in a sorted percent encoded sequence" do
3722
+ Addressable::URI.form_encode(
3723
+ [["a", "1"], ["dup", "3"], ["dup", "2"]], true
3724
+ ).should == "a=1&dup=2&dup=3"
3725
+ end
3726
+ end
3727
+
3728
+ describe Addressable::URI, "when form encoding a non-Array object" do
3729
+ it "should raise a TypeError for objects than cannot be converted" do
3730
+ (lambda do
3731
+ Addressable::URI.form_encode(42)
3732
+ end).should raise_error(TypeError, "Can't convert Fixnum into Array.")
3733
+ end
3734
+ end
3735
+
3736
+ describe Addressable::URI, "when form unencoding a string" do
3737
+ it "should result in correct values" do
3738
+ Addressable::URI.form_unencode(
3739
+ "%26one=%2F1&%3Dtwo=%3F2&%3Athree=%233"
3740
+ ).should == [["&one", "/1"], ["=two", "?2"], [":three", "#3"]]
3741
+ end
3742
+
3743
+ it "should result in correct values" do
3744
+ Addressable::URI.form_unencode(
3745
+ "q=one+two+three"
3746
+ ).should == [["q", "one two three"]]
3747
+ end
3748
+
3749
+ it "should result in correct values" do
3750
+ Addressable::URI.form_unencode(
3751
+ "text=one%0D%0Atwo%0D%0Athree%0D%0Afour%0D%0A%0D%0A"
3752
+ ).should == [["text", "one\ntwo\nthree\nfour\n\n"]]
3753
+ end
3754
+
3755
+ it "should result in correct values" do
3756
+ Addressable::URI.form_unencode(
3757
+ "a=1&dup=2&dup=3"
3758
+ ).should == [["a", "1"], ["dup", "2"], ["dup", "3"]]
3759
+ end
3760
+
3761
+ it "should result in correct values" do
3762
+ Addressable::URI.form_unencode(
3763
+ "key"
3764
+ ).should == [["key", nil]]
3765
+ end
3766
+
3767
+ it "should result in correct values" do
3768
+ Addressable::URI.form_unencode("GivenName=Ren%C3%A9").should ==
3769
+ [["GivenName", "René"]]
3770
+ end
3771
+ end
3772
+
3773
+ describe Addressable::URI, "when form unencoding a non-String object" do
3774
+ it "should correctly parse anything with a 'to_str' method" do
3775
+ Addressable::URI.form_unencode(SuperString.new(42))
3776
+ end
3777
+
3778
+ it "should raise a TypeError for objects than cannot be converted" do
3779
+ (lambda do
3780
+ Addressable::URI.form_unencode(42)
3781
+ end).should raise_error(TypeError, "Can't convert Fixnum into String.")
3782
+ end
3783
+ end
3784
+
3785
+ describe Addressable::URI, "when normalizing a non-String object" do
3786
+ it "should correctly parse anything with a 'to_str' method" do
3787
+ Addressable::URI.normalize_component(SuperString.new(42))
3788
+ end
3789
+
3790
+ it "should raise a TypeError for objects than cannot be converted" do
3791
+ (lambda do
3792
+ Addressable::URI.normalize_component(42)
3793
+ end).should raise_error(TypeError, "Can't convert Fixnum into String.")
3794
+ end
3795
+
3796
+ it "should raise a TypeError for objects than cannot be converted" do
3797
+ (lambda do
3798
+ Addressable::URI.normalize_component("component", 42)
3799
+ end).should raise_error(TypeError)
3800
+ end
3801
+ end
3802
+
3803
+ describe Addressable::URI, "when normalizing a path with an encoded slash" do
3804
+ it "should result in correct percent encoded sequence" do
3805
+ Addressable::URI.parse("/path%2Fsegment/").normalize.path.should ==
3806
+ "/path%2Fsegment/"
3807
+ end
3808
+ end
3809
+
3810
+ describe Addressable::URI, "when normalizing a partially encoded string" do
3811
+ it "should result in correct percent encoded sequence" do
3812
+ Addressable::URI.normalize_component(
3813
+ "partially % encoded%21"
3814
+ ).should == "partially%20%25%20encoded!"
3815
+ end
3816
+
3817
+ it "should result in correct percent encoded sequence" do
3818
+ Addressable::URI.normalize_component(
3819
+ "partially %25 encoded!"
3820
+ ).should == "partially%20%25%20encoded!"
3821
+ end
3822
+ end
3823
+
3824
+ describe Addressable::URI, "when normalizing a unicode sequence" do
3825
+ it "should result in correct percent encoded sequence" do
3826
+ Addressable::URI.normalize_component(
3827
+ "/C%CC%A7"
3828
+ ).should == "/%C3%87"
3829
+ end
3830
+
3831
+ it "should result in correct percent encoded sequence" do
3832
+ Addressable::URI.normalize_component(
3833
+ "/%C3%87"
3834
+ ).should == "/%C3%87"
3835
+ end
3836
+ end
3837
+
3838
+ describe Addressable::URI, "when normalizing a multibyte string" do
3839
+ it "should result in correct percent encoded sequence" do
3840
+ Addressable::URI.normalize_component("günther").should ==
3841
+ "g%C3%BCnther"
3842
+ end
3843
+
3844
+ it "should result in correct percent encoded sequence" do
3845
+ Addressable::URI.normalize_component("g%C3%BCnther").should ==
3846
+ "g%C3%BCnther"
3847
+ end
3848
+ end
3849
+
3850
+ describe Addressable::URI, "when encoding a multibyte string" do
3851
+ it "should result in correct percent encoded sequence" do
3852
+ Addressable::URI.encode_component("günther").should == "g%C3%BCnther"
3853
+ end
3854
+
3855
+ it "should result in correct percent encoded sequence" do
3856
+ Addressable::URI.encode_component(
3857
+ "günther", /[^a-zA-Z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\-\.\_\~]/
3858
+ ).should == "g%C3%BCnther"
3859
+ end
3860
+ end
3861
+
3862
+ describe Addressable::URI, "when form encoding a multibyte string" do
3863
+ it "should result in correct percent encoded sequence" do
3864
+ Addressable::URI.form_encode({"GivenName" => "René"}).should ==
3865
+ "GivenName=Ren%C3%A9"
3866
+ end
3867
+ end
3868
+
3869
+ describe Addressable::URI, "when encoding a string with ASCII chars 0-15" do
3870
+ it "should result in correct percent encoded sequence" do
3871
+ Addressable::URI.encode_component("one\ntwo").should == "one%0Atwo"
3872
+ end
3873
+
3874
+ it "should result in correct percent encoded sequence" do
3875
+ Addressable::URI.encode_component(
3876
+ "one\ntwo", /[^a-zA-Z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\-\.\_\~]/
3877
+ ).should == "one%0Atwo"
3878
+ end
3879
+ end
3880
+
3881
+ describe Addressable::URI, "when unencoding a multibyte string" do
3882
+ it "should result in correct percent encoded sequence" do
3883
+ Addressable::URI.unencode_component("g%C3%BCnther").should == "günther"
3884
+ end
3885
+
3886
+ it "should result in correct percent encoded sequence as a URI" do
3887
+ Addressable::URI.unencode(
3888
+ "/path?g%C3%BCnther", ::Addressable::URI
3889
+ ).should == Addressable::URI.new(
3890
+ :path => "/path", :query => "günther"
3891
+ )
3892
+ end
3893
+ end
3894
+
3895
+ describe Addressable::URI, "when unencoding a bogus object" do
3896
+ it "should raise a TypeError" do
3897
+ (lambda do
3898
+ Addressable::URI.unencode_component(42)
3899
+ end).should raise_error(TypeError)
3900
+ end
3901
+
3902
+ it "should raise a TypeError" do
3903
+ (lambda do
3904
+ Addressable::URI.unencode("/path?g%C3%BCnther", Integer)
3905
+ end).should raise_error(TypeError)
3906
+ end
3907
+ end
3908
+
3909
+ describe Addressable::URI, "when encoding a bogus object" do
3910
+ it "should raise a TypeError" do
3911
+ (lambda do
3912
+ Addressable::URI.encode(42)
3913
+ end).should raise_error(TypeError)
3914
+ end
3915
+
3916
+ it "should raise a TypeError" do
3917
+ (lambda do
3918
+ Addressable::URI.normalized_encode(42)
3919
+ end).should raise_error(TypeError)
3920
+ end
3921
+
3922
+ it "should raise a TypeError" do
3923
+ (lambda do
3924
+ Addressable::URI.encode_component("günther", 42)
3925
+ end).should raise_error(TypeError)
3926
+ end
3927
+
3928
+ it "should raise a TypeError" do
3929
+ (lambda do
3930
+ Addressable::URI.encode_component(42)
3931
+ end).should raise_error(TypeError)
3932
+ end
3933
+ end
3934
+
3935
+ describe Addressable::URI, "when given the input " +
3936
+ "'http://example.com/'" do
3937
+ before do
3938
+ @input = "http://example.com/"
3939
+ end
3940
+
3941
+ it "should heuristically parse to 'http://example.com/'" do
3942
+ @uri = Addressable::URI.heuristic_parse(@input)
3943
+ @uri.to_s.should == "http://example.com/"
3944
+ end
3945
+ end
3946
+
3947
+
3948
+ describe Addressable::URI, "when given the input " +
3949
+ "'http:example.com/'" do
3950
+ before do
3951
+ @input = "http:example.com/"
3952
+ end
3953
+
3954
+ it "should heuristically parse to 'http://example.com/'" do
3955
+ @uri = Addressable::URI.heuristic_parse(@input)
3956
+ @uri.to_s.should == "http://example.com/"
3957
+ end
3958
+
3959
+ it "should heuristically parse to 'http://example.com/' " +
3960
+ "even with a scheme hint of 'ftp'" do
3961
+ @uri = Addressable::URI.heuristic_parse(@input, {:scheme => 'ftp'})
3962
+ @uri.to_s.should == "http://example.com/"
3963
+ end
3964
+ end
3965
+
3966
+ describe Addressable::URI, "when given the input " +
3967
+ "'http://example.com/example.com/'" do
3968
+ before do
3969
+ @input = "http://example.com/example.com/"
3970
+ end
3971
+
3972
+ it "should heuristically parse to 'http://example.com/example.com/'" do
3973
+ @uri = Addressable::URI.heuristic_parse(@input)
3974
+ @uri.to_s.should == "http://example.com/example.com/"
3975
+ end
3976
+ end
3977
+
3978
+ describe Addressable::URI, "when given the input " +
3979
+ "'/path/to/resource'" do
3980
+ before do
3981
+ @input = "/path/to/resource"
3982
+ end
3983
+
3984
+ it "should heuristically parse to '/path/to/resource'" do
3985
+ @uri = Addressable::URI.heuristic_parse(@input)
3986
+ @uri.to_s.should == "/path/to/resource"
3987
+ end
3988
+ end
3989
+
3990
+ describe Addressable::URI, "when given the input " +
3991
+ "'relative/path/to/resource'" do
3992
+ before do
3993
+ @input = "relative/path/to/resource"
3994
+ end
3995
+
3996
+ it "should heuristically parse to 'relative/path/to/resource'" do
3997
+ @uri = Addressable::URI.heuristic_parse(@input)
3998
+ @uri.to_s.should == "relative/path/to/resource"
3999
+ end
4000
+ end
4001
+
4002
+ describe Addressable::URI, "when given the input " +
4003
+ "'example.com'" do
4004
+ before do
4005
+ @input = "example.com"
4006
+ end
4007
+
4008
+ it "should heuristically parse to 'http://example.com'" do
4009
+ @uri = Addressable::URI.heuristic_parse(@input)
4010
+ @uri.to_s.should == "http://example.com"
4011
+ end
4012
+ end
4013
+
4014
+ describe Addressable::URI, "when given the input " +
4015
+ "'example.com' and a scheme hint of 'ftp'" do
4016
+ before do
4017
+ @input = "example.com"
4018
+ @hints = {:scheme => 'ftp'}
4019
+ end
4020
+
4021
+ it "should heuristically parse to 'http://example.com'" do
4022
+ @uri = Addressable::URI.heuristic_parse(@input, @hints)
4023
+ @uri.to_s.should == "ftp://example.com"
4024
+ end
4025
+ end
4026
+
4027
+ describe Addressable::URI, "when given the input " +
4028
+ "'example.com:21' and a scheme hint of 'ftp'" do
4029
+ before do
4030
+ @input = "example.com:21"
4031
+ @hints = {:scheme => 'ftp'}
4032
+ end
4033
+
4034
+ it "should heuristically parse to 'http://example.com:21'" do
4035
+ @uri = Addressable::URI.heuristic_parse(@input, @hints)
4036
+ @uri.to_s.should == "ftp://example.com:21"
4037
+ end
4038
+ end
4039
+
4040
+ describe Addressable::URI, "when given the input " +
4041
+ "'example.com/path/to/resource'" do
4042
+ before do
4043
+ @input = "example.com/path/to/resource"
4044
+ end
4045
+
4046
+ it "should heuristically parse to 'http://example.com/path/to/resource'" do
4047
+ @uri = Addressable::URI.heuristic_parse(@input)
4048
+ @uri.to_s.should == "http://example.com/path/to/resource"
4049
+ end
4050
+ end
4051
+
4052
+ describe Addressable::URI, "when given the input " +
4053
+ "'http:///example.com'" do
4054
+ before do
4055
+ @input = "http:///example.com"
4056
+ end
4057
+
4058
+ it "should heuristically parse to 'http://example.com'" do
4059
+ @uri = Addressable::URI.heuristic_parse(@input)
4060
+ @uri.to_s.should == "http://example.com"
4061
+ end
4062
+ end
4063
+
4064
+ describe Addressable::URI, "when given the input " +
4065
+ "'feed:///example.com'" do
4066
+ before do
4067
+ @input = "feed:///example.com"
4068
+ end
4069
+
4070
+ it "should heuristically parse to 'feed://example.com'" do
4071
+ @uri = Addressable::URI.heuristic_parse(@input)
4072
+ @uri.to_s.should == "feed://example.com"
4073
+ end
4074
+ end
4075
+
4076
+ describe Addressable::URI, "when given the input " +
4077
+ "'file://path/to/resource/'" do
4078
+ before do
4079
+ @input = "file://path/to/resource/"
4080
+ end
4081
+
4082
+ it "should heuristically parse to 'file:///path/to/resource/'" do
4083
+ @uri = Addressable::URI.heuristic_parse(@input)
4084
+ @uri.to_s.should == "file:///path/to/resource/"
4085
+ end
4086
+ end
4087
+
4088
+ describe Addressable::URI, "when given the input " +
4089
+ "'feed://http://example.com'" do
4090
+ before do
4091
+ @input = "feed://http://example.com"
4092
+ end
4093
+
4094
+ it "should heuristically parse to 'feed:http://example.com'" do
4095
+ @uri = Addressable::URI.heuristic_parse(@input)
4096
+ @uri.to_s.should == "feed:http://example.com"
4097
+ end
4098
+ end
4099
+
4100
+ describe Addressable::URI, "when assigning query values" do
4101
+ before do
4102
+ @uri = Addressable::URI.new
4103
+ end
4104
+
4105
+ it "should correctly assign {:a => 'a', :b => ['c', 'd', 'e']}" do
4106
+ @uri.query_values = {:a => "a", :b => ["c", "d", "e"]}
4107
+ @uri.query.should == "a=a&b[0]=c&b[1]=d&b[2]=e"
4108
+ end
4109
+
4110
+ it "should correctly assign " +
4111
+ "{:a => 'a', :b => [{:c => 'c', :d => 'd'}, {:e => 'e', :f => 'f'}]}" do
4112
+ @uri.query_values = {
4113
+ :a => "a", :b => [{:c => "c", :d => "d"}, {:e => "e", :f => "f"}]
4114
+ }
4115
+ @uri.query.should == "a=a&b[0][c]=c&b[0][d]=d&b[1][e]=e&b[1][f]=f"
4116
+ end
4117
+
4118
+ it "should correctly assign " +
4119
+ "{:a => 'a', :b => [{:c => true, :d => 'd'}, {:e => 'e', :f => 'f'}]}" do
4120
+ @uri.query_values = {
4121
+ :a => 'a', :b => [{:c => true, :d => 'd'}, {:e => 'e', :f => 'f'}]
4122
+ }
4123
+ @uri.query.should == "a=a&b[0][c]&b[0][d]=d&b[1][e]=e&b[1][f]=f"
4124
+ end
4125
+
4126
+ it "should correctly assign " +
4127
+ "{:a => 'a', :b => {:c => true, :d => 'd'}}" do
4128
+ @uri.query_values = {
4129
+ :a => 'a', :b => {:c => true, :d => 'd'}
4130
+ }
4131
+ @uri.query.should == "a=a&b[c]&b[d]=d"
4132
+ end
4133
+
4134
+ it "should correctly assign " +
4135
+ "{:a => 'a', :b => {:c => true, :d => 'd'}, :e => []}" do
4136
+ @uri.query_values = {
4137
+ :a => 'a', :b => {:c => true, :d => 'd'}
4138
+ }
4139
+ @uri.query.should == "a=a&b[c]&b[d]=d"
4140
+ end
4141
+
4142
+ it "should correctly assign {}" do
4143
+ @uri.query_values = {}
4144
+ @uri.query.should == ''
4145
+ end
4146
+
4147
+ it "should correctly assign nil" do
4148
+ @uri.query_values = nil
4149
+ @uri.query.should == nil
4150
+ end
4151
+
4152
+ it "should correctly sort {'ab' => 'c', :ab => 'a', :a => 'x'}" do
4153
+ @uri.query_values = {'ab' => 'c', :ab => 'a', :a => 'x'}
4154
+ @uri.query.should == "a=x&ab=a&ab=c"
4155
+ end
4156
+ end
4157
+
4158
+ describe Addressable::URI, "when assigning path values" do
4159
+ before do
4160
+ @uri = Addressable::URI.new
4161
+ end
4162
+
4163
+ it "should correctly assign paths containing colons" do
4164
+ @uri.path = "acct:bob@sporkmonger.com"
4165
+ Addressable::URI.parse(@uri.normalize.to_str).path.should == @uri.path
4166
+ @uri.normalize.to_str.should == "acct%2Fbob@sporkmonger.com"
4167
+ end
4168
+
4169
+ it "should correctly assign paths containing colons" do
4170
+ @uri.path = "/acct:bob@sporkmonger.com"
4171
+ @uri.authority = "example.com"
4172
+ @uri.normalize.to_str.should == "//example.com/acct:bob@sporkmonger.com"
4173
+ end
4174
+
4175
+ it "should correctly assign paths containing colons" do
4176
+ @uri.path = "acct:bob@sporkmonger.com"
4177
+ @uri.scheme = "something"
4178
+ @uri.normalize.to_str.should == "something:acct:bob@sporkmonger.com"
4179
+ end
4180
+
4181
+ it "should not allow relative paths to be assigned on absolute URIs" do
4182
+ (lambda do
4183
+ @uri.scheme = "http"
4184
+ @uri.host = "example.com"
4185
+ @uri.path = "acct:bob@sporkmonger.com"
4186
+ end).should raise_error(Addressable::URI::InvalidURIError)
4187
+ end
4188
+
4189
+ it "should not allow relative paths to be assigned on absolute URIs" do
4190
+ (lambda do
4191
+ @uri.path = "acct:bob@sporkmonger.com"
4192
+ @uri.scheme = "http"
4193
+ @uri.host = "example.com"
4194
+ end).should raise_error(Addressable::URI::InvalidURIError)
4195
+ end
4196
+
4197
+ it "should not allow relative paths to be assigned on absolute URIs" do
4198
+ (lambda do
4199
+ @uri.path = "uuid:0b3ecf60-3f93-11df-a9c3-001f5bfffe12"
4200
+ @uri.scheme = "urn"
4201
+ end).should_not raise_error(Addressable::URI::InvalidURIError)
4202
+ end
4203
+ end