ramaze 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -12
- data/bin/ramaze +95 -171
- data/doc/CHANGELOG +387 -4
- data/doc/README +81 -13
- data/doc/meta/announcement.txt +51 -8
- data/doc/meta/configuration.txt +17 -34
- data/doc/meta/internals.txt +34 -4
- data/doc/migrate/1110_to_1111.txt +131 -0
- data/doc/readme_chunks/features.txt +81 -12
- data/doc/readme_chunks/installing.txt +0 -1
- data/doc/tutorial/todolist.html +293 -65
- data/doc/tutorial/{todolist.txt → todolist.mkd} +251 -51
- data/examples/blog/main.rb +1 -1
- data/examples/blog/src/model.rb +0 -1
- data/examples/hello.rb +2 -5
- data/examples/templates/template/external.haml +5 -5
- data/examples/templates/template/external.liquid +1 -1
- data/examples/templates/template/external.mab +8 -8
- data/examples/templates/template/external.rem +30 -0
- data/examples/templates/template/external.rhtml +6 -7
- data/examples/templates/template/external.zmr +13 -9
- data/examples/templates/template_amrita2.rb +8 -8
- data/examples/templates/template_erubis.rb +11 -11
- data/examples/templates/template_ezamar.rb +9 -11
- data/examples/templates/template_haml.rb +13 -13
- data/examples/templates/template_liquid.rb +10 -10
- data/examples/templates/template_markaby.rb +13 -10
- data/examples/templates/template_remarkably.rb +59 -0
- data/examples/todolist/main.rb +1 -7
- data/examples/todolist/src/controller/main.rb +26 -13
- data/examples/todolist/src/element/page.rb +5 -0
- data/examples/whywiki/main.rb +1 -1
- data/lib/proto/main.rb +0 -8
- data/lib/proto/public/css/ramaze_error.css +12 -4
- data/lib/proto/public/error.zmr +6 -25
- data/lib/ramaze.rb +35 -245
- data/lib/ramaze/action.rb +21 -0
- data/lib/ramaze/adapter.rb +94 -29
- data/lib/ramaze/adapter/base.rb +57 -0
- data/lib/ramaze/adapter/mongrel.rb +12 -19
- data/lib/ramaze/adapter/webrick.rb +21 -20
- data/lib/ramaze/cache.rb +47 -3
- data/lib/ramaze/cache/memcached.rb +22 -0
- data/lib/ramaze/cache/yaml_store.rb +19 -0
- data/lib/ramaze/controller.rb +47 -271
- data/lib/ramaze/controller/error.rb +43 -0
- data/lib/ramaze/controller/render.rb +90 -0
- data/lib/ramaze/controller/resolve.rb +147 -0
- data/lib/ramaze/dispatcher.rb +41 -9
- data/lib/ramaze/dispatcher/file.rb +1 -1
- data/lib/ramaze/global.rb +73 -158
- data/lib/ramaze/global/dsl.rb +29 -0
- data/lib/ramaze/global/globalstruct.rb +90 -0
- data/lib/ramaze/helper.rb +1 -1
- data/lib/ramaze/helper/aspect.rb +39 -179
- data/lib/ramaze/helper/cache.rb +8 -9
- data/lib/ramaze/helper/cgi.rb +23 -0
- data/lib/ramaze/helper/file.rb +3 -0
- data/lib/ramaze/helper/inform.rb +3 -0
- data/lib/ramaze/helper/link.rb +56 -63
- data/lib/ramaze/helper/nitroform.rb +4 -0
- data/lib/ramaze/helper/redirect.rb +1 -1
- data/lib/ramaze/inform.rb +6 -2
- data/lib/ramaze/inform/analogger.rb +5 -1
- data/lib/ramaze/inform/hub.rb +1 -1
- data/lib/ramaze/inform/informing.rb +7 -0
- data/lib/ramaze/snippets/kernel/aquire.rb +2 -0
- data/lib/ramaze/snippets/kernel/constant.rb +2 -0
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +2 -0
- data/lib/ramaze/snippets/object/traits.rb +4 -0
- data/lib/ramaze/snippets/openstruct/temp.rb +3 -0
- data/lib/ramaze/snippets/string/DIVIDE.rb +2 -0
- data/lib/ramaze/snippets/string/camel_case.rb +2 -0
- data/lib/ramaze/snippets/string/color.rb +2 -0
- data/lib/ramaze/snippets/string/each.rb +2 -0
- data/lib/ramaze/snippets/string/snake_case.rb +3 -0
- data/lib/ramaze/snippets/struct/fill.rb +8 -2
- data/lib/ramaze/snippets/struct/values_at.rb +16 -0
- data/lib/ramaze/snippets/symbol/to_proc.rb +3 -0
- data/lib/ramaze/sourcereload.rb +89 -0
- data/lib/ramaze/template.rb +21 -12
- data/lib/ramaze/template/amrita2.rb +6 -6
- data/lib/ramaze/template/erubis.rb +4 -9
- data/lib/ramaze/template/ezamar.rb +13 -57
- data/lib/ramaze/template/ezamar/element.rb +10 -12
- data/lib/ramaze/template/ezamar/engine.rb +40 -101
- data/lib/ramaze/template/ezamar/morpher.rb +3 -3
- data/lib/ramaze/template/haml.rb +3 -6
- data/lib/ramaze/template/liquid.rb +4 -9
- data/lib/ramaze/template/markaby.rb +16 -22
- data/lib/ramaze/template/remarkably.rb +28 -0
- data/lib/ramaze/tool/mime.rb +2 -0
- data/lib/ramaze/tool/record.rb +6 -0
- data/lib/ramaze/trinity/request.rb +44 -54
- data/lib/ramaze/trinity/response.rb +1 -1
- data/lib/ramaze/trinity/session.rb +15 -37
- data/lib/ramaze/version.rb +1 -1
- data/rake_tasks/gem.rake +2 -2
- data/rake_tasks/maintaince.rake +42 -1
- data/rake_tasks/spec.rake +45 -0
- data/spec/examples/caching.rb +1 -1
- data/spec/examples/simple.rb +1 -1
- data/spec/examples/templates/template_amrita2.rb +1 -0
- data/spec/examples/templates/template_erubis.rb +2 -1
- data/spec/examples/templates/template_ezamar.rb +1 -1
- data/spec/examples/templates/template_haml.rb +2 -1
- data/spec/examples/templates/template_liquid.rb +2 -1
- data/spec/examples/templates/template_markaby.rb +2 -1
- data/spec/examples/templates/template_remarkably.rb +22 -0
- data/spec/examples/todolist.rb +125 -0
- data/spec/helper.rb +2 -23
- data/spec/helper/minimal.rb +20 -0
- data/spec/helper/mock_http.rb +24 -30
- data/spec/helper/simple_http.rb +2 -2
- data/spec/helper/wrap.rb +6 -9
- data/spec/ramaze/adapter.rb +1 -1
- data/spec/ramaze/adapter/record.rb +31 -0
- data/spec/ramaze/cache.rb +41 -54
- data/spec/ramaze/controller.rb +121 -137
- data/spec/ramaze/controller/template/list.xhtml +1 -0
- data/spec/ramaze/controller/template/other/greet/other.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +27 -3
- data/spec/ramaze/element.rb +11 -7
- data/spec/ramaze/error.rb +1 -1
- data/spec/ramaze/gestalt.rb +2 -0
- data/spec/ramaze/helper/aspect.rb +30 -21
- data/spec/ramaze/helper/auth.rb +1 -1
- data/spec/ramaze/helper/cache.rb +2 -1
- data/spec/ramaze/helper/form.rb +14 -11
- data/spec/ramaze/helper/link.rb +18 -41
- data/spec/ramaze/localize.rb +29 -2
- data/spec/ramaze/morpher.rb +23 -12
- data/spec/ramaze/params.rb +46 -24
- data/spec/ramaze/request.rb +6 -2
- data/spec/ramaze/store/yaml.rb +5 -0
- data/spec/ramaze/template.rb +22 -27
- data/spec/ramaze/template/amrita2.rb +1 -2
- data/spec/ramaze/template/erubis.rb +1 -1
- data/spec/ramaze/template/ezamar.rb +1 -2
- data/spec/ramaze/template/haml.rb +2 -2
- data/spec/ramaze/template/haml/with_vars.haml +1 -1
- data/spec/ramaze/template/liquid.rb +1 -1
- data/spec/ramaze/template/markaby.rb +1 -1
- data/spec/ramaze/template/remarkably.rb +56 -0
- data/spec/ramaze/template/remarkably/external.rem +8 -0
- data/spec/ramaze/template/remarkably/sum.rem +1 -0
- metadata +38 -63
- data/doc/README.html +0 -637
- data/doc/allison/LICENSE +0 -184
- data/doc/allison/README +0 -37
- data/doc/allison/allison.css +0 -299
- data/doc/allison/allison.gif +0 -0
- data/doc/allison/allison.js +0 -307
- data/doc/allison/allison.rb +0 -287
- data/doc/allison/cache/BODY +0 -588
- data/doc/allison/cache/CLASS_INDEX +0 -4
- data/doc/allison/cache/CLASS_PAGE +0 -1
- data/doc/allison/cache/FILE_INDEX +0 -4
- data/doc/allison/cache/FILE_PAGE +0 -1
- data/doc/allison/cache/FONTS +0 -1
- data/doc/allison/cache/FR_INDEX_BODY +0 -1
- data/doc/allison/cache/IMGPATH +0 -1
- data/doc/allison/cache/INDEX +0 -1
- data/doc/allison/cache/JAVASCRIPT +0 -307
- data/doc/allison/cache/METHOD_INDEX +0 -4
- data/doc/allison/cache/METHOD_LIST +0 -1
- data/doc/allison/cache/SRC_PAGE +0 -1
- data/doc/allison/cache/STYLE +0 -321
- data/doc/allison/cache/URL +0 -1
- data/doc/changes.txt +0 -3375
- data/doc/changes.xml +0 -3378
- data/examples/todolist/conf/benchmark.yaml +0 -35
- data/examples/todolist/conf/debug.yaml +0 -34
- data/examples/todolist/conf/live.yaml +0 -33
- data/examples/todolist/conf/silent.yaml +0 -31
- data/examples/todolist/conf/stage.yaml +0 -33
- data/examples/todolist/public/css/coderay.css +0 -105
- data/examples/todolist/public/css/ramaze_error.css +0 -42
- data/lib/proto/conf/benchmark.yaml +0 -21
- data/lib/proto/conf/debug.yaml +0 -21
- data/lib/proto/conf/live.yaml +0 -21
- data/lib/proto/conf/silent.yaml +0 -21
- data/lib/proto/conf/stage.yaml +0 -21
- data/lib/proto/public/css/coderay.css +0 -105
- data/lib/ramaze/http_status.rb +0 -66
- data/lib/ramaze/snippets/hash/keys_to_sym.rb +0 -19
- data/lib/ramaze/snippets/kernel/method.rb +0 -26
- data/lib/ramaze/snippets/method/name.rb +0 -22
- data/lib/ramaze/snippets/ramaze/autoreload.rb +0 -135
- data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +0 -65
- data/spec/all.rb +0 -32
- data/spec/ramaze/conf/locale_de.yaml +0 -6
- data/spec/ramaze/conf/locale_en.yaml +0 -6
- data/spec/ramaze/dependencies.rb +0 -16
- data/spec/ramaze/global.rb +0 -44
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
class TCRecordController < Ramaze::Controller
|
4
|
+
map '/'
|
5
|
+
|
6
|
+
def index
|
7
|
+
'The index'
|
8
|
+
end
|
9
|
+
|
10
|
+
def foo
|
11
|
+
'The foo'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'Adapter recording' do
|
16
|
+
setup do
|
17
|
+
ramaze :adapter => :webrick, :record => lambda{|request|
|
18
|
+
request.remote_addr == '127.0.0.1'
|
19
|
+
}
|
20
|
+
|
21
|
+
@record = Ramaze::Record
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should record' do
|
25
|
+
get('/').body.should == 'The index'
|
26
|
+
get('/foo').body.should == 'The foo'
|
27
|
+
@record.should have(2).requests
|
28
|
+
@record.first.path_info.should == '/'
|
29
|
+
@record.last.path_info.should == '/foo'
|
30
|
+
end
|
31
|
+
end
|
data/spec/ramaze/cache.rb
CHANGED
@@ -3,75 +3,62 @@
|
|
3
3
|
|
4
4
|
require 'spec/helper'
|
5
5
|
|
6
|
-
|
7
|
-
cache = Ramaze::MemoryCache.new
|
6
|
+
caches = {:memory => 'Hash', :yaml => 'Ramaze::YAMLStoreCache'}
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
it "set keys" do
|
15
|
-
(cache[:one] = 'eins').should == "eins"
|
16
|
-
(cache[:two] = 'zwei').should == "zwei"
|
17
|
-
end
|
18
|
-
|
19
|
-
it "read keys" do
|
20
|
-
cache[:one].should == 'eins'
|
21
|
-
cache[:two].should == 'zwei'
|
22
|
-
end
|
23
|
-
|
24
|
-
it "values_at" do
|
25
|
-
cache.values_at(:one, :two).should == %w[eins zwei]
|
26
|
-
end
|
8
|
+
begin
|
9
|
+
require 'memcache'
|
10
|
+
caches[:memcached] = 'Ramaze::MemcachedCache'
|
11
|
+
rescue LoadError
|
12
|
+
puts "skipping memcached"
|
27
13
|
end
|
28
14
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
15
|
+
caches.each do |cache, name|
|
16
|
+
describe "#{name} setup" do
|
17
|
+
it "should be assignable to Global" do
|
18
|
+
Ramaze::Global.cache = cache
|
19
|
+
Ramaze::Global.cache.to_s.should == name
|
20
|
+
end
|
36
21
|
|
37
|
-
|
38
|
-
|
39
|
-
|
22
|
+
it "should do .new" do
|
23
|
+
@cache = Ramaze::Global.cache.new
|
24
|
+
@cache.class.name.should == name
|
25
|
+
end
|
40
26
|
end
|
41
27
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
28
|
+
describe "#{name} modification" do
|
29
|
+
setup do
|
30
|
+
Ramaze::Global.cache = cache
|
31
|
+
@cache = Ramaze::Global.cache.new
|
32
|
+
end
|
46
33
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
34
|
+
after :each do
|
35
|
+
@cache.clear
|
36
|
+
end
|
51
37
|
|
52
|
-
|
53
|
-
|
54
|
-
|
38
|
+
after :all do
|
39
|
+
FileUtils.rm(@cache.file) if cache == :yaml
|
40
|
+
end
|
55
41
|
|
56
|
-
it "
|
57
|
-
cache
|
58
|
-
cache.
|
42
|
+
it "should be assignable with #[]=" do
|
43
|
+
@cache[:foo] = :bar
|
44
|
+
@cache[:foo].should == :bar
|
59
45
|
end
|
60
46
|
|
61
|
-
it "
|
62
|
-
|
63
|
-
|
47
|
+
it "should be retrievable with #[]" do
|
48
|
+
@cache[:yoh] = :bar
|
49
|
+
@cache[:yoh].should == :bar
|
64
50
|
end
|
65
51
|
|
66
|
-
it "
|
67
|
-
cache[:
|
68
|
-
cache
|
52
|
+
it "should delete keys" do
|
53
|
+
@cache[:bar] = :duh
|
54
|
+
@cache.delete(:bar)
|
55
|
+
@cache[:bar].should be_nil
|
69
56
|
end
|
70
57
|
|
71
|
-
it "
|
72
|
-
cache
|
58
|
+
it "should show values for multiple keys" do
|
59
|
+
@cache[:baz] = :foo
|
60
|
+
@cache[:beh] = :feh
|
61
|
+
@cache.values_at(:baz, :beh).should == [:foo, :feh]
|
73
62
|
end
|
74
63
|
end
|
75
|
-
rescue LoadError
|
76
|
-
puts "cannot run test for memcached"
|
77
64
|
end
|
data/spec/ramaze/controller.rb
CHANGED
@@ -5,7 +5,7 @@ require 'spec/helper'
|
|
5
5
|
|
6
6
|
class TCControllerController < Ramaze::Controller
|
7
7
|
map '/'
|
8
|
-
|
8
|
+
template_root 'spec/ramaze/template/ezamar'
|
9
9
|
|
10
10
|
def index
|
11
11
|
@text = "World"
|
@@ -28,157 +28,141 @@ class TCControllerController < Ramaze::Controller
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "Controller" do
|
31
|
-
|
32
|
-
|
33
|
-
describe 'dry specs' do
|
34
|
-
describe 'pattern_for' do
|
35
|
-
hash = {
|
36
|
-
'/' => [
|
37
|
-
["/", 'index', []]
|
38
|
-
],
|
39
|
-
|
40
|
-
'/foo' => [
|
41
|
-
["/foo", 'index',[]],
|
42
|
-
['/', 'foo', []],
|
43
|
-
["/", 'index', ["foo"]],
|
44
|
-
],
|
45
|
-
|
46
|
-
'/foo/bar' => [
|
47
|
-
["/foo__bar", "index", []],
|
48
|
-
["/foo/bar", "index", []],
|
49
|
-
|
50
|
-
["/foo", "bar", []],
|
51
|
-
["/foo", "index", ["bar"]],
|
52
|
-
|
53
|
-
["/", "foo__bar", []],
|
54
|
-
["/", "foo", ["bar"]],
|
55
|
-
["/", "index", ["foo", "bar"]],
|
56
|
-
],
|
57
|
-
|
58
|
-
'/foo/bar/baz' => [
|
59
|
-
|
60
|
-
['/foo__bar__baz', 'index', []],
|
61
|
-
['/foo/bar/baz', 'index', []],
|
62
|
-
|
63
|
-
['/foo__bar', 'baz', []],
|
64
|
-
['/foo__bar', 'index', ['baz']],
|
65
|
-
|
66
|
-
['/foo/bar', 'baz', []],
|
67
|
-
['/foo/bar', 'index', ['baz']],
|
68
|
-
|
69
|
-
['/foo', 'bar__baz', []],
|
70
|
-
['/foo', 'bar', ['baz']],
|
71
|
-
['/foo', 'index', ['bar', 'baz']],
|
72
|
-
|
73
|
-
['/', 'foo__bar__baz', []],
|
74
|
-
['/', 'foo__bar', ['baz']],
|
75
|
-
['/', 'foo', ['bar', 'baz']],
|
76
|
-
['/', 'index', ['foo', 'bar', 'baz']],
|
77
|
-
],
|
78
|
-
|
79
|
-
'/foo/bar/baz/oof' => [
|
80
|
-
['/foo__bar__baz__oof', 'index', []],
|
81
|
-
|
82
|
-
['/foo/bar/baz/oof', 'index', []],
|
83
|
-
|
84
|
-
['/foo__bar__baz', 'oof', []],
|
85
|
-
['/foo__bar__baz', 'index', ['oof']],
|
86
|
-
|
87
|
-
['/foo/bar/baz', 'oof', []],
|
88
|
-
['/foo/bar/baz', 'index', ['oof']],
|
89
|
-
|
90
|
-
['/foo__bar', 'baz__oof', []],
|
91
|
-
['/foo__bar', 'baz', ['oof']],
|
92
|
-
['/foo__bar', 'index', ['baz', 'oof']],
|
93
|
-
|
94
|
-
['/foo/bar', 'baz__oof', []],
|
95
|
-
['/foo/bar', 'baz', ['oof']],
|
96
|
-
['/foo/bar', 'index', ['baz', 'oof']],
|
97
|
-
|
98
|
-
['/foo', 'bar__baz__oof', []],
|
99
|
-
['/foo', 'bar__baz', ['oof']],
|
100
|
-
['/foo', 'bar', ['baz', 'oof']],
|
101
|
-
['/foo', 'index', ['bar', 'baz', 'oof']],
|
102
|
-
|
103
|
-
['/', 'foo__bar__baz__oof', []],
|
104
|
-
['/', 'foo__bar__baz', ['oof']],
|
105
|
-
['/', 'foo__bar', ['baz', 'oof']],
|
106
|
-
['/', 'foo', ['bar', 'baz', 'oof']],
|
107
|
-
['/', 'index', ['foo', 'bar', 'baz', 'oof']],
|
108
|
-
]
|
109
|
-
}
|
110
|
-
|
111
|
-
hash.each do |path, correct|
|
112
|
-
describe path do
|
113
|
-
patterns = Ramaze::Controller.pattern_for(path)
|
114
|
-
|
115
|
-
describe path do
|
116
|
-
=begin
|
117
|
-
puts
|
118
|
-
patterns.zip(correct).each do |pa, co|
|
119
|
-
p :pa => pa
|
120
|
-
p :co => co
|
121
|
-
puts
|
122
|
-
end
|
123
|
-
puts
|
124
|
-
=end
|
125
|
-
it(path){ patterns.should == correct }
|
126
|
-
correct.zip(patterns).each do |(cc,cm,cp),(pc,pm,pp)|
|
127
|
-
{cc,pc,cm,pm,cp,pp}.each{|a,b| a.should == b}
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
31
|
+
def handle(*args)
|
32
|
+
Ramaze::Controller.handle(*args)
|
133
33
|
end
|
134
34
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
end
|
35
|
+
def resolve(*args)
|
36
|
+
Ramaze::Controller.resolve(*args)
|
37
|
+
end
|
139
38
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
end
|
39
|
+
def values(*url)
|
40
|
+
resolve(*url).last.values_at(:method, :params, :template)
|
41
|
+
end
|
144
42
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
43
|
+
before :all do
|
44
|
+
ramaze :error_page => false
|
45
|
+
@hash = {
|
46
|
+
'/' => [
|
47
|
+
["/", 'index', []]
|
48
|
+
],
|
149
49
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
50
|
+
'/foo' => [
|
51
|
+
["/foo", 'index',[]],
|
52
|
+
['/', 'foo', []],
|
53
|
+
["/", 'index', ["foo"]],
|
54
|
+
],
|
55
|
+
|
56
|
+
'/foo/bar' => [
|
57
|
+
["/foo__bar", "index", []],
|
58
|
+
["/foo/bar", "index", []],
|
59
|
+
|
60
|
+
["/foo", "bar", []],
|
61
|
+
["/foo", "index", ["bar"]],
|
62
|
+
|
63
|
+
["/", "foo__bar", []],
|
64
|
+
["/", "foo", ["bar"]],
|
65
|
+
["/", "index", ["foo", "bar"]],
|
66
|
+
],
|
67
|
+
|
68
|
+
'/foo/bar/baz' => [
|
69
|
+
|
70
|
+
['/foo__bar__baz', 'index', []],
|
71
|
+
['/foo/bar/baz', 'index', []],
|
72
|
+
|
73
|
+
['/foo__bar', 'baz', []],
|
74
|
+
['/foo__bar', 'index', ['baz']],
|
75
|
+
|
76
|
+
['/foo/bar', 'baz', []],
|
77
|
+
['/foo/bar', 'index', ['baz']],
|
78
|
+
|
79
|
+
['/foo', 'bar__baz', []],
|
80
|
+
['/foo', 'bar', ['baz']],
|
81
|
+
['/foo', 'index', ['bar', 'baz']],
|
82
|
+
|
83
|
+
['/', 'foo__bar__baz', []],
|
84
|
+
['/', 'foo__bar', ['baz']],
|
85
|
+
['/', 'foo', ['bar', 'baz']],
|
86
|
+
['/', 'index', ['foo', 'bar', 'baz']],
|
87
|
+
],
|
88
|
+
|
89
|
+
'/foo/bar/baz/oof' => [
|
90
|
+
['/foo__bar__baz__oof', 'index', []],
|
91
|
+
|
92
|
+
['/foo/bar/baz/oof', 'index', []],
|
93
|
+
|
94
|
+
['/foo__bar__baz', 'oof', []],
|
95
|
+
['/foo__bar__baz', 'index', ['oof']],
|
96
|
+
|
97
|
+
['/foo/bar/baz', 'oof', []],
|
98
|
+
['/foo/bar/baz', 'index', ['oof']],
|
99
|
+
|
100
|
+
['/foo__bar', 'baz__oof', []],
|
101
|
+
['/foo__bar', 'baz', ['oof']],
|
102
|
+
['/foo__bar', 'index', ['baz', 'oof']],
|
103
|
+
|
104
|
+
['/foo/bar', 'baz__oof', []],
|
105
|
+
['/foo/bar', 'baz', ['oof']],
|
106
|
+
['/foo/bar', 'index', ['baz', 'oof']],
|
107
|
+
|
108
|
+
['/foo', 'bar__baz__oof', []],
|
109
|
+
['/foo', 'bar__baz', ['oof']],
|
110
|
+
['/foo', 'bar', ['baz', 'oof']],
|
111
|
+
['/foo', 'index', ['bar', 'baz', 'oof']],
|
112
|
+
|
113
|
+
['/', 'foo__bar__baz__oof', []],
|
114
|
+
['/', 'foo__bar__baz', ['oof']],
|
115
|
+
['/', 'foo__bar', ['baz', 'oof']],
|
116
|
+
['/', 'foo', ['bar', 'baz', 'oof']],
|
117
|
+
['/', 'index', ['foo', 'bar', 'baz', 'oof']],
|
118
|
+
]
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
it "dry pattern_for" do
|
123
|
+
@hash.each do |path, correct|
|
124
|
+
patterns = Ramaze::Controller.pattern_for(path)
|
125
|
+
patterns.should == correct
|
157
126
|
end
|
158
127
|
end
|
159
128
|
|
129
|
+
it '/' do
|
130
|
+
values('/').should ==
|
131
|
+
['index', [], 'spec/ramaze/template/ezamar/index.zmr']
|
132
|
+
end
|
133
|
+
|
134
|
+
it '/sum/1/2' do
|
135
|
+
values('/sum/1/2').should ==
|
136
|
+
['sum', ['1', '2'],'spec/ramaze/template/ezamar/sum.zmr']
|
137
|
+
end
|
138
|
+
|
139
|
+
it '/another/long/action' do
|
140
|
+
values('/another/long/action').should ==
|
141
|
+
['another__long__action', [], 'spec/ramaze/template/ezamar/another/long/action.zmr']
|
142
|
+
end
|
143
|
+
it '/some/long/action' do
|
144
|
+
values('/some/long/action').should ==
|
145
|
+
['some__long__action', [], 'spec/ramaze/template/ezamar/some__long__action.zmr']
|
146
|
+
end
|
147
|
+
|
160
148
|
it "simple request to index" do
|
161
|
-
|
149
|
+
handle('/').should == 'Hello, World!'
|
162
150
|
end
|
163
151
|
|
164
152
|
it "summing two values" do
|
165
|
-
|
153
|
+
handle('/sum/1/2').should == '3'
|
166
154
|
end
|
167
155
|
|
168
156
|
it "double underscore in templates" do
|
169
|
-
|
170
|
-
|
171
|
-
end
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
response = get(path)
|
179
|
-
response.body.should =~ %r(No Action found for `#{path}' on TCControllerControlle)
|
180
|
-
response.status.should == 404
|
181
|
-
end
|
157
|
+
handle('/some/long/action').should == 'some long action'
|
158
|
+
handle('/another/long/action').should == 'another long action'
|
159
|
+
end
|
160
|
+
|
161
|
+
TCControllerController.private_methods.sort.each do |action|
|
162
|
+
it action do
|
163
|
+
path = "/#{action}"
|
164
|
+
message = "No Action found for `#{path}' on TCControllerController"
|
165
|
+
lambda{ resolve(path) }.should raise_error(Ramaze::Error::NoAction, message)
|
182
166
|
end
|
183
167
|
end
|
184
168
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<html>#{@obj}</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<html>Other: #{@greet}</html>
|
@@ -4,21 +4,32 @@
|
|
4
4
|
require 'spec/helper'
|
5
5
|
|
6
6
|
class MainController < Ramaze::Controller
|
7
|
-
|
7
|
+
template_root "#{File.expand_path(File.dirname(__FILE__))}/template"
|
8
8
|
|
9
9
|
def greet(type, message = "Message")
|
10
10
|
@greet = "#{type} : #{message}"
|
11
11
|
end
|
12
|
+
|
13
|
+
def list
|
14
|
+
@obj = @action.method
|
15
|
+
end
|
16
|
+
alias_method :index, :list
|
17
|
+
template :index, 'list'
|
18
|
+
|
12
19
|
end
|
13
20
|
|
14
21
|
class OtherController < MainController
|
15
|
-
|
22
|
+
template_root "#{File.expand_path(File.dirname(__FILE__))}/template/other"
|
16
23
|
|
17
24
|
def greet__mom(message = "Moms are cool!")
|
18
25
|
greet('Mom', message)
|
19
26
|
end
|
27
|
+
template :greet__mom, MainController, :greet
|
20
28
|
|
21
|
-
|
29
|
+
def greet__other(one, two)
|
30
|
+
@greet = "Other"
|
31
|
+
end
|
32
|
+
template :greet__other, 'greet/other'
|
22
33
|
|
23
34
|
def partial_stuff
|
24
35
|
render_partial('/greet/the/world', :foo => :bar)
|
@@ -44,6 +55,19 @@ describe "Testing Template overriding" do
|
|
44
55
|
it "referencing template from MainController" do
|
45
56
|
get('/other/greet/mom').body.should == '<html>Mom : Moms are cool!</html>'
|
46
57
|
end
|
58
|
+
|
59
|
+
it "should accept template overrides with same name as controller" do
|
60
|
+
get('/other/greet/other/one/two').body.should == '<html>Other: Other</html>'
|
61
|
+
end
|
62
|
+
|
63
|
+
it "setting template for non-existant :index action should not arbitrary parameters" do
|
64
|
+
get('/list').body.should == '<html>list</html>'
|
65
|
+
|
66
|
+
response = get('/non_existant_method')
|
67
|
+
response.status.should == 404
|
68
|
+
response.body.should =~ %r(No Action found for `/non_existant_method' on MainController)
|
69
|
+
end
|
70
|
+
|
47
71
|
end
|
48
72
|
|
49
73
|
describe "render_partial" do
|