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.
- data/CHANGELOG +136 -2
- data/CONTRIBUTORS +6 -0
- data/PUBLIC_CHANGELOG +38 -0
- data/Rakefile +38 -30
- data/lib/merb-core.rb +88 -23
- data/lib/merb-core/bootloader.rb +235 -51
- data/lib/merb-core/config.rb +121 -36
- data/lib/merb-core/controller/abstract_controller.rb +59 -36
- data/lib/merb-core/controller/exceptions.rb +2 -15
- data/lib/merb-core/controller/merb_controller.rb +44 -1
- data/lib/merb-core/controller/mime.rb +4 -0
- data/lib/merb-core/controller/mixins/controller.rb +38 -21
- data/lib/merb-core/controller/mixins/render.rb +44 -29
- data/lib/merb-core/controller/mixins/responder.rb +3 -31
- data/lib/merb-core/controller/template.rb +45 -21
- data/lib/merb-core/core_ext/kernel.rb +60 -32
- data/lib/merb-core/dispatch/default_exception/default_exception.rb +2 -2
- data/lib/merb-core/dispatch/default_exception/views/_css.html.erb +3 -1
- data/lib/merb-core/dispatch/default_exception/views/_javascript.html.erb +71 -67
- data/lib/merb-core/dispatch/default_exception/views/index.html.erb +7 -3
- data/lib/merb-core/dispatch/dispatcher.rb +3 -3
- data/lib/merb-core/dispatch/request.rb +56 -9
- data/lib/merb-core/dispatch/router.rb +159 -133
- data/lib/merb-core/dispatch/router/behavior.rb +462 -703
- data/lib/merb-core/dispatch/router/cached_proc.rb +3 -3
- data/lib/merb-core/dispatch/router/resources.rb +289 -0
- data/lib/merb-core/dispatch/router/route.rb +514 -294
- data/lib/merb-core/dispatch/session.rb +4 -2
- data/lib/merb-core/logger.rb +213 -202
- data/lib/merb-core/plugins.rb +9 -1
- data/lib/merb-core/rack.rb +3 -1
- data/lib/merb-core/rack/adapter.rb +7 -4
- data/lib/merb-core/rack/adapter/abstract.rb +188 -0
- data/lib/merb-core/rack/adapter/ebb.rb +12 -13
- data/lib/merb-core/rack/adapter/evented_mongrel.rb +2 -15
- data/lib/merb-core/rack/adapter/irb.rb +3 -2
- data/lib/merb-core/rack/adapter/mongrel.rb +22 -15
- data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +4 -16
- data/lib/merb-core/rack/adapter/thin.rb +21 -22
- data/lib/merb-core/rack/adapter/thin_turbo.rb +4 -11
- data/lib/merb-core/rack/adapter/webrick.rb +54 -18
- data/lib/merb-core/rack/application.rb +4 -4
- data/lib/merb-core/rack/handler/mongrel.rb +12 -13
- data/lib/merb-core/rack/middleware/csrf.rb +1 -1
- data/lib/merb-core/rack/stream_wrapper.rb +41 -0
- data/lib/merb-core/server.rb +157 -90
- data/lib/merb-core/tasks/gem_management.rb +267 -0
- data/lib/merb-core/tasks/merb.rb +1 -0
- data/lib/merb-core/tasks/merb_rake_helper.rb +48 -34
- data/lib/merb-core/tasks/stats.rake +1 -1
- data/lib/merb-core/test.rb +9 -3
- data/lib/merb-core/test/helpers.rb +1 -0
- data/lib/merb-core/test/helpers/mock_request_helper.rb +393 -0
- data/lib/merb-core/test/helpers/multipart_request_helper.rb +3 -2
- data/lib/merb-core/test/helpers/request_helper.rb +40 -372
- data/lib/merb-core/test/helpers/route_helper.rb +16 -2
- data/lib/merb-core/test/matchers.rb +1 -0
- data/lib/merb-core/test/matchers/controller_matchers.rb +4 -247
- data/lib/merb-core/test/matchers/request_matchers.rb +140 -0
- data/lib/merb-core/test/matchers/view_matchers.rb +22 -4
- data/lib/merb-core/test/run_specs.rb +118 -26
- data/lib/merb-core/test/test_ext/rspec.rb +181 -0
- data/lib/merb-core/version.rb +1 -9
- metadata +10 -342
- data/docs/bootloading.dox +0 -58
- data/docs/documentation_standards +0 -40
- data/docs/merb-core-call-stack-diagram.mmap +0 -0
- data/docs/merb-core-call-stack-diagram.pdf +0 -0
- data/docs/merb-core-call-stack-diagram.png +0 -0
- data/docs/new_render_api +0 -51
- data/lib/merb-core/vendor/facets.rb +0 -2
- data/lib/merb-core/vendor/facets/dictionary.rb +0 -433
- data/lib/merb-core/vendor/facets/inflect.rb +0 -342
- data/spec/private/config/adapter_spec.rb +0 -32
- data/spec/private/config/config_spec.rb +0 -202
- data/spec/private/config/environment_spec.rb +0 -13
- data/spec/private/config/merb_spec.rb +0 -34
- data/spec/private/config/spec_helper.rb +0 -1
- data/spec/private/core_ext/kernel_spec.rb +0 -159
- data/spec/private/dispatch/bootloader_spec.rb +0 -24
- data/spec/private/dispatch/fixture/app/controllers/application.rb +0 -4
- data/spec/private/dispatch/fixture/app/controllers/exceptions.rb +0 -25
- data/spec/private/dispatch/fixture/app/controllers/foo.rb +0 -19
- data/spec/private/dispatch/fixture/app/helpers/global_helpers.rb +0 -8
- data/spec/private/dispatch/fixture/app/views/exeptions/client_error.html.erb +0 -37
- data/spec/private/dispatch/fixture/app/views/exeptions/internal_server_error.html.erb +0 -216
- data/spec/private/dispatch/fixture/app/views/exeptions/not_acceptable.html.erb +0 -38
- data/spec/private/dispatch/fixture/app/views/exeptions/not_found.html.erb +0 -40
- data/spec/private/dispatch/fixture/app/views/foo/bar.html.erb +0 -0
- data/spec/private/dispatch/fixture/app/views/layout/application.html.erb +0 -11
- data/spec/private/dispatch/fixture/config/black_hole.rb +0 -12
- data/spec/private/dispatch/fixture/config/environments/development.rb +0 -6
- data/spec/private/dispatch/fixture/config/environments/production.rb +0 -5
- data/spec/private/dispatch/fixture/config/environments/test.rb +0 -6
- data/spec/private/dispatch/fixture/config/init.rb +0 -45
- data/spec/private/dispatch/fixture/config/rack.rb +0 -11
- data/spec/private/dispatch/fixture/config/router.rb +0 -35
- data/spec/private/dispatch/fixture/log/merb_test.log +0 -8839
- data/spec/private/dispatch/fixture/public/images/merb.jpg +0 -0
- data/spec/private/dispatch/fixture/public/merb.fcgi +0 -4
- data/spec/private/dispatch/fixture/public/stylesheets/master.css +0 -119
- data/spec/private/dispatch/route_params_spec.rb +0 -23
- data/spec/private/dispatch/spec_helper.rb +0 -1
- data/spec/private/router/behavior_spec.rb +0 -60
- data/spec/private/router/fixture/log/merb_test.log +0 -35
- data/spec/private/router/route_spec.rb +0 -418
- data/spec/private/router/router_spec.rb +0 -183
- data/spec/private/vendor/facets/plural_spec.rb +0 -564
- data/spec/private/vendor/facets/singular_spec.rb +0 -489
- data/spec/public/DEFINITIONS +0 -11
- data/spec/public/abstract_controller/controllers/alt_views/layout/application.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_string_controller_layout.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_template_controller_layout.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/show.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/partial/basic_partial_with_multiple_roots/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_and_custom_location/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_inherited/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/cousins.rb +0 -41
- data/spec/public/abstract_controller/controllers/display.rb +0 -60
- data/spec/public/abstract_controller/controllers/filters.rb +0 -260
- data/spec/public/abstract_controller/controllers/helpers.rb +0 -41
- data/spec/public/abstract_controller/controllers/partial.rb +0 -121
- data/spec/public/abstract_controller/controllers/render.rb +0 -113
- data/spec/public/abstract_controller/controllers/views/helpers/capture/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/helpers/capture_eq/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/helpers/capture_with_args/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/helpers/concat/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/layout/alt.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/layout/custom.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object_with_action/new.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template/index.erb +0 -1
- 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 +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/show.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_two_throw_contents/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/another_directory/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial_with_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_first.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_second.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_in_another_directory/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/_variables.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/_both.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/_with_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/_with_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/_with_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/test_display/foo.html.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/test_render/foo.html.erb +0 -0
- data/spec/public/abstract_controller/controllers/views/wonderful/index.erb +0 -1
- data/spec/public/abstract_controller/display_spec.rb +0 -37
- data/spec/public/abstract_controller/filter_spec.rb +0 -136
- data/spec/public/abstract_controller/helper_spec.rb +0 -21
- data/spec/public/abstract_controller/partial_spec.rb +0 -61
- data/spec/public/abstract_controller/render_spec.rb +0 -90
- data/spec/public/abstract_controller/spec_helper.rb +0 -31
- data/spec/public/boot_loader/boot_loader_spec.rb +0 -33
- data/spec/public/boot_loader/spec_helper.rb +0 -1
- data/spec/public/controller/authentication_spec.rb +0 -174
- data/spec/public/controller/base_spec.rb +0 -88
- data/spec/public/controller/conditional_get_spec.rb +0 -100
- data/spec/public/controller/config/init.rb +0 -6
- data/spec/public/controller/controllers/authentication.rb +0 -74
- data/spec/public/controller/controllers/base.rb +0 -65
- data/spec/public/controller/controllers/conditional_get.rb +0 -35
- data/spec/public/controller/controllers/cookies.rb +0 -36
- data/spec/public/controller/controllers/dispatcher.rb +0 -35
- data/spec/public/controller/controllers/display.rb +0 -118
- data/spec/public/controller/controllers/redirect.rb +0 -36
- data/spec/public/controller/controllers/responder.rb +0 -93
- data/spec/public/controller/controllers/url.rb +0 -7
- data/spec/public/controller/controllers/views/layout/custom.html.erb +0 -1
- data/spec/public/controller/controllers/views/layout/custom_arg.html.erb +0 -1
- data/spec/public/controller/controllers/views/layout/custom_arg.json.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.xml.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.xml.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/no_layout.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template_argument/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/html_default/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/layout/custom.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.xml.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.js.erb +0 -1
- data/spec/public/controller/cookies_spec.rb +0 -95
- data/spec/public/controller/dispatcher_spec.rb +0 -410
- data/spec/public/controller/display_spec.rb +0 -84
- data/spec/public/controller/redirect_spec.rb +0 -33
- data/spec/public/controller/responder_spec.rb +0 -169
- data/spec/public/controller/spec_helper.rb +0 -13
- data/spec/public/controller/url_spec.rb +0 -255
- data/spec/public/core/merb_core_spec.rb +0 -45
- data/spec/public/core_ext/fixtures/core_ext_dependency.rb +0 -2
- data/spec/public/core_ext/kernel_spec.rb +0 -88
- data/spec/public/core_ext/spec_helper.rb +0 -1
- data/spec/public/directory_structure/directory/app/controllers/application.rb +0 -3
- data/spec/public/directory_structure/directory/app/controllers/base.rb +0 -13
- data/spec/public/directory_structure/directory/app/controllers/custom.rb +0 -19
- data/spec/public/directory_structure/directory/app/views/base/template.html.erb +0 -1
- data/spec/public/directory_structure/directory/app/views/wonderful/template.erb +0 -1
- data/spec/public/directory_structure/directory/config/router.rb +0 -3
- data/spec/public/directory_structure/directory/log/merb_test.log +0 -4588
- data/spec/public/directory_structure/directory_spec.rb +0 -43
- data/spec/public/logger/logger_spec.rb +0 -181
- data/spec/public/logger/spec_helper.rb +0 -1
- data/spec/public/rack/conditinal_get_middleware_spec.rb +0 -127
- data/spec/public/rack/csrf_middleware_spec.rb +0 -70
- data/spec/public/rack/rack_middleware_spec.rb +0 -99
- data/spec/public/rack/shared_example_groups.rb +0 -35
- data/spec/public/reloading/directory/app/controllers/application.rb +0 -3
- data/spec/public/reloading/directory/app/controllers/reload.rb +0 -6
- data/spec/public/reloading/directory/config/init.rb +0 -2
- data/spec/public/reloading/directory/log/merb_test.log +0 -288231
- data/spec/public/reloading/reload_spec.rb +0 -103
- data/spec/public/request/multipart_spec.rb +0 -41
- data/spec/public/request/request_spec.rb +0 -250
- data/spec/public/router/default_spec.rb +0 -21
- data/spec/public/router/deferred_spec.rb +0 -22
- data/spec/public/router/fixation_spec.rb +0 -49
- data/spec/public/router/fixture/log/merb_test.log +0 -524
- data/spec/public/router/namespace_spec.rb +0 -113
- data/spec/public/router/nested_matches_spec.rb +0 -97
- data/spec/public/router/nested_resources_spec.rb +0 -41
- data/spec/public/router/resource_spec.rb +0 -37
- data/spec/public/router/resources_spec.rb +0 -82
- data/spec/public/router/spec_helper.rb +0 -90
- data/spec/public/router/special_spec.rb +0 -61
- data/spec/public/router/string_spec.rb +0 -61
- data/spec/public/session/controllers/sessions.rb +0 -56
- data/spec/public/session/cookie_session_spec.rb +0 -73
- data/spec/public/session/memcached_session_spec.rb +0 -31
- data/spec/public/session/memory_session_spec.rb +0 -28
- data/spec/public/session/multiple_sessions_spec.rb +0 -74
- data/spec/public/session/no_session_spec.rb +0 -12
- data/spec/public/session/session_spec.rb +0 -106
- data/spec/public/template/template_spec.rb +0 -104
- data/spec/public/template/templates/error.html.erb +0 -2
- data/spec/public/template/templates/template.html.erb +0 -1
- data/spec/public/template/templates/template.html.myt +0 -1
- data/spec/public/test/controller_matchers_spec.rb +0 -412
- data/spec/public/test/controllers/controller_assertion_mock.rb +0 -7
- data/spec/public/test/controllers/dispatch_controller.rb +0 -11
- data/spec/public/test/controllers/spec_helper_controller.rb +0 -39
- data/spec/public/test/multipart_request_helper_spec.rb +0 -159
- data/spec/public/test/multipart_upload_text_file.txt +0 -1
- data/spec/public/test/request_helper_spec.rb +0 -269
- data/spec/public/test/route_helper_spec.rb +0 -78
- data/spec/public/test/route_matchers_spec.rb +0 -166
- data/spec/public/test/view_helper_spec.rb +0 -96
- data/spec/public/test/view_matchers_spec.rb +0 -183
- data/spec/spec_helper.rb +0 -121
@@ -1,21 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
|
-
|
3
|
-
describe Merb::AbstractController, " with capture and concat" do
|
4
|
-
|
5
|
-
it "should support capture" do
|
6
|
-
dispatch_should_make_body("Capture", "Capture")
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should support capture with arguments" do
|
10
|
-
dispatch_should_make_body("CaptureWithArgs", "Capture: one, two")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should support basic helpers that use capture with <%=" do
|
14
|
-
dispatch_should_make_body("CaptureEq", "Pre. Beginning... Capturing... Done. Post.")
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should support concat" do
|
18
|
-
dispatch_should_make_body("Concat", "Concat")
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
|
-
|
3
|
-
describe Merb::AbstractController, " Partials" do
|
4
|
-
|
5
|
-
it "should work with no options" do
|
6
|
-
dispatch_should_make_body("BasicPartial", "Index Partial")
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should work with :with" do
|
10
|
-
dispatch_should_make_body("WithPartial", "Partial with With")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should work with nil :with" do
|
14
|
-
dispatch_should_make_body("WithNilPartial", "Partial with nil local")
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should work with :with and :as" do
|
18
|
-
dispatch_should_make_body("WithAsPartial", "Partial with With and As")
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should work with collections" do
|
22
|
-
dispatch_should_make_body("PartialWithCollections", "Partial with collection")
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should work with collections and :as" do
|
26
|
-
dispatch_should_make_body("PartialWithCollectionsAndAs", "Partial with collection")
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should work with key/value pairs of locals" do
|
30
|
-
dispatch_should_make_body("PartialWithLocals", "Partial with local variables")
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should work with both collections and locals" do
|
34
|
-
dispatch_should_make_body("PartialWithBoth", "Partial with c-o-l-l-e-c-t-i-o-n-")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should work with both :with/:as and regular locals" do
|
38
|
-
dispatch_should_make_body("PartialWithWithAndLocals", "Partial with with and locals")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should work with a partial in another directory" do
|
42
|
-
dispatch_should_make_body("PartialInAnotherDirectory", "Index Partial in another directory")
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should work with nested partials with locals" do
|
46
|
-
dispatch_should_make_body("NestedPartial", "first second first")
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should work with multiple template roots" do
|
50
|
-
dispatch_should_make_body("BasicPartialWithMultipleRoots", "Base Index: Alt Partial")
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should be able to count collections" do
|
54
|
-
dispatch_should_make_body("PartialWithCollectionsAndCounter", "Partial counting: 0/5 1/5 2/5 3/5 4/5 ")
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should render a partial using an absolute path" do
|
58
|
-
dispatch_should_make_body("WithAbsolutePartial", "Index Absolute Partial")
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
|
-
|
3
|
-
describe Merb::AbstractController, " rendering plain strings" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
Merb.push_path(:layout, File.dirname(__FILE__) / "controllers" / "views" / "layouts")
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should render two thrown_contents into same object" do
|
10
|
-
dispatch_should_make_body("RenderTwoThrowContents", "FooBar")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should support rendering plain strings with no layout" do
|
14
|
-
dispatch_should_make_body("RenderString", "the index")
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should support rendering plain strings with custom layouts" do
|
18
|
-
dispatch_should_make_body("RenderStringCustomLayout", "Custom: the index")
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should support rendering plain strings with the application layout" do
|
22
|
-
dispatch_should_make_body("RenderStringAppLayout", "App: the index")
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should support rendering plain strings with the controller layout" do
|
26
|
-
dispatch_should_make_body("RenderStringControllerLayout", "Controller: the index")
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should support rendering plain strings with dynamic layouts" do
|
30
|
-
dispatch_should_make_body("RenderStringDynamicLayout", "Custom: the index", :index)
|
31
|
-
dispatch_should_make_body("RenderStringDynamicLayout", "Alt: the alt index", :alt_index)
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
describe Merb::AbstractController, " rendering templates" do
|
37
|
-
|
38
|
-
it "should support rendering templates with no layout" do
|
39
|
-
dispatch_should_make_body("RenderTemplate", "the index")
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should support rendering templates with custom layouts" do
|
43
|
-
dispatch_should_make_body("RenderStringCustomLayout", "Custom: the index")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should support rendering templates with the application layout" do
|
47
|
-
dispatch_should_make_body("RenderTemplateAppLayout", "App: the index")
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should support rendering plain strings with the controller layout" do
|
51
|
-
dispatch_should_make_body("RenderTemplateControllerLayout", "Controller: the index")
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should support rendering templates without any layout (even if the default layout exists)" do
|
55
|
-
dispatch_should_make_body("RenderNoDefaultAppLayout", "the index")
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should inherit the layout setting from a parent controller class" do
|
59
|
-
dispatch_should_make_body("RenderNoDefaultAppLayoutInherited", "the index")
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should support reverting to the default layout" do
|
63
|
-
dispatch_should_make_body("RenderDefaultAppLayoutInheritedOverride", "App: the index")
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should support rendering templates with a custom location" do
|
67
|
-
dispatch_should_make_body("RenderTemplateCustomLocation", "Wonderful")
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should support rendering templates from an absolute path location" do
|
71
|
-
dispatch_should_make_body("RenderTemplateAbsolutePath", "Wonderful")
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should support rendering templates with multiple roots" do
|
75
|
-
dispatch_should_make_body("RenderTemplateMultipleRoots", "App: Multiple")
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should support rendering templates with multiple roots, first root" do
|
79
|
-
dispatch_should_make_body("RenderTemplateMultipleRoots", "default show", "show")
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should support rendering templates with multiple roots and custom location" do
|
83
|
-
dispatch_should_make_body("RenderTemplateMultipleRootsAndCustomLocation", "Woot.")
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should support rendering templates with multiple roots and custom location from an inherited controller" do
|
87
|
-
dispatch_should_make_body("RenderTemplateMultipleRootsInherited", "Good.")
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
__DIR__ = File.dirname(__FILE__)
|
2
|
-
require File.join(__DIR__, "..", "..", "spec_helper")
|
3
|
-
|
4
|
-
require File.join(__DIR__, "controllers", "filters")
|
5
|
-
require File.join(__DIR__, "controllers", "cousins")
|
6
|
-
require File.join(__DIR__, "controllers", "render")
|
7
|
-
require File.join(__DIR__, "controllers", "partial")
|
8
|
-
require File.join(__DIR__, "controllers", "display")
|
9
|
-
require File.join(__DIR__, "controllers", "helpers")
|
10
|
-
|
11
|
-
Merb.start :environment => 'test'
|
12
|
-
|
13
|
-
module Merb::Test::Behaviors
|
14
|
-
include Merb::Test::RequestHelper
|
15
|
-
|
16
|
-
def dispatch_should_make_body(klass, body, action = :index, opts = {}, env = {}, &blk)
|
17
|
-
klass = Merb::Test::Fixtures::Abstract.const_get(klass)
|
18
|
-
if opts.key?(:presets)
|
19
|
-
controller = klass.new
|
20
|
-
opts[:presets].each { |attr, value| controller.send(attr, value)}
|
21
|
-
controller._dispatch(action.to_s)
|
22
|
-
else
|
23
|
-
controller = dispatch_to(klass, action, opts, env, &blk)
|
24
|
-
end
|
25
|
-
controller.body.should == body
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
Spec::Runner.configure do |config|
|
30
|
-
config.include Merb::Test::Behaviors
|
31
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# The before/after filters in BootLoaders are considered public API.
|
2
|
-
#
|
3
|
-
# However, Merb::BootLoader.subclasses is not considered public API and should not be used in plugins.
|
4
|
-
|
5
|
-
require File.join(File.dirname(__FILE__), "spec_helper")
|
6
|
-
|
7
|
-
class Merb::BootLoader::AfterTest < Merb::BootLoader
|
8
|
-
after Merb::BootLoader::BeforeAppLoads
|
9
|
-
|
10
|
-
def self.run
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class Merb::BootLoader::BeforeTest < Merb::BootLoader
|
15
|
-
before Merb::BootLoader::Templates
|
16
|
-
|
17
|
-
def self.run
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "The BootLoader" do
|
22
|
-
|
23
|
-
it "should support adding a BootLoader after another" do
|
24
|
-
idx = Merb::BootLoader.subclasses.index("Merb::BootLoader::BeforeAppLoads")
|
25
|
-
Merb::BootLoader.subclasses.index("Merb::BootLoader::AfterTest").should == idx + 1
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should support adding a BootLoader before another" do
|
29
|
-
idx = Merb::BootLoader.subclasses.index("Merb::BootLoader::Templates")
|
30
|
-
Merb::BootLoader.subclasses.index("Merb::BootLoader::BeforeTest").should == idx - 1
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
|
@@ -1,174 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
|
-
|
3
|
-
describe "basic_authentication in general", :shared => true do
|
4
|
-
|
5
|
-
it "should halt the filter chain and return a 401 status code if no authentication is sent" do
|
6
|
-
response = dispatch_to(Merb::Test::Fixtures::Controllers::BasicAuthentication, :index)
|
7
|
-
response.body.should == "HTTP Basic: Access denied.\n"
|
8
|
-
response.status.should == 401
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should halt the filter chain and return a 401 status code on invalid username and password" do
|
12
|
-
u, p = "John", "password"
|
13
|
-
response = dispatch_with_basic_authentication_to(Merb::Test::Fixtures::Controllers::BasicAuthentication, :index, u, p)
|
14
|
-
response.body.should == "HTTP Basic: Access denied.\n"
|
15
|
-
response.status.should == 401
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should halt the filter chain and return a 401 status code on invalid username and valid password" do
|
19
|
-
u, p = "John", "secret"
|
20
|
-
response = dispatch_with_basic_authentication_to(Merb::Test::Fixtures::Controllers::BasicAuthentication, :index, u, p)
|
21
|
-
response.body.should == "HTTP Basic: Access denied.\n"
|
22
|
-
response.status.should == 401
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should halt the filter chain and return a 401 status code on valid username and invalid password" do
|
26
|
-
u, p = "Fred", "password"
|
27
|
-
response = dispatch_with_basic_authentication_to(Merb::Test::Fixtures::Controllers::BasicAuthentication, :index, u, p)
|
28
|
-
response.body.should == "HTTP Basic: Access denied.\n"
|
29
|
-
response.status.should == 401
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should call the action on valid username and password" do
|
33
|
-
u, p = "Fred", "secret"
|
34
|
-
response = dispatch_with_basic_authentication_to(Merb::Test::Fixtures::Controllers::BasicAuthentication, :index, u, p)
|
35
|
-
response.body.should == "authenticated"
|
36
|
-
response.status.should == 200
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
describe Merb::Controller do
|
42
|
-
MTFC = Merb::Test::Fixtures::Controllers
|
43
|
-
|
44
|
-
describe "#basic_authentication with no realm" do
|
45
|
-
it_should_behave_like "basic_authentication in general"
|
46
|
-
|
47
|
-
it "should have a default WWW-Authenticate realm of 'Application' if no authentication is sent" do
|
48
|
-
response = dispatch_to(MTFC::BasicAuthentication, :index)
|
49
|
-
response.headers['WWW-Authenticate'] = 'Basic realm="Application"'
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should have a default WWW-Authenticate realm of 'Application' if incorrect authentication is sent" do
|
53
|
-
u, p = "John", "password"
|
54
|
-
response = dispatch_with_basic_authentication_to(MTFC::BasicAuthentication, :index, u, p)
|
55
|
-
response.headers['WWW-Authenticate'] = 'Basic realm="Application"'
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#basic_authentication with realm" do
|
60
|
-
|
61
|
-
it_should_behave_like "basic_authentication in general"
|
62
|
-
|
63
|
-
it "should set the WWW-Authenticate realm if no authentication is sent" do
|
64
|
-
response = dispatch_to(MTFC::BasicAuthenticationWithRealm, :index)
|
65
|
-
response.headers['WWW-Authenticate'] = 'Basic realm="My SuperApp"'
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should set the WWW-Authenticate realm if incorrect authentication is sent" do
|
69
|
-
u, p = "John", "password"
|
70
|
-
response = dispatch_with_basic_authentication_to(MTFC::BasicAuthenticationWithRealm, :index, u, p)
|
71
|
-
response.headers['WWW-Authenticate'] = 'Basic realm="My SuperApp"'
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
describe "#basic_authentication.authenticate" do
|
77
|
-
|
78
|
-
it "should pass in the username and password and return the result of the block" do
|
79
|
-
u, p = "Fred", "secret"
|
80
|
-
response = dispatch_with_basic_authentication_to(MTFC::AuthenticateBasicAuthentication, :index, u, p)
|
81
|
-
response.body.should == "Fred:secret"
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "#basic_authentication.request" do
|
87
|
-
|
88
|
-
it "should halt the filter chain and return a 401 status code" do
|
89
|
-
response = dispatch_to(MTFC::RequestBasicAuthentication, :index)
|
90
|
-
response.body.should == "HTTP Basic: Access denied.\n"
|
91
|
-
response.status.should == 401
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should have a default WWW-Authenticate realm of 'Application'" do
|
95
|
-
response = dispatch_to(MTFC::RequestBasicAuthentication, :index)
|
96
|
-
response.headers['WWW-Authenticate'].should == 'Basic realm="Application"'
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should set the WWW-Authenticate realm" do
|
100
|
-
response = dispatch_to(MTFC::RequestBasicAuthenticationWithRealm, :index)
|
101
|
-
response.headers['WWW-Authenticate'].should == 'Basic realm="My SuperApp"'
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "#basic_authentication.request!" do
|
107
|
-
|
108
|
-
it "should not halt the filter chain and provide a 401 status code" do
|
109
|
-
response = dispatch_to(MTFC::PassiveBasicAuthentication, :index)
|
110
|
-
response.status = 401
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should have a default WWW=Authentication realm of 'Application'" do
|
114
|
-
response = dispatch_to(MTFC::PassiveBasicAuthentication, :index)
|
115
|
-
response.headers['WWW-Authenticate'].should == 'Basic realm="Application"'
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should set the WWW-Authenticate realm" do
|
119
|
-
response = dispatch_to(MTFC::PassiveBasicAuthenticationWithRealm, :index)
|
120
|
-
response.headers['WWW-Authenticate'].should == 'Basic realm="My Super App"'
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should allow the action to render it's output" do
|
124
|
-
response = dispatch_to(MTFC::PassiveBasicAuthentication, :index)
|
125
|
-
response.body.should == "My Output"
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should be callable from within an action" do
|
129
|
-
response = dispatch_to(MTFC::PassiveBasicAuthenticationInAction, :index)
|
130
|
-
response.body.should == "In Action"
|
131
|
-
response.status.should == 401
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
135
|
-
|
136
|
-
describe "basic_authentication.provided?" do
|
137
|
-
|
138
|
-
it "should return true when basic authentication credentials have been supplied" do
|
139
|
-
u, p = "Fred", "secret"
|
140
|
-
response = dispatch_with_basic_authentication_to(MTFC::PassiveBasicAuthentication, :index, u, p)
|
141
|
-
response.basic_authentication.provided?.should be_true
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should return false when basic authentication credentials have not been supplied" do
|
145
|
-
response = dispatch_to(MTFC::PassiveBasicAuthentication, :index)
|
146
|
-
response.basic_authentication.provided?.should be_false
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
describe "basic_authentication.username and password" do
|
151
|
-
it "return username if set" do
|
152
|
-
u, p = "Fred", "secret"
|
153
|
-
response = dispatch_with_basic_authentication_to(MTFC::PassiveBasicAuthentication, :index, u, p)
|
154
|
-
response.basic_authentication.username.should == "Fred"
|
155
|
-
end
|
156
|
-
|
157
|
-
it "should return nil if the username is not set" do
|
158
|
-
response = dispatch_to(MTFC::PassiveBasicAuthentication, :index)
|
159
|
-
response.basic_authentication.username.should be_nil
|
160
|
-
end
|
161
|
-
|
162
|
-
it "should return password if set" do
|
163
|
-
u, p = "Fred", "secret"
|
164
|
-
response = dispatch_with_basic_authentication_to(MTFC::PassiveBasicAuthentication, :index, u, p)
|
165
|
-
response.basic_authentication.password.should == "secret"
|
166
|
-
end
|
167
|
-
|
168
|
-
it "shoudl return nil for the password if not set" do
|
169
|
-
response = dispatch_to(MTFC::PassiveBasicAuthentication, :index)
|
170
|
-
response.basic_authentication.password.should be_nil
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
|
-
Controllers = Merb::Test::Fixtures::Controllers
|
3
|
-
|
4
|
-
describe Merb::Controller, "callable actions" do
|
5
|
-
|
6
|
-
before do
|
7
|
-
Merb.push_path(:layout, File.dirname(__FILE__) / "controllers" / "views" / "layouts")
|
8
|
-
Merb::Router.prepare do |r|
|
9
|
-
r.default_routes
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
it "has no any callable actions by default" do
|
14
|
-
Merb::Controller.callable_actions.should be_empty
|
15
|
-
end
|
16
|
-
|
17
|
-
it "sets body on dispatch to callable action" do
|
18
|
-
controller = dispatch_to(Merb::Test::Fixtures::Controllers::Base, :index)
|
19
|
-
controller.body.should == "index"
|
20
|
-
end
|
21
|
-
|
22
|
-
it "sets status on dispatch to callable action" do
|
23
|
-
controller = dispatch_to(Merb::Test::Fixtures::Controllers::Base, :index)
|
24
|
-
controller.status.should == 200
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should not dispatch to hidden actions" do
|
28
|
-
calling { dispatch_to(Merb::Test::Fixtures::Controllers::Base, :hidden) }.
|
29
|
-
should raise_error(Merb::ControllerExceptions::ActionNotFound)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should dispatch to included methods with show_action called" do
|
33
|
-
dispatch_to(Merb::Test::Fixtures::Controllers::Base, :baz).body.should == "baz"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should not dispatch to included methods with show_action not called" do
|
37
|
-
calling { dispatch_to(Merb::Test::Fixtures::Controllers::Base, :bat) }.
|
38
|
-
should raise_error(Merb::ControllerExceptions::ActionNotFound)
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
describe Merb::Controller, "filtered params" do
|
44
|
-
it "removes filtered parameters from the log" do
|
45
|
-
out = with_level(:info) do
|
46
|
-
dispatch_to(Controllers::FilteredParams, :index, :username => "Awesome", :password => "sekrit")
|
47
|
-
end
|
48
|
-
out.should include_log(/Params:.*"username"\s*=>\s*"Awesome"/)
|
49
|
-
out.should_not include_log(/"password"/)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "doesn't put the parameters in the log in levels higher than info" do
|
53
|
-
out = with_level(:warn) do
|
54
|
-
dispatch_to(Controllers::FilteredParams, :index, :username => "Awesome", :password => "sekrit")
|
55
|
-
end
|
56
|
-
out.should_not include_log(/Params/)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe Merb::Controller, "records benchmarks" do
|
61
|
-
it "collects benchmarks for the amount of time the action took" do
|
62
|
-
controller = dispatch_to(Controllers::Base, :index)
|
63
|
-
controller._benchmarks[:action_time].should be_kind_of(Numeric)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe Merb::Controller, "handles invalid actions" do
|
68
|
-
it "raises if an action was not found" do
|
69
|
-
calling { controller = dispatch_to(Controllers::Base, :awesome) }.
|
70
|
-
should raise_error(Merb::ControllerExceptions::ActionNotFound,
|
71
|
-
/Action.*awesome.*was not found in.*Base/)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe Merb::Controller, "handles invalid status codes" do
|
76
|
-
it "raises if an invalid status is set" do
|
77
|
-
calling { dispatch_to(Controllers::SetStatus, :index) }.
|
78
|
-
should raise_error(ArgumentError, /was.*String/)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe Merb::Controller, "before/after dispatch callbacks" do
|
83
|
-
it "are used for internal purposes" do
|
84
|
-
controller = dispatch_to(Controllers::DispatchCallbacks, :index)
|
85
|
-
controller.called_before.should be_true
|
86
|
-
controller.called_after.should be_true
|
87
|
-
end
|
88
|
-
end
|