ramaze 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +14 -259
- data/bin/ramaze +52 -25
- data/doc/AUTHORS +6 -0
- data/doc/CHANGELOG +1363 -42
- data/doc/INSTALL +1 -1
- data/doc/README +48 -35
- data/doc/README.html +637 -0
- data/doc/TODO +7 -16
- data/doc/allison/allison.css +6 -7
- data/doc/allison/allison.gif +0 -0
- data/doc/allison/cache/STYLE +1 -2
- data/doc/changes.txt +3375 -0
- data/doc/changes.xml +3378 -0
- data/doc/meta/announcement.txt +47 -0
- data/doc/meta/configuration.txt +179 -0
- data/doc/meta/internals.txt +111 -0
- data/doc/readme_chunks/features.txt +8 -16
- data/doc/readme_chunks/installing.txt +7 -1
- data/doc/tutorial/todolist.txt +2 -3
- data/examples/blog/main.rb +9 -8
- data/examples/blog/public/styles/blog.css +132 -0
- data/examples/blog/src/controller.rb +14 -41
- data/examples/blog/src/model.rb +12 -13
- data/examples/blog/src/view.rb +16 -0
- data/examples/blog/template/edit.xhtml +19 -8
- data/examples/blog/template/index.xhtml +14 -22
- data/examples/blog/template/new.xhtml +18 -5
- data/examples/caching.rb +5 -8
- data/examples/element.rb +3 -3
- data/examples/hello.rb +3 -5
- data/examples/simple.rb +4 -7
- data/examples/templates/template/external.haml +8 -7
- data/examples/templates/template/external.mab +11 -8
- data/examples/templates/template_amrita2.rb +4 -4
- data/examples/templates/template_erubis.rb +3 -3
- data/examples/templates/template_ezamar.rb +1 -2
- data/examples/templates/template_haml.rb +24 -23
- data/examples/templates/template_liquid.rb +3 -1
- data/examples/templates/template_markaby.rb +15 -9
- data/examples/todolist/src/element/page.rb +1 -1
- data/lib/proto/conf/benchmark.yaml +6 -20
- data/lib/proto/conf/debug.yaml +6 -19
- data/lib/proto/conf/live.yaml +7 -19
- data/lib/proto/conf/silent.yaml +6 -16
- data/lib/proto/conf/stage.yaml +6 -18
- data/lib/proto/public/error.zmr +2 -2
- data/lib/ramaze.rb +34 -72
- data/lib/ramaze/adapter.rb +21 -18
- data/lib/ramaze/adapter/mongrel.rb +0 -3
- data/lib/ramaze/adapter/webrick.rb +6 -6
- data/lib/ramaze/cache/memcached.rb +3 -0
- data/lib/ramaze/controller.rb +227 -183
- data/lib/ramaze/dispatcher.rb +34 -129
- data/lib/ramaze/dispatcher/action.rb +28 -0
- data/lib/ramaze/dispatcher/error.rb +43 -0
- data/lib/ramaze/dispatcher/file.rb +34 -0
- data/lib/ramaze/global.rb +89 -48
- data/lib/ramaze/helper/aspect.rb +8 -6
- data/lib/ramaze/helper/auth.rb +3 -3
- data/lib/ramaze/helper/cache.rb +2 -2
- data/lib/ramaze/helper/file.rb +14 -0
- data/lib/ramaze/helper/inform.rb +36 -0
- data/lib/ramaze/helper/link.rb +7 -3
- data/lib/ramaze/helper/markaby.rb +30 -0
- data/lib/ramaze/helper/redirect.rb +2 -0
- data/lib/ramaze/inform.rb +8 -182
- data/lib/ramaze/inform/analogger.rb +19 -0
- data/lib/ramaze/inform/growl.rb +28 -0
- data/lib/ramaze/inform/hub.rb +26 -0
- data/lib/ramaze/inform/informer.rb +92 -0
- data/lib/ramaze/inform/informing.rb +44 -0
- data/lib/ramaze/inform/syslog.rb +27 -0
- data/lib/ramaze/inform/xosd.rb +42 -0
- data/lib/ramaze/snippets.rb +6 -2
- data/lib/ramaze/snippets/object/traits.rb +13 -1
- data/lib/ramaze/snippets/ramaze/autoreload.rb +58 -2
- data/lib/ramaze/snippets/string/color.rb +27 -0
- data/lib/ramaze/snippets/string/each.rb +6 -0
- data/lib/ramaze/snippets/struct/fill.rb +15 -0
- data/lib/ramaze/template/ezamar.rb +13 -22
- data/lib/ramaze/template/ezamar/element.rb +12 -12
- data/lib/ramaze/template/liquid.rb +19 -18
- data/lib/ramaze/template/markaby.rb +37 -58
- data/lib/ramaze/tool/localize.rb +128 -0
- data/lib/ramaze/tool/tidy.rb +51 -21
- data/lib/ramaze/trinity.rb +3 -3
- data/lib/ramaze/trinity/request.rb +41 -23
- data/lib/ramaze/trinity/response.rb +10 -5
- data/lib/ramaze/trinity/session.rb +17 -3
- data/lib/ramaze/version.rb +2 -2
- data/rake_tasks/conf.rake +56 -0
- data/rake_tasks/gem.rake +44 -0
- data/rake_tasks/maintaince.rake +187 -0
- data/spec/all.rb +32 -0
- data/spec/examples/caching.rb +19 -0
- data/spec/examples/element.rb +15 -0
- data/spec/examples/hello.rb +11 -0
- data/spec/examples/simple.rb +51 -0
- data/spec/examples/templates/template_amrita2.rb +14 -0
- data/spec/examples/templates/template_erubis.rb +21 -0
- data/spec/examples/templates/template_ezamar.rb +22 -0
- data/spec/examples/templates/template_haml.rb +23 -0
- data/spec/examples/templates/template_liquid.rb +24 -0
- data/spec/examples/templates/template_markaby.rb +21 -0
- data/spec/helper.rb +81 -0
- data/spec/{spec_helper_context.rb → helper/context.rb} +1 -1
- data/spec/helper/layout.rb +55 -0
- data/spec/helper/mock_http.rb +66 -0
- data/spec/{spec_helper_requester.rb → helper/requester.rb} +0 -6
- data/spec/{spec_helper_simple_http.rb → helper/simple_http.rb} +57 -57
- data/spec/helper/wrap.rb +193 -0
- data/spec/{adapter_spec.rb → ramaze/adapter.rb} +7 -5
- data/spec/{tc_adapter_mongrel.rb → ramaze/adapter/mongrel.rb} +2 -2
- data/spec/{tc_adapter_webrick.rb → ramaze/adapter/webrick.rb} +2 -2
- data/spec/{tc_cache.rb → ramaze/cache.rb} +16 -16
- data/spec/ramaze/conf/locale_de.yaml +6 -0
- data/spec/ramaze/conf/locale_en.yaml +6 -0
- data/spec/ramaze/controller.rb +184 -0
- data/spec/ramaze/controller/template/greet.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +54 -0
- data/spec/ramaze/dependencies.rb +16 -0
- data/spec/{tc_element.rb → ramaze/element.rb} +21 -19
- data/spec/ramaze/error.rb +64 -0
- data/spec/{tc_gestalt.rb → ramaze/gestalt.rb} +10 -10
- data/spec/{tc_global.rb → ramaze/global.rb} +7 -7
- data/spec/{tc_helper_aspect.rb → ramaze/helper/aspect.rb} +22 -14
- data/spec/{tc_helper_auth.rb → ramaze/helper/auth.rb} +9 -7
- data/spec/{tc_helper_cache.rb → ramaze/helper/cache.rb} +14 -24
- data/spec/{tc_helper_feed.rb → ramaze/helper/feed.rb} +12 -12
- data/spec/ramaze/helper/file.rb +17 -0
- data/spec/{tc_helper_flash.rb → ramaze/helper/flash.rb} +16 -17
- data/spec/{tc_helper_form.rb → ramaze/helper/form.rb} +25 -26
- data/spec/{tc_helper_link.rb → ramaze/helper/link.rb} +9 -9
- data/spec/{tc_helper_redirect.rb → ramaze/helper/redirect.rb} +11 -10
- data/spec/{tc_helper_stack.rb → ramaze/helper/stack.rb} +10 -11
- data/spec/ramaze/inform/informer.rb +40 -0
- data/spec/ramaze/inform/syslog.rb +10 -0
- data/spec/ramaze/localize.rb +40 -0
- data/spec/ramaze/morpher.rb +82 -0
- data/spec/ramaze/params.rb +124 -0
- data/spec/{public → ramaze/public}/error404.xhtml +0 -0
- data/spec/{public → ramaze/public}/favicon.ico +0 -0
- data/spec/{public → ramaze/public}/ramaze.png +0 -0
- data/spec/{public → ramaze/public}/test_download.css +0 -0
- data/spec/ramaze/request.rb +129 -0
- data/spec/{tc_request_mongrel.rb → ramaze/request/mongrel.rb} +2 -2
- data/spec/{tc_request_webrick.rb → ramaze/request/webrick.rb} +1 -1
- data/spec/{tc_session.rb → ramaze/session.rb} +18 -18
- data/spec/{tc_store.rb → ramaze/store/default.rb} +10 -10
- data/spec/{tc_store_yaml.rb → ramaze/store/yaml.rb} +9 -9
- data/spec/ramaze/template.rb +86 -0
- data/spec/{tc_template_amrita2.rb → ramaze/template/amrita2.rb} +5 -5
- data/spec/{template → ramaze/template}/amrita2/data.amrita +0 -0
- data/spec/{template → ramaze/template}/amrita2/index.amrita +0 -0
- data/spec/{template → ramaze/template}/amrita2/sum.amrita +0 -0
- data/spec/{tc_template_erubis.rb → ramaze/template/erubis.rb} +9 -9
- data/spec/{template → ramaze/template}/erubis/sum.rhtml +0 -0
- data/spec/ramaze/template/ezamar.rb +62 -0
- data/spec/{template → ramaze/template}/ezamar/another/long/action.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/combined.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/file_only.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/index.zmr +0 -0
- data/spec/ramaze/template/ezamar/nested.zmr +1 -0
- data/spec/{template → ramaze/template}/ezamar/some__long__action.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/sum.zmr +0 -0
- data/spec/{tc_template_haml.rb → ramaze/template/haml.rb} +7 -7
- data/spec/{template → ramaze/template}/haml/index.haml +0 -0
- data/spec/{template → ramaze/template}/haml/with_vars.haml +0 -0
- data/spec/{tc_template_liquid.rb → ramaze/template/liquid.rb} +7 -7
- data/spec/{template → ramaze/template}/liquid/index.liquid +0 -0
- data/spec/{template → ramaze/template}/liquid/products.liquid +0 -0
- data/spec/ramaze/template/markaby.rb +59 -0
- data/spec/{template → ramaze/template}/markaby/external.mab +0 -0
- data/spec/{template → ramaze/template}/markaby/sum.mab +0 -0
- data/spec/ramaze/template/ramaze/external.test +1 -0
- data/spec/{tc_tidy.rb → ramaze/tidy.rb} +3 -3
- metadata +145 -81
- data/examples/blog/public/screen.css +0 -106
- data/examples/blog/src/element.rb +0 -58
- data/examples/blog/template/view.xhtml +0 -15
- data/examples/blog/test/tc_entry.rb +0 -18
- data/lib/proto/public/404.jpg +0 -0
- data/spec/request_tc_helper.rb +0 -135
- data/spec/spec_all.rb +0 -118
- data/spec/spec_helper.rb +0 -66
- data/spec/tc_controller.rb +0 -49
- data/spec/tc_dependencies.rb +0 -13
- data/spec/tc_error.rb +0 -43
- data/spec/tc_morpher.rb +0 -88
- data/spec/tc_params.rb +0 -125
- data/spec/tc_template_ezamar.rb +0 -64
- data/spec/tc_template_markaby.rb +0 -72
- data/spec/template/ezamar/nested.zmr +0 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/
|
4
|
+
require 'spec/helper'
|
5
5
|
|
6
6
|
class TCAdapterController < Ramaze::Controller
|
7
7
|
def index
|
@@ -9,12 +9,14 @@ class TCAdapterController < Ramaze::Controller
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
describe "Adapter" do
|
13
13
|
ramaze ramaze_options.merge( :port => '7007..7010', :mapping => {'/' => TCAdapterController} )
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
describe "multiple" do
|
16
|
+
it "simple request" do
|
17
|
+
browser do
|
18
|
+
get('/').should == "The index"
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/
|
4
|
+
require 'spec/helper'
|
5
5
|
|
6
6
|
testcase_requires 'mongrel'
|
7
7
|
|
@@ -9,4 +9,4 @@ def ramaze_options
|
|
9
9
|
{ :adapter => :mongrel }
|
10
10
|
end
|
11
11
|
|
12
|
-
require 'spec/
|
12
|
+
require 'spec/ramaze/adapter'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/
|
4
|
+
require 'spec/helper'
|
5
5
|
|
6
6
|
testcase_requires 'webrick'
|
7
7
|
|
@@ -9,4 +9,4 @@ def ramaze_options
|
|
9
9
|
{ :adapter => :webrick }
|
10
10
|
end
|
11
11
|
|
12
|
-
require 'spec/
|
12
|
+
require 'spec/ramaze/adapter'
|
@@ -1,74 +1,74 @@
|
|
1
1
|
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/
|
4
|
+
require 'spec/helper'
|
5
5
|
|
6
|
-
|
6
|
+
describe "MemoryCache" do
|
7
7
|
cache = Ramaze::MemoryCache.new
|
8
8
|
|
9
|
-
|
9
|
+
it "delete" do
|
10
10
|
cache.delete(:one)
|
11
11
|
cache.delete(:two)
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
it "set keys" do
|
15
15
|
(cache[:one] = 'eins').should == "eins"
|
16
16
|
(cache[:two] = 'zwei').should == "zwei"
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
it "read keys" do
|
20
20
|
cache[:one].should == 'eins'
|
21
21
|
cache[:two].should == 'zwei'
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
it "values_at" do
|
25
25
|
cache.values_at(:one, :two).should == %w[eins zwei]
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
describe "YAMLStoreCache" do
|
30
30
|
cache = Ramaze::YAMLStoreCache.new
|
31
31
|
|
32
|
-
|
32
|
+
it "delete" do
|
33
33
|
cache.delete(:one)
|
34
34
|
cache.delete(:two)
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
it "set keys" do
|
38
38
|
(cache[:one] = 'eins').should == "eins"
|
39
39
|
(cache[:two] = 'zwei').should == "zwei"
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
it "read keys" do
|
43
43
|
cache[:one].should == 'eins'
|
44
44
|
cache[:two].should == 'zwei'
|
45
45
|
end
|
46
46
|
|
47
|
-
|
47
|
+
it "values_at" do
|
48
48
|
cache.values_at(:one, :two).should == %w[eins zwei]
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
begin
|
53
|
-
|
53
|
+
describe "MemcachedCache" do
|
54
54
|
cache = Ramaze::MemcachedCache.new
|
55
55
|
|
56
|
-
|
56
|
+
it "delete" do
|
57
57
|
cache.delete(:one)
|
58
58
|
cache.delete(:two)
|
59
59
|
end
|
60
60
|
|
61
|
-
|
61
|
+
it "set keys" do
|
62
62
|
(cache[:one] = 'eins').should == "eins"
|
63
63
|
(cache[:two] = 'zwei').should == "zwei"
|
64
64
|
end
|
65
65
|
|
66
|
-
|
66
|
+
it "read keys" do
|
67
67
|
cache[:one].should == 'eins'
|
68
68
|
cache[:two].should == 'zwei'
|
69
69
|
end
|
70
70
|
|
71
|
-
|
71
|
+
it "values_at" do
|
72
72
|
cache.values_at(:one, :two).should == %w[eins zwei]
|
73
73
|
end
|
74
74
|
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'spec/helper'
|
5
|
+
|
6
|
+
class TCControllerController < Ramaze::Controller
|
7
|
+
map '/'
|
8
|
+
trait :template_root => 'spec/ramaze/template/ezamar'
|
9
|
+
|
10
|
+
def index
|
11
|
+
@text = "World"
|
12
|
+
end
|
13
|
+
|
14
|
+
def sum first, second
|
15
|
+
@num1, @num2 = first.to_i, second.to_i
|
16
|
+
end
|
17
|
+
|
18
|
+
def some__long__action
|
19
|
+
end
|
20
|
+
|
21
|
+
def another__long__action
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def test_private
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "Controller" do
|
31
|
+
ramaze :error_page => false
|
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
|
133
|
+
end
|
134
|
+
|
135
|
+
describe 'resolve' do
|
136
|
+
def resolve(path)
|
137
|
+
TCControllerController.resolve(path)
|
138
|
+
end
|
139
|
+
|
140
|
+
it '/' do
|
141
|
+
resolve('/').last.should ==
|
142
|
+
Ramaze::Action.new('index', [],'spec/ramaze/template/ezamar/index.zmr')
|
143
|
+
end
|
144
|
+
|
145
|
+
it '/sum/1/2' do
|
146
|
+
resolve('/sum/1/2').last.should ==
|
147
|
+
Ramaze::Action.new('sum', ['1', '2'],'spec/ramaze/template/ezamar/sum.zmr')
|
148
|
+
end
|
149
|
+
|
150
|
+
it '/another/long/action' do
|
151
|
+
resolve('/another/long/action').last.should ==
|
152
|
+
Ramaze::Action.new('another__long__action', [], 'spec/ramaze/template/ezamar/another/long/action.zmr')
|
153
|
+
end
|
154
|
+
it '/some/long/action' do
|
155
|
+
resolve('/some/long/action').last.should ==
|
156
|
+
Ramaze::Action.new('some__long__action', [], 'spec/ramaze/template/ezamar/some__long__action.zmr')
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
it "simple request to index" do
|
161
|
+
get('/').body.should == 'Hello, World!'
|
162
|
+
end
|
163
|
+
|
164
|
+
it "summing two values" do
|
165
|
+
get('/sum/1/2').body.should == '3'
|
166
|
+
end
|
167
|
+
|
168
|
+
it "double underscore in templates" do
|
169
|
+
get('/some/long/action').body.should == 'some long action'
|
170
|
+
get('/another/long/action').body.should == 'another long action'
|
171
|
+
end
|
172
|
+
|
173
|
+
describe "should not respond to private methods" do
|
174
|
+
TCControllerController.private_methods.sort.each do |action|
|
175
|
+
next if action =~ /\?$/ or action == '`'
|
176
|
+
it action do
|
177
|
+
path = "/#{action}"
|
178
|
+
response = get(path)
|
179
|
+
response.body.should =~ %r(No Action found for `#{path}' on TCControllerControlle)
|
180
|
+
response.status.should == 404
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<html>#{@greet}</html>
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'spec/helper'
|
5
|
+
|
6
|
+
class MainController < Ramaze::Controller
|
7
|
+
trait :template_root => "#{File.expand_path(File.dirname(__FILE__))}/template"
|
8
|
+
|
9
|
+
def greet(type, message = "Message")
|
10
|
+
@greet = "#{type} : #{message}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class OtherController < MainController
|
15
|
+
trait :template_root => "#{File.expand_path(File.dirname(__FILE__))}/template/other"
|
16
|
+
|
17
|
+
def greet__mom(message = "Moms are cool!")
|
18
|
+
greet('Mom', message)
|
19
|
+
end
|
20
|
+
|
21
|
+
trait :greet__mom_template => '/greet'
|
22
|
+
|
23
|
+
def partial_stuff
|
24
|
+
render_partial('/greet/the/world', :foo => :bar)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Ramaze::Controller
|
29
|
+
private
|
30
|
+
|
31
|
+
def render_partial(url, options = {})
|
32
|
+
body = Ramaze::Controller.handle(url)
|
33
|
+
body
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "Testing Template overriding" do
|
38
|
+
ramaze(:mapping => {'/' => MainController, '/other' => OtherController})
|
39
|
+
|
40
|
+
it "simple request to greet" do
|
41
|
+
get('/greet/asdf').body.should == '<html>asdf : Message</html>'
|
42
|
+
end
|
43
|
+
|
44
|
+
it "referencing template from MainController" do
|
45
|
+
get('/other/greet/mom').body.should == '<html>Mom : Moms are cool!</html>'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "render_partial" do
|
50
|
+
it 'greet' do
|
51
|
+
result = get('/other/partial_stuff')
|
52
|
+
result.body.should == '<html>the : world</html>'
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'spec/helper'
|
5
|
+
|
6
|
+
testcase_requires 'rubygems'
|
7
|
+
|
8
|
+
describe "dependencies" do
|
9
|
+
it "no gems" do
|
10
|
+
# rspec, systemu and syntax (loaded by rspec since 0.9)
|
11
|
+
# are used for testing
|
12
|
+
regex = /rspec|rack|systemu|syntax/
|
13
|
+
gems = $:.grep(/gems/).reject{|g| g =~ regex}
|
14
|
+
gems.should == []
|
15
|
+
end
|
16
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/
|
4
|
+
require 'spec/helper'
|
5
5
|
|
6
6
|
class TCElementController < Ramaze::Controller
|
7
7
|
trait :engine => Ramaze::Template::Ezamar
|
@@ -46,7 +46,8 @@ end
|
|
46
46
|
|
47
47
|
class PageWithParams < Ezamar::Element
|
48
48
|
def render
|
49
|
-
@
|
49
|
+
ivs = (instance_variables - ['@content'])
|
50
|
+
ivs.inject({}){|s,v| s.merge(v => instance_variable_get(v)) }.inspect
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
@@ -58,44 +59,45 @@ end
|
|
58
59
|
|
59
60
|
class PageLittleWithParams < Ezamar::Element
|
60
61
|
def render
|
61
|
-
@
|
62
|
+
ivs = (instance_variables - ['@content'])
|
63
|
+
ivs.inject({}){|s,v| s.merge(v => instance_variable_get(v)) }.inspect
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
67
|
class PageWithTemplating < Ezamar::Element
|
66
68
|
def render
|
67
|
-
(1..@
|
69
|
+
(1..@times).to_a.join(', ')
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
71
|
-
|
73
|
+
describe "Element" do
|
72
74
|
ramaze(:mapping => {'/' => TCElementController})
|
73
75
|
|
74
|
-
|
75
|
-
get('/').should == "The index"
|
76
|
+
it "simple request" do
|
77
|
+
get('/').body.should == "The index"
|
76
78
|
end
|
77
79
|
|
78
|
-
|
79
|
-
get('/elementy').should == "<wrap> The index </wrap>"
|
80
|
+
it "with element" do
|
81
|
+
get('/elementy').body.should == "<wrap> The index </wrap>"
|
80
82
|
end
|
81
83
|
|
82
|
-
|
83
|
-
get('/nested').should == "<wrap> some stuff <wrap> The index </wrap> more stuff </wrap>"
|
84
|
+
it "nested element" do
|
85
|
+
get('/nested').body.should == "<wrap> some stuff <wrap> The index </wrap> more stuff </wrap>"
|
84
86
|
end
|
85
87
|
|
86
|
-
|
87
|
-
get('/with_params/one/two').should == {'one' => 'two'}.inspect
|
88
|
+
it "with_params" do
|
89
|
+
get('/with_params/one/two').body.should == {'@one' => 'two'}.inspect
|
88
90
|
end
|
89
91
|
|
90
|
-
|
91
|
-
get('/little').should == 'little'
|
92
|
+
it "little" do
|
93
|
+
get('/little').body.should == 'little'
|
92
94
|
end
|
93
95
|
|
94
|
-
|
95
|
-
get('/little_params/one/eins').should == {'one' => 'eins'}.inspect
|
96
|
+
it "little params" do
|
97
|
+
get('/little_params/one/eins').body.should == {'@one' => 'eins'}.inspect
|
96
98
|
end
|
97
99
|
|
98
|
-
|
99
|
-
get('/templating/10').should == (1..10).to_a.join(', ')
|
100
|
+
it "templating" do
|
101
|
+
get('/templating/10').body.should == (1..10).to_a.join(', ')
|
100
102
|
end
|
101
103
|
end
|