public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Search Repo:
Specs working
wycats (author)
Sun Jan 13 08:04:44 -0800 2008
commit  86eef63c291eb02a236ee9f966aee55c0b0c21b0
tree    d9cc25227b49d4b84fcb34bf87c7282d022a6bcc
parent  cbb18af8ab84e9c92bea6f8fac6a916ffaf98746
...
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
0
@@ -1 +1,12 @@
0
+==== Public API
0
+This is the API that is available in your app itself. Anything not in the public API is subject to change.
0
+
0
+==== Semipublic API
0
+This is the API that is guaranteed to be available between components of Merb. If something in the semipublic
0
+API changes, this will likely require changes in other parts of Merb. Additionally, items in the semipublic
0
+API can be relied upon for introspection, for testing purposes.
0
+
0
+For instance, AbstractController#_body should not be used in Merb apps themselves, as it may change, but
0
+it may be used in other components of Merb and in the Merb tests themselves. Including it in the semipublic
0
+API is designed to alert Merb's maintainers that changing it will have framework-wide repercussions.
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
0
@@ -1 +1,121 @@
0
+# ==== Methodology
0
+# Each of the controllers tested here tests a discrete, single case. This
0
+# is to ensure that each test is actually testing exactly what we want,
0
+# and that other features (or lack thereof), are not causing tests to fail
0
+# that would otherwise pass.
0
+module Merb::Test::Fixtures
0
+ class Testing < Merb::AbstractController
0
+ self._template_root = File.dirname(__FILE__) / "views"
0
+ end
0
+
0
+ class TestBeforeFilter < Testing
0
+ before :foo
0
+
0
+ def index
0
+ "#{@x}"
0
+ end
0
+
0
+ private
0
+ def foo
0
+ @x = "foo filter"
0
+ end
0
+ end
0
+
0
+ class TestAfterFilter < Testing
0
+ after :foo
0
+
0
+ def index
0
+ "index action"
0
+ end
0
+
0
+ private
0
+ def foo
0
+ @_body = "foo filter"
0
+ end
0
+ end
0
+
0
+ class TestSkipFilter < TestBeforeFilter
0
+ skip_before :foo
0
+ end
0
+
0
+ class TestBeforeFilterOrder < TestBeforeFilter
0
+ before :bar
0
+
0
+ def index
0
+ "#{@x}"
0
+ end
0
+
0
+ private
0
+ def bar
0
+ @x = "bar filter"
0
+ end
0
+ end
0
+
0
+ class TestAfterFilterOrder < TestAfterFilter
0
+ after :bar
0
+
0
+ def index
0
+ "index action"
0
+ end
0
+
0
+ private
0
+ def bar
0
+ @_body = "bar filter"
0
+ end
0
+ end
0
+
0
+ class TestProcFilter < Testing
0
+ before { @x = "proc filter1" }
0
+ before Proc.new { @y = "proc filter2" }
0
+
0
+ def index
0
+ "#{@x} #{@y}"
0
+ end
0
+ end
0
+
0
+ class TestExcludeFilter < Testing
0
+ before :foo, :exclude => :index
0
+ before :bar, :exclude => [:index]
0
+
0
+ def index
0
+ "#{@x} #{@y}"
0
+ end
0
+
0
+ def show
0
+ "#{@x} #{@y}"
0
+ end
0
+
0
+ private
0
+ def foo
0
+ @x = "foo filter"
0
+ end
0
+
0
+ def bar
0
+ @y = "bar filter"
0
+ end
0
+ end
0
+
0
+ class TestOnlyFilter < Testing
0
+ before :foo, :only => :index
0
+ before :bar, :only => [:index]
0
+
0
+ def index
0
+ "#{@x} #{@y}"
0
+ end
0
+
0
+ def show
0
+ "#{@x} #{@y}"
0
+ end
0
+
0
+ private
0
+ def foo
0
+ @x = "foo filter"
0
+ end
0
+
0
+ def bar
0
+ @y = "bar filter"
0
+ end
0
+ end
0
+
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
0
@@ -1 +1,64 @@
0
+# ==== Public API
0
+# Merb::AbstractController.before(filter<Symbol, Proc>, opts<Hash>)
0
+# Merb::AbstractController.after(filter<Symbol, Proc>, opts<Hash>)
0
+# Merb::AbstractController.skip_before(filter<Symbol>)
0
+# Merb::AbstractController.skip_after(filter<Symbol>)
0
+#
0
+# ==== Semipublic API
0
+# Merb::AbstractController#_body
0
+# Merb::AbstractController#_dispatch(action<~to_s>)
0
+
0
+require File.join(File.dirname(__FILE__), "spec_helper")
0
+
0
+describe Merb::AbstractController, " should support before and after filters" do
0
+
0
+ def dispatch_should_make_body(klass, body, action = :index)
0
+ controller = Merb::Test::Fixtures.const_get(klass).new
0
+ controller._dispatch(action)
0
+ controller._body.should == body
0
+ end
0
+
0
+ it "should support before filters" do
0
+ dispatch_should_make_body("TestBeforeFilter", "foo filter")
0
+ end
0
+
0
+ it "should support after filters" do
0
+ dispatch_should_make_body("TestAfterFilter", "foo filter")
0
+ end
0
+
0
+ it "should support skipping filters that were defined in a superclass" do
0
+ dispatch_should_make_body("TestSkipFilter", "")
0
+ end
0
+
0
+ it "should prepend before filters when added" do
0
+ dispatch_should_make_body("TestBeforeFilterOrder", "foo filter")
0
+ end
0
+
0
+ it "should append after filters when added" do
0
+ dispatch_should_make_body("TestAfterFilterOrder", "bar filter")
0
+ end
0
+
0
+ it "should support proc arguments to filters evaluated in the controller's instance" do
0
+ dispatch_should_make_body("TestProcFilter", "proc filter1 proc filter2")
0
+ end
0
+
0
+ it "should support filters that skip specific actions via :exclude" do
0
+ dispatch_should_make_body("TestExcludeFilter", " ", :index)
0
+ dispatch_should_make_body("TestExcludeFilter", "foo filter bar filter", :show)
0
+ end
0
+
0
+ it "should support filters that work only on specific actions via :only" do
0
+ dispatch_should_make_body("TestOnlyFilter", "foo filter bar filter", :index)
0
+ dispatch_should_make_body("TestOnlyFilter", " ", :show)
0
+ end
0
+
0
+ it "should throw an error if both :exclude and :only are passed to a filter" do
0
+ running { Merb::Test::Fixtures.class_eval do
0
+ class TestErrorFilter < Merb::Test::Fixtures::Testing
0
+ before :foo, :only => :index, :exclude => :show
0
+ end
0
+ end }.should raise_error(ArgumentError, /either :only or :exclude/)
0
+ end
0
+
0
+end
...
 
...
1
0
@@ -1 +1,2 @@
0
+require File.join(File.dirname(__FILE__), "spec_helper")
...
 
 
 
 
...
1
2
3
4
0
@@ -1 +1,5 @@
0
+require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
0
+require File.join(File.dirname(__FILE__), "controllers", "filters")
0
+
0
+Merb::BootLoader::Templates.new.run
...
1
2
3
4
 
 
 
5
6
7
...
1
2
 
3
4
5
6
7
8
9
0
@@ -1,7 +1,9 @@
0
 # ==== Public Template API
0
 # Merb::Template.register_extensions(engine<Class>, extenstions<Array[String]>)
0
-# Merb::Template.engine_for(path<String>)
0
 # Merb::Template.inline_template(path<String>, mod<Module>)
0
+#
0
+# ==== Semipublic Template API
0
+# Merb::Template.engine_for(path<String>)
0
 #
0
 # ==== Requirements for a new Template Engine
0
 # A Template Engine must have at least a single class method called compile_template

Comments

    No one has commented yet.