merb-core 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +21 -0
- data/Rakefile +285 -0
- data/TODO +0 -0
- data/bin/merb +8 -0
- data/bin/merb-specs +5 -0
- data/docs/bootloading.dox +57 -0
- data/docs/documentation_standards +40 -0
- data/docs/new_render_api +51 -0
- data/lib/merb-core.rb +304 -0
- data/lib/merb-core/autoload.rb +29 -0
- data/lib/merb-core/bootloader.rb +601 -0
- data/lib/merb-core/config.rb +284 -0
- data/lib/merb-core/constants.rb +43 -0
- data/lib/merb-core/controller/abstract_controller.rb +531 -0
- data/lib/merb-core/controller/exceptions.rb +257 -0
- data/lib/merb-core/controller/merb_controller.rb +214 -0
- data/lib/merb-core/controller/mime.rb +88 -0
- data/lib/merb-core/controller/mixins/controller.rb +262 -0
- data/lib/merb-core/controller/mixins/render.rb +324 -0
- data/lib/merb-core/controller/mixins/responder.rb +464 -0
- data/lib/merb-core/controller/template.rb +205 -0
- data/lib/merb-core/core_ext.rb +12 -0
- data/lib/merb-core/core_ext/class.rb +192 -0
- data/lib/merb-core/core_ext/hash.rb +422 -0
- data/lib/merb-core/core_ext/kernel.rb +304 -0
- data/lib/merb-core/core_ext/mash.rb +154 -0
- data/lib/merb-core/core_ext/object.rb +136 -0
- data/lib/merb-core/core_ext/object_space.rb +14 -0
- data/lib/merb-core/core_ext/rubygems.rb +28 -0
- data/lib/merb-core/core_ext/set.rb +41 -0
- data/lib/merb-core/core_ext/string.rb +69 -0
- data/lib/merb-core/dispatch/cookies.rb +92 -0
- data/lib/merb-core/dispatch/dispatcher.rb +233 -0
- data/lib/merb-core/dispatch/exceptions.html.erb +297 -0
- data/lib/merb-core/dispatch/request.rb +560 -0
- data/lib/merb-core/dispatch/router.rb +141 -0
- data/lib/merb-core/dispatch/router/behavior.rb +777 -0
- data/lib/merb-core/dispatch/router/cached_proc.rb +52 -0
- data/lib/merb-core/dispatch/router/route.rb +212 -0
- data/lib/merb-core/dispatch/session.rb +28 -0
- data/lib/merb-core/dispatch/session/cookie.rb +166 -0
- data/lib/merb-core/dispatch/session/memcached.rb +161 -0
- data/lib/merb-core/dispatch/session/memory.rb +234 -0
- data/lib/merb-core/gem_ext/erubis.rb +19 -0
- data/lib/merb-core/logger.rb +230 -0
- data/lib/merb-core/plugins.rb +25 -0
- data/lib/merb-core/rack.rb +15 -0
- data/lib/merb-core/rack/adapter.rb +42 -0
- data/lib/merb-core/rack/adapter/ebb.rb +22 -0
- data/lib/merb-core/rack/adapter/evented_mongrel.rb +24 -0
- data/lib/merb-core/rack/adapter/fcgi.rb +16 -0
- data/lib/merb-core/rack/adapter/irb.rb +108 -0
- data/lib/merb-core/rack/adapter/mongrel.rb +25 -0
- data/lib/merb-core/rack/adapter/runner.rb +27 -0
- data/lib/merb-core/rack/adapter/thin.rb +27 -0
- data/lib/merb-core/rack/adapter/webrick.rb +35 -0
- data/lib/merb-core/rack/application.rb +77 -0
- data/lib/merb-core/rack/handler/mongrel.rb +97 -0
- data/lib/merb-core/server.rb +184 -0
- data/lib/merb-core/test.rb +10 -0
- data/lib/merb-core/test/helpers.rb +9 -0
- data/lib/merb-core/test/helpers/controller_helper.rb +8 -0
- data/lib/merb-core/test/helpers/multipart_request_helper.rb +175 -0
- data/lib/merb-core/test/helpers/request_helper.rb +257 -0
- data/lib/merb-core/test/helpers/route_helper.rb +33 -0
- data/lib/merb-core/test/helpers/view_helper.rb +121 -0
- data/lib/merb-core/test/matchers.rb +9 -0
- data/lib/merb-core/test/matchers/controller_matchers.rb +269 -0
- data/lib/merb-core/test/matchers/route_matchers.rb +136 -0
- data/lib/merb-core/test/matchers/view_matchers.rb +293 -0
- data/lib/merb-core/test/run_specs.rb +38 -0
- data/lib/merb-core/test/tasks/spectasks.rb +39 -0
- data/lib/merb-core/test/test_ext/hpricot.rb +32 -0
- data/lib/merb-core/test/test_ext/object.rb +14 -0
- data/lib/merb-core/vendor/facets.rb +2 -0
- data/lib/merb-core/vendor/facets/dictionary.rb +433 -0
- data/lib/merb-core/vendor/facets/inflect.rb +211 -0
- data/lib/merb-core/version.rb +11 -0
- data/spec/private/config/adapter_spec.rb +32 -0
- data/spec/private/config/config_spec.rb +139 -0
- data/spec/private/config/environment_spec.rb +13 -0
- data/spec/private/config/spec_helper.rb +1 -0
- data/spec/private/core_ext/hash_spec.rb +506 -0
- data/spec/private/core_ext/kernel_spec.rb +46 -0
- data/spec/private/core_ext/object_spec.rb +39 -0
- data/spec/private/core_ext/set_spec.rb +26 -0
- data/spec/private/core_ext/string_spec.rb +9 -0
- data/spec/private/dispatch/cookies_spec.rb +107 -0
- data/spec/private/dispatch/dispatch_spec.rb +26 -0
- data/spec/private/dispatch/fixture/app/controllers/application.rb +4 -0
- data/spec/private/dispatch/fixture/app/controllers/exceptions.rb +27 -0
- data/spec/private/dispatch/fixture/app/controllers/foo.rb +21 -0
- data/spec/private/dispatch/fixture/app/helpers/global_helpers.rb +8 -0
- data/spec/private/dispatch/fixture/app/views/exeptions/client_error.html.erb +37 -0
- data/spec/private/dispatch/fixture/app/views/exeptions/internal_server_error.html.erb +216 -0
- data/spec/private/dispatch/fixture/app/views/exeptions/not_acceptable.html.erb +38 -0
- data/spec/private/dispatch/fixture/app/views/exeptions/not_found.html.erb +40 -0
- data/spec/private/dispatch/fixture/app/views/foo/bar.html.erb +0 -0
- data/spec/private/dispatch/fixture/app/views/layout/application.html.erb +11 -0
- data/spec/private/dispatch/fixture/config/environments/development.rb +6 -0
- data/spec/private/dispatch/fixture/config/environments/production.rb +5 -0
- data/spec/private/dispatch/fixture/config/environments/test.rb +6 -0
- data/spec/private/dispatch/fixture/config/init.rb +45 -0
- data/spec/private/dispatch/fixture/config/rack.rb +1 -0
- data/spec/private/dispatch/fixture/config/router.rb +35 -0
- data/spec/private/dispatch/fixture/log/development.log +1 -0
- data/spec/private/dispatch/fixture/log/merb.4000.pid +1 -0
- data/spec/private/dispatch/fixture/log/merb_test.log +2040 -0
- data/spec/private/dispatch/fixture/log/production.log +1 -0
- data/spec/private/dispatch/fixture/merb.4000.pid +1 -0
- data/spec/private/dispatch/fixture/public/images/merb.jpg +0 -0
- data/spec/private/dispatch/fixture/public/merb.fcgi +4 -0
- data/spec/private/dispatch/fixture/public/stylesheets/master.css +119 -0
- data/spec/private/dispatch/route_params_spec.rb +24 -0
- data/spec/private/dispatch/spec_helper.rb +1 -0
- data/spec/private/plugins/plugin_spec.rb +81 -0
- data/spec/private/rack/application_spec.rb +43 -0
- data/spec/public/DEFINITIONS +11 -0
- data/spec/public/abstract_controller/controllers/alt_views/layout/application.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_string_controller_layout.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_template_controller_layout.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/show.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/partial/basic_partial_with_multiple_roots/_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_and_custom_location/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_inherited/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/display.rb +54 -0
- data/spec/public/abstract_controller/controllers/filters.rb +167 -0
- data/spec/public/abstract_controller/controllers/helpers.rb +31 -0
- data/spec/public/abstract_controller/controllers/partial.rb +106 -0
- data/spec/public/abstract_controller/controllers/render.rb +86 -0
- data/spec/public/abstract_controller/controllers/views/helpers/capture/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/helpers/concat/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/layout/alt.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/layout/custom.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object_with_action/new.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_app_layout/index.erb +0 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_custom_layout/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/show.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/another_directory/_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial_with_multiple_roots/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_first.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_second.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_in_another_directory/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/_collection.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/_collection.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/_collection.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/_variables.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/_both.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/_with_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/_with_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/_with_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/test_display/foo.html.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/test_render/foo.html.erb +0 -0
- data/spec/public/abstract_controller/controllers/views/wonderful/index.erb +1 -0
- data/spec/public/abstract_controller/display_spec.rb +33 -0
- data/spec/public/abstract_controller/filter_spec.rb +80 -0
- data/spec/public/abstract_controller/helper_spec.rb +13 -0
- data/spec/public/abstract_controller/partial_spec.rb +53 -0
- data/spec/public/abstract_controller/render_spec.rb +70 -0
- data/spec/public/abstract_controller/spec_helper.rb +27 -0
- data/spec/public/boot_loader/boot_loader_spec.rb +33 -0
- data/spec/public/boot_loader/spec_helper.rb +1 -0
- data/spec/public/controller/base_spec.rb +31 -0
- data/spec/public/controller/controllers/base.rb +41 -0
- data/spec/public/controller/controllers/display.rb +40 -0
- data/spec/public/controller/controllers/responder.rb +67 -0
- data/spec/public/controller/controllers/url.rb +7 -0
- data/spec/public/controller/controllers/views/layout/custom.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.xml.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/html_default/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/layout/custom.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.xml.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.js.erb +1 -0
- data/spec/public/controller/display_spec.rb +34 -0
- data/spec/public/controller/log/merb.4000.pid +1 -0
- data/spec/public/controller/responder_spec.rb +95 -0
- data/spec/public/controller/spec_helper.rb +9 -0
- data/spec/public/controller/url_spec.rb +152 -0
- data/spec/public/directory_structure/directory/app/controllers/application.rb +3 -0
- data/spec/public/directory_structure/directory/app/controllers/base.rb +13 -0
- data/spec/public/directory_structure/directory/app/controllers/custom.rb +19 -0
- data/spec/public/directory_structure/directory/app/views/base/template.html.erb +1 -0
- data/spec/public/directory_structure/directory/app/views/wonderful/template.erb +1 -0
- data/spec/public/directory_structure/directory/config/router.rb +3 -0
- data/spec/public/directory_structure/directory/log/merb.4000.pid +1 -0
- data/spec/public/directory_structure/directory/log/merb_test.log +265 -0
- data/spec/public/directory_structure/directory/merb.4000.pid +1 -0
- data/spec/public/directory_structure/directory_spec.rb +44 -0
- data/spec/public/logger/logger_spec.rb +175 -0
- data/spec/public/logger/spec_helper.rb +1 -0
- data/spec/public/reloading/directory/app/controllers/application.rb +3 -0
- data/spec/public/reloading/directory/app/controllers/reload.rb +6 -0
- data/spec/public/reloading/directory/config/init.rb +2 -0
- data/spec/public/reloading/directory/log/merb.4000.pid +1 -0
- data/spec/public/reloading/directory/log/merb_test.log +59 -0
- data/spec/public/reloading/directory/merb.4000.pid +1 -0
- data/spec/public/reloading/reload_spec.rb +80 -0
- data/spec/public/request/multipart_spec.rb +15 -0
- data/spec/public/request/request_spec.rb +207 -0
- data/spec/public/router/default_spec.rb +21 -0
- data/spec/public/router/deferred_spec.rb +22 -0
- data/spec/public/router/namespace_spec.rb +113 -0
- data/spec/public/router/nested_resources_spec.rb +34 -0
- data/spec/public/router/resource_spec.rb +45 -0
- data/spec/public/router/resources_spec.rb +57 -0
- data/spec/public/router/spec_helper.rb +72 -0
- data/spec/public/router/special_spec.rb +44 -0
- data/spec/public/router/string_spec.rb +61 -0
- data/spec/public/template/template_spec.rb +92 -0
- data/spec/public/template/templates/error.html.erb +2 -0
- data/spec/public/template/templates/template.html.erb +1 -0
- data/spec/public/template/templates/template.html.myt +1 -0
- data/spec/public/test/controller_matchers_spec.rb +378 -0
- data/spec/public/test/controllers/controller_assertion_mock.rb +7 -0
- data/spec/public/test/controllers/dispatch_controller.rb +11 -0
- data/spec/public/test/controllers/spec_helper_controller.rb +30 -0
- data/spec/public/test/multipart_request_helper_spec.rb +159 -0
- data/spec/public/test/multipart_upload_text_file.txt +1 -0
- data/spec/public/test/request_helper_spec.rb +153 -0
- data/spec/public/test/route_helper_spec.rb +54 -0
- data/spec/public/test/route_matchers_spec.rb +133 -0
- data/spec/public/test/view_helper_spec.rb +96 -0
- data/spec/public/test/view_matchers_spec.rb +107 -0
- data/spec/spec_helper.rb +71 -0
- metadata +488 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
module Merb::Test::Fixtures
|
2
|
+
module Abstract
|
3
|
+
|
4
|
+
class HelperTesting < Merb::AbstractController
|
5
|
+
self._template_root = File.dirname(__FILE__) / "views"
|
6
|
+
|
7
|
+
def _template_location(action, type = nil, controller = controller_name)
|
8
|
+
"helpers/#{File.basename(controller)}/#{action}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Capture < HelperTesting
|
13
|
+
def index
|
14
|
+
render
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module ConcatHelper
|
19
|
+
def concatter(&blk)
|
20
|
+
concat("Concat", blk.binding)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Concat < HelperTesting
|
25
|
+
def index
|
26
|
+
render
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Merb::Test::Fixtures
|
4
|
+
|
5
|
+
module Abstract
|
6
|
+
|
7
|
+
class RenderIt < Merb::AbstractController
|
8
|
+
self._template_root = File.dirname(__FILE__) / "views"
|
9
|
+
|
10
|
+
def _template_location(action, type = nil, controller = controller_name)
|
11
|
+
"partial/#{File.basename(controller)}/#{action}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class BasicPartial < RenderIt
|
16
|
+
|
17
|
+
def index
|
18
|
+
render
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class WithPartial < RenderIt
|
23
|
+
|
24
|
+
def index
|
25
|
+
@foo = "With"
|
26
|
+
render
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class WithNilPartial < RenderIt
|
31
|
+
|
32
|
+
def index
|
33
|
+
render
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class WithAsPartial < RenderIt
|
38
|
+
|
39
|
+
def index
|
40
|
+
@foo = "With and As"
|
41
|
+
render
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class PartialWithCollections < RenderIt
|
46
|
+
|
47
|
+
def index
|
48
|
+
@foo = %w{ c o l l e c t i o n }
|
49
|
+
render
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class PartialWithCollectionsAndAs < RenderIt
|
54
|
+
|
55
|
+
def index
|
56
|
+
@foo = %w{ c o l l e c t i o n }
|
57
|
+
render
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class PartialWithLocals < RenderIt
|
62
|
+
|
63
|
+
def index
|
64
|
+
@foo, @bar = %w{ local variables }
|
65
|
+
render
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class PartialWithBoth < RenderIt
|
70
|
+
|
71
|
+
def index
|
72
|
+
@foo = %w{ c o l l e c t i o n }
|
73
|
+
@delimiter = "-"
|
74
|
+
render
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class PartialWithWithAndLocals < RenderIt
|
79
|
+
|
80
|
+
def index
|
81
|
+
@foo, @bar = "with", "and locals"
|
82
|
+
render
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class PartialInAnotherDirectory < RenderIt
|
87
|
+
|
88
|
+
def index
|
89
|
+
render
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
class NestedPartial < RenderIt
|
94
|
+
def index
|
95
|
+
render
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
class BasicPartialWithMultipleRoots < RenderIt
|
100
|
+
self._template_roots << [File.dirname(__FILE__) / "alt_views", :_template_location]
|
101
|
+
def index
|
102
|
+
render
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Merb::Test::Fixtures
|
4
|
+
|
5
|
+
module Abstract
|
6
|
+
|
7
|
+
class Testing < Merb::AbstractController
|
8
|
+
self._template_root = File.dirname(__FILE__) / "views"
|
9
|
+
end
|
10
|
+
|
11
|
+
class RenderString < Testing
|
12
|
+
|
13
|
+
def index
|
14
|
+
render "the index"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class RenderStringCustomLayout < RenderString
|
19
|
+
layout :custom
|
20
|
+
end
|
21
|
+
|
22
|
+
class RenderStringAppLayout < RenderString
|
23
|
+
self._template_root = File.dirname(__FILE__) / "alt_views"
|
24
|
+
end
|
25
|
+
|
26
|
+
class RenderStringControllerLayout < RenderString
|
27
|
+
self._template_root = File.dirname(__FILE__) / "alt_views"
|
28
|
+
end
|
29
|
+
|
30
|
+
class RenderStringDynamicLayout < RenderString
|
31
|
+
layout :determine_layout
|
32
|
+
|
33
|
+
def alt_index
|
34
|
+
render "the alt index"
|
35
|
+
end
|
36
|
+
|
37
|
+
def determine_layout
|
38
|
+
action_name.index('alt') == 0 ? 'alt' : 'custom'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class RenderTemplate < Testing
|
43
|
+
|
44
|
+
def index
|
45
|
+
render
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class RenderTemplateCustomLayout < RenderString
|
50
|
+
layout :custom
|
51
|
+
end
|
52
|
+
|
53
|
+
class RenderTemplateAppLayout < RenderString
|
54
|
+
self._template_root = File.dirname(__FILE__) / "alt_views"
|
55
|
+
end
|
56
|
+
|
57
|
+
class RenderTemplateControllerLayout < RenderString
|
58
|
+
self._template_root = File.dirname(__FILE__) / "alt_views"
|
59
|
+
end
|
60
|
+
|
61
|
+
class RenderTemplateCustomLocation < RenderTemplate
|
62
|
+
def _template_location(action, type = nil, controller = controller_name)
|
63
|
+
"wonderful/#{action}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class RenderTemplateMultipleRoots < RenderTemplate
|
68
|
+
self._template_roots << [File.dirname(__FILE__) / "alt_views", :_template_location]
|
69
|
+
|
70
|
+
def show
|
71
|
+
render :layout=>false
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
class RenderTemplateMultipleRootsAndCustomLocation < RenderTemplate
|
76
|
+
self._template_roots = [[File.dirname(__FILE__) / "alt_views", :_custom_template_location]]
|
77
|
+
|
78
|
+
def _custom_template_location(action, type = nil, controller = controller_name)
|
79
|
+
"#{self.class.name.split('::')[-1].to_const_path}/#{action}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class RenderTemplateMultipleRootsInherited < RenderTemplateMultipleRootsAndCustomLocation
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<% x = capture do -%>Capture<% end -%><%= x %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<% concatter do -%>Hello<% end -%>
|
@@ -0,0 +1 @@
|
|
1
|
+
Alt: <%= catch_content(:for_layout) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Custom: <%= catch_content(:for_layout) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
the index
|
@@ -0,0 +1 @@
|
|
1
|
+
new action
|
@@ -0,0 +1 @@
|
|
1
|
+
the index
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
the index
|
@@ -0,0 +1 @@
|
|
1
|
+
This is overriden by the custom template root
|
@@ -0,0 +1 @@
|
|
1
|
+
default show
|
@@ -0,0 +1 @@
|
|
1
|
+
Partial in another directory
|
@@ -0,0 +1 @@
|
|
1
|
+
Partial
|
@@ -0,0 +1 @@
|
|
1
|
+
Index <%= partial :partial %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Base Index: <%= partial :partial %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= msg %> <%= partial 'second', :another => 'second' %> <%= msg %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= another %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= partial 'first', :msg => 'first' %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Index <%= partial 'another_directory/partial' %>
|
data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/_collection.erb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
<%= letter %><%= delimiter %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Partial with <%= partial :collection, :with => @foo, :as => :letter, :delimiter => @delimiter %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= collection %>
|
data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/index.erb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Partial with <%= partial :collection, :with => @foo %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= letter %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Partial with <%= partial :collection, :with => @foo, :as => :letter %>
|
data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/_variables.erb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
<%= local %> <%= variables %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Partial with <%= partial :variables, :local => @foo, :variables => @bar %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= first %> <%= second %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Partial with <%= partial :both, :with => @foo, :as => :first, :second => @bar %>
|
data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/_with_partial.erb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
<%= w00t %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Partial with <%= partial :with_partial, :with => @foo, :as => :w00t %>
|
data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/_with_partial.erb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
<%= with_partial || "nil local" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Partial with <%= partial :with_partial, :with => nil %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= with_partial || "nil local" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Partial with <%= partial :with_partial, :with => @foo %>
|
@@ -0,0 +1 @@
|
|
1
|
+
fooness
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
Wonderful
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
|
+
|
3
|
+
describe Merb::AbstractController, " displaying objects with templates" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Merb.push_path(:layout, File.dirname(__FILE__) / "controllers" / "views" / "layouts")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should allow you to pass an object" do
|
10
|
+
dispatch_should_make_body("DisplayObject", "the index")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should allow you to pass an object with an action specified" do
|
14
|
+
dispatch_should_make_body("DisplayObjectWithAction", "new action", :create)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should allow you to pass an object with a path specified for the template" do
|
18
|
+
dispatch_should_make_body("DisplayObjectWithPath", "fooness")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should allow you to pass an object using multiple template root" do
|
22
|
+
dispatch_should_make_body("DisplayObjectWithMultipleRoots", "App: new index")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should allow you to pass an object using multiple template root, with layout" do
|
26
|
+
dispatch_should_make_body("DisplayObjectWithMultipleRoots", "Alt: new show", "show")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should allow you to pass an object using multiple template root, without layout" do
|
30
|
+
dispatch_should_make_body("DisplayObjectWithMultipleRoots", "fooness", "another")
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# ==== Public API
|
2
|
+
# Merb::AbstractController.before(filter<Symbol, Proc>, opts<Hash>)
|
3
|
+
# Merb::AbstractController.after(filter<Symbol, Proc>, opts<Hash>)
|
4
|
+
# Merb::AbstractController.skip_before(filter<Symbol>)
|
5
|
+
# Merb::AbstractController.skip_after(filter<Symbol>)
|
6
|
+
#
|
7
|
+
# ==== Semipublic API
|
8
|
+
# Merb::AbstractController#_body
|
9
|
+
# Merb::AbstractController#_dispatch(action<~to_s>)
|
10
|
+
|
11
|
+
require File.join(File.dirname(__FILE__), "spec_helper")
|
12
|
+
|
13
|
+
describe Merb::AbstractController, " should support before and after filters" do
|
14
|
+
|
15
|
+
it "should support before filters" do
|
16
|
+
dispatch_should_make_body("TestBeforeFilter", "foo filter")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should support after filters" do
|
20
|
+
dispatch_should_make_body("TestAfterFilter", "foo filter")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should support skipping filters that were defined in a superclass" do
|
24
|
+
dispatch_should_make_body("TestSkipFilter", "")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should append before filters when added" do
|
28
|
+
dispatch_should_make_body("TestBeforeFilterOrder", "bar filter")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should append after filters when added" do
|
32
|
+
dispatch_should_make_body("TestAfterFilterOrder", "bar filter")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should support proc arguments to filters evaluated in the controller's instance" do
|
36
|
+
dispatch_should_make_body("TestProcFilter", "proc filter1 proc filter2")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should support filters that skip specific actions via :exclude" do
|
40
|
+
dispatch_should_make_body("TestExcludeFilter", " ", :index)
|
41
|
+
dispatch_should_make_body("TestExcludeFilter", "foo filter bar filter", :show)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should support filters that work only on specific actions via :only" do
|
45
|
+
dispatch_should_make_body("TestOnlyFilter", "foo filter bar filter", :index)
|
46
|
+
dispatch_should_make_body("TestOnlyFilter", " ", :show)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should throw an error if both :exclude and :only are passed to a filter" do
|
50
|
+
running { Merb::Test::Fixtures::Abstract.class_eval do
|
51
|
+
|
52
|
+
class TestErrorFilter < Merb::Test::Fixtures::Abstract::Testing
|
53
|
+
before :foo, :only => :index, :exclude => :show
|
54
|
+
end
|
55
|
+
end }.should raise_error(ArgumentError, /either :only or :exclude/)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should support filters that work only when a condition is met via :if" do
|
59
|
+
dispatch_should_make_body("TestConditionalFilterWithMethod", "foo filter", :index, :presets => {:bar= => true})
|
60
|
+
dispatch_should_make_body("TestConditionalFilterWithMethod", "", :index, :presets => {:bar= => false})
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should support filters that work only when a condition is met via :unless" do
|
64
|
+
dispatch_should_make_body("TestConditionalFilterWithProc", "foo filter", :index, :presets => {:bar= => 'baz'})
|
65
|
+
dispatch_should_make_body("TestConditionalFilterWithProc", "index action", :index, :presets => {:bar= => 'bar'})
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should throw an error if both :if and :unless are passed to a filter" do
|
69
|
+
running { Merb::Test::Fixtures::Abstract.class_eval do
|
70
|
+
|
71
|
+
class TestErrorFilter < Merb::Test::Fixtures::Abstract::Testing
|
72
|
+
before :foo, :if => :index, :unless => :show
|
73
|
+
end
|
74
|
+
end }.should raise_error(ArgumentError, /either :if or :unless/)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should throw an error" do
|
78
|
+
running { dispatch_should_make_body("TestConditionalFilterWithNoProcOrSymbol", "") }.should raise_error(ArgumentError, /a Symbol or a Proc/)
|
79
|
+
end
|
80
|
+
end
|