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,43 +0,0 @@
1
- $START_OPTIONS = {:merb_root => File.join(File.dirname(__FILE__), "directory")}
2
- require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
3
-
4
- describe "The default Merb directory structure" do
5
-
6
- it "should load in controllers" do
7
- calling { Base }.should_not raise_error
8
- end
9
-
10
- it "should be able to complete the dispatch cycle" do
11
- controller = dispatch_to(Base, :string)
12
- controller.body.should == "String"
13
- end
14
-
15
- it "should be able to complete the dispatch cycle with templates" do
16
- controller = dispatch_to(Base, :template)
17
- controller.body.should == "Template ERB"
18
- end
19
-
20
- end
21
-
22
- describe "Modifying the _template_path" do
23
-
24
- it "should move the templates to a new location" do
25
- controller = dispatch_to(Custom, :template)
26
- controller.body.should == "Wonderful Template"
27
- end
28
-
29
- end
30
-
31
- describe "Merb.root_path" do
32
-
33
- it "should return a path relative to Merb.root" do
34
- path = Merb.root_path('/app/controllers/base.rb')
35
- path.to_s.should == File.join(Merb.root, '/app/controllers/base.rb')
36
- end
37
-
38
- it "should accept multiple arguments like File.join" do
39
- path = Merb.root_path('app', 'controllers', 'base.rb')
40
- path.to_s.should == File.join(Merb.root, 'app', 'controllers', 'base.rb')
41
- end
42
-
43
- end
@@ -1,181 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "spec_helper")
2
-
3
- describe Merb do
4
-
5
- describe "Command Line Options" do
6
-
7
- it "should allow -l / --log_level to set the log_level" do
8
- pending("How do we spec these?")
9
- end
10
-
11
- it "should allow -L / --log_file to set the log_file" do
12
- pending("How do we spec these?")
13
- # Run an instance of merb from the command line
14
- # using system and test if the file was created?
15
- end
16
-
17
- end
18
-
19
- end
20
-
21
- describe Merb::Logger do
22
-
23
- describe "#new" do
24
- it "should call set_log with the arguments it was passed." do
25
- logger = Merb::Logger.allocate # create an object sans initialization
26
- logger.should_receive(:set_log).with('a partridge', 'a pear tree', 'a time bomb').and_return(true)
27
- logger.send(:initialize, 'a partridge', 'a pear tree', 'a time bomb')
28
- end
29
- end
30
-
31
- describe "#set_log" do
32
-
33
- before(:each) do
34
- @logger = Merb::Logger.new(Merb.log_file)
35
- end
36
-
37
- it "should set the log level to :warn (4) when second parameter is :warn" do
38
- Merb::Logger.new(Merb.log_file, :warn).level.should eql(4)
39
- end
40
-
41
- it "should set the log level to :debug (0) when Merb.environment is development" do
42
- Merb.should_receive(:environment).and_return("development")
43
- @logger.set_log(Merb.log_path / "development.log")
44
- @logger.level.should eql(0)
45
- end
46
-
47
- it "should set the log level to :error (6) when Merb.environment is production" do
48
- Merb.should_receive(:environment).and_return("production")
49
- @logger.set_log(Merb.log_path / "production.log")
50
- @logger.level.should eql(4)
51
- end
52
-
53
- it "should initialize the buffer to an empty array" do
54
- @logger.buffer.should eql([])
55
- end
56
-
57
- it "should default the delimiter to ' ~ '" do
58
- @logger.delimiter.should eql(" ~ ")
59
- end
60
-
61
- it "should assign the newly created object to Merb.logger" do
62
- @logger = Merb::Logger.new(Merb.log_file)
63
- Merb.logger.should eql(@logger)
64
- end
65
-
66
- end
67
-
68
- describe "#flush" do
69
-
70
- before(:each) do
71
- @logger = Merb::Logger.new(Merb.log_file)
72
- end
73
-
74
- it "should immediately return if the buffer is empty" do
75
- @logger.should_not_receive(:write)
76
- @logger.flush
77
- end
78
-
79
- it "should call the write_method with the stringified contents of the buffer if the buffer is non-empty" do
80
- @logger.send(:<<, "a message")
81
- @logger.send(:<<, "another message")
82
- @logger.log.should_receive(:write).with(" ~ a message\n ~ another message\n")
83
- @logger.flush
84
- end
85
-
86
- end
87
-
88
- describe "#close" do
89
- before(:each) do
90
- @logger = Merb::Logger.new(Merb.log_file)
91
- end
92
-
93
- it "should flush the buffer before closing" do
94
- # TODO: how to specify order? eg. flush then close
95
- @logger.should_receive(:flush)
96
- @logger.log.should_receive(:close)
97
- @logger.close
98
- end
99
-
100
- it "should call the close method if the log responds to close" do
101
- @logger.log.should_receive(:close)
102
- @logger.close
103
- end
104
-
105
- it "shouldn't call the close method if the log is a terminal" do
106
- @logger.log.should_receive(:tty?).and_return(true)
107
- @logger.log.should_not_receive(:close)
108
- @logger.close
109
- end
110
-
111
- it "should set the stored log attribute to nil" do
112
- @logger.close
113
- @logger.log.should eql(nil)
114
- end
115
-
116
- end
117
-
118
- describe "<<" do
119
-
120
- end
121
-
122
- describe "level methods" do
123
-
124
- before(:all) do
125
- @logger = Merb::Logger.new(Merb.log_file)
126
- end
127
-
128
- it "should provide a #debug method which can be used to log" do
129
- @logger.should respond_to(:debug)
130
- @logger.should_receive(:<<).with("message").and_return(true)
131
- @logger.debug("message")
132
- end
133
-
134
- it "should provide a #info method which can be used to log" do
135
- @logger.should respond_to(:info)
136
- @logger.should_receive(:<<).with("message").and_return(true)
137
- @logger.info("message")
138
- end
139
-
140
- it "should provide a #warn method which can be used to log" do
141
- @logger.should respond_to(:warn)
142
- @logger.should_receive(:<<).with("message").and_return(true)
143
- @logger.warn("message")
144
- end
145
-
146
- it "should provide a #error method which can be used to log" do
147
- @logger.should respond_to(:error)
148
- @logger.should_receive(:<<).with("message").and_return(true)
149
- @logger.error("message")
150
- end
151
-
152
- it "should provide a #fatal method which can be used to log" do
153
- @logger.should respond_to(:fatal)
154
- @logger.should_receive(:<<).with("message").and_return(true)
155
- @logger.fatal("message")
156
- end
157
-
158
- # TODO: add positive and negative tests for each of the methods below:
159
- it "should provide a #debug? method" do
160
- @logger.should respond_to(:debug?)
161
- end
162
-
163
- it "should provide a #info? method" do
164
- @logger.should respond_to(:info?)
165
- end
166
-
167
- it "should provide a #warn? method" do
168
- @logger.should respond_to(:warn?)
169
- end
170
-
171
- it "should provide a #error? method" do
172
- @logger.should respond_to(:error?)
173
- end
174
-
175
- it "should provide a #fatal? method" do
176
- @logger.should respond_to(:fatal?)
177
- end
178
-
179
- end
180
-
181
- end
@@ -1 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
@@ -1,127 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
2
-
3
- require "sha1"
4
-
5
- class ConditionalGetTestController < Merb::Controller
6
- def with_etag
7
- response = "original message-body"
8
- headers['ETag'] = Digest::SHA1.hexdigest(response)
9
-
10
- response
11
- end
12
-
13
- def with_last_modified
14
- headers[Merb::Const::LAST_MODIFIED] = :documents_last_modified_time
15
- "original message-body"
16
- end
17
-
18
- def without
19
- # sanity check
20
- headers.delete('ETag')
21
- headers.delete(Merb::Const::LAST_MODIFIED)
22
-
23
- "original message-body"
24
- end
25
- end
26
-
27
-
28
- Merb::Router.prepare do |r|
29
- r.match("/with_etag").to(
30
- :controller => "conditional_get_test_controller", :action => "with_etag"
31
- )
32
- r.match("/with_last_modified").to(
33
- :controller => "conditional_get_test_controller", :action => "with_last_modified"
34
- )
35
- r.match("/without").to(
36
- :controller => "conditional_get_test_controller", :action => "without"
37
- )
38
- end
39
-
40
- describe Merb::Rack::ConditionalGet do
41
-
42
- describe(
43
- "when the client already has an up-to-date document",
44
- :shared => true
45
- ) do
46
- it 'sets status to "304"' do
47
- @status.should == 304
48
- end
49
-
50
- it 'returns no message-body' do
51
- @body.should == ""
52
- end
53
- end
54
-
55
- describe(
56
- "when the client does NOT have an up-to-date document",
57
- :shared => true
58
- ) do
59
- it 'does not modify status' do
60
- @status.should == 200
61
- end
62
-
63
- it 'does not modify message-body' do
64
- @body.should == "original message-body"
65
- end
66
- end
67
-
68
- before(:each) do
69
- @app = Merb::Rack::Application.new
70
- @middleware = Merb::Rack::ConditionalGet.new(@app)
71
- end
72
-
73
- describe "when response has no ETag header and no Last-Modified header" do
74
- before(:each) do
75
- env = Rack::MockRequest.env_for('/without')
76
- @status, @headers, @body = @middleware.call(env)
77
- end
78
-
79
- it_should_behave_like "when the client does NOT have an up-to-date document"
80
- end
81
-
82
- describe "when response has ETag header" do
83
- describe "and it == to HTTP_IF_NONE_MATCH of the request" do
84
- before(:each) do
85
- env = Rack::MockRequest.env_for('/with_etag')
86
- env['HTTP_IF_NONE_MATCH'] =
87
- Digest::SHA1.hexdigest("original message-body")
88
- @status, @headers, @body = @middleware.call(env)
89
- end
90
-
91
- it_should_behave_like "when the client already has an up-to-date document"
92
- end
93
-
94
- describe "and it IS NOT == to HTTP_IF_NONE_MATCH of the request" do
95
- before(:each) do
96
- env = Rack::MockRequest.env_for('/with_etag')
97
- env['HTTP_IF_NONE_MATCH'] =
98
- Digest::SHA1.hexdigest("a different message-body")
99
- @status, @headers, @body = @middleware.call(env)
100
- end
101
-
102
- it_should_behave_like "when the client does NOT have an up-to-date document"
103
- end
104
- end
105
-
106
- describe "when response has Last-Modified header" do
107
- describe "and it == to HTTP_IF_NOT_MODIFIED_SINCE of the request" do
108
- before(:each) do
109
- env = Rack::MockRequest.env_for('/with_last_modified')
110
- env[Merb::Const::HTTP_IF_MODIFIED_SINCE] = :documents_last_modified_time
111
- @status, @headers, @body = @middleware.call(env)
112
- end
113
-
114
- it_should_behave_like "when the client already has an up-to-date document"
115
- end
116
-
117
- describe "and it IS NOT == to HTTP_IF_NOT_MODIFIED_SINCE of the request" do
118
- before(:each) do
119
- env = Rack::MockRequest.env_for('/with_last_modified')
120
- env[Merb::Const::HTTP_IF_MODIFIED_SINCE] = :some_other_time
121
- @status, @headers, @body = @middleware.call(env)
122
- end
123
-
124
- it_should_behave_like "when the client does NOT have an up-to-date document"
125
- end
126
- end
127
- end
@@ -1,70 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
2
- require File.join(File.dirname(__FILE__), "shared_example_groups")
3
-
4
-
5
- Merb::Router.prepare do |r|
6
- r.resources :users
7
- end
8
-
9
- class Users < Merb::Controller
10
- def new
11
- body = "<div><form action='/users' method='POST'></form></div>"
12
- body
13
- end
14
-
15
- def index
16
- body = "<div>This is my index action</div>"
17
- body
18
- end
19
-
20
- def edit
21
- body = "<div><form action='/users' method='POST'></form><form action='/sessions' method='POST'></form></div>"
22
- end
23
-
24
- def create
25
-
26
- end
27
- end
28
-
29
-
30
- describe Merb::Rack::Csrf do
31
- before(:each) do
32
- @app = Merb::Rack::Application.new
33
- @middleware = Merb::Rack::Csrf.new(@app)
34
- @env = Rack::MockRequest.env_for('/users/new')
35
-
36
- Merb::Config[:session_secret_key] = "ABC"
37
- end
38
-
39
- it "should be successful" do
40
- env = Rack::MockRequest.env_for('/users', :method => 'POST', 'csrf_authentication_token' => "b072aa15485e028dc8973d48089efe0e")
41
- status, header, body = @middleware.call(env)
42
- status.should == 200
43
- end
44
-
45
- it "should return a Merb::ExceptionsController::Forbidden (403)" do
46
- env = Rack::MockRequest.env_for('/users', :method => 'POST', 'csrf_authentication_token' => "INCORRECT_AUTH_TOKEN")
47
- status, header, body = @middleware.call(env)
48
- status.should == 403
49
- end
50
-
51
- it "should insert a hidden field in to any form with a POST method" do
52
- env = Rack::MockRequest.env_for('/users/new')
53
- status, header, body = @middleware.call(env)
54
- body.should have_tag(:form, :action => '/users')
55
- body.should have_tag(:input, :type => 'hidden', :id => 'csrf_authentication_token')
56
- end
57
-
58
- it "should not do anything if there is no form found in the response" do
59
- env = Rack::MockRequest.env_for('/users')
60
- status, header, body = @middleware.call(env)
61
- body.should not_match_tag('form')
62
- end
63
-
64
- it "should insert hidden fields in to both forms" do
65
- env = Rack::MockRequest.env_for('/users/1/edit')
66
- status, header, body = @middleware.call(env)
67
- body.should have_tag(:form, :action => '/users')
68
- body.should have_tag(:form, :action => '/sessions')
69
- end
70
- end
@@ -1,99 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
2
- require File.join(File.dirname(__FILE__), "shared_example_groups")
3
-
4
- class RackyController < Merb::Controller
5
- def index
6
- body = "Everyone loves Rack"
7
- headers['Content-Length'] = body.size.to_s
8
-
9
- body
10
- end
11
- end
12
-
13
- Merb::Router.prepare do |r|
14
- r.match("/heavy/lifting").to(:controller => "racky_controller")
15
- end
16
-
17
-
18
- describe Merb::Rack::Application do
19
- before(:each) do
20
- @app = Merb::Rack::Application.new
21
- @env = Rack::MockRequest.env_for('/heavy/lifting')
22
-
23
- @result = @app.call(@env)
24
- @body = "Everyone loves Rack"
25
- end
26
-
27
- it_should_behave_like "rack application"
28
-
29
- it 'sets Date header' do
30
- status, headers, body = @app.call(@env)
31
-
32
- headers.should include(Merb::Const::DATE)
33
- end
34
-
35
- describe "#deferred?" do
36
- it "returns true when request path matches deferred actions regexp" do
37
- Merb::Config[:deferred_actions] = ['/heavy/lifting']
38
-
39
- @app.deferred?(@env).should be(true)
40
- end
41
-
42
- it "returns false when request path DOES NOT match deferred actions regexp" do
43
- @app.deferred?(Rack::MockRequest.env_for('/not/deferred')).should be(false)
44
- end
45
- end
46
- end
47
-
48
-
49
- describe Merb::Rack::Middleware do
50
- before(:each) do
51
- @app = Merb::Rack::Application.new
52
- @middleware = Merb::Rack::Middleware.new(@app)
53
- @env = Rack::MockRequest.env_for('/heavy/lifting')
54
-
55
- @result = @middleware.call(@env)
56
- @body = "Everyone loves Rack"
57
- end
58
-
59
- it_should_behave_like "rack application"
60
-
61
- it_should_behave_like "transparent middleware"
62
- end
63
-
64
-
65
-
66
- describe Merb::Rack::Tracer do
67
- before(:each) do
68
- @app = Merb::Rack::Application.new
69
- @middleware = Merb::Rack::Tracer.new(@app)
70
- @env = Rack::MockRequest.env_for('/heavy/lifting')
71
-
72
- @result = @middleware.call(@env)
73
- @body = "Everyone loves Rack"
74
- end
75
-
76
- it_should_behave_like "rack application"
77
-
78
- it_should_behave_like "transparent middleware"
79
- end
80
-
81
-
82
- describe Merb::Rack::ContentLength do
83
- before(:each) do
84
- @app = Merb::Rack::Application.new
85
- @middleware = Merb::Rack::ContentLength.new(@app)
86
- @env = Rack::MockRequest.env_for('/heavy/lifting')
87
-
88
- @result = @middleware.call(@env)
89
- @body = "Everyone loves Rack"
90
- end
91
-
92
- it_should_behave_like "rack application"
93
-
94
- it_should_behave_like "transparent middleware"
95
-
96
- it 'sets Content-Length header to response body size' do
97
- @result[1]['Content-Length'].should == @body.size.to_s
98
- end
99
- end