merb 0.5.3 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (294) hide show
  1. data/LICENSE +0 -20
  2. data/README +0 -277
  3. data/Rakefile +80 -199
  4. data/TODO +0 -3
  5. metadata +19 -438
  6. data/SVN_REVISION +0 -1
  7. data/app_generators/merb/USAGE +0 -5
  8. data/app_generators/merb/merb_generator.rb +0 -108
  9. data/app_generators/merb/templates/Rakefile +0 -124
  10. data/app_generators/merb/templates/app/controllers/application.rb +0 -3
  11. data/app_generators/merb/templates/app/controllers/exceptions.rb +0 -13
  12. data/app_generators/merb/templates/app/helpers/global_helper.rb +0 -5
  13. data/app_generators/merb/templates/app/mailers/views/layout/application.html.erb +0 -1
  14. data/app_generators/merb/templates/app/mailers/views/layout/application.text.erb +0 -1
  15. data/app_generators/merb/templates/app/parts/views/layout/application.html.erb +0 -1
  16. data/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb +0 -216
  17. data/app_generators/merb/templates/app/views/exceptions/not_acceptable.html.erb +0 -38
  18. data/app_generators/merb/templates/app/views/exceptions/not_found.html.erb +0 -40
  19. data/app_generators/merb/templates/app/views/layout/application.html.erb +0 -11
  20. data/app_generators/merb/templates/config/boot.rb +0 -11
  21. data/app_generators/merb/templates/config/dependencies.rb +0 -41
  22. data/app_generators/merb/templates/config/environments/development.rb +0 -1
  23. data/app_generators/merb/templates/config/environments/production.rb +0 -1
  24. data/app_generators/merb/templates/config/environments/test.rb +0 -1
  25. data/app_generators/merb/templates/config/merb.yml +0 -82
  26. data/app_generators/merb/templates/config/merb_init.rb +0 -17
  27. data/app_generators/merb/templates/config/plugins.yml +0 -1
  28. data/app_generators/merb/templates/config/router.rb +0 -35
  29. data/app_generators/merb/templates/config/upload.conf +0 -0
  30. data/app_generators/merb/templates/public/images/merb.jpg +0 -0
  31. data/app_generators/merb/templates/public/merb.fcgi +0 -6
  32. data/app_generators/merb/templates/public/stylesheets/master.css +0 -119
  33. data/app_generators/merb/templates/script/destroy +0 -32
  34. data/app_generators/merb/templates/script/generate +0 -32
  35. data/app_generators/merb/templates/script/stop_merb +0 -13
  36. data/app_generators/merb/templates/script/win_script.cmd +0 -1
  37. data/app_generators/merb/templates/spec/spec.opts +0 -6
  38. data/app_generators/merb/templates/spec/spec_helper.rb +0 -15
  39. data/app_generators/merb/templates/test/test_helper.rb +0 -14
  40. data/app_generators/merb_plugin/USAGE +0 -5
  41. data/app_generators/merb_plugin/merb_plugin_generator.rb +0 -68
  42. data/app_generators/merb_plugin/templates/LICENSE +0 -20
  43. data/app_generators/merb_plugin/templates/README +0 -4
  44. data/app_generators/merb_plugin/templates/Rakefile +0 -35
  45. data/app_generators/merb_plugin/templates/TODO +0 -5
  46. data/app_generators/merb_plugin/templates/merbtasks.rb +0 -6
  47. data/app_generators/merb_plugin/templates/sampleplugin.rb +0 -10
  48. data/app_generators/merb_plugin/templates/sampleplugin_spec.rb +0 -7
  49. data/app_generators/merb_plugin/templates/spec_helper.rb +0 -2
  50. data/bin/merb +0 -4
  51. data/lib/autotest/discover.rb +0 -3
  52. data/lib/autotest/merb_rspec.rb +0 -80
  53. data/lib/merb.rb +0 -188
  54. data/lib/merb/abstract_controller.rb +0 -399
  55. data/lib/merb/assets.rb +0 -160
  56. data/lib/merb/assets.rb.orig +0 -119
  57. data/lib/merb/boot_loader.rb +0 -286
  58. data/lib/merb/boot_loader.rb.orig +0 -235
  59. data/lib/merb/caching.rb +0 -5
  60. data/lib/merb/caching/action_cache.rb +0 -92
  61. data/lib/merb/caching/fragment_cache.rb +0 -39
  62. data/lib/merb/caching/store/file_cache.rb +0 -90
  63. data/lib/merb/caching/store/memory_cache.rb +0 -85
  64. data/lib/merb/config.rb +0 -290
  65. data/lib/merb/constants.rb +0 -50
  66. data/lib/merb/controller.rb +0 -220
  67. data/lib/merb/cookies.rb +0 -95
  68. data/lib/merb/core_ext.rb +0 -15
  69. data/lib/merb/core_ext/array.rb +0 -0
  70. data/lib/merb/core_ext/class.rb +0 -180
  71. data/lib/merb/core_ext/enumerable.rb +0 -49
  72. data/lib/merb/core_ext/get_args.rb +0 -76
  73. data/lib/merb/core_ext/hash.rb +0 -306
  74. data/lib/merb/core_ext/inflections.rb +0 -112
  75. data/lib/merb/core_ext/inflector.rb +0 -275
  76. data/lib/merb/core_ext/kernel.rb +0 -242
  77. data/lib/merb/core_ext/mash.rb +0 -88
  78. data/lib/merb/core_ext/module.rb +0 -67
  79. data/lib/merb/core_ext/numeric.rb +0 -72
  80. data/lib/merb/core_ext/object.rb +0 -183
  81. data/lib/merb/core_ext/string.rb +0 -53
  82. data/lib/merb/core_ext/symbol.rb +0 -6
  83. data/lib/merb/dispatcher.rb +0 -109
  84. data/lib/merb/drb_server.rb +0 -19
  85. data/lib/merb/erubis_ext.rb +0 -10
  86. data/lib/merb/exceptions.rb +0 -192
  87. data/lib/merb/generators/merb_app/merb_app.rb +0 -22
  88. data/lib/merb/generators/merb_generator_helpers.rb +0 -318
  89. data/lib/merb/generators/merb_plugin.rb +0 -22
  90. data/lib/merb/logger.rb +0 -78
  91. data/lib/merb/mail_controller.rb +0 -268
  92. data/lib/merb/mailer.rb +0 -87
  93. data/lib/merb/mixins/basic_authentication.rb +0 -35
  94. data/lib/merb/mixins/controller.rb +0 -160
  95. data/lib/merb/mixins/erubis_capture.rb +0 -68
  96. data/lib/merb/mixins/general_controller.rb +0 -253
  97. data/lib/merb/mixins/inline_partial.rb +0 -32
  98. data/lib/merb/mixins/render.rb +0 -465
  99. data/lib/merb/mixins/responder.rb +0 -449
  100. data/lib/merb/mixins/view_context.rb +0 -558
  101. data/lib/merb/mixins/web_controller.rb +0 -36
  102. data/lib/merb/mongrel_handler.rb +0 -168
  103. data/lib/merb/part_controller.rb +0 -29
  104. data/lib/merb/plugins.rb +0 -16
  105. data/lib/merb/rack_adapter.rb +0 -37
  106. data/lib/merb/request.rb +0 -465
  107. data/lib/merb/router.rb +0 -646
  108. data/lib/merb/server.rb +0 -169
  109. data/lib/merb/session.rb +0 -23
  110. data/lib/merb/session/cookie_store.rb +0 -118
  111. data/lib/merb/session/mem_cache_session.rb +0 -131
  112. data/lib/merb/session/memory_session.rb +0 -176
  113. data/lib/merb/template.rb +0 -37
  114. data/lib/merb/template/erubis.rb +0 -68
  115. data/lib/merb/template/haml.rb +0 -87
  116. data/lib/merb/template/markaby.rb +0 -59
  117. data/lib/merb/template/xml_builder.rb +0 -50
  118. data/lib/merb/test/fake_request.rb +0 -74
  119. data/lib/merb/test/helper.rb +0 -260
  120. data/lib/merb/test/hpricot.rb +0 -136
  121. data/lib/merb/test/multipart.rb +0 -66
  122. data/lib/merb/test/rspec.rb +0 -18
  123. data/lib/merb/test/rspec_matchers/controller_matchers.rb +0 -117
  124. data/lib/merb/test/rspec_matchers/markup_matchers.rb +0 -98
  125. data/lib/merb/upload_handler.rb +0 -80
  126. data/lib/merb/upload_progress.rb +0 -48
  127. data/lib/merb/version.rb +0 -49
  128. data/lib/merb/view_context.rb +0 -79
  129. data/lib/tasks.rb +0 -7
  130. data/lib/tasks/merb.rake +0 -54
  131. data/merb_default_generators/model/USAGE +0 -0
  132. data/merb_default_generators/model/model_generator.rb +0 -16
  133. data/merb_default_generators/model/templates/new_model_template.erb +0 -5
  134. data/merb_default_generators/resource_controller/USAGE +0 -0
  135. data/merb_default_generators/resource_controller/resource_controller_generator.rb +0 -26
  136. data/merb_default_generators/resource_controller/templates/controller.rb +0 -30
  137. data/merb_default_generators/resource_controller/templates/edit.html.erb +0 -1
  138. data/merb_default_generators/resource_controller/templates/helper.rb +0 -5
  139. data/merb_default_generators/resource_controller/templates/index.html.erb +0 -1
  140. data/merb_default_generators/resource_controller/templates/new.html.erb +0 -1
  141. data/merb_default_generators/resource_controller/templates/show.html.erb +0 -1
  142. data/merb_generators/controller/USAGE +0 -5
  143. data/merb_generators/controller/controller_generator.rb +0 -16
  144. data/merb_generators/controller/templates/controller.rb +0 -8
  145. data/merb_generators/controller/templates/helper.rb +0 -5
  146. data/merb_generators/controller/templates/index.html.erb +0 -3
  147. data/merb_generators/part_controller/USAGE +0 -5
  148. data/merb_generators/part_controller/part_controller_generator.rb +0 -27
  149. data/merb_generators/part_controller/templates/controller.rb +0 -8
  150. data/merb_generators/part_controller/templates/helper.rb +0 -5
  151. data/merb_generators/part_controller/templates/index.html.erb +0 -3
  152. data/merb_generators/resource/USAGE +0 -0
  153. data/merb_generators/resource/resource_generator.rb +0 -67
  154. data/rspec_generators/merb_controller_test/merb_controller_test_generator.rb +0 -67
  155. data/rspec_generators/merb_controller_test/templates/controller_spec.rb +0 -8
  156. data/rspec_generators/merb_controller_test/templates/edit_spec.rb +0 -12
  157. data/rspec_generators/merb_controller_test/templates/helper_spec.rb +0 -5
  158. data/rspec_generators/merb_controller_test/templates/index_spec.rb +0 -12
  159. data/rspec_generators/merb_controller_test/templates/new_spec.rb +0 -12
  160. data/rspec_generators/merb_controller_test/templates/show_spec.rb +0 -5
  161. data/rspec_generators/merb_model_test/merb_model_test_generator.rb +0 -26
  162. data/rspec_generators/merb_model_test/templates/model_spec_template.erb +0 -7
  163. data/script/destroy +0 -14
  164. data/script/generate +0 -14
  165. data/spec/fixtures/config/environments/environment_config_test.yml +0 -1
  166. data/spec/fixtures/config/merb.yml +0 -18
  167. data/spec/fixtures/controllers/dispatch_spec_controllers.rb +0 -235
  168. data/spec/fixtures/controllers/render_spec_controllers.rb +0 -184
  169. data/spec/fixtures/foo.rb +0 -3
  170. data/spec/fixtures/mailers/views/layout/application.html.erb +0 -3
  171. data/spec/fixtures/mailers/views/layout/application.text.erb +0 -3
  172. data/spec/fixtures/mailers/views/test_mail_controller/eighth.html.erb +0 -1
  173. data/spec/fixtures/mailers/views/test_mail_controller/eighth.text.erb +0 -1
  174. data/spec/fixtures/mailers/views/test_mail_controller/first.html.erb +0 -1
  175. data/spec/fixtures/mailers/views/test_mail_controller/first.text.erb +0 -1
  176. data/spec/fixtures/mailers/views/test_mail_controller/ninth.html.erb +0 -1
  177. data/spec/fixtures/mailers/views/test_mail_controller/ninth.text.erb +0 -1
  178. data/spec/fixtures/mailers/views/test_mail_controller/second.text.erb +0 -1
  179. data/spec/fixtures/mailers/views/test_mail_controller/third.html.erb +0 -1
  180. data/spec/fixtures/models/router_spec_models.rb +0 -30
  181. data/spec/fixtures/parts/views/layout/todo_part.html.erb +0 -3
  182. data/spec/fixtures/parts/views/layout/todo_part.xml.erb +0 -3
  183. data/spec/fixtures/parts/views/todo_part/formatted_output.html.erb +0 -1
  184. data/spec/fixtures/parts/views/todo_part/formatted_output.js.erb +0 -1
  185. data/spec/fixtures/parts/views/todo_part/formatted_output.xml.erb +0 -1
  186. data/spec/fixtures/parts/views/todo_part/list.html.erb +0 -3
  187. data/spec/fixtures/sample.txt +0 -1
  188. data/spec/fixtures/views/erubis.html.erb +0 -1
  189. data/spec/fixtures/views/examples/_erubis.html.erb +0 -1
  190. data/spec/fixtures/views/examples/_haml.html.haml +0 -1
  191. data/spec/fixtures/views/examples/_markaby.html.mab +0 -1
  192. data/spec/fixtures/views/examples/_throw_content.html.erb +0 -6
  193. data/spec/fixtures/views/examples/hello.xml.builder +0 -1
  194. data/spec/fixtures/views/examples/js.js.erb +0 -1
  195. data/spec/fixtures/views/examples/template_catch_content.html.erb +0 -15
  196. data/spec/fixtures/views/examples/template_catch_content_from_partial.html.erb +0 -6
  197. data/spec/fixtures/views/examples/template_throw_content.html.erb +0 -10
  198. data/spec/fixtures/views/examples/template_throw_content_without_block.html.erb +0 -3
  199. data/spec/fixtures/views/exceptions/admin_access_required.html.erb +0 -1
  200. data/spec/fixtures/views/extension_template_controller/_nested_js.js.erb +0 -1
  201. data/spec/fixtures/views/extension_template_controller/_nested_xml.xml.erb +0 -1
  202. data/spec/fixtures/views/extension_template_controller/_render_partial_multiple_times.html.erb +0 -1
  203. data/spec/fixtures/views/extension_template_controller/erubis_templates.html.erb +0 -1
  204. data/spec/fixtures/views/extension_template_controller/erubis_templates.js.erb +0 -1
  205. data/spec/fixtures/views/extension_template_controller/erubis_templates.rhtml +0 -1
  206. data/spec/fixtures/views/extension_template_controller/erubis_templates.xml.erb +0 -1
  207. data/spec/fixtures/views/extension_template_controller/haml_index.html.haml +0 -0
  208. data/spec/fixtures/views/extension_template_controller/haml_templates.html.haml +0 -1
  209. data/spec/fixtures/views/extension_template_controller/haml_templates.js.haml +0 -1
  210. data/spec/fixtures/views/extension_template_controller/haml_templates.xml.haml +0 -1
  211. data/spec/fixtures/views/extension_template_controller/index.html.erb +0 -0
  212. data/spec/fixtures/views/extension_template_controller/markaby_index.html.mab +0 -0
  213. data/spec/fixtures/views/extension_template_controller/markaby_templates.html.mab +0 -1
  214. data/spec/fixtures/views/extension_template_controller/markaby_templates.js.mab +0 -1
  215. data/spec/fixtures/views/extension_template_controller/markaby_templates.xml.mab +0 -1
  216. data/spec/fixtures/views/extension_template_controller/render_multiple_partials.html.erb +0 -4
  217. data/spec/fixtures/views/extension_template_controller/render_nested_js.js.erb +0 -1
  218. data/spec/fixtures/views/extension_template_controller/render_nested_xml.xml.erb +0 -1
  219. data/spec/fixtures/views/haml.html.haml +0 -1
  220. data/spec/fixtures/views/haml.xml.haml +0 -2
  221. data/spec/fixtures/views/layout/application.html.erb +0 -1
  222. data/spec/fixtures/views/layout/application.xml.erb +0 -1
  223. data/spec/fixtures/views/layout/nested/example.html.erb +0 -1
  224. data/spec/fixtures/views/markaby.html.mab +0 -1
  225. data/spec/fixtures/views/nested/example/test.html.erb +0 -1
  226. data/spec/fixtures/views/partials/_erubis.html.erb +0 -1
  227. data/spec/fixtures/views/partials/_erubis_collection.html.erb +0 -1
  228. data/spec/fixtures/views/partials/_erubis_collection_with_locals.html.erb +0 -1
  229. data/spec/fixtures/views/partials/_erubis_new.html.erb +0 -1
  230. data/spec/fixtures/views/partials/_haml.html.haml +0 -1
  231. data/spec/fixtures/views/partials/_haml_collection.html.haml +0 -1
  232. data/spec/fixtures/views/partials/_haml_collection_with_locals.html.haml +0 -1
  233. data/spec/fixtures/views/partials/_haml_new.html.haml +0 -1
  234. data/spec/fixtures/views/partials/_markaby.html.mab +0 -1
  235. data/spec/fixtures/views/partials/_markaby_collection.html.mab +0 -1
  236. data/spec/fixtures/views/partials/_markaby_collection_with_locals.html.mab +0 -1
  237. data/spec/fixtures/views/partials/_markaby_new.html.mab +0 -1
  238. data/spec/fixtures/views/render_object_controller/render_object_with_template.html.erb +0 -1
  239. data/spec/fixtures/views/render_object_controller/render_object_with_template.js.erb +0 -1
  240. data/spec/fixtures/views/render_object_controller/render_object_with_template.xml.erb +0 -1
  241. data/spec/fixtures/views/template_views/interface__buffer_erubis.html.erb +0 -4
  242. data/spec/fixtures/views/template_views/interface__buffer_haml.html.haml +0 -7
  243. data/spec/fixtures/views/template_views/interface__buffer_markaby.html.mab +0 -7
  244. data/spec/fixtures/views/template_views/interface_capture_erubis.html.erb +0 -15
  245. data/spec/fixtures/views/template_views/interface_capture_haml.html.haml +0 -15
  246. data/spec/fixtures/views/template_views/interface_capture_markaby.html.mab +0 -4
  247. data/spec/fixtures/views/template_views/interface_concat_erubis.html.erb +0 -12
  248. data/spec/fixtures/views/template_views/interface_concat_haml.html.haml +0 -11
  249. data/spec/fixtures/views/template_views/interface_concat_markaby.html.mab +0 -14
  250. data/spec/fixtures/views/test.dir/the_template.html.erb +0 -1
  251. data/spec/merb/abstract_controller_spec.rb +0 -38
  252. data/spec/merb/assets_spec.rb +0 -207
  253. data/spec/merb/caching_spec.rb +0 -102
  254. data/spec/merb/config_spec.rb +0 -29
  255. data/spec/merb/controller_filters_spec.rb +0 -253
  256. data/spec/merb/controller_spec.rb +0 -126
  257. data/spec/merb/cookie_store_spec.rb +0 -72
  258. data/spec/merb/cookies_spec.rb +0 -96
  259. data/spec/merb/core_ext/class_spec.rb +0 -97
  260. data/spec/merb/core_ext/enumerable_spec.rb +0 -27
  261. data/spec/merb/core_ext/hash_spec.rb +0 -251
  262. data/spec/merb/core_ext/inflector_spec.rb +0 -34
  263. data/spec/merb/core_ext/kernel_spec.rb +0 -25
  264. data/spec/merb/core_ext/numeric_spec.rb +0 -26
  265. data/spec/merb/core_ext/object_spec.rb +0 -47
  266. data/spec/merb/core_ext/string_spec.rb +0 -22
  267. data/spec/merb/core_ext/symbol_spec.rb +0 -7
  268. data/spec/merb/dependency_spec.rb +0 -22
  269. data/spec/merb/dispatch_spec.rb +0 -528
  270. data/spec/merb/fake_request_spec.rb +0 -80
  271. data/spec/merb/generator_spec.rb +0 -248
  272. data/spec/merb/handler_spec.rb +0 -169
  273. data/spec/merb/mail_controller_spec.rb +0 -177
  274. data/spec/merb/mailer_spec.rb +0 -87
  275. data/spec/merb/multipart_spec.rb +0 -50
  276. data/spec/merb/part_controller_spec.rb +0 -124
  277. data/spec/merb/plugins_spec.rb +0 -80
  278. data/spec/merb/render_spec.rb +0 -469
  279. data/spec/merb/request_spec.rb +0 -287
  280. data/spec/merb/responder_spec.rb +0 -562
  281. data/spec/merb/router_spec.rb +0 -900
  282. data/spec/merb/server_spec.rb +0 -19
  283. data/spec/merb/template_spec.rb +0 -41
  284. data/spec/merb/upload_handler_spec.rb +0 -108
  285. data/spec/merb/version_spec.rb +0 -33
  286. data/spec/merb/view_context_spec.rb +0 -366
  287. data/spec/spec_generator_helper.rb +0 -34
  288. data/spec/spec_helper.rb +0 -101
  289. data/spec/spec_helpers/url_shared_behaviour.rb +0 -112
  290. data/test_unit_generators/merb_controller_test/merb_controller_test_generator.rb +0 -53
  291. data/test_unit_generators/merb_controller_test/templates/functional_test.rb +0 -17
  292. data/test_unit_generators/merb_controller_test/templates/helper_test.rb +0 -9
  293. data/test_unit_generators/merb_model_test/merb_model_test_generator.rb +0 -29
  294. data/test_unit_generators/merb_model_test/templates/model_test_unit_template.erb +0 -9
@@ -1,80 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe Merb::Test::FakeRequest, ".new(env = {}, method = 'GET', req = StringIO.new)" do
4
- it "should create request with default enviroment" do
5
- @mock = Merb::Test::FakeRequest.new
6
- @mock.env.should == Merb::Test::FakeRequest::DEFAULT_ENV
7
- end
8
-
9
- it "should override default env values passed in HTTP format" do
10
- @mock = Merb::Test::FakeRequest.new('HTTP_ACCEPT' => 'nothing')
11
- @mock['HTTP_ACCEPT'].should == 'nothing'
12
- end
13
-
14
- it "should override default env values passed in symbol format" do
15
- @mock = Merb::Test::FakeRequest.new(:http_accept => 'nothing')
16
- @mock['HTTP_ACCEPT'].should == 'nothing'
17
- end
18
-
19
- it "should change :cookies into HTTP_COOKIE" do
20
- @mock = Merb::Test::FakeRequest.new(:cookies => 'icanhazcookie=true')
21
- @mock['HTTP_COOKIE'].should == 'icanhazcookie=true'
22
- end
23
-
24
- it "should set body to an empty StringIO" do
25
- @mock = Merb::Test::FakeRequest.new
26
- @mock.body.should be_kind_of(StringIO)
27
- @mock.body.read.should == ''
28
- end
29
- end
30
-
31
- describe Merb::Test::FakeRequest, ".with(path, options = {})" do
32
- before(:each) do
33
- @mock = Merb::Test::FakeRequest.with('/foo?bar=baz')
34
- end
35
-
36
- it "should set REQUEST_URI to path" do
37
- @mock['REQUEST_URI'].should == '/foo?bar=baz'
38
- end
39
-
40
- it "should set PATH_INFO to path without query string" do
41
- @mock['PATH_INFO'].should == '/foo'
42
- end
43
-
44
- it "should pass other options through to new" do
45
- @mock = Merb::Test::FakeRequest.with('/foo?bar=baz', :http_accept => 'cash/money')
46
- @mock['HTTP_ACCEPT'].should == 'cash/money'
47
- end
48
- end
49
-
50
- describe Merb::Test::FakeRequest, ".post_body=(post)" do
51
- it "should wrap post param in new StringIO" do
52
- @mock = Merb::Test::FakeRequest.new
53
- @mock.post_body = "hello world"
54
- @mock.body.should be_kind_of(StringIO)
55
- @mock.body.read.should == "hello world"
56
- end
57
- end
58
-
59
- describe Merb::Test::FakeRequest, "[](key)" do
60
- it "should return the key from @env" do
61
- @mock = Merb::Test::FakeRequest.new(:http_accept => 'cash/money')
62
- @mock['HTTP_ACCEPT'].should == 'cash/money'
63
- end
64
- end
65
-
66
- describe Merb::Test::FakeRequest, "[]=(key, value)" do
67
- it "should set key in @env to value" do
68
- @mock = Merb::Test::FakeRequest.new(:http_accept => 'cash/money')
69
- @mock['HTTP_ACCEPT'] = 'also/credit_card'
70
- @mock['HTTP_ACCEPT'].should == 'also/credit_card'
71
- end
72
- end
73
-
74
- describe Merb::Test::FakeRequest, "session" do
75
- it "should have a memory-based session" do
76
- @mock = Merb::Test::FakeRequest.new
77
- @mock.session[:random] = "random"
78
- @mock.session[:random].should == "random"
79
- end
80
- end
@@ -1,248 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require File.dirname(__FILE__) + '/../spec_generator_helper'
3
-
4
-
5
- describe "an app generator" do
6
- include RubiGen::GeneratorTestHelper
7
-
8
- before :all do
9
- module Kernel
10
- alias_method :old_dependency, :dependency
11
- undef dependency
12
- end
13
- end
14
-
15
- after :all do
16
- module Kernel
17
- alias_method :dependency, :old_dependency
18
- end
19
- end
20
-
21
- before do
22
- @generator = build_generator('merb', [APP_ROOT], sources, {})
23
- end
24
-
25
- after do
26
- bare_teardown # Cleans up the temporary application directory that gets created as part of the test.
27
- end
28
-
29
- it "should be get created" do
30
- @generator.should_not be_nil
31
- end
32
-
33
- it "should be a MerbGenerator" do
34
- @generator.should be_an_instance_of(MerbGenerator)
35
- end
36
-
37
- it "should create directory structure" do
38
- silence_generator do
39
- @generator.command(:create).invoke!
40
- end
41
- %w{
42
- app
43
- app/controllers
44
- app/helpers
45
- app/mailers
46
- app/mailers/helpers
47
- app/mailers/views/layout
48
- app/mailers/views
49
- app/models
50
- app/views
51
- app/views/layout
52
- config
53
- config/environments
54
- lib
55
- log
56
- public
57
- public/images
58
- public/javascripts
59
- public/stylesheets
60
- script
61
- test
62
- }.each{|dir| directory_should_be_created(dir)}
63
- end
64
-
65
- it "should create files from templates" do
66
- silence_generator do
67
- @generator.command(:create).invoke!
68
- end
69
- %w{
70
- app/controllers/application.rb
71
- app/helpers/global_helper.rb
72
- app/mailers/views/layout/application.html.erb
73
- app/views/layout/application.html.erb
74
- config/environments/development.rb
75
- config/environments/production.rb
76
- config/environments/test.rb
77
- config/merb.yml
78
- config/merb_init.rb
79
- config/router.rb
80
- config/dependencies.rb
81
- config/upload.conf
82
- Rakefile
83
- script/stop_merb
84
- script/generate
85
- script/destroy
86
- }.each{|file| file_should_be_created(file)}
87
- end
88
-
89
- it "should create files from rubigen dependency" do
90
- silence_generator do
91
- @generator.command(:create).invoke!
92
- end
93
- %w{
94
- script/generate
95
- script/destroy
96
- }.each{|file| file_should_be_created(file)}
97
- end
98
-
99
- it "should make script files executable" do
100
- silence_generator do
101
- @generator.command(:create).invoke!
102
- end
103
-
104
- %w{
105
- script/stop_merb
106
- script/generate
107
- script/destroy
108
- }.each{|file| file_should_be_executable(file)}
109
- end
110
-
111
- def sources
112
- [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"../../", generator_path))
113
- ]
114
- end
115
-
116
- def generator_path
117
- "app_generators"
118
- end
119
-
120
- end
121
-
122
- describe "a controller generator" do
123
- include RubiGen::GeneratorTestHelper
124
-
125
- before :all do
126
- module Kernel
127
- alias_method :old_dependency, :dependency
128
- undef dependency
129
- end
130
- end
131
-
132
- after :all do
133
- module Kernel
134
- alias_method :dependency, :old_dependency
135
- end
136
- end
137
-
138
- before do
139
- @generator = build_generator('controller', ["my_posts"], sources, {})
140
- end
141
-
142
- after do
143
- bare_teardown # Cleans up the temporary application directory that gets created as part of the test.
144
- end
145
-
146
- it "should be get created" do
147
- @generator.should_not be_nil
148
- end
149
-
150
- it "should be a ControllerGenerator" do
151
- @generator.should be_an_instance_of(ControllerGenerator)
152
- end
153
-
154
- it "should create directory structure" do
155
- silence_generator do
156
- @generator.command(:create).invoke!
157
- end
158
- %w{
159
- app
160
- app/controllers
161
- app/helpers
162
- app/views
163
- app/views/my_posts
164
- }.each{|dir| directory_should_be_created(dir)}
165
- end
166
-
167
- it "should create files from templates" do
168
- silence_generator do
169
- @generator.command(:create).invoke!
170
- end
171
- %w{
172
- app/controllers/my_posts.rb
173
- app/helpers/my_posts_helper.rb
174
- app/views/my_posts/index.html.erb
175
- }.each{|file| file_should_be_created(file)}
176
- end
177
-
178
- def sources
179
- [
180
- RubiGen::PathSource.new(:app, File.join(File.dirname(__FILE__),"../../", "merb_generators")),
181
- RubiGen::PathSource.new(:app, File.join(File.dirname(__FILE__),"../../", "rspec_generators"))
182
- ]
183
- end
184
- end
185
-
186
- describe "a part_controller generator" do
187
- include RubiGen::GeneratorTestHelper
188
-
189
- before :all do
190
- module Kernel
191
- alias_method :old_dependency, :dependency
192
- undef dependency
193
- end
194
- end
195
-
196
- after :all do
197
- module Kernel
198
- alias_method :dependency, :old_dependency
199
- end
200
- end
201
-
202
- before do
203
- @generator = build_generator('part_controller', ["my_posts"], sources, {})
204
- end
205
-
206
- after do
207
- bare_teardown # Cleans up the temporary application directory that gets created as part of the test.
208
- end
209
-
210
- it "should be get created" do
211
- @generator.should_not be_nil
212
- end
213
-
214
- it "should be a PartControllerGenerator" do
215
- @generator.should be_an_instance_of(PartControllerGenerator)
216
- end
217
-
218
- it "should create directory structure" do
219
- silence_generator do
220
- @generator.command(:create).invoke!
221
- end
222
- %w{
223
- app
224
- app/parts/controllers
225
- app/parts/helpers
226
- app/parts/views
227
- app/parts/views/my_posts_part
228
- }.each{|dir| directory_should_be_created(dir)}
229
- end
230
-
231
- it "should create files from templates" do
232
- silence_generator do
233
- @generator.command(:create).invoke!
234
- end
235
- %w{
236
- app/parts/controllers/my_posts_part.rb
237
- app/parts/helpers/my_posts_part_helper.rb
238
- app/parts/views/my_posts_part/index.html.erb
239
- }.each{|file| file_should_be_created(file)}
240
- end
241
-
242
- def sources
243
- [
244
- RubiGen::PathSource.new(:app, File.join(File.dirname(__FILE__),"../../", "merb_generators")),
245
- RubiGen::PathSource.new(:app, File.join(File.dirname(__FILE__),"../../", "rspec_generators"))
246
- ]
247
- end
248
- end
@@ -1,169 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe MerbHandler, "process" do
4
-
5
- def do_process
6
- @handler.process( @request, @response )
7
- end
8
-
9
- def log_info_with( with_param )
10
- Merb.logger.should_receive(:info).with( with_param )
11
- end
12
-
13
- before(:each) do
14
- @params = { Mongrel::Const::REQUEST_METHOD => "GET",
15
- Mongrel::Const::PATH_INFO => "PUBLIC",
16
- Mongrel::Const::REQUEST_URI => "www.example.com/file" }
17
-
18
-
19
- @static_file_handler = mock( "mongrel_dir_handler", :null_object => true )
20
- @static_file_handler.stub!( :can_serve ).and_return( false )
21
- Mongrel::DirHandler.stub!(:new).and_return( @static_file_handler ) # Need to get a handle on the dir handler in initialize
22
-
23
- @handler = MerbHandler.new( "public" )
24
-
25
- @response = mock( "response", :null_object => true )
26
- @response.stub!( :socket ).and_return( mock( "socket" ) )
27
- @response.socket.stub!( :closed? ).and_return( false )
28
-
29
- @request = mock( "request", :null_object => true )
30
- @request.stub!( :params ).and_return( @params )
31
-
32
- @benchmarks = { :setup_time => 1 }
33
- @controller = mock( "controller", :null_object => true )
34
- @controller.stub!(:class).and_return( "CONTROLLER_CLASS" )
35
- @controller.stub!(:_benchmarks).and_return( @benchmarks )
36
- @action = "ACTION"
37
- Merb::Dispatcher.stub!( :handle ).and_return( [@controller, @action] )
38
-
39
- Merb.logger.stub!(:info)
40
- end
41
-
42
- it "should return nil if the socket is closed" do
43
- @response.socket.stub!( :closed? ).and_return( true )
44
- do_process.should be_nil
45
- end
46
-
47
- it "should log the request URI to the Merb.logger.info" do
48
- log_info_with( /REQUEST_URI/ )
49
- do_process
50
- end
51
-
52
-
53
- it "should serve static files" do
54
- @static_file_handler.stub!( :can_serve ).and_return( true )
55
- log_info_with( /static/i )
56
- @static_file_handler.should_receive( :process ).with( @request, @response )
57
- do_process
58
- end
59
-
60
- it "should fall back to .html and try and serve the file" do
61
- @static_file_handler.should_receive( :can_serve ).with( "PUBLIC.html" ).and_return( true )
62
- @static_file_handler.should_receive( :process ).with( @request, @response )
63
- log_info_with( /static/i )
64
- do_process
65
- @request.params[Mongrel::Const::PATH_INFO].should == "PUBLIC.html"
66
- end
67
-
68
- it "should ask the Dispatcher for the controller and action" do
69
- Merb::Dispatcher.should_receive( :handle ).with( @request, @response ).and_return( [@controller, @action] )
70
- do_process
71
- end
72
-
73
- it "should log any exceptions that reach the handler and return 500" do
74
- @out = ""
75
- @head = {}
76
- Merb::Dispatcher.should_receive( :handle ).and_raise( Exception )
77
- @response.should_receive( :send_status ).with( 500 )
78
- Merb.logger.should_receive(:error)
79
- do_process
80
- end
81
-
82
- it "should set the response.status to the controller.status" do
83
- @controller.should_receive( :status ).and_return( "SPEC_STATUS" )
84
- @response.should_receive( :status= ).with( "SPEC_STATUS" )
85
- do_process
86
- end
87
-
88
- it "should handle the X-SENDFILE header" do
89
- @controller.should_receive( :headers ).and_return( { "X-SENDFILE" => __FILE__ } )
90
- log_info_with( /X-SENDFILE/im )
91
- @response.should_receive( :status= ).with( 200 )
92
- @response.header.should_receive( :[]= ).with( Mongrel::Const::LAST_MODIFIED, an_instance_of( String ) )
93
- @response.header.should_receive( :[]= ).with( Mongrel::Const::ETAG, anything() )
94
- @response.should_recieve( :send_status ).with( File.size( __FILE__ ) )
95
- @response.should_receive( :send_header )
96
- @response.should_receive( :send_file )
97
-
98
- do_process
99
- end
100
-
101
- it "should setup the headers" do
102
- @response_header = {}
103
- @controller.should_receive( :headers ).and_return( { "X-MY_HEADER" => "MY_HEADER_CONTENT" } )
104
- @response.should_receive( :header ).and_return( @response_header )
105
- @response_header.should_receive( :[]= ).with( "X-MY_HEADER", "MY_HEADER_CONTENT" )
106
- do_process
107
- end
108
-
109
-
110
- it "should handle a controller body that can be read" do
111
- # This is a bit dependent on implementation
112
- @controller.should_receive( :headers ).and_return( { "CONTENT-LENGTH" => 5 } )
113
- @body = Object.new
114
- @body.stub!( :close ).and_return( true )
115
- @body.stub!( :read ).and_return( false )
116
- @body.should_receive( :read ).and_return( true, true, false )
117
- @controller.stub!( :body ).and_return( @body )
118
- @response.should_receive( :send_status ).with( 5 )
119
- @response.should_receive( :send_header )
120
- @response.should_receive( :write ).at_least( :once )
121
- @body.should_receive( :close )
122
-
123
- do_process
124
- end
125
-
126
- it "should handle a controller body that is a proc" do
127
- @proc = Proc.new { "PROC_CONTENTS" }
128
- @controller.should_receive( :body ).at_least(:once).and_return( @proc )
129
- @proc.should_receive( :call )
130
- do_process
131
- end
132
-
133
- it "should spit out a normal rendering of the controller" do
134
- @body = "CONTROLLER_BODY"
135
- @controller.stub!( :body ).and_return( @body )
136
- @controller.should_receieve( :body ).at_least( :once ).and_return( @body )
137
-
138
- @response.should_receive( :send_status ).with( @body.length )
139
- @response.should_receive( :send_header )
140
- @response.should_receive( :write ).with( @body )
141
-
142
- do_process
143
- end
144
-
145
- it "should log the controller and action called" do
146
- log_info_with( /Routing to.+CONTROLLER_CLASS.+ACTION/ )
147
- do_process
148
- end
149
-
150
- it "should render the request times" do
151
- log_info_with( /request times/i )
152
- do_process
153
- end
154
-
155
- it "should render the Response status" do
156
- log_info_with( /response status/i )
157
- do_process
158
- end
159
-
160
- it "should remove path_prefix from the request_uri and path_info environment variables" do
161
- MerbHandler.path_prefix = "/prefix"
162
- @request.params[Mongrel::Const::PATH_INFO] = "/prefix/PUBLIC"
163
- @request.params[Mongrel::Const::REQUEST_URI] = "/prefix/file"
164
- do_process
165
- @request.params[Mongrel::Const::PATH_INFO].should == "/PUBLIC"
166
- @request.params[Mongrel::Const::REQUEST_URI].should == "/file"
167
- MerbHandler.path_prefix = nil
168
- end
169
- end