merb-core 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README +3 -3
- data/Rakefile +144 -33
- data/bin/merb +0 -0
- data/bin/merb-specs +0 -0
- data/docs/bootloading.dox +1 -0
- 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/lib/merb-core.rb +159 -37
- data/lib/merb-core/autoload.rb +1 -0
- data/lib/merb-core/bootloader.rb +208 -92
- data/lib/merb-core/config.rb +20 -6
- data/lib/merb-core/controller/abstract_controller.rb +113 -61
- data/lib/merb-core/controller/exceptions.rb +28 -13
- data/lib/merb-core/controller/merb_controller.rb +73 -44
- data/lib/merb-core/controller/mime.rb +25 -7
- data/lib/merb-core/controller/mixins/authentication.rb +1 -1
- data/lib/merb-core/controller/mixins/controller.rb +44 -8
- data/lib/merb-core/controller/mixins/render.rb +191 -128
- data/lib/merb-core/controller/mixins/responder.rb +65 -63
- data/lib/merb-core/controller/template.rb +103 -54
- data/lib/merb-core/core_ext.rb +7 -12
- data/lib/merb-core/core_ext/kernel.rb +128 -136
- data/lib/merb-core/dispatch/cookies.rb +26 -4
- data/lib/merb-core/dispatch/default_exception/default_exception.rb +93 -0
- data/lib/merb-core/dispatch/default_exception/views/_css.html.erb +198 -0
- data/lib/merb-core/dispatch/default_exception/views/_javascript.html.erb +73 -0
- data/lib/merb-core/dispatch/default_exception/views/index.html.erb +92 -0
- data/lib/merb-core/dispatch/dispatcher.rb +156 -224
- data/lib/merb-core/dispatch/request.rb +126 -25
- data/lib/merb-core/dispatch/router.rb +61 -6
- data/lib/merb-core/dispatch/router/behavior.rb +122 -41
- data/lib/merb-core/dispatch/router/route.rb +147 -22
- data/lib/merb-core/dispatch/session.rb +52 -2
- data/lib/merb-core/dispatch/session/cookie.rb +4 -2
- data/lib/merb-core/dispatch/session/memcached.rb +38 -27
- data/lib/merb-core/dispatch/session/memory.rb +18 -11
- data/lib/merb-core/dispatch/worker.rb +28 -0
- data/lib/merb-core/gem_ext/erubis.rb +58 -0
- data/lib/merb-core/logger.rb +3 -31
- data/lib/merb-core/plugins.rb +25 -3
- data/lib/merb-core/rack.rb +18 -12
- data/lib/merb-core/rack/adapter.rb +10 -8
- data/lib/merb-core/rack/adapter/ebb.rb +2 -2
- data/lib/merb-core/rack/adapter/irb.rb +31 -21
- data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +26 -0
- data/lib/merb-core/rack/adapter/thin.rb +19 -9
- data/lib/merb-core/rack/adapter/thin_turbo.rb +24 -0
- data/lib/merb-core/rack/application.rb +9 -84
- data/lib/merb-core/rack/middleware.rb +26 -0
- data/lib/merb-core/rack/middleware/path_prefix.rb +31 -0
- data/lib/merb-core/rack/middleware/profiler.rb +19 -0
- data/lib/merb-core/rack/middleware/static.rb +45 -0
- data/lib/merb-core/server.rb +27 -9
- data/lib/merb-core/tasks/audit.rake +68 -0
- data/lib/merb-core/tasks/merb.rb +1 -0
- data/lib/merb-core/tasks/merb_rake_helper.rb +12 -0
- data/lib/merb-core/tasks/stats.rake +71 -0
- data/lib/merb-core/test.rb +2 -1
- data/lib/merb-core/test/helpers/multipart_request_helper.rb +3 -3
- data/lib/merb-core/test/helpers/request_helper.rb +66 -24
- data/lib/merb-core/test/matchers/controller_matchers.rb +36 -4
- data/lib/merb-core/test/matchers/route_matchers.rb +12 -3
- data/lib/merb-core/test/matchers/view_matchers.rb +3 -3
- data/lib/merb-core/test/run_specs.rb +1 -0
- data/lib/merb-core/test/tasks/spectasks.rb +13 -5
- data/lib/merb-core/test/test_ext/string.rb +14 -0
- data/lib/merb-core/vendor/facets/dictionary.rb +3 -3
- data/lib/merb-core/vendor/facets/inflect.rb +82 -37
- data/lib/merb-core/version.rb +2 -2
- data/spec/private/config/config_spec.rb +39 -4
- data/spec/private/core_ext/kernel_spec.rb +3 -14
- data/spec/private/dispatch/bootloader_spec.rb +1 -1
- data/spec/private/dispatch/cookies_spec.rb +181 -69
- data/spec/private/dispatch/fixture/app/controllers/exceptions.rb +0 -2
- data/spec/private/dispatch/fixture/app/controllers/foo.rb +0 -2
- data/spec/private/dispatch/fixture/config/rack.rb +10 -0
- data/spec/private/dispatch/fixture/log/merb_test.log +7054 -1802
- data/spec/private/dispatch/route_params_spec.rb +2 -3
- data/spec/private/dispatch/session_mixin_spec.rb +47 -0
- data/spec/private/plugins/plugin_spec.rb +73 -59
- data/spec/private/router/behavior_spec.rb +60 -0
- data/spec/private/router/fixture/log/merb_test.log +1693 -0
- data/spec/private/router/route_spec.rb +414 -0
- data/spec/private/router/router_spec.rb +175 -0
- data/spec/private/vendor/facets/plural_spec.rb +564 -0
- data/spec/private/vendor/facets/singular_spec.rb +489 -0
- data/spec/public/abstract_controller/controllers/cousins.rb +41 -0
- data/spec/public/abstract_controller/controllers/helpers.rb +12 -2
- data/spec/public/abstract_controller/controllers/partial.rb +17 -2
- data/spec/public/abstract_controller/controllers/render.rb +16 -1
- data/spec/public/abstract_controller/controllers/views/helpers/capture_eq/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/helpers/capture_with_args/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_two_throw_contents/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/_collection.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/index.erb +1 -0
- data/spec/public/abstract_controller/filter_spec.rb +20 -1
- data/spec/public/abstract_controller/helper_spec.rb +10 -2
- data/spec/public/abstract_controller/partial_spec.rb +8 -0
- data/spec/public/abstract_controller/render_spec.rb +8 -0
- data/spec/public/abstract_controller/spec_helper.rb +7 -3
- data/spec/public/boot_loader/boot_loader_spec.rb +2 -2
- data/spec/public/controller/base_spec.rb +10 -2
- data/spec/public/controller/config/init.rb +6 -0
- data/spec/public/controller/controllers/authentication.rb +9 -11
- data/spec/public/controller/controllers/base.rb +2 -8
- data/spec/public/controller/controllers/cookies.rb +16 -0
- data/spec/public/controller/controllers/dispatcher.rb +35 -0
- data/spec/public/controller/controllers/display.rb +62 -14
- data/spec/public/controller/controllers/redirect.rb +36 -0
- data/spec/public/controller/controllers/responder.rb +37 -11
- data/spec/public/controller/controllers/views/layout/custom_arg.json.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.xml.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/no_layout.html.erb +1 -0
- data/spec/public/controller/cookies_spec.rb +23 -0
- data/spec/public/controller/dispatcher_spec.rb +411 -0
- data/spec/public/controller/display_spec.rb +43 -10
- data/spec/public/controller/redirect_spec.rb +33 -0
- data/spec/public/controller/responder_spec.rb +79 -11
- data/spec/public/controller/spec_helper.rb +3 -1
- data/spec/public/controller/url_spec.rb +10 -0
- data/spec/public/core/merb_core_spec.rb +11 -0
- data/spec/public/core_ext/fixtures/core_ext_dependency.rb +2 -0
- data/spec/public/core_ext/kernel_spec.rb +9 -0
- data/spec/public/core_ext/spec_helper.rb +1 -0
- data/spec/public/directory_structure/directory/log/merb_test.log +3729 -272
- data/spec/public/directory_structure/directory_spec.rb +3 -4
- data/spec/public/logger/logger_spec.rb +4 -4
- data/spec/public/reloading/directory/log/merb_test.log +288066 -15
- data/spec/public/reloading/reload_spec.rb +49 -27
- data/spec/public/request/multipart_spec.rb +26 -0
- data/spec/public/request/request_spec.rb +21 -2
- data/spec/public/router/fixation_spec.rb +27 -0
- data/spec/public/router/fixture/log/merb_test.log +30050 -0
- data/spec/public/router/nested_matches_spec.rb +97 -0
- data/spec/public/router/resource_spec.rb +1 -9
- data/spec/public/router/resources_spec.rb +0 -20
- data/spec/public/router/spec_helper.rb +27 -9
- data/spec/public/router/special_spec.rb +21 -8
- data/spec/public/template/template_spec.rb +17 -5
- data/spec/public/test/controller_matchers_spec.rb +10 -0
- data/spec/public/test/request_helper_spec.rb +29 -0
- data/spec/public/test/route_helper_spec.rb +18 -1
- data/spec/public/test/route_matchers_spec.rb +28 -1
- data/spec/public/test/view_matchers_spec.rb +3 -3
- data/spec/spec_helper.rb +56 -12
- metadata +89 -47
- data/lib/merb-core/core_ext/class.rb +0 -299
- data/lib/merb-core/core_ext/hash.rb +0 -426
- data/lib/merb-core/core_ext/mash.rb +0 -154
- data/lib/merb-core/core_ext/object.rb +0 -147
- data/lib/merb-core/core_ext/object_space.rb +0 -14
- data/lib/merb-core/core_ext/rubygems.rb +0 -28
- data/lib/merb-core/core_ext/set.rb +0 -46
- data/lib/merb-core/core_ext/string.rb +0 -89
- data/lib/merb-core/core_ext/time.rb +0 -13
- data/lib/merb-core/dispatch/exceptions.html.erb +0 -297
- data/spec/private/core_ext/class_spec.rb +0 -22
- data/spec/private/core_ext/hash_spec.rb +0 -522
- data/spec/private/core_ext/object_spec.rb +0 -121
- data/spec/private/core_ext/set_spec.rb +0 -26
- data/spec/private/core_ext/string_spec.rb +0 -167
- data/spec/private/core_ext/time_spec.rb +0 -16
- data/spec/private/dispatch/dispatch_spec.rb +0 -26
- data/spec/private/dispatch/fixture/log/development.log +0 -1
- data/spec/private/dispatch/fixture/log/merb.4000.pid +0 -1
- data/spec/private/dispatch/fixture/log/production.log +0 -1
- data/spec/private/dispatch/fixture/merb.4000.pid +0 -1
- data/spec/private/rack/application_spec.rb +0 -43
- data/spec/public/controller/log/merb.4000.pid +0 -1
- data/spec/public/directory_structure/directory/log/merb.4000.pid +0 -1
- data/spec/public/directory_structure/directory/merb.4000.pid +0 -1
- data/spec/public/reloading/directory/log/merb.4000.pid +0 -1
- data/spec/public/reloading/directory/merb.4000.pid +0 -1
@@ -0,0 +1,41 @@
|
|
1
|
+
module Merb::Test::Fixtures
|
2
|
+
|
3
|
+
module Abstract
|
4
|
+
|
5
|
+
class Testing < Merb::AbstractController
|
6
|
+
self._template_root = File.dirname(__FILE__) / "views"
|
7
|
+
end
|
8
|
+
|
9
|
+
class FilterParent < Testing
|
10
|
+
before :print_before_filter
|
11
|
+
|
12
|
+
def print_before_filter
|
13
|
+
@before_string = "Before"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class FilterChild1 < FilterParent
|
18
|
+
before :print_before_filter, :only => :limited
|
19
|
+
|
20
|
+
def index
|
21
|
+
@before_string.to_s + " Index"
|
22
|
+
end
|
23
|
+
|
24
|
+
def limited
|
25
|
+
@before_string.to_s + " Limited"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class FilterChild2 < FilterParent
|
30
|
+
|
31
|
+
def index
|
32
|
+
@before_string.to_s + " Index"
|
33
|
+
end
|
34
|
+
|
35
|
+
def limited
|
36
|
+
@before_string.to_s + " Limited"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -7,11 +7,21 @@ module Merb::Test::Fixtures
|
|
7
7
|
def _template_location(context, type = nil, controller = controller_name)
|
8
8
|
"helpers/#{File.basename(controller)}/#{context}"
|
9
9
|
end
|
10
|
+
|
11
|
+
def index
|
12
|
+
render
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
class Capture < HelperTesting
|
13
|
-
|
14
|
-
|
17
|
+
end
|
18
|
+
|
19
|
+
class CaptureWithArgs < HelperTesting
|
20
|
+
end
|
21
|
+
|
22
|
+
class CaptureEq < HelperTesting
|
23
|
+
def helper_using_capture(&blk)
|
24
|
+
"Beginning... #{capture(&blk)}... Done"
|
15
25
|
end
|
16
26
|
end
|
17
27
|
|
@@ -11,7 +11,7 @@ module Merb::Test::Fixtures
|
|
11
11
|
"partial/#{File.basename(controller)}/#{context}"
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
class BasicPartial < RenderIt
|
16
16
|
|
17
17
|
def index
|
@@ -19,6 +19,14 @@ module Merb::Test::Fixtures
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
class WithAbsolutePartial < RenderIt
|
23
|
+
|
24
|
+
def index
|
25
|
+
@absolute_partial_path = File.expand_path(File.dirname(__FILE__)) / 'views' / 'partial' / 'with_absolute_partial' / 'partial'
|
26
|
+
render
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
22
30
|
class WithPartial < RenderIt
|
23
31
|
|
24
32
|
def index
|
@@ -57,6 +65,13 @@ module Merb::Test::Fixtures
|
|
57
65
|
render
|
58
66
|
end
|
59
67
|
end
|
68
|
+
|
69
|
+
class PartialWithCollectionsAndCounter < RenderIt
|
70
|
+
def index
|
71
|
+
@foo = %w(1 2 3 4 5)
|
72
|
+
render
|
73
|
+
end
|
74
|
+
end
|
60
75
|
|
61
76
|
class PartialWithLocals < RenderIt
|
62
77
|
|
@@ -103,4 +118,4 @@ module Merb::Test::Fixtures
|
|
103
118
|
end
|
104
119
|
end
|
105
120
|
end
|
106
|
-
end
|
121
|
+
end
|
@@ -8,6 +8,13 @@ module Merb::Test::Fixtures
|
|
8
8
|
self._template_root = File.dirname(__FILE__) / "views"
|
9
9
|
end
|
10
10
|
|
11
|
+
class RenderTwoThrowContents < Testing
|
12
|
+
|
13
|
+
def index
|
14
|
+
render
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
11
18
|
class RenderString < Testing
|
12
19
|
|
13
20
|
def index
|
@@ -76,11 +83,19 @@ module Merb::Test::Fixtures
|
|
76
83
|
end
|
77
84
|
end
|
78
85
|
|
86
|
+
class RenderTemplateAbsolutePath < RenderTemplate
|
87
|
+
|
88
|
+
def index
|
89
|
+
render :template => File.expand_path(self._template_root) / 'wonderful' / 'index'
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
79
94
|
class RenderTemplateMultipleRoots < RenderTemplate
|
80
95
|
self._template_roots << [File.dirname(__FILE__) / "alt_views", :_template_location]
|
81
96
|
|
82
97
|
def show
|
83
|
-
render :layout=>false
|
98
|
+
render :layout => false
|
84
99
|
end
|
85
100
|
end
|
86
101
|
|
@@ -0,0 +1 @@
|
|
1
|
+
Pre. <%= helper_using_capture do %>Capturing<% end =%>. Post.
|
@@ -0,0 +1 @@
|
|
1
|
+
<% x = capture('one', 'two') do |one, two| -%>Capture: <%= one %>, <%= two %><% end -%><%= x %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<% throw_content(:foo, "Foo") %><% throw_content(:foo, "Bar") %><%= catch_content(:foo) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= collection_index %>/<%= collection_size %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Partial counting: <%= partial :collection, :with => @foo %>
|
data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/_partial.erb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Absolute Partial
|
data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/index.erb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Index <%= partial @absolute_partial_path %>
|
@@ -78,6 +78,15 @@ describe Merb::AbstractController, " should support before and after filters" do
|
|
78
78
|
running { dispatch_should_make_body("TestConditionalFilterWithNoProcOrSymbol", "") }.should raise_error(ArgumentError, /a Symbol or a Proc/)
|
79
79
|
end
|
80
80
|
|
81
|
+
it "should throw an error if an unknown option is passed to a filter" do
|
82
|
+
running { Merb::Test::Fixtures::Abstract.class_eval do
|
83
|
+
|
84
|
+
class TestErrorFilter < Merb::Test::Fixtures::Abstract::Testing
|
85
|
+
before :foo, :except => :index
|
86
|
+
end
|
87
|
+
end }.should raise_error(ArgumentError, /known filter options/)
|
88
|
+
end
|
89
|
+
|
81
90
|
it "should support passing an argument to a before filter method" do
|
82
91
|
dispatch_should_make_body("TestBeforeFilterWithArgument", "index action")
|
83
92
|
end
|
@@ -85,4 +94,14 @@ describe Merb::AbstractController, " should support before and after filters" do
|
|
85
94
|
it "should support passing arguments to a before filter method" do
|
86
95
|
dispatch_should_make_body("TestBeforeFilterWithArguments", "index action")
|
87
96
|
end
|
88
|
-
|
97
|
+
|
98
|
+
it "should inherit before filters" do
|
99
|
+
dispatch_should_make_body("FilterChild2", "Before Limited", :limited)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should not get contaminated by cousins" do
|
103
|
+
dispatch_should_make_body("FilterChild2", "Before Index")
|
104
|
+
dispatch_should_make_body("FilterChild1", "Before Limited", :limited)
|
105
|
+
dispatch_should_make_body("FilterChild1", " Index")
|
106
|
+
end
|
107
|
+
end
|
@@ -3,11 +3,19 @@ require File.join(File.dirname(__FILE__), "spec_helper")
|
|
3
3
|
describe Merb::AbstractController, " with capture and concat" do
|
4
4
|
|
5
5
|
it "should support capture" do
|
6
|
-
dispatch_should_make_body("Capture", "Capture")
|
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.")
|
7
15
|
end
|
8
16
|
|
9
17
|
it "should support concat" do
|
10
18
|
dispatch_should_make_body("Concat", "Concat")
|
11
19
|
end
|
12
|
-
|
20
|
+
|
13
21
|
end
|
@@ -50,4 +50,12 @@ describe Merb::AbstractController, " Partials" do
|
|
50
50
|
dispatch_should_make_body("BasicPartialWithMultipleRoots", "Base Index: Alt Partial")
|
51
51
|
end
|
52
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
|
+
|
53
61
|
end
|
@@ -6,6 +6,10 @@ describe Merb::AbstractController, " rendering plain strings" do
|
|
6
6
|
Merb.push_path(:layout, File.dirname(__FILE__) / "controllers" / "views" / "layouts")
|
7
7
|
end
|
8
8
|
|
9
|
+
it "should render two thrown_contents into same object" do
|
10
|
+
dispatch_should_make_body("RenderTwoThrowContents", "FooBar")
|
11
|
+
end
|
12
|
+
|
9
13
|
it "should support rendering plain strings with no layout" do
|
10
14
|
dispatch_should_make_body("RenderString", "the index")
|
11
15
|
end
|
@@ -63,6 +67,10 @@ describe Merb::AbstractController, " rendering templates" do
|
|
63
67
|
dispatch_should_make_body("RenderTemplateCustomLocation", "Wonderful")
|
64
68
|
end
|
65
69
|
|
70
|
+
it "should support rendering templates from an absolute path location" do
|
71
|
+
dispatch_should_make_body("RenderTemplateAbsolutePath", "Wonderful")
|
72
|
+
end
|
73
|
+
|
66
74
|
it "should support rendering templates with multiple roots" do
|
67
75
|
dispatch_should_make_body("RenderTemplateMultipleRoots", "App: Multiple")
|
68
76
|
end
|
@@ -2,6 +2,7 @@ __DIR__ = File.dirname(__FILE__)
|
|
2
2
|
require File.join(__DIR__, "..", "..", "spec_helper")
|
3
3
|
|
4
4
|
require File.join(__DIR__, "controllers", "filters")
|
5
|
+
require File.join(__DIR__, "controllers", "cousins")
|
5
6
|
require File.join(__DIR__, "controllers", "render")
|
6
7
|
require File.join(__DIR__, "controllers", "partial")
|
7
8
|
require File.join(__DIR__, "controllers", "display")
|
@@ -12,12 +13,15 @@ Merb.start :environment => 'test'
|
|
12
13
|
module Merb::Test::Behaviors
|
13
14
|
include Merb::Test::RequestHelper
|
14
15
|
|
15
|
-
def dispatch_should_make_body(klass, body, action = :index, opts = {})
|
16
|
-
|
16
|
+
def dispatch_should_make_body(klass, body, action = :index, opts = {}, env = {}, &blk)
|
17
|
+
klass = Merb::Test::Fixtures::Abstract.const_get(klass)
|
17
18
|
if opts.key?(:presets)
|
19
|
+
controller = klass.new
|
18
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)
|
19
24
|
end
|
20
|
-
controller._dispatch(action.to_s)
|
21
25
|
controller.body.should == body
|
22
26
|
end
|
23
27
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
require File.join(File.dirname(__FILE__), "spec_helper")
|
6
6
|
|
7
7
|
class Merb::BootLoader::AfterTest < Merb::BootLoader
|
8
|
-
after Merb::BootLoader::
|
8
|
+
after Merb::BootLoader::BeforeAppLoads
|
9
9
|
|
10
10
|
def self.run
|
11
11
|
end
|
@@ -21,7 +21,7 @@ end
|
|
21
21
|
describe "The BootLoader" do
|
22
22
|
|
23
23
|
it "should support adding a BootLoader after another" do
|
24
|
-
idx = Merb::BootLoader.subclasses.index("Merb::BootLoader::
|
24
|
+
idx = Merb::BootLoader.subclasses.index("Merb::BootLoader::BeforeAppLoads")
|
25
25
|
Merb::BootLoader.subclasses.index("Merb::BootLoader::AfterTest").should == idx + 1
|
26
26
|
end
|
27
27
|
|
@@ -9,9 +9,17 @@ describe Merb::Controller, " callable actions" do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
12
|
+
it "has no any callable actions by default" do
|
13
|
+
Merb::Controller.callable_actions.should be_empty
|
14
|
+
end
|
15
|
+
|
16
|
+
it "sets body on dispatch to callable action" do
|
13
17
|
controller = dispatch_to(Merb::Test::Fixtures::Controllers::Base, :index)
|
14
18
|
controller.body.should == "index"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "sets status on dispatch to callable action" do
|
22
|
+
controller = dispatch_to(Merb::Test::Fixtures::Controllers::Base, :index)
|
15
23
|
controller.status.should == 200
|
16
24
|
end
|
17
25
|
|
@@ -29,4 +37,4 @@ describe Merb::Controller, " callable actions" do
|
|
29
37
|
should raise_error(Merb::ControllerExceptions::ActionNotFound)
|
30
38
|
end
|
31
39
|
|
32
|
-
end
|
40
|
+
end
|
@@ -1,47 +1,45 @@
|
|
1
1
|
module Merb::Test::Fixtures::Controllers
|
2
|
-
|
2
|
+
|
3
3
|
class Testing < Merb::Controller
|
4
4
|
self._template_root = File.dirname(__FILE__) / "views"
|
5
5
|
end
|
6
6
|
|
7
7
|
class BasicAuthentication < Testing
|
8
|
-
|
9
8
|
before :authenticate, :only => :index
|
10
9
|
|
11
10
|
def index
|
12
11
|
"authenticated"
|
13
12
|
end
|
14
|
-
|
13
|
+
|
15
14
|
protected
|
16
|
-
|
15
|
+
|
17
16
|
def authenticate
|
18
17
|
basic_authentication { |u, p| u == "Fred" && p == "secret" }
|
19
18
|
end
|
20
|
-
|
21
19
|
end
|
22
|
-
|
20
|
+
|
23
21
|
class BasicAuthenticationWithRealm < BasicAuthentication
|
24
22
|
def authenticate
|
25
23
|
basic_authentication("My Super App") { |u, p| u == "Fred" && p == "secret" }
|
26
24
|
end
|
27
25
|
end
|
28
|
-
|
26
|
+
|
29
27
|
class AuthenticateBasicAuthentication < Testing
|
30
28
|
def index
|
31
29
|
basic_authentication.authenticate { |u, p| "Fred:secret" }
|
32
30
|
end
|
33
31
|
end
|
34
|
-
|
32
|
+
|
35
33
|
class RequestBasicAuthentication < BasicAuthentication
|
36
34
|
def authenticate
|
37
35
|
basic_authentication.request
|
38
36
|
end
|
39
37
|
end
|
40
|
-
|
38
|
+
|
41
39
|
class RequestBasicAuthenticationWithRealm < BasicAuthentication
|
42
40
|
def authenticate
|
43
41
|
basic_authentication("My SuperApp").request
|
44
42
|
end
|
45
43
|
end
|
46
|
-
|
47
|
-
end
|
44
|
+
|
45
|
+
end
|
@@ -1,15 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
module Merb::Test::Fixtures
|
4
|
-
|
5
2
|
module Controllers
|
6
|
-
|
7
3
|
class Testing < Merb::Controller
|
8
4
|
self._template_root = File.dirname(__FILE__) / "views"
|
9
5
|
end
|
10
6
|
|
11
7
|
module Inclusion
|
12
|
-
|
13
8
|
def self.included(base)
|
14
9
|
base.show_action(:baz)
|
15
10
|
end
|
@@ -21,12 +16,11 @@ module Merb::Test::Fixtures
|
|
21
16
|
def bat
|
22
17
|
"bat"
|
23
18
|
end
|
24
|
-
|
25
19
|
end
|
26
20
|
|
27
21
|
class Base < Testing
|
28
22
|
include Inclusion
|
29
|
-
|
23
|
+
|
30
24
|
def index
|
31
25
|
self.status = :ok
|
32
26
|
"index"
|
@@ -39,4 +33,4 @@ module Merb::Test::Fixtures
|
|
39
33
|
end
|
40
34
|
|
41
35
|
end
|
42
|
-
end
|
36
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Merb::Test::Fixtures::Controllers
|
2
|
+
|
3
|
+
class Testing < Merb::Controller
|
4
|
+
self._template_root = File.dirname(__FILE__) / "views"
|
5
|
+
end
|
6
|
+
|
7
|
+
class CookiesController < Testing
|
8
|
+
end
|
9
|
+
|
10
|
+
class OverridingSessionCookieDomain < CookiesController
|
11
|
+
self._session_cookie_domain = "overridden.merbivore.com"
|
12
|
+
end
|
13
|
+
|
14
|
+
class NotOverridingSessionCookieDomain < CookiesController
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Application < Merb::Controller
|
2
|
+
end
|
3
|
+
|
4
|
+
module Merb::Test::Fixtures
|
5
|
+
module Controllers
|
6
|
+
class Testing < Merb::Controller
|
7
|
+
self._template_root = File.dirname(__FILE__) / "views"
|
8
|
+
end
|
9
|
+
|
10
|
+
class DispatchTo < Testing
|
11
|
+
def index
|
12
|
+
"Dispatched"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class NotAController
|
17
|
+
def index
|
18
|
+
"Dispatched"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class RaiseGone < Testing
|
23
|
+
def index
|
24
|
+
raise Gone
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class RaiseLoadError < Merb::Controller
|
29
|
+
def index
|
30
|
+
raise LoadError, "In the controller"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|