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,36 +0,0 @@
1
- module Merb::Test::Fixtures::Controllers
2
- class Testing < Merb::Controller
3
- self._template_root = File.dirname(__FILE__) / "views"
4
- end
5
-
6
- class SimpleRedirect < Testing
7
- def index
8
- redirect("/")
9
- end
10
- end
11
-
12
- class PermanentRedirect < Testing
13
- def index
14
- redirect("/", :permanent => true)
15
- end
16
- end
17
-
18
- class RedirectWithMessage < Testing
19
- def index
20
- redirect("/", :message => { :notice => "what?" })
21
- end
22
- end
23
-
24
- class ConsumesMessage < Testing
25
- def index
26
- message[:notice].inspect
27
- end
28
- end
29
-
30
- class SetsMessage < Testing
31
- def index
32
- message[:notice] = "Hello"
33
- message[:notice]
34
- end
35
- end
36
- end
@@ -1,93 +0,0 @@
1
- module Merb::Test::Fixtures::Controllers
2
- class Testing < Merb::Controller
3
- self._template_root = File.dirname(__FILE__) / "views"
4
- end
5
-
6
-
7
- class Responder < Testing
8
- def index
9
- render
10
- end
11
- end
12
-
13
-
14
- class HtmlDefault < Responder; end
15
-
16
-
17
- class ClassProvides < Responder
18
- provides :xml
19
- end
20
-
21
-
22
- class LocalProvides < Responder
23
- def index
24
- provides :xml
25
- render
26
- end
27
- end
28
-
29
-
30
- class MultiProvides < Responder
31
- def index
32
- provides :html, :js
33
- render
34
- end
35
- end
36
-
37
- class ClassAndLocalProvides < Responder
38
- provides :html
39
- def index
40
- provides :xml
41
- render
42
- end
43
- end
44
-
45
- class ClassOnlyProvides < Responder
46
- only_provides :text, :xml
47
-
48
- def index
49
- "nothing"
50
- end
51
- end
52
-
53
-
54
- class OnlyProvides < Responder
55
- def index
56
- only_provides :text, :xml
57
- "nothing"
58
- end
59
- end
60
-
61
- class ClassDoesntProvides < Responder
62
- provides :xml
63
- does_not_provide :html
64
-
65
- def index
66
- "nothing"
67
- end
68
- end
69
-
70
-
71
- class DoesntProvide < Responder
72
- def index
73
- provides :xml
74
- does_not_provide :html
75
- "nothing"
76
- end
77
- end
78
-
79
-
80
- class FooFormatProvides < Responder
81
- only_provides :foo
82
-
83
- def index
84
- render "nothing"
85
- end
86
-
87
- def show
88
- headers["Content-Language"] = 'nl'
89
- headers["Biz"] = "buzz"
90
- render "nothing"
91
- end
92
- end
93
- end
@@ -1,7 +0,0 @@
1
- module Merb::Test::Fixtures::Controllers
2
- class Url < Testing
3
- def index
4
- 'index'
5
- end
6
- end
7
- end
@@ -1 +0,0 @@
1
- Custom: <%= catch_content(:for_layout) %>
@@ -1 +0,0 @@
1
- Custom Arg: <%= catch_content(:for_layout) %>
@@ -1 +0,0 @@
1
- {custom_arg: <%= catch_content(:for_layout) %>}
@@ -1 +0,0 @@
1
- HTML: Wins Over XML If Both Are Specified
@@ -1 +0,0 @@
1
- Custom: <%= catch_content(:for_layout) %>
@@ -1,95 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "spec_helper")
2
-
3
- describe Merb::Controller, "._default_cookie_domain" do
4
-
5
- before(:each) do
6
- Merb::Config[:default_cookie_domain].should_not be(nil)
7
- end
8
-
9
- it 'is set to Merb::Config[:default_cookie_domain] by default' do
10
- Merb::Controller._default_cookie_domain.should == Merb::Config[:default_cookie_domain]
11
- Merb::Test::Fixtures::Controllers::CookiesController._default_cookie_domain.should ==
12
- Merb::Config[:default_cookie_domain]
13
- end
14
-
15
- it "can be overridden for particular controller" do
16
- Merb::Test::Fixtures::Controllers::OverridingDefaultCookieDomain._default_cookie_domain.should ==
17
- "overridden.merbivore.com"
18
- end
19
-
20
- it 'is inherited by subclasses unless overriden' do
21
- Merb::Test::Fixtures::Controllers::NotOverridingDefaultCookieDomain._default_cookie_domain.should ==
22
- Merb::Config[:default_cookie_domain]
23
- end
24
- end
25
-
26
- describe Merb::Controller, "#cookies creating" do
27
-
28
- it "should set all the cookies for a request" do
29
- controller = dispatch_to(Merb::Test::Fixtures::Controllers::CookiesController, :store_cookies)
30
- controller.headers['Set-Cookie'].length.should == 4
31
- end
32
-
33
- it "should set a simple cookie" do
34
- controller = dispatch_to(Merb::Test::Fixtures::Controllers::CookiesController, :store_cookies)
35
- cookie = controller.headers['Set-Cookie'].sort[1]
36
- cookie.should match(/foo=bar;/)
37
- cookie.should match(/domain=specs.merbivore.com;/)
38
- end
39
-
40
- it "should set the cookie domain correctly when it is specified" do
41
- controller = dispatch_to(Merb::Test::Fixtures::Controllers::CookiesController, :store_cookies)
42
- cookie = controller.headers['Set-Cookie'].sort[0]
43
- cookie.should match(/awesome=super-cookie;/)
44
- cookie.should match(/domain=blog.merbivore.com;/)
45
- end
46
-
47
- it "should format the expires time to the correct format" do
48
- controller = dispatch_to(Merb::Test::Fixtures::Controllers::CookiesController, :store_cookies)
49
- cookie = controller.headers['Set-Cookie'].sort[2]
50
- cookie.should include("oldcookie=this+is+really+old;")
51
- cookie.should include("expires=Wed, 01-Jan-2020 00:00:00 GMT;")
52
- end
53
-
54
- it "should append secure to the end of the cookie header when marked as such" do
55
- controller = dispatch_to(Merb::Test::Fixtures::Controllers::CookiesController, :store_cookies)
56
- cookie = controller.headers['Set-Cookie'].sort[3]
57
- cookie.should match(/secure$/)
58
- end
59
-
60
- it "sets the Set-Cookie response header - and ignores blank options" do
61
- controller_klass = Merb::Test::Fixtures::Controllers::EmptyDefaultCookieDomain
62
- with_cookies(controller_klass) do |cookie_jar|
63
- controller = dispatch_to(controller_klass, :store_cookies)
64
- cookies = controller.headers['Set-Cookie'].sort
65
- cookies[1].should == "foo=bar; path=/;"
66
- end
67
- end
68
-
69
- it "it gives access to cookie values" do
70
- controller_klass = Merb::Test::Fixtures::Controllers::CookiesController
71
- with_cookies(controller_klass) do |cookie_jar|
72
- controller = dispatch_to(controller_klass, :store_cookies)
73
- controller = dispatch_to(controller_klass, :retrieve_cookies)
74
- controller.cookies['awesome'].should == 'super-cookie'
75
- controller.cookies['foo'].should == 'bar'
76
- controller.cookies.should == cookie_jar
77
- end
78
- end
79
-
80
- end
81
-
82
- describe Merb::Controller, "#cookies destroying" do
83
-
84
- it "should send a cookie when deleting a cookie" do
85
- controller = dispatch_to(Merb::Test::Fixtures::Controllers::CookiesController, :destroy_cookies)
86
- controller.headers['Set-Cookie'].length.should == 1
87
- end
88
-
89
- it "should set the expiration time of the cookie being destroyed to the past" do
90
- controller = dispatch_to(Merb::Test::Fixtures::Controllers::CookiesController, :destroy_cookies)
91
- cookie = controller.headers['Set-Cookie'].sort[0]
92
- cookie.should include("expires=Thu, 01-Jan-1970 00:00:00 GMT;")
93
- end
94
-
95
- end
@@ -1,410 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "spec_helper")
2
- require File.join(File.dirname(__FILE__), "controllers", "dispatcher")
3
-
4
- include Merb::Test::Fixtures::Controllers
5
-
6
- describe Merb::Dispatcher do
7
- include Merb::Test::Rspec::ControllerMatchers
8
- include Merb::Test::Rspec::ViewMatchers
9
-
10
- def dispatch(url)
11
- Merb::Dispatcher.handle(request_for(url))
12
- end
13
-
14
- def request_for(url)
15
- Merb::Request.new(Rack::MockRequest.env_for(url))
16
- end
17
-
18
- before(:each) do
19
- Merb::Config[:exception_details] = true
20
- end
21
-
22
- describe "with a regular route, " do
23
- before(:each) do
24
- Merb::Router.prepare do |r|
25
- r.default_routes
26
- end
27
- @url = "/dispatch_to/index"
28
- end
29
-
30
- it "dispatches to the right controller and action" do
31
- controller = dispatch(@url)
32
- controller.body.should == "Dispatched"
33
- end
34
-
35
- it "has the correct status code" do
36
- controller = dispatch(@url)
37
- controller.status.should == 200
38
- end
39
-
40
- it "sets the Request#params to include the route params" do
41
- controller = dispatch(@url)
42
- controller.request.params.should ==
43
- {"controller" => "dispatch_to", "action" => "index",
44
- "id" => nil, "format" => nil}
45
- end
46
-
47
- it "provides the time for start of request handling via Logger#info" do
48
- with_level(:info) do
49
- dispatch(@url)
50
- end.should include_log("Started request handling")
51
-
52
- with_level(:warn) do
53
- dispatch(@url)
54
- end.should_not include_log("Started request handling")
55
- end
56
-
57
- it "provides the routed params via Logger#debug" do
58
- with_level(:debug) do
59
- dispatch(@url)
60
- end.should include_log("Routed to:")
61
-
62
- with_level(:info) do
63
- dispatch(@url)
64
- end.should_not include_log("Routed to:")
65
- end
66
-
67
- it "provides the benchmarks via Logger#info" do
68
- with_level(:info) do
69
- dispatch(@url)
70
- end.should include_log(":after_filters_time")
71
-
72
- with_level(:warn) do
73
- dispatch(@url)
74
- end.should_not include_log(":after_filters_time")
75
- end
76
- end
77
-
78
- describe "with a route that redirects" do
79
- before(:each) do
80
- Merb::Router.prepare do |r|
81
- r.match("/redirect/to/foo").redirect("/foo")
82
- r.default_routes
83
- end
84
- @url = "/redirect/to/foo"
85
- @controller = dispatch(@url)
86
- end
87
-
88
- it "redirects" do
89
- @controller.body.should =~ %r{You are being <a href="/foo">redirected}
90
- end
91
-
92
- it "reports that it is redirecting via Logger#info" do
93
- with_level(:info) do
94
- dispatch(@url)
95
- end.should include_log("Dispatcher redirecting to: /foo (301)")
96
-
97
- with_level(:warn) do
98
- dispatch(@url)
99
- end.should_not include_log("Dispatcher redirecting to: /foo (301)")
100
- end
101
-
102
- it "sets the status correctly" do
103
- @controller.status.should == 301
104
- end
105
-
106
- it "sets the location correctly" do
107
- @controller.headers["Location"].should == "/foo"
108
- end
109
- end
110
-
111
- describe "with a route that points to a class that is not a Controller, " do
112
- before(:each) do
113
- Merb::Router.prepare do |r|
114
- r.default_routes
115
- end
116
- @url = "/not_a_controller/index"
117
- @controller = dispatch(@url)
118
- end
119
-
120
- describe "with exception details showing" do
121
- it "raises a NotFound" do
122
- @controller.should be_error(Merb::ControllerExceptions::NotFound)
123
- end
124
-
125
- it "returns a 404 status" do
126
- @controller.status.should == 404
127
- end
128
-
129
- it "returns useful info in the body" do
130
- @controller.body.should =~
131
- %r{<h2>Controller 'Merb::Test::Fixtures::Controllers::NotAController' not found.</h2>}
132
- end
133
- end
134
-
135
- describe "when the action raises an Exception" do
136
- before(:each) do
137
- Object.class_eval <<-RUBY
138
- class Exceptions < Application
139
- def gone
140
- "Gone"
141
- end
142
- end
143
- RUBY
144
- end
145
-
146
- after(:each) do
147
- Object.send(:remove_const, :Exceptions)
148
- end
149
-
150
- before(:each) do
151
- Merb::Router.prepare do |r|
152
- r.default_routes
153
- end
154
- @url = "/raise_gone/index"
155
- @controller = dispatch(@url)
156
- end
157
-
158
- it "remembers that the Exception is Gone" do
159
- @controller.should be_error(Merb::ControllerExceptions::Gone)
160
- end
161
-
162
- it "renders the action Exception#gone" do
163
- @controller.body.should == "Gone"
164
- end
165
-
166
- it "returns the status 410" do
167
- @controller.status.should == 410
168
- end
169
- end
170
-
171
- describe "when the action raises an Exception that has a superclass Exception available" do
172
- before(:each) do
173
- Object.class_eval <<-RUBY
174
- class Exceptions < Application
175
- def client_error
176
- "ClientError"
177
- end
178
- end
179
- RUBY
180
- end
181
-
182
- after(:each) do
183
- Object.send(:remove_const, :Exceptions)
184
- end
185
-
186
- before(:each) do
187
- Merb::Router.prepare do |r|
188
- r.default_routes
189
- end
190
- @url = "/raise_gone/index"
191
- @controller = dispatch(@url)
192
- end
193
-
194
- it "renders the Exception from the Exceptions controller" do
195
- @controller.should be_error(Merb::ControllerExceptions::Gone)
196
- end
197
-
198
- it "renders the action Exceptions#client_error since #gone is not defined" do
199
- @controller.body.should == "ClientError"
200
- end
201
-
202
- it "returns the status 410 (Gone) even though we rendered #client_error" do
203
- @controller.status.should == 410
204
- end
205
- end
206
- end
207
-
208
- describe "when the action raises an Error that is not a ControllerError" do
209
- before(:each) do
210
- Object.class_eval <<-RUBY
211
- class Exceptions < Application
212
- def load_error
213
- "LoadError"
214
- end
215
- end
216
- RUBY
217
- end
218
-
219
- after(:each) do
220
- Object.send(:remove_const, :Exceptions)
221
- end
222
-
223
- before(:each) do
224
- Merb::Router.prepare do |r|
225
- r.default_routes
226
- end
227
- @url = "/raise_load_error/index"
228
- @controller = dispatch(@url)
229
- end
230
-
231
- it "knows that the error is a LoadError" do
232
- @controller.should be_error(LoadError)
233
- end
234
-
235
- it "renders Exceptions#load_error" do
236
- @controller.body.should == "LoadError"
237
- end
238
-
239
- it "returns a 500 status code" do
240
- @controller.status.should == 500
241
- end
242
- end
243
-
244
- describe "when the Exception action raises" do
245
- before(:each) do
246
- Object.class_eval <<-RUBY
247
- class Exceptions < Application
248
- def load_error
249
- raise StandardError, "Big error"
250
- end
251
- end
252
- RUBY
253
- end
254
-
255
- after(:each) do
256
- Object.send(:remove_const, :Exceptions)
257
- end
258
-
259
- before(:each) do
260
- Merb::Router.prepare do |r|
261
- r.default_routes
262
- end
263
- @url = "/raise_load_error/index"
264
- @controller = dispatch(@url)
265
- end
266
-
267
- it "knows that the error is a StandardError" do
268
- @controller.should be_error(StandardError)
269
- end
270
-
271
- it "renders the default exception template" do
272
- @controller.body.should have_xpath("//h1[contains(.,'Standard Error')]")
273
- @controller.body.should have_xpath("//h2[contains(.,'Big error')]")
274
-
275
- @controller.body.should have_xpath("//h1[contains(.,'Load Error')]")
276
- @controller.body.should have_xpath("//h2[contains(.,'Big error')]")
277
- end
278
-
279
- it "returns a 500 status code" do
280
- @controller.status.should == 500
281
- end
282
- end
283
-
284
-
285
- describe "when the Exception action raises a NotFound" do
286
- before(:each) do
287
- Object.class_eval <<-RUBY
288
- class Exceptions < Application
289
- def not_found
290
- raise NotFound, "Somehow, the thing you were looking for was not found."
291
- end
292
- end
293
- RUBY
294
- end
295
-
296
- after(:each) do
297
- Object.send(:remove_const, :Exceptions)
298
- end
299
-
300
- before(:each) do
301
- Merb::Router.prepare do |r|
302
- r.default_routes
303
- end
304
- @url = "/page/not/found"
305
- @controller = dispatch(@url)
306
- end
307
-
308
- it "knows that the error is a NotFound" do
309
- @controller.should be_error(Merb::ControllerExceptions::NotFound)
310
- end
311
-
312
- it "renders the default exception template" do
313
- @controller.body.should have_xpath("//h1[contains(.,'Not Found')]")
314
- @controller.body.should have_xpath("//h2[contains(.,'Somehow, the thing')]")
315
- end
316
-
317
- it "returns a 404 status code" do
318
- @controller.status.should == 404
319
- end
320
- end
321
-
322
- describe "when the Exception action raises the same thing as the original failure" do
323
- before(:each) do
324
- Object.class_eval <<-RUBY
325
- class Exceptions < Application
326
- def load_error
327
- raise LoadError, "Something failed here"
328
- end
329
- end
330
- RUBY
331
- end
332
-
333
- after(:each) do
334
- Object.send(:remove_const, :Exceptions)
335
- end
336
-
337
- before(:each) do
338
- Merb::Router.prepare do |r|
339
- r.default_routes
340
- end
341
- @url = "/raise_load_error/index"
342
- @controller = dispatch(@url)
343
- end
344
-
345
- it "knows that the error is a NotFound" do
346
- @controller.should be_error(LoadError)
347
- end
348
-
349
- it "renders the default exception template" do
350
- @controller.body.should have_xpath("//h2[contains(.,'Something failed here')]")
351
- end
352
-
353
- it "returns a 500 status code" do
354
- @controller.status.should == 500
355
- end
356
- end
357
-
358
- describe "when more than one Exceptions methods raises an Error" do
359
- before(:each) do
360
- Object.class_eval <<-RUBY
361
- class Exceptions < Application
362
- def load_error
363
- raise StandardError, "StandardError"
364
- end
365
-
366
- def standard_error
367
- raise Exception, "Exception"
368
- end
369
- end
370
- RUBY
371
- end
372
-
373
- after(:each) do
374
- Object.send(:remove_const, :Exceptions)
375
- end
376
-
377
- before(:each) do
378
- Merb::Router.prepare do |r|
379
- r.default_routes
380
- end
381
- @url = "/raise_load_error/index"
382
- @controller = dispatch(@url)
383
- @body = @controller.body
384
- end
385
-
386
- it "knows that the error is a NotFound" do
387
- @controller.should be_error(Exception)
388
- end
389
-
390
- it "renders a list of links to the traces" do
391
- @body.should have_xpath("//li//a[@href='#exception_0']")
392
- @body.should have_xpath("//li//a[@href='#exception_1']")
393
- @body.should have_xpath("//li//a[@href='#exception_2']")
394
- end
395
-
396
- it "renders the default exception template" do
397
- @body.should have_xpath("//h1[contains(.,'Load Error')]")
398
- @body.should have_xpath("//h2[contains(.,'In the controller')]")
399
- @body.should have_xpath("//h1[contains(.,'Standard Error')]")
400
- @body.should have_xpath("//h2[contains(.,'StandardError')]")
401
- @body.should have_xpath("//h1[contains(.,'Exception')]")
402
- @body.should have_xpath("//h2[contains(.,'Exception')]")
403
- end
404
-
405
- it "returns a 500 status code" do
406
- @controller.status.should == 500
407
- end
408
- end
409
-
410
- end