ramaze 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +26 -6
- data/bin/ramaze +8 -1
- data/doc/AUTHORS +13 -11
- data/doc/CHANGELOG +472 -13
- data/doc/LEGAL +22 -0
- data/doc/README +1 -4
- data/doc/TODO +7 -2
- data/doc/changes.txt +472 -13
- data/doc/changes.xml +472 -13
- data/doc/meta/announcement.txt +21 -23
- data/doc/readme_chunks/appendix.txt +0 -3
- data/doc/readme_chunks/features.txt +1 -1
- data/examples/auth/auth.rb +49 -0
- data/examples/auth/template/layout.haml +20 -0
- data/examples/auth/template/login.haml +16 -0
- data/examples/blog/spec/blog.rb +1 -0
- data/examples/caching.rb +5 -6
- data/examples/css.rb +37 -0
- data/examples/layout.rb +3 -17
- data/examples/simple_auth.rb +23 -0
- data/examples/sourceview/public/images/file.gif +0 -0
- data/examples/sourceview/public/images/folder.gif +0 -0
- data/examples/sourceview/public/images/tv-collapsable-last.gif +0 -0
- data/examples/sourceview/public/images/tv-collapsable.gif +0 -0
- data/examples/sourceview/public/images/tv-expandable-last.gif +0 -0
- data/examples/sourceview/public/images/tv-expandable.gif +0 -0
- data/examples/sourceview/public/images/tv-item-last.gif +0 -0
- data/examples/sourceview/public/images/tv-item.gif +0 -0
- data/examples/sourceview/public/jquery.js +11 -0
- data/examples/sourceview/public/jquery.treeview.css +47 -0
- data/examples/sourceview/public/jquery.treeview.js +223 -0
- data/examples/sourceview/public/sourceview.js +16 -0
- data/examples/sourceview/sourceview.rb +74 -0
- data/examples/sourceview/template/index.haml +43 -0
- data/examples/templates/template/external.nag +28 -0
- data/examples/templates/template/external.xsl +57 -0
- data/examples/templates/template_amrita2.rb +2 -4
- data/examples/templates/template_erubis.rb +1 -1
- data/examples/templates/template_haml.rb +1 -1
- data/examples/templates/template_liquid.rb +2 -4
- data/examples/templates/template_markaby.rb +2 -4
- data/examples/templates/template_nagoro.rb +53 -0
- data/examples/templates/template_remarkably.rb +2 -4
- data/examples/templates/template_xslt.rb +52 -0
- data/examples/whywiki/spec/whywiki.rb +63 -0
- data/examples/whywiki/start.rb +11 -13
- data/examples/whywiki/template/edit.xhtml +3 -3
- data/examples/whywiki/template/show.xhtml +5 -8
- data/examples/wikore/spec/wikore.rb +115 -0
- data/examples/wikore/src/controller.rb +81 -0
- data/examples/wikore/src/model.rb +51 -0
- data/examples/wikore/start.rb +6 -0
- data/examples/wikore/template/index.xhtml +8 -0
- data/examples/wiktacular/spec/wiktacular.rb +1 -0
- data/examples/wiktacular/src/controller.rb +1 -1
- data/lib/ramaze.rb +6 -3
- data/lib/ramaze/action.rb +2 -13
- data/lib/ramaze/action/render.rb +36 -18
- data/lib/ramaze/adapter.rb +1 -1
- data/lib/ramaze/adapter/cgi.rb +0 -3
- data/lib/ramaze/adapter/evented_mongrel.rb +7 -0
- data/lib/ramaze/adapter/mongrel.rb +4 -13
- data/lib/ramaze/adapter/swiftiplied_mongrel.rb +7 -0
- data/lib/ramaze/cache.rb +12 -7
- data/lib/ramaze/contrib.rb +22 -0
- data/lib/ramaze/contrib/auto_params.rb +128 -0
- data/lib/ramaze/contrib/auto_params/get_args.rb +56 -0
- data/lib/ramaze/contrib/gzip_filter.rb +57 -0
- data/lib/ramaze/contrib/route.rb +40 -0
- data/lib/ramaze/contrib/sequel/fill.rb +12 -0
- data/lib/ramaze/controller.rb +17 -6
- data/lib/ramaze/controller/resolve.rb +51 -14
- data/lib/ramaze/dispatcher.rb +15 -13
- data/lib/ramaze/dispatcher/action.rb +4 -3
- data/lib/ramaze/dispatcher/directory.rb +3 -3
- data/lib/ramaze/dispatcher/error.rb +1 -1
- data/lib/ramaze/dispatcher/file.rb +17 -6
- data/lib/ramaze/error.rb +3 -0
- data/lib/ramaze/gestalt.rb +28 -8
- data/lib/ramaze/global.rb +26 -6
- data/lib/ramaze/global/globalstruct.rb +31 -6
- data/lib/ramaze/helper.rb +2 -1
- data/lib/ramaze/helper/aspect.rb +2 -2
- data/lib/ramaze/helper/auth.rb +6 -9
- data/lib/ramaze/helper/cache.rb +89 -9
- data/lib/ramaze/helper/cgi.rb +2 -2
- data/lib/ramaze/helper/formatting.rb +44 -0
- data/lib/ramaze/helper/link.rb +7 -5
- data/lib/ramaze/helper/partial.rb +6 -4
- data/lib/ramaze/helper/redirect.rb +24 -9
- data/lib/ramaze/helper/stack.rb +6 -1
- data/lib/ramaze/inform/growl.rb +1 -1
- data/lib/ramaze/inform/informer.rb +2 -1
- data/lib/ramaze/inform/informing.rb +6 -0
- data/lib/ramaze/inform/syslog.rb +1 -0
- data/lib/ramaze/snippets/array/put_within.rb +24 -0
- data/lib/ramaze/snippets/dictionary.rb +499 -0
- data/lib/ramaze/snippets/numeric/filesize_format.rb +19 -0
- data/lib/ramaze/snippets/ordered_set.rb +31 -0
- data/lib/ramaze/snippets/string/DIVIDE.rb +1 -1
- data/lib/ramaze/snippets/string/snake_case.rb +1 -1
- data/lib/ramaze/snippets/struct/values_at.rb +5 -1
- data/lib/ramaze/snippets/thread/into.rb +25 -0
- data/lib/ramaze/sourcereload.rb +39 -19
- data/lib/ramaze/spec/helper.rb +4 -1
- data/lib/ramaze/spec/helper/{context.rb → browser.rb} +3 -0
- data/lib/ramaze/spec/helper/layout.rb +3 -0
- data/lib/ramaze/spec/helper/minimal.rb +3 -0
- data/lib/ramaze/spec/helper/mock_http.rb +8 -5
- data/lib/ramaze/spec/helper/requester.rb +4 -1
- data/lib/ramaze/spec/helper/wrap.rb +15 -7
- data/lib/ramaze/template.rb +5 -1
- data/lib/ramaze/template/ezamar/engine.rb +2 -3
- data/lib/ramaze/template/ezamar/morpher.rb +26 -45
- data/lib/ramaze/template/nagoro.rb +53 -0
- data/lib/ramaze/template/none.rb +14 -0
- data/lib/ramaze/template/xslt.rb +96 -0
- data/lib/ramaze/tool.rb +0 -1
- data/lib/ramaze/tool/localize.rb +7 -2
- data/lib/ramaze/trinity/request.rb +1 -0
- data/lib/ramaze/trinity/session.rb +3 -3
- data/lib/ramaze/version.rb +2 -2
- data/rake_tasks/conf.rake +1 -2
- data/rake_tasks/{maintaince.rake → maintenance.rake} +25 -17
- data/spec/contrib/auto_params.rb +97 -0
- data/spec/contrib/route.rb +60 -0
- data/spec/contrib/sequel/fill.rb +46 -0
- data/spec/examples/caching.rb +1 -2
- data/spec/examples/css.rb +12 -0
- data/spec/examples/element.rb +0 -1
- data/spec/examples/hello.rb +0 -1
- data/spec/examples/simple.rb +0 -1
- data/spec/helper.rb +3 -2
- data/spec/ramaze/action/cache.rb +24 -7
- data/spec/ramaze/action/layout.rb +19 -11
- data/spec/ramaze/action/template/sub/sub_wrapper.xhtml +1 -0
- data/spec/ramaze/controller.rb +11 -0
- data/spec/ramaze/controller/template_resolving.rb +28 -27
- data/spec/ramaze/dispatcher.rb +32 -0
- data/spec/ramaze/dispatcher/directory.rb +2 -1
- data/spec/ramaze/element.rb +1 -1
- data/spec/ramaze/gestalt.rb +28 -0
- data/spec/ramaze/helper/aspect.rb +14 -3
- data/spec/ramaze/helper/cache.rb +78 -13
- data/spec/ramaze/helper/formatting.rb +20 -0
- data/spec/ramaze/helper/link.rb +2 -0
- data/spec/ramaze/helper/partial.rb +12 -1
- data/spec/ramaze/helper/redirect.rb +44 -8
- data/spec/ramaze/helper/stack.rb +3 -3
- data/spec/ramaze/helper/template/loop.xhtml +3 -0
- data/spec/ramaze/helper/template/num.xhtml +1 -0
- data/spec/ramaze/helper/template/recursive.xhtml +8 -0
- data/spec/ramaze/morpher.rb +25 -6
- data/spec/ramaze/params.rb +6 -2
- data/spec/ramaze/request.rb +5 -2
- data/spec/ramaze/session.rb +19 -0
- data/spec/ramaze/template.rb +2 -2
- data/spec/ramaze/template/amrita2.rb +2 -2
- data/spec/ramaze/template/erubis.rb +2 -2
- data/spec/ramaze/template/ezamar.rb +6 -3
- data/spec/ramaze/template/haml.rb +3 -3
- data/spec/ramaze/template/liquid.rb +1 -1
- data/spec/ramaze/template/markaby.rb +1 -1
- data/spec/ramaze/template/nagoro.rb +65 -0
- data/spec/ramaze/template/nagoro/another/long/action.nag +1 -0
- data/spec/ramaze/template/nagoro/combined.nag +1 -0
- data/spec/ramaze/template/nagoro/file_only.nag +1 -0
- data/spec/ramaze/template/nagoro/index.nag +1 -0
- data/spec/ramaze/template/nagoro/nested.nag +1 -0
- data/spec/ramaze/template/nagoro/some__long__action.nag +1 -0
- data/spec/ramaze/template/nagoro/sum.nag +1 -0
- data/spec/ramaze/template/remarkably.rb +1 -1
- data/spec/ramaze/template/sass.rb +1 -1
- data/spec/ramaze/template/xslt.rb +93 -0
- data/spec/ramaze/template/xslt/concat_words.xsl +16 -0
- data/spec/ramaze/template/xslt/index.xsl +14 -0
- data/spec/ramaze/template/xslt/products.xsl +32 -0
- data/spec/ramaze/template/xslt/ruby_version.xsl +14 -0
- data/spec/snippets/array/put_within.rb +32 -0
- data/spec/snippets/numeric/filesize_format.rb +12 -0
- data/spec/snippets/ordered_set.rb +56 -0
- data/spec/snippets/ramaze/caller_lines.rb +6 -3
- data/spec/snippets/string/snake_case.rb +3 -0
- metadata +118 -22
- data/doc/README.html +0 -737
- data/examples/fcgi.rb +0 -13
- data/lib/ramaze/snippets/numeric/human_readable_filesize_format.rb +0 -33
- data/lib/ramaze/tool/tidy.rb +0 -104
- data/spec/ramaze/controller/template/edit.xhtml +0 -1
- data/spec/ramaze/controller/template/edit/content.xhtml +0 -1
- data/spec/ramaze/tidy.rb +0 -12
- data/spec/snippets/numeric/human_readable_filesize_format.rb +0 -11
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
require 'ramaze/contrib'
|
4
|
+
|
5
|
+
testcase_requires 'sequel', 'sequel/sqlite'
|
6
|
+
|
7
|
+
DB = Sequel('sqlite:/')
|
8
|
+
|
9
|
+
require 'ramaze/contrib/sequel/fill'
|
10
|
+
|
11
|
+
class Person < Sequel::Model(:person)
|
12
|
+
set_schema do
|
13
|
+
primary_key :id
|
14
|
+
text :name
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Person.create_table!
|
19
|
+
|
20
|
+
class MainController < Ramaze::Controller
|
21
|
+
def index
|
22
|
+
'Hello, World!'
|
23
|
+
end
|
24
|
+
|
25
|
+
def insert
|
26
|
+
person = Person.fill
|
27
|
+
person.save
|
28
|
+
end
|
29
|
+
|
30
|
+
def show id
|
31
|
+
Person[id.to_i].name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'Route' do
|
36
|
+
before :all do
|
37
|
+
ramaze
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should fill values from current request' do
|
41
|
+
insert = get('/insert', 'name' => 'manveru')
|
42
|
+
insert.status.should == 200
|
43
|
+
person = get('/show/1')
|
44
|
+
person.body.should == 'manveru'
|
45
|
+
end
|
46
|
+
end
|
data/spec/examples/caching.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
require 'examples/css'
|
3
|
+
|
4
|
+
describe 'CSSController' do
|
5
|
+
ramaze
|
6
|
+
|
7
|
+
def req(path) r = get(path); [r.content_type, r.body] end
|
8
|
+
|
9
|
+
it 'should cache generated css' do
|
10
|
+
lambda{ req('/css/style.css') }.should_not change{ req('/css/style.css') }
|
11
|
+
end
|
12
|
+
end
|
data/spec/examples/element.rb
CHANGED
data/spec/examples/hello.rb
CHANGED
data/spec/examples/simple.rb
CHANGED
data/spec/helper.rb
CHANGED
data/spec/ramaze/action/cache.rb
CHANGED
@@ -7,22 +7,39 @@ class TCActionCache < Ramaze::Controller
|
|
7
7
|
def index
|
8
8
|
rand
|
9
9
|
end
|
10
|
+
cache :index
|
11
|
+
end
|
12
|
+
|
13
|
+
class TCOtherCache < Ramaze::Controller
|
14
|
+
map '/other'
|
15
|
+
helper :cache
|
10
16
|
|
11
|
-
|
17
|
+
def index
|
18
|
+
rand
|
19
|
+
end
|
20
|
+
cache :index
|
12
21
|
end
|
13
22
|
|
14
23
|
describe 'Action rendering' do
|
15
24
|
before :all do
|
16
25
|
@public_root = __DIR__ / :public
|
17
26
|
FileUtils.mkdir_p @public_root
|
18
|
-
ramaze :
|
27
|
+
ramaze :file_cache => true
|
19
28
|
end
|
20
29
|
|
21
|
-
|
22
|
-
|
30
|
+
def req(path) r = get(path); [r.content_type, r.body] end
|
31
|
+
|
32
|
+
it 'should cache to file' do
|
33
|
+
lambda{ req('/') }.should_not change{ req('/') }
|
34
|
+
File.file?(@public_root/'index').should be_true
|
23
35
|
end
|
24
36
|
|
25
|
-
it 'should
|
26
|
-
lambda{
|
37
|
+
it 'should create subdirs as needed' do
|
38
|
+
lambda{ req('/other') }.should_not change{ req('/other') }
|
39
|
+
File.file?(@public_root/'other'/'index').should be_true
|
27
40
|
end
|
28
|
-
|
41
|
+
|
42
|
+
after :all do
|
43
|
+
FileUtils.rm_rf @public_root
|
44
|
+
end
|
45
|
+
end
|
@@ -2,8 +2,7 @@ require 'spec/helper'
|
|
2
2
|
|
3
3
|
class TCActionLayout < Ramaze::Controller
|
4
4
|
map '/'
|
5
|
-
layout
|
6
|
-
template_root __DIR__ / :template
|
5
|
+
layout '/wrapper'
|
7
6
|
|
8
7
|
def wrapper
|
9
8
|
"<pre>#@content</pre>"
|
@@ -20,8 +19,8 @@ end
|
|
20
19
|
|
21
20
|
class TCActionOtherLayout < Ramaze::Controller
|
22
21
|
map '/other'
|
23
|
-
layout
|
24
|
-
template_root __DIR__
|
22
|
+
layout '/other_wrapper'
|
23
|
+
template_root __DIR__/:template
|
25
24
|
|
26
25
|
def index
|
27
26
|
"Others Hello"
|
@@ -30,8 +29,7 @@ end
|
|
30
29
|
|
31
30
|
class TCActionSingleLayout < Ramaze::Controller
|
32
31
|
map '/single'
|
33
|
-
|
34
|
-
layout :single_wrapper => :index
|
32
|
+
layout '/single_wrapper' => :index
|
35
33
|
|
36
34
|
def index
|
37
35
|
"Single Hello"
|
@@ -44,8 +42,7 @@ end
|
|
44
42
|
|
45
43
|
class TCActionDenyLayout < Ramaze::Controller
|
46
44
|
map '/deny'
|
47
|
-
|
48
|
-
layout :single_wrapper
|
45
|
+
layout '/single_wrapper'
|
49
46
|
deny_layout :without
|
50
47
|
|
51
48
|
def index
|
@@ -59,9 +56,7 @@ end
|
|
59
56
|
|
60
57
|
class TCActionMultiLayout < Ramaze::Controller
|
61
58
|
map '/multi'
|
62
|
-
|
63
|
-
layout :single_wrapper => [:index, :second]
|
64
|
-
p trait
|
59
|
+
layout '/single_wrapper' => [:index, :second]
|
65
60
|
|
66
61
|
def index
|
67
62
|
"Single Hello"
|
@@ -76,6 +71,15 @@ class TCActionMultiLayout < Ramaze::Controller
|
|
76
71
|
end
|
77
72
|
end
|
78
73
|
|
74
|
+
class TCActionSubLayout < Ramaze::Controller
|
75
|
+
map '/sub'
|
76
|
+
layout :sub_wrapper
|
77
|
+
|
78
|
+
def index
|
79
|
+
"Sub Hello"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
79
83
|
describe 'Action rendering' do
|
80
84
|
before :all do
|
81
85
|
ramaze
|
@@ -107,4 +111,8 @@ describe 'Action rendering' do
|
|
107
111
|
get('/multi/second').body.should == "<b>Second with layout</b>"
|
108
112
|
get('/multi/without').body.should == "Without wrapper"
|
109
113
|
end
|
114
|
+
|
115
|
+
it 'should apply relative layouts' do
|
116
|
+
get('/sub').body.should == "<h1>SubWrapper</h1>"
|
117
|
+
end
|
110
118
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>SubWrapper</h1>
|
data/spec/ramaze/controller.rb
CHANGED
@@ -151,4 +151,15 @@ describe "Controller" do
|
|
151
151
|
lambda{ resolve(path) }.should raise_error(Ramaze::Error::NoAction, message)
|
152
152
|
end
|
153
153
|
end
|
154
|
+
|
155
|
+
it 'should resolve correctly even if the action is cached already.' do
|
156
|
+
handle('/').should == 'Hello, World!'
|
157
|
+
handle('/').should == 'Hello, World!'
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'should remove invalid cached actions' do
|
161
|
+
handle('/').should == 'Hello, World!'
|
162
|
+
Ramaze::Cache.resolved['/'] = 'duh'
|
163
|
+
handle('/').should == 'Hello, World!'
|
164
|
+
end
|
154
165
|
end
|
@@ -4,7 +4,6 @@
|
|
4
4
|
require 'spec/helper'
|
5
5
|
|
6
6
|
class MainController < Ramaze::Controller
|
7
|
-
template_root __DIR__ / :template
|
8
7
|
|
9
8
|
def greet(type, message = "Message")
|
10
9
|
@greet = "#{type} : #{message}"
|
@@ -13,40 +12,41 @@ class MainController < Ramaze::Controller
|
|
13
12
|
def list
|
14
13
|
@obj = Ramaze::Action.current.method
|
15
14
|
end
|
15
|
+
|
16
16
|
alias_method :index, :list
|
17
17
|
template :index, 'list'
|
18
|
+
template :non_existant_method, :list
|
18
19
|
|
19
20
|
end
|
20
21
|
|
21
22
|
class OtherController < MainController
|
22
|
-
template_root __DIR__ / "template/other"
|
23
23
|
|
24
24
|
def greet__mom(message = "Moms are cool!")
|
25
25
|
greet('Mom', message)
|
26
26
|
end
|
27
27
|
template :greet__mom, MainController, :greet
|
28
28
|
|
29
|
-
def greet__other
|
29
|
+
def greet__other
|
30
30
|
@greet = "Other"
|
31
31
|
end
|
32
|
-
template :greet__other,
|
32
|
+
template :greet__other, :blah
|
33
33
|
|
34
|
-
def
|
35
|
-
|
34
|
+
def greet__another
|
35
|
+
@greet = "Another"
|
36
36
|
end
|
37
|
-
|
38
|
-
|
39
|
-
class Ramaze::Controller
|
40
|
-
private
|
37
|
+
template :greet__another, :greet__other
|
41
38
|
|
42
|
-
def
|
43
|
-
|
44
|
-
body
|
39
|
+
def greet__last
|
40
|
+
@greet = 'Last'
|
45
41
|
end
|
42
|
+
template :greet__last, 'greet/other'
|
43
|
+
|
46
44
|
end
|
47
45
|
|
48
46
|
describe "Testing Template overriding" do
|
49
|
-
|
47
|
+
before(:all) do
|
48
|
+
ramaze
|
49
|
+
end
|
50
50
|
|
51
51
|
it "simple request to greet" do
|
52
52
|
get('/greet/asdf').body.should == '<html>asdf : Message</html>'
|
@@ -56,23 +56,24 @@ describe "Testing Template overriding" do
|
|
56
56
|
get('/other/greet/mom').body.should == '<html>Mom : Moms are cool!</html>'
|
57
57
|
end
|
58
58
|
|
59
|
-
it "should
|
60
|
-
get('/other/greet/other
|
59
|
+
it "should treat template overrides as possible alternatives (only use if found)" do
|
60
|
+
get('/other/greet/other').body.should == '<html>Other: Other</html>'
|
61
61
|
end
|
62
62
|
|
63
|
-
it "
|
64
|
-
get('/
|
63
|
+
it "should accept template overrides given as symbols" do
|
64
|
+
get('/other/greet/another').body.should == '<html>Other: Another</html>'
|
65
|
+
end
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
response.body.should =~ %r(No Action found for `/non_existant_method' on MainController)
|
67
|
+
it "should accept template overrides given as strings" do
|
68
|
+
get('/other/greet/last').body.should == '<html>Other: Last</html>'
|
69
69
|
end
|
70
70
|
|
71
|
-
|
71
|
+
it "should set template for aliased :index action" do
|
72
|
+
get('/list').body.should == '<html>list</html>'
|
73
|
+
get('/index').body.should == '<html>index</html>'
|
74
|
+
end
|
72
75
|
|
73
|
-
|
74
|
-
|
75
|
-
result = get('/other/partial_stuff')
|
76
|
-
result.body.should == '<html>the : world</html>'
|
76
|
+
it "should use template overrides for non-existant actions" do
|
77
|
+
get('/non_existant_method').body.should == '<html></html>'
|
77
78
|
end
|
78
|
-
end
|
79
|
+
end
|
@@ -0,0 +1,32 @@
|
|
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 TCDispatcherController < Ramaze::Controller
|
7
|
+
map '/'
|
8
|
+
|
9
|
+
def index
|
10
|
+
"Hello, World!"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "Dispatcher" do
|
15
|
+
before :all do
|
16
|
+
ramaze :ignore => ['/favicon.ico', '/robots.txt'],
|
17
|
+
:ignore_body => 'File not found'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should resolve a normal request' do
|
21
|
+
page = get('/')
|
22
|
+
page.status.should == 200
|
23
|
+
page.body.should == 'Hello, World!'
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should ignore /foo.ico' do
|
27
|
+
Ramaze::Global.ignore = ['/foo.ico']
|
28
|
+
page = get('/foo.ico')
|
29
|
+
page.status.should == 404
|
30
|
+
page.body.should == 'File not found'
|
31
|
+
end
|
32
|
+
end
|
data/spec/ramaze/element.rb
CHANGED
data/spec/ramaze/gestalt.rb
CHANGED
@@ -6,6 +6,8 @@ require 'spec/helper'
|
|
6
6
|
testcase_requires 'ramaze/gestalt'
|
7
7
|
|
8
8
|
describe "Gestalt" do
|
9
|
+
# This is useful for any controller using Gestalt,
|
10
|
+
# should be made a MixIn somewhen.
|
9
11
|
def gestalt &block
|
10
12
|
Ramaze::Gestalt.new(&block).to_s
|
11
13
|
end
|
@@ -89,4 +91,30 @@ describe "Gestalt" do
|
|
89
91
|
end
|
90
92
|
}.should == '<table><tr><td>one</td><td>two</td><td>three</td></tr></table>'
|
91
93
|
end
|
94
|
+
|
95
|
+
it "children as parameters" do
|
96
|
+
gestalt {
|
97
|
+
a "Hello"
|
98
|
+
b(23, 5) { "1" }
|
99
|
+
c(42) {
|
100
|
+
d
|
101
|
+
}
|
102
|
+
e("f & g")
|
103
|
+
}.should == '<a>Hello</a><b>2351</b><c>42<d /></c><e>f & g</e>'
|
104
|
+
end
|
105
|
+
|
106
|
+
it "escapeable attributes" do
|
107
|
+
gestalt {
|
108
|
+
a(:href => "http://example.org/?a=one&b=two") {
|
109
|
+
"Click here"
|
110
|
+
}
|
111
|
+
}.should == '<a href="http://example.org/?a=one&b=two">Click here</a>'
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should accept symbols as attributes' do
|
115
|
+
input = gestalt{ input(:type => :text, :value => :one) }
|
116
|
+
|
117
|
+
input.should =~ /type="text"/
|
118
|
+
input.should =~ /value="one"/
|
119
|
+
end
|
92
120
|
end
|
@@ -7,7 +7,6 @@ class TCAspectController < Ramaze::Controller
|
|
7
7
|
map '/'
|
8
8
|
trait :foo => :bar
|
9
9
|
helper :aspect
|
10
|
-
template_root(__DIR__/:template)
|
11
10
|
|
12
11
|
def test_before() 'test before' end
|
13
12
|
before(:test_before){ '<aspect>' }
|
@@ -24,8 +23,8 @@ end
|
|
24
23
|
class TCAspectAllController < Ramaze::Controller
|
25
24
|
map '/all'
|
26
25
|
|
27
|
-
helper :aspect
|
28
|
-
template_root
|
26
|
+
helper :aspect, :partial
|
27
|
+
template_root __DIR__/:template
|
29
28
|
|
30
29
|
def test_all_first() 'first' end
|
31
30
|
def test_all_second() 'second' end
|
@@ -34,6 +33,10 @@ class TCAspectAllController < Ramaze::Controller
|
|
34
33
|
after_all{ '</pre>' }
|
35
34
|
|
36
35
|
def test_all_after() 'after' end
|
36
|
+
|
37
|
+
def layout() '<div>#@content</div>' end
|
38
|
+
template :loop_with_layout, :loop
|
39
|
+
layout :layout => [:loop_with_layout]
|
37
40
|
end
|
38
41
|
|
39
42
|
describe "AspectHelper" do
|
@@ -71,4 +74,12 @@ describe "AspectHelper" do
|
|
71
74
|
it 'should before_all and after_all for all defined actions' do
|
72
75
|
get('/all/test_all_after').body.should == '<pre>after</pre>'
|
73
76
|
end
|
77
|
+
|
78
|
+
it 'should not apply aspects to render_template' do
|
79
|
+
get('/all/loop').body.gsub(/\s/,'').should == '<pre>12345</pre>'
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should not apply aspects to layouts' do
|
83
|
+
get('/all/loop_with_layout').body.gsub(/\s/,'').should == '<div><pre>12345</pre></div>'
|
84
|
+
end
|
74
85
|
end
|