merb-core 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (274) hide show
  1. data/CHANGELOG +136 -2
  2. data/CONTRIBUTORS +6 -0
  3. data/PUBLIC_CHANGELOG +38 -0
  4. data/Rakefile +38 -30
  5. data/lib/merb-core.rb +88 -23
  6. data/lib/merb-core/bootloader.rb +235 -51
  7. data/lib/merb-core/config.rb +121 -36
  8. data/lib/merb-core/controller/abstract_controller.rb +59 -36
  9. data/lib/merb-core/controller/exceptions.rb +2 -15
  10. data/lib/merb-core/controller/merb_controller.rb +44 -1
  11. data/lib/merb-core/controller/mime.rb +4 -0
  12. data/lib/merb-core/controller/mixins/controller.rb +38 -21
  13. data/lib/merb-core/controller/mixins/render.rb +44 -29
  14. data/lib/merb-core/controller/mixins/responder.rb +3 -31
  15. data/lib/merb-core/controller/template.rb +45 -21
  16. data/lib/merb-core/core_ext/kernel.rb +60 -32
  17. data/lib/merb-core/dispatch/default_exception/default_exception.rb +2 -2
  18. data/lib/merb-core/dispatch/default_exception/views/_css.html.erb +3 -1
  19. data/lib/merb-core/dispatch/default_exception/views/_javascript.html.erb +71 -67
  20. data/lib/merb-core/dispatch/default_exception/views/index.html.erb +7 -3
  21. data/lib/merb-core/dispatch/dispatcher.rb +3 -3
  22. data/lib/merb-core/dispatch/request.rb +56 -9
  23. data/lib/merb-core/dispatch/router.rb +159 -133
  24. data/lib/merb-core/dispatch/router/behavior.rb +462 -703
  25. data/lib/merb-core/dispatch/router/cached_proc.rb +3 -3
  26. data/lib/merb-core/dispatch/router/resources.rb +289 -0
  27. data/lib/merb-core/dispatch/router/route.rb +514 -294
  28. data/lib/merb-core/dispatch/session.rb +4 -2
  29. data/lib/merb-core/logger.rb +213 -202
  30. data/lib/merb-core/plugins.rb +9 -1
  31. data/lib/merb-core/rack.rb +3 -1
  32. data/lib/merb-core/rack/adapter.rb +7 -4
  33. data/lib/merb-core/rack/adapter/abstract.rb +188 -0
  34. data/lib/merb-core/rack/adapter/ebb.rb +12 -13
  35. data/lib/merb-core/rack/adapter/evented_mongrel.rb +2 -15
  36. data/lib/merb-core/rack/adapter/irb.rb +3 -2
  37. data/lib/merb-core/rack/adapter/mongrel.rb +22 -15
  38. data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +4 -16
  39. data/lib/merb-core/rack/adapter/thin.rb +21 -22
  40. data/lib/merb-core/rack/adapter/thin_turbo.rb +4 -11
  41. data/lib/merb-core/rack/adapter/webrick.rb +54 -18
  42. data/lib/merb-core/rack/application.rb +4 -4
  43. data/lib/merb-core/rack/handler/mongrel.rb +12 -13
  44. data/lib/merb-core/rack/middleware/csrf.rb +1 -1
  45. data/lib/merb-core/rack/stream_wrapper.rb +41 -0
  46. data/lib/merb-core/server.rb +157 -90
  47. data/lib/merb-core/tasks/gem_management.rb +267 -0
  48. data/lib/merb-core/tasks/merb.rb +1 -0
  49. data/lib/merb-core/tasks/merb_rake_helper.rb +48 -34
  50. data/lib/merb-core/tasks/stats.rake +1 -1
  51. data/lib/merb-core/test.rb +9 -3
  52. data/lib/merb-core/test/helpers.rb +1 -0
  53. data/lib/merb-core/test/helpers/mock_request_helper.rb +393 -0
  54. data/lib/merb-core/test/helpers/multipart_request_helper.rb +3 -2
  55. data/lib/merb-core/test/helpers/request_helper.rb +40 -372
  56. data/lib/merb-core/test/helpers/route_helper.rb +16 -2
  57. data/lib/merb-core/test/matchers.rb +1 -0
  58. data/lib/merb-core/test/matchers/controller_matchers.rb +4 -247
  59. data/lib/merb-core/test/matchers/request_matchers.rb +140 -0
  60. data/lib/merb-core/test/matchers/view_matchers.rb +22 -4
  61. data/lib/merb-core/test/run_specs.rb +118 -26
  62. data/lib/merb-core/test/test_ext/rspec.rb +181 -0
  63. data/lib/merb-core/version.rb +1 -9
  64. metadata +10 -342
  65. data/docs/bootloading.dox +0 -58
  66. data/docs/documentation_standards +0 -40
  67. data/docs/merb-core-call-stack-diagram.mmap +0 -0
  68. data/docs/merb-core-call-stack-diagram.pdf +0 -0
  69. data/docs/merb-core-call-stack-diagram.png +0 -0
  70. data/docs/new_render_api +0 -51
  71. data/lib/merb-core/vendor/facets.rb +0 -2
  72. data/lib/merb-core/vendor/facets/dictionary.rb +0 -433
  73. data/lib/merb-core/vendor/facets/inflect.rb +0 -342
  74. data/spec/private/config/adapter_spec.rb +0 -32
  75. data/spec/private/config/config_spec.rb +0 -202
  76. data/spec/private/config/environment_spec.rb +0 -13
  77. data/spec/private/config/merb_spec.rb +0 -34
  78. data/spec/private/config/spec_helper.rb +0 -1
  79. data/spec/private/core_ext/kernel_spec.rb +0 -159
  80. data/spec/private/dispatch/bootloader_spec.rb +0 -24
  81. data/spec/private/dispatch/fixture/app/controllers/application.rb +0 -4
  82. data/spec/private/dispatch/fixture/app/controllers/exceptions.rb +0 -25
  83. data/spec/private/dispatch/fixture/app/controllers/foo.rb +0 -19
  84. data/spec/private/dispatch/fixture/app/helpers/global_helpers.rb +0 -8
  85. data/spec/private/dispatch/fixture/app/views/exeptions/client_error.html.erb +0 -37
  86. data/spec/private/dispatch/fixture/app/views/exeptions/internal_server_error.html.erb +0 -216
  87. data/spec/private/dispatch/fixture/app/views/exeptions/not_acceptable.html.erb +0 -38
  88. data/spec/private/dispatch/fixture/app/views/exeptions/not_found.html.erb +0 -40
  89. data/spec/private/dispatch/fixture/app/views/foo/bar.html.erb +0 -0
  90. data/spec/private/dispatch/fixture/app/views/layout/application.html.erb +0 -11
  91. data/spec/private/dispatch/fixture/config/black_hole.rb +0 -12
  92. data/spec/private/dispatch/fixture/config/environments/development.rb +0 -6
  93. data/spec/private/dispatch/fixture/config/environments/production.rb +0 -5
  94. data/spec/private/dispatch/fixture/config/environments/test.rb +0 -6
  95. data/spec/private/dispatch/fixture/config/init.rb +0 -45
  96. data/spec/private/dispatch/fixture/config/rack.rb +0 -11
  97. data/spec/private/dispatch/fixture/config/router.rb +0 -35
  98. data/spec/private/dispatch/fixture/log/merb_test.log +0 -8839
  99. data/spec/private/dispatch/fixture/public/images/merb.jpg +0 -0
  100. data/spec/private/dispatch/fixture/public/merb.fcgi +0 -4
  101. data/spec/private/dispatch/fixture/public/stylesheets/master.css +0 -119
  102. data/spec/private/dispatch/route_params_spec.rb +0 -23
  103. data/spec/private/dispatch/spec_helper.rb +0 -1
  104. data/spec/private/router/behavior_spec.rb +0 -60
  105. data/spec/private/router/fixture/log/merb_test.log +0 -35
  106. data/spec/private/router/route_spec.rb +0 -418
  107. data/spec/private/router/router_spec.rb +0 -183
  108. data/spec/private/vendor/facets/plural_spec.rb +0 -564
  109. data/spec/private/vendor/facets/singular_spec.rb +0 -489
  110. data/spec/public/DEFINITIONS +0 -11
  111. data/spec/public/abstract_controller/controllers/alt_views/layout/application.erb +0 -1
  112. data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_string_controller_layout.erb +0 -1
  113. data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_template_controller_layout.erb +0 -1
  114. data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/index.erb +0 -1
  115. data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/show.erb +0 -1
  116. data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +0 -1
  117. data/spec/public/abstract_controller/controllers/alt_views/partial/basic_partial_with_multiple_roots/_partial.erb +0 -1
  118. data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_and_custom_location/index.erb +0 -1
  119. data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_inherited/index.erb +0 -1
  120. data/spec/public/abstract_controller/controllers/cousins.rb +0 -41
  121. data/spec/public/abstract_controller/controllers/display.rb +0 -60
  122. data/spec/public/abstract_controller/controllers/filters.rb +0 -260
  123. data/spec/public/abstract_controller/controllers/helpers.rb +0 -41
  124. data/spec/public/abstract_controller/controllers/partial.rb +0 -121
  125. data/spec/public/abstract_controller/controllers/render.rb +0 -113
  126. data/spec/public/abstract_controller/controllers/views/helpers/capture/index.erb +0 -1
  127. data/spec/public/abstract_controller/controllers/views/helpers/capture_eq/index.erb +0 -1
  128. data/spec/public/abstract_controller/controllers/views/helpers/capture_with_args/index.erb +0 -1
  129. data/spec/public/abstract_controller/controllers/views/helpers/concat/index.erb +0 -1
  130. data/spec/public/abstract_controller/controllers/views/layout/alt.erb +0 -1
  131. data/spec/public/abstract_controller/controllers/views/layout/custom.erb +0 -1
  132. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object/index.erb +0 -1
  133. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object_with_action/new.erb +0 -1
  134. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template/index.erb +0 -1
  135. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_app_layout/index.erb +0 -0
  136. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_custom_layout/index.erb +0 -1
  137. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +0 -1
  138. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/show.erb +0 -1
  139. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_two_throw_contents/index.erb +0 -1
  140. data/spec/public/abstract_controller/controllers/views/partial/another_directory/_partial.erb +0 -1
  141. data/spec/public/abstract_controller/controllers/views/partial/basic_partial/_partial.erb +0 -1
  142. data/spec/public/abstract_controller/controllers/views/partial/basic_partial/index.erb +0 -1
  143. data/spec/public/abstract_controller/controllers/views/partial/basic_partial_with_multiple_roots/index.erb +0 -1
  144. data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_first.erb +0 -1
  145. data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_second.erb +0 -1
  146. data/spec/public/abstract_controller/controllers/views/partial/nested_partial/index.erb +0 -1
  147. data/spec/public/abstract_controller/controllers/views/partial/partial_in_another_directory/index.erb +0 -1
  148. data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/_collection.erb +0 -1
  149. data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/index.erb +0 -1
  150. data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/_collection.erb +0 -1
  151. data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/index.erb +0 -1
  152. data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/_collection.erb +0 -1
  153. data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/index.erb +0 -1
  154. data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/_collection.erb +0 -1
  155. data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/index.erb +0 -1
  156. data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/_variables.erb +0 -1
  157. data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/index.erb +0 -1
  158. data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/_both.erb +0 -1
  159. data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/index.erb +0 -1
  160. data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/_partial.erb +0 -1
  161. data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/index.erb +0 -1
  162. data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/_with_partial.erb +0 -1
  163. data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/index.erb +0 -1
  164. data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/_with_partial.erb +0 -1
  165. data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/index.erb +0 -1
  166. data/spec/public/abstract_controller/controllers/views/partial/with_partial/_with_partial.erb +0 -1
  167. data/spec/public/abstract_controller/controllers/views/partial/with_partial/index.erb +0 -1
  168. data/spec/public/abstract_controller/controllers/views/test_display/foo.html.erb +0 -1
  169. data/spec/public/abstract_controller/controllers/views/test_render/foo.html.erb +0 -0
  170. data/spec/public/abstract_controller/controllers/views/wonderful/index.erb +0 -1
  171. data/spec/public/abstract_controller/display_spec.rb +0 -37
  172. data/spec/public/abstract_controller/filter_spec.rb +0 -136
  173. data/spec/public/abstract_controller/helper_spec.rb +0 -21
  174. data/spec/public/abstract_controller/partial_spec.rb +0 -61
  175. data/spec/public/abstract_controller/render_spec.rb +0 -90
  176. data/spec/public/abstract_controller/spec_helper.rb +0 -31
  177. data/spec/public/boot_loader/boot_loader_spec.rb +0 -33
  178. data/spec/public/boot_loader/spec_helper.rb +0 -1
  179. data/spec/public/controller/authentication_spec.rb +0 -174
  180. data/spec/public/controller/base_spec.rb +0 -88
  181. data/spec/public/controller/conditional_get_spec.rb +0 -100
  182. data/spec/public/controller/config/init.rb +0 -6
  183. data/spec/public/controller/controllers/authentication.rb +0 -74
  184. data/spec/public/controller/controllers/base.rb +0 -65
  185. data/spec/public/controller/controllers/conditional_get.rb +0 -35
  186. data/spec/public/controller/controllers/cookies.rb +0 -36
  187. data/spec/public/controller/controllers/dispatcher.rb +0 -35
  188. data/spec/public/controller/controllers/display.rb +0 -118
  189. data/spec/public/controller/controllers/redirect.rb +0 -36
  190. data/spec/public/controller/controllers/responder.rb +0 -93
  191. data/spec/public/controller/controllers/url.rb +0 -7
  192. data/spec/public/controller/controllers/views/layout/custom.html.erb +0 -1
  193. data/spec/public/controller/controllers/views/layout/custom_arg.html.erb +0 -1
  194. data/spec/public/controller/controllers/views/layout/custom_arg.json.erb +0 -1
  195. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.html.erb +0 -1
  196. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.xml.erb +0 -1
  197. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.html.erb +0 -1
  198. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.xml.erb +0 -1
  199. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/index.html.erb +0 -1
  200. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/no_layout.html.erb +0 -1
  201. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template_argument/index.html.erb +0 -1
  202. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/html_default/index.html.erb +0 -1
  203. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/layout/custom.html.erb +0 -1
  204. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.html.erb +0 -1
  205. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.xml.erb +0 -1
  206. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.html.erb +0 -1
  207. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.js.erb +0 -1
  208. data/spec/public/controller/cookies_spec.rb +0 -95
  209. data/spec/public/controller/dispatcher_spec.rb +0 -410
  210. data/spec/public/controller/display_spec.rb +0 -84
  211. data/spec/public/controller/redirect_spec.rb +0 -33
  212. data/spec/public/controller/responder_spec.rb +0 -169
  213. data/spec/public/controller/spec_helper.rb +0 -13
  214. data/spec/public/controller/url_spec.rb +0 -255
  215. data/spec/public/core/merb_core_spec.rb +0 -45
  216. data/spec/public/core_ext/fixtures/core_ext_dependency.rb +0 -2
  217. data/spec/public/core_ext/kernel_spec.rb +0 -88
  218. data/spec/public/core_ext/spec_helper.rb +0 -1
  219. data/spec/public/directory_structure/directory/app/controllers/application.rb +0 -3
  220. data/spec/public/directory_structure/directory/app/controllers/base.rb +0 -13
  221. data/spec/public/directory_structure/directory/app/controllers/custom.rb +0 -19
  222. data/spec/public/directory_structure/directory/app/views/base/template.html.erb +0 -1
  223. data/spec/public/directory_structure/directory/app/views/wonderful/template.erb +0 -1
  224. data/spec/public/directory_structure/directory/config/router.rb +0 -3
  225. data/spec/public/directory_structure/directory/log/merb_test.log +0 -4588
  226. data/spec/public/directory_structure/directory_spec.rb +0 -43
  227. data/spec/public/logger/logger_spec.rb +0 -181
  228. data/spec/public/logger/spec_helper.rb +0 -1
  229. data/spec/public/rack/conditinal_get_middleware_spec.rb +0 -127
  230. data/spec/public/rack/csrf_middleware_spec.rb +0 -70
  231. data/spec/public/rack/rack_middleware_spec.rb +0 -99
  232. data/spec/public/rack/shared_example_groups.rb +0 -35
  233. data/spec/public/reloading/directory/app/controllers/application.rb +0 -3
  234. data/spec/public/reloading/directory/app/controllers/reload.rb +0 -6
  235. data/spec/public/reloading/directory/config/init.rb +0 -2
  236. data/spec/public/reloading/directory/log/merb_test.log +0 -288231
  237. data/spec/public/reloading/reload_spec.rb +0 -103
  238. data/spec/public/request/multipart_spec.rb +0 -41
  239. data/spec/public/request/request_spec.rb +0 -250
  240. data/spec/public/router/default_spec.rb +0 -21
  241. data/spec/public/router/deferred_spec.rb +0 -22
  242. data/spec/public/router/fixation_spec.rb +0 -49
  243. data/spec/public/router/fixture/log/merb_test.log +0 -524
  244. data/spec/public/router/namespace_spec.rb +0 -113
  245. data/spec/public/router/nested_matches_spec.rb +0 -97
  246. data/spec/public/router/nested_resources_spec.rb +0 -41
  247. data/spec/public/router/resource_spec.rb +0 -37
  248. data/spec/public/router/resources_spec.rb +0 -82
  249. data/spec/public/router/spec_helper.rb +0 -90
  250. data/spec/public/router/special_spec.rb +0 -61
  251. data/spec/public/router/string_spec.rb +0 -61
  252. data/spec/public/session/controllers/sessions.rb +0 -56
  253. data/spec/public/session/cookie_session_spec.rb +0 -73
  254. data/spec/public/session/memcached_session_spec.rb +0 -31
  255. data/spec/public/session/memory_session_spec.rb +0 -28
  256. data/spec/public/session/multiple_sessions_spec.rb +0 -74
  257. data/spec/public/session/no_session_spec.rb +0 -12
  258. data/spec/public/session/session_spec.rb +0 -106
  259. data/spec/public/template/template_spec.rb +0 -104
  260. data/spec/public/template/templates/error.html.erb +0 -2
  261. data/spec/public/template/templates/template.html.erb +0 -1
  262. data/spec/public/template/templates/template.html.myt +0 -1
  263. data/spec/public/test/controller_matchers_spec.rb +0 -412
  264. data/spec/public/test/controllers/controller_assertion_mock.rb +0 -7
  265. data/spec/public/test/controllers/dispatch_controller.rb +0 -11
  266. data/spec/public/test/controllers/spec_helper_controller.rb +0 -39
  267. data/spec/public/test/multipart_request_helper_spec.rb +0 -159
  268. data/spec/public/test/multipart_upload_text_file.txt +0 -1
  269. data/spec/public/test/request_helper_spec.rb +0 -269
  270. data/spec/public/test/route_helper_spec.rb +0 -78
  271. data/spec/public/test/route_matchers_spec.rb +0 -166
  272. data/spec/public/test/view_helper_spec.rb +0 -96
  273. data/spec/public/test/view_matchers_spec.rb +0 -183
  274. data/spec/spec_helper.rb +0 -121
@@ -1,183 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
-
3
- describe Merb::Router, "initially" do
4
- it "has empty routes array" do
5
- Merb::Router.routes.should be_empty
6
- end
7
-
8
- it "has empty named routes" do
9
- Merb::Router.named_routes.should be_empty
10
- end
11
-
12
- it "stores named routes in a Hash" do
13
- Merb::Router.named_routes.should be_kind_of(Hash)
14
- end
15
-
16
- it "has no .match method" do
17
- Merb::Router.should_not respond_to(:match)
18
- end
19
- end
20
-
21
-
22
-
23
- describe Merb::Router, ".prepare" do
24
- before :each do
25
- Merb::Router.routes = []
26
- end
27
-
28
- it "adds prepared routes to existing" do
29
- Merb::Router.prepare do |r|
30
- r.match("/").to(:controller => "home")
31
- end
32
-
33
- Merb::Router.routes.should_not be_empty
34
- end
35
-
36
- it "(re-)compiles routes" do
37
- Merb::Router.should_receive(:compile)
38
-
39
- Merb::Router.prepare do |r|
40
- r.match("/").to(:controller => "home")
41
- end
42
- end
43
-
44
- it "defines match method" do
45
- Merb::Router.prepare do |r|
46
- r.match("/").to(:controller => "home")
47
- end
48
-
49
- Merb::Router.should respond_to(:match)
50
- end
51
- end
52
-
53
-
54
-
55
- describe Merb::Router, ".append" do
56
- before :each do
57
- Merb::Router.prepare do |r|
58
- r.match("/").to(:controller => "home")
59
- end
60
- end
61
-
62
- it "appends routes to existing" do
63
- Merb::Router.append do |r|
64
- r.match("/append").to(:controller => "appended_by_router").name(:appended)
65
- end
66
-
67
- Merb::Router.named_routes[:appended].index.should == 0
68
- end
69
- end
70
-
71
-
72
-
73
- describe Merb::Router, ".prepend" do
74
- before :each do
75
- Merb::Router.prepare do |r|
76
- r.match("/").to(:controller => "home")
77
- end
78
- end
79
-
80
- it "prepends routes to existing" do
81
- Merb::Router.prepend do |r|
82
- r.match("/prepend").to(:controller => "prepended_by_router").name(:prepended)
83
- end
84
-
85
- Merb::Router.named_routes[:appended].index.should == 0
86
- end
87
- end
88
-
89
-
90
-
91
- describe Merb::Router, ".generate", "given a Symbol" do
92
- before :each do
93
- Merb::Router.prepare do |r|
94
- r.match("/elements/").to(:controller => "elements").name(:elements)
95
- end
96
- end
97
-
98
- it "searches among named routes" do
99
- Merb::Router.generate(:elements).should == "/elements/"
100
- end
101
-
102
- it "raises RuntimeError when named route is not found" do
103
- lambda { Merb::Router.generate(:mountains) }.should raise_error(RuntimeError, /Named route not found/)
104
- end
105
- end
106
-
107
-
108
-
109
- describe Merb::Router, ".generate", "given a Hash" do
110
- before :each do
111
- Merb::Router.prepare do |r|
112
- r.match("/elements/").to(:controller => "elements").name(:elements)
113
- end
114
- end
115
-
116
- it "uses default routes mapping" do
117
- Merb::Router.generate({ :controller => "elements", :action => "show", :id => "fire" }).should == "/elements/show/fire"
118
- end
119
-
120
- it "appends extra parameters to URL" do
121
- Merb::Router.generate({ :controller => "elements", :action => "search" }, { :q => "water" }).should == "/elements/search?q=water"
122
- end
123
-
124
- it "uses fallback hash when controller is not available" do
125
- Merb::Router.generate({ :action => "show", :id => "Olympus" }, {}, { :controller => "mountains" }).should == "/mountains/show/Olympus"
126
- end
127
-
128
- it "uses fallback hash when action is not available" do
129
- Merb::Router.generate({ :controller => "mountains", :id => "Olympus" }, {}, { :action => "show" }).should == "/mountains/show/Olympus"
130
- end
131
-
132
- it "ignores nil parameters" do
133
- Merb::Router.generate({ :controller => "mountains", :action => nil, :id => "Olympus" }, {}, { :action => "show" }).should == "/mountains/show/Olympus"
134
- end
135
-
136
- it "respects format parameter" do
137
- Merb::Router.generate({ :controller => "elements", :action => "show", :id => "fire", :format => :json }).should == "/elements/show/fire.json"
138
- end
139
-
140
- it "respects fragment parameter" do
141
- Merb::Router.generate({ :controller => "elements", :action => "search", :fragment => :a_fragment }, { :q => "water" }).should == "/elements/search?q=water#a_fragment"
142
- end
143
- end
144
-
145
-
146
-
147
- describe Merb::Router, ".generate_for_default_route", "given a Hash" do
148
- before :each do
149
- Merb::Router.prepare do |r|
150
- r.match("/elements/").to(:controller => "elements").name(:elements)
151
- end
152
- end
153
-
154
- it "uses default routes mapping" do
155
- Merb::Router.generate_for_default_route({ :controller => "elements", :action => "show", :id => "fire" }, {}).should == "/elements/show/fire"
156
- end
157
-
158
- it "respects format parameter" do
159
- Merb::Router.generate({ :controller => "elements", :action => "show", :id => "fire", :format => :json }).should == "/elements/show/fire.json"
160
- end
161
-
162
- it "respects fragment parameter" do
163
- Merb::Router.generate({ :controller => "elements", :action => "show", :id => "fire", :format => :json, :fragment => :a_fragment }).should == "/elements/show/fire.json#a_fragment"
164
- end
165
-
166
- it "requires both parameters to be present" do
167
- lambda {
168
- Merb::Router.generate_for_default_route({ :controller => "elements", :action => "show", :id => "fire" })
169
- }.should raise_error(ArgumentError)
170
- end
171
-
172
- it "uses fallback hash when controller is not available" do
173
- Merb::Router.generate_for_default_route({ :action => "show", :id => "Olympus" }, { :controller => "mountains" }).should == "/mountains/show/Olympus"
174
- end
175
-
176
- it "uses fallback hash when action is not available" do
177
- Merb::Router.generate_for_default_route({ :controller => "mountains", :id => "Olympus" }, { :action => "show" }).should == "/mountains/show/Olympus"
178
- end
179
-
180
- it "ignores nil parameters" do
181
- Merb::Router.generate_for_default_route({ :controller => "mountains", :action => nil, :id => "Olympus" }, { :action => "show" }).should == "/mountains/show/Olympus"
182
- end
183
- end
@@ -1,564 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
-
3
- describe English::Inflect, "#singular" do
4
- it "pluralizes equipment => equipment" do
5
- "equipment".plural.should == "equipment"
6
- end
7
-
8
- it "pluralizes information => information" do
9
- "information".plural.should == "information"
10
- end
11
-
12
- it "pluralizes money => money" do
13
- "money".plural.should == "money"
14
- end
15
-
16
- it "pluralizes species => species" do
17
- "species".plural.should == "species"
18
- end
19
-
20
- it "pluralizes series => series" do
21
- "series".plural.should == "series"
22
- end
23
-
24
- it "pluralizes fish => fish" do
25
- "fish".plural.should == "fish"
26
- end
27
-
28
- it "pluralizes sheep => sheep" do
29
- "sheep".plural.should == "sheep"
30
- end
31
-
32
- it "pluralizes news => news" do
33
- "news".plural.should == "news"
34
- end
35
-
36
- it "pluralizes rain => rain" do
37
- "rain".plural.should == "rain"
38
- end
39
-
40
- it "pluralizes milk => milk" do
41
- "milk".plural.should == "milk"
42
- end
43
-
44
- it "pluralizes moose => moose" do
45
- "moose".plural.should == "moose"
46
- end
47
-
48
- it "pluralizes hovercraft => hovercraft" do
49
- "hovercraft".plural.should == "hovercraft"
50
- end
51
-
52
- it "pluralizes cacti => cactus" do
53
- "cactus".plural.should == "cacti"
54
- end
55
-
56
- it "pluralizes thesaurus => thesauri" do
57
- "thesaurus".plural.should == "thesauri"
58
- end
59
-
60
- it "pluralizes matrix => matrices" do
61
- "matrix".plural.should == "matrices"
62
- end
63
-
64
- it "pluralizes Swiss => Swiss" do
65
- "Swiss".plural.should == "Swiss"
66
- end
67
-
68
- it "pluralizes life => lives" do
69
- "life".plural.should == "lives"
70
- end
71
-
72
- it "pluralizes wife => wives" do
73
- "wife".plural.should == "wives"
74
- end
75
-
76
- it "pluralizes goose => geese" do
77
- "goose".plural.should == "geese"
78
- end
79
-
80
- it "pluralizes criterion => criteria" do
81
- "criterion".plural.should == "criteria"
82
- end
83
-
84
- it "pluralizes alias => aliases" do
85
- "alias".plural.should == "aliases"
86
- end
87
-
88
- it "pluralizes status => statuses" do
89
- "status".plural.should == "statuses"
90
- end
91
-
92
- it "pluralizes axis => axes" do
93
- "axis".plural.should == "axes"
94
- end
95
-
96
- it "pluralizes crisis => crises" do
97
- "crisis".plural.should == "crises"
98
- end
99
-
100
- it "pluralizes testis => testes" do
101
- "testis".plural.should == "testes"
102
- end
103
-
104
- it "pluralizes child => children" do
105
- "child".plural.should == "children"
106
- end
107
-
108
- it "pluralizes person => people" do
109
- "person".plural.should == "people"
110
- end
111
-
112
- it "pluralizes potato => potatoes" do
113
- "potato".plural.should == "potatoes"
114
- end
115
-
116
- it "pluralizes tomato => tomatoes" do
117
- "tomato".plural.should == "tomatoes"
118
- end
119
-
120
- it "pluralizes buffalo => buffaloes" do
121
- "buffalo".plural.should == "buffaloes"
122
- end
123
-
124
- it "pluralizes torpedo => torpedoes" do
125
- "torpedo".plural.should == "torpedoes"
126
- end
127
-
128
- it "pluralizes quiz => quizzes" do
129
- "quiz".plural.should == "quizzes"
130
- end
131
-
132
- # used to be a bug exposed by this specs suite,
133
- # this MUST pass or we've got regression
134
- it "pluralizes vertex => vertices" do
135
- "vertex".plural.should == "vertices"
136
- end
137
-
138
- it "pluralizes index => indices" do
139
- "index".plural.should == "indices"
140
- end
141
-
142
- it "pluralizes ox => oxen" do
143
- "ox".plural.should == "oxen"
144
- end
145
-
146
- it "pluralizes mouse => mice" do
147
- "mouse".plural.should == "mice"
148
- end
149
-
150
- it "pluralizes louse => lice" do
151
- "louse".plural.should == "lice"
152
- end
153
-
154
- it "pluralizes thesis => theses" do
155
- "thesis".plural.should == "theses"
156
- end
157
-
158
- it "pluralizes thief => thieves" do
159
- "thief".plural.should == "thieves"
160
- end
161
-
162
- it "pluralizes analysis => analyses" do
163
- "analysis".plural.should == "analyses"
164
- end
165
-
166
- it "pluralizes octopus => octopi" do
167
- "octopus".plural.should == "octopi"
168
- end
169
-
170
- it "pluralizes grass => grass" do
171
- "grass".plural.should == "grass"
172
- end
173
-
174
- it "pluralizes phenomenon => phenomena" do
175
- "phenomenon".plural.should == "phenomena"
176
- end
177
-
178
-
179
-
180
-
181
-
182
- # ==== bugs, typos and reported issues
183
-
184
-
185
-
186
-
187
-
188
- # ==== rules and most common cases
189
-
190
- it "pluralizes forum => forums" do
191
- "forum".plural.should == "forums"
192
- end
193
-
194
- it "pluralizes hive => hives" do
195
- "hive".plural.should == "hives"
196
- end
197
-
198
- it "pluralizes athlete => athletes" do
199
- "athlete".plural.should == "athletes"
200
- end
201
-
202
- it "pluralizes dwarf => dwarves" do
203
- "dwarf".plural.should == "dwarves"
204
- end
205
-
206
- it "pluralizes hero => heroes" do
207
- "hero".plural.should == "heroes"
208
- end
209
-
210
- it "pluralizes zero => zeroes" do
211
- "zero".plural.should == "zeroes"
212
- end
213
-
214
- it "pluralizes man => men" do
215
- "man".plural.should == "men"
216
- end
217
-
218
- it "pluralizes woman => women" do
219
- "woman".plural.should == "women"
220
- end
221
-
222
- it "pluralizes sportsman => sportsmen" do
223
- "sportsman".plural.should == "sportsmen"
224
- end
225
-
226
- it "pluralizes branch => branches" do
227
- "branch".plural.should == "branches"
228
- end
229
-
230
- it "pluralizes crunch => crunches" do
231
- "crunch".plural.should == "crunches"
232
- end
233
-
234
- it "pluralizes trash => trashes" do
235
- "trash".plural.should == "trashes"
236
- end
237
-
238
- it "pluralizes mash => mashes" do
239
- "mash".plural.should == "mashes"
240
- end
241
-
242
- it "pluralizes cross => crosses" do
243
- "cross".plural.should == "crosses"
244
- end
245
-
246
- it "pluralizes erratum => errata" do
247
- "erratum".plural.should == "errata"
248
- end
249
-
250
- # FIXME: add -ia => -ium cases
251
-
252
- # FIXME: add -ra => -rum cases
253
-
254
- it "pluralizes ray => rays" do
255
- "ray".plural.should == "rays"
256
- end
257
-
258
- it "pluralizes spray => sprays" do
259
- "spray".plural.should == "sprays"
260
- end
261
-
262
- # Merriam-Webster dictionary says
263
- # preys is correct, too.
264
- it "pluralizes prey => preys" do
265
- "prey".plural.should == "preys"
266
- end
267
-
268
- it "pluralizes toy => toys" do
269
- "toy".plural.should == "toys"
270
- end
271
-
272
- it "pluralizes joy => joys" do
273
- "joy".plural.should == "joys"
274
- end
275
-
276
- it "pluralizes buy => buys" do
277
- "buy".plural.should == "buys"
278
- end
279
-
280
- it "pluralizes guy => guys" do
281
- "guy".plural.should == "guys"
282
- end
283
-
284
- it "pluralizes cry => cries" do
285
- "cry".plural.should == "cries"
286
- end
287
-
288
- it "pluralizes fly => flies" do
289
- "fly".plural.should == "flies"
290
- end
291
-
292
- it "pluralizes fox => foxes" do
293
- "fox".plural.should == "foxes"
294
- end
295
-
296
- it "pluralizes elf => elves" do
297
- "elf".plural.should == "elves"
298
- end
299
-
300
- it "pluralizes shelf => shelves" do
301
- "shelf".plural.should == "shelves"
302
- end
303
-
304
- it "pluralizes plus => plusses" do
305
- "plus".plural.should == "plusses"
306
- end
307
-
308
- it "pluralizes cat => cats" do
309
- "cat".plural.should == "cats"
310
- end
311
-
312
- it "pluralizes rat => rats" do
313
- "rat".plural.should == "rats"
314
- end
315
-
316
- it "pluralizes rose => roses" do
317
- "rose".plural.should == "roses"
318
- end
319
-
320
- it "pluralizes project => projects" do
321
- "project".plural.should == "projects"
322
- end
323
-
324
- it "pluralizes post => posts" do
325
- "post".plural.should == "posts"
326
- end
327
-
328
- it "pluralizes article => articles" do
329
- "article".plural.should == "articles"
330
- end
331
-
332
- it "pluralizes location => locations" do
333
- "location".plural.should == "locations"
334
- end
335
-
336
- it "pluralizes friend => friends" do
337
- "friend".plural.should == "friends"
338
- end
339
-
340
- it "pluralizes link => links" do
341
- "link".plural.should == "links"
342
- end
343
-
344
- it "pluralizes url => urls" do
345
- "url".plural.should == "urls"
346
- end
347
-
348
- it "pluralizes account => accounts" do
349
- "account".plural.should == "accounts"
350
- end
351
-
352
- it "pluralizes server => servers" do
353
- "server".plural.should == "servers"
354
- end
355
-
356
- it "pluralizes fruit => fruits" do
357
- "fruit".plural.should == "fruits"
358
- end
359
-
360
- it "pluralizes map => maps" do
361
- "map".plural.should == "maps"
362
- end
363
-
364
- it "pluralizes income => incomes" do
365
- "income".plural.should == "incomes"
366
- end
367
-
368
- it "pluralizes ping => pings" do
369
- "ping".plural.should == "pings"
370
- end
371
-
372
- it "pluralizes event => events" do
373
- "event".plural.should == "events"
374
- end
375
-
376
- it "pluralizes proof => proofs" do
377
- "proof".plural.should == "proofs"
378
- end
379
-
380
- it "pluralizes typo => typos" do
381
- "typo".plural.should == "typos"
382
- end
383
-
384
- it "pluralizes attachment => attachments" do
385
- "attachment".plural.should == "attachments"
386
- end
387
-
388
- it "pluralizes download => downloads" do
389
- "download".plural.should == "downloads"
390
- end
391
-
392
- it "pluralizes asset => assets" do
393
- "asset".plural.should == "assets"
394
- end
395
-
396
- it "pluralizes job => jobs" do
397
- "job".plural.should == "jobs"
398
- end
399
-
400
- it "pluralizes city => cities" do
401
- "city".plural.should == "cities"
402
- end
403
-
404
- it "pluralizes package => packages" do
405
- "package".plural.should == "packages"
406
- end
407
-
408
- it "pluralizes commit => commits" do
409
- "commit".plural.should == "commits"
410
- end
411
-
412
- it "pluralizes version => versions" do
413
- "version".plural.should == "versions"
414
- end
415
-
416
- it "pluralizes document => documents" do
417
- "document".plural.should == "documents"
418
- end
419
-
420
- it "pluralizes edition => editions" do
421
- "edition".plural.should == "editions"
422
- end
423
-
424
- it "pluralizes movie => movies" do
425
- "movie".plural.should == "movies"
426
- end
427
-
428
- it "pluralizes song => songs" do
429
- "song".plural.should == "songs"
430
- end
431
-
432
- it "pluralizes invoice => invoices" do
433
- "invoice".plural.should == "invoices"
434
- end
435
-
436
- it "pluralizes product => products" do
437
- "product".plural.should == "products"
438
- end
439
-
440
- it "pluralizes book => books" do
441
- "book".plural.should == "books"
442
- end
443
-
444
- it "pluralizes ticket => tickets" do
445
- "ticket".plural.should == "tickets"
446
- end
447
-
448
- it "pluralizes game => games" do
449
- "game".plural.should == "games"
450
- end
451
-
452
- it "pluralizes tournament => tournaments" do
453
- "tournament".plural.should == "tournaments"
454
- end
455
-
456
- it "pluralizes prize => prizes" do
457
- "prize".plural.should == "prizes"
458
- end
459
-
460
- it "pluralizes price => prices" do
461
- "price".plural.should == "prices"
462
- end
463
-
464
- it "pluralizes installation => installations" do
465
- "installation".plural.should == "installations"
466
- end
467
-
468
- it "pluralizes date => dates" do
469
- "date".plural.should == "dates"
470
- end
471
-
472
- it "pluralizes schedule => schedules" do
473
- "schedule".plural.should == "schedules"
474
- end
475
-
476
- it "pluralizes arena => arenas" do
477
- "arena".plural.should == "arenas"
478
- end
479
-
480
- it "pluralizes spam => spams" do
481
- "spam".plural.should == "spams"
482
- end
483
-
484
- it "pluralizes bus => buses" do
485
- "bus".plural.should == "buses"
486
- end
487
-
488
- it "pluralizes rice => rice" do
489
- "rice".plural.should == "rice"
490
- end
491
-
492
- # Some specs from Rails
493
- SingularToPlural = {
494
- "search" => "searches",
495
- "switch" => "switches",
496
- "fix" => "fixes",
497
- "box" => "boxes",
498
- "process" => "processes",
499
- "address" => "addresses",
500
- "case" => "cases",
501
- "stack" => "stacks",
502
- "wish" => "wishes",
503
-
504
- "category" => "categories",
505
- "query" => "queries",
506
- "ability" => "abilities",
507
- "agency" => "agencies",
508
-
509
- "archive" => "archives",
510
-
511
- "safe" => "saves",
512
- "half" => "halves",
513
-
514
- "move" => "moves",
515
-
516
- "salesperson" => "salespeople",
517
-
518
- "spokesman" => "spokesmen",
519
-
520
- "basis" => "bases",
521
- "diagnosis" => "diagnoses",
522
- "diagnosis_a" => "diagnosis_as",
523
-
524
- "datum" => "data",
525
- "medium" => "media",
526
-
527
- "node_child" => "node_children",
528
-
529
- "experience" => "experiences",
530
- "day" => "days",
531
-
532
- "comment" => "comments",
533
- "foobar" => "foobars",
534
- "newsletter" => "newsletters",
535
-
536
- "old_news" => "old_news",
537
-
538
- "perspective" => "perspectives",
539
-
540
- "photo" => "photos",
541
- "status_code" => "status_codes",
542
-
543
- "house" => "houses",
544
- "virus" => "viruses",
545
- "portfolio" => "portfolios",
546
-
547
- "matrix_fu" => "matrix_fus",
548
-
549
- "axis" => "axes",
550
-
551
- "shoe" => "shoes",
552
-
553
- "horse" => "horses",
554
- "edge" => "edges",
555
-
556
- "cow" => "kine"
557
- }
558
-
559
- SingularToPlural.each do |single_word, plural_word|
560
- it "pluralizes #{single_word} => #{plural_word}" do
561
- single_word.plural.should == plural_word
562
- end
563
- end
564
- end