ramaze 0.3.5 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +5 -20
- data/bin/ramaze +0 -4
- data/doc/AUTHORS +5 -0
- data/doc/meta/announcement.txt +2 -1
- data/doc/tutorial/todolist.html +20 -21
- data/doc/tutorial/todolist.mkd +10 -9
- data/examples/blog/{src/controller.rb → controller/main.rb} +2 -0
- data/examples/blog/{src/model.rb → model/entry.rb} +0 -0
- data/examples/blog/spec/blog.rb +3 -3
- data/examples/blog/start.rb +2 -3
- data/examples/blog/view/edit.xhtml +17 -0
- data/examples/blog/view/index.xhtml +17 -0
- data/examples/blog/view/layout.xhtml +11 -0
- data/examples/blog/view/new.xhtml +16 -0
- data/examples/facebook.rb +15 -8
- data/examples/identity.rb +1 -1
- data/examples/memleak_detector.rb +1 -1
- data/examples/rammit/src/model.rb +1 -1
- data/examples/rapaste/controller/paste.rb +7 -7
- data/examples/rapaste/model/paste.rb +1 -3
- data/examples/rapaste/public/css/display.css +2 -1
- data/examples/rapaste/start.rb +2 -3
- data/examples/sourceview/sourceview.rb +1 -1
- data/examples/templates/template/external.tenjin +28 -0
- data/examples/templates/template_amrita2.rb +0 -3
- data/examples/templates/template_tenjin.rb +57 -0
- data/examples/todolist/spec/todolist.rb +13 -2
- data/examples/todolist/src/controller/main.rb +1 -1
- data/examples/todolist/template/index.xhtml +1 -1
- data/examples/wiktacular/spec/wiktacular.rb +18 -0
- data/examples/wiktacular/src/controller.rb +2 -2
- data/examples/wiktacular/src/model.rb +8 -2
- data/lib/proto/public/css/ramaze_error.css +4 -0
- data/lib/proto/public/dispatch.fcgi +11 -0
- data/lib/proto/spec/main.rb +1 -1
- data/lib/proto/start.ru +8 -0
- data/lib/proto/view/error.xhtml +2 -0
- data/lib/ramaze.rb +28 -5
- data/lib/ramaze/action.rb +9 -2
- data/lib/ramaze/action/render.rb +40 -24
- data/lib/ramaze/adapter.rb +10 -17
- data/lib/ramaze/adapter/base.rb +8 -12
- data/lib/ramaze/adapter/cgi.rb +14 -13
- data/lib/ramaze/adapter/ebb.rb +34 -0
- data/lib/ramaze/adapter/evented_mongrel.rb +1 -1
- data/lib/ramaze/adapter/fcgi.rb +14 -14
- data/lib/ramaze/adapter/lsws.rb +15 -11
- data/lib/ramaze/adapter/mongrel.rb +2 -1
- data/lib/ramaze/adapter/scgi.rb +24 -0
- data/lib/ramaze/adapter/swiftiplied_mongrel.rb +1 -1
- data/lib/ramaze/adapter/thin.rb +4 -5
- data/lib/ramaze/adapter/webrick.rb +5 -5
- data/lib/ramaze/cache.rb +1 -1
- data/lib/ramaze/cache/memcached.rb +1 -1
- data/lib/ramaze/contrib.rb +70 -10
- data/lib/ramaze/contrib/auto_params.rb +1 -1
- data/lib/ramaze/contrib/email.rb +15 -15
- data/lib/ramaze/contrib/facebook.rb +2 -2
- data/lib/ramaze/contrib/facebook/facebook.rb +7 -4
- data/lib/ramaze/contrib/file_cache.rb +65 -0
- data/lib/ramaze/contrib/gettext.rb +56 -55
- data/lib/ramaze/contrib/profiling.rb +36 -0
- data/lib/ramaze/contrib/sequel_cache.rb +92 -0
- data/lib/ramaze/controller.rb +80 -47
- data/lib/ramaze/controller/error.rb +10 -5
- data/lib/ramaze/controller/resolve.rb +36 -48
- data/lib/ramaze/current.rb +70 -0
- data/lib/ramaze/{trinity → current}/request.rb +62 -15
- data/lib/ramaze/current/response.rb +19 -0
- data/lib/ramaze/{trinity → current}/session.rb +32 -110
- data/lib/ramaze/current/session/flash.rb +67 -0
- data/lib/ramaze/current/session/hash.rb +65 -0
- data/lib/ramaze/dispatcher.rb +1 -28
- data/lib/ramaze/dispatcher/action.rb +6 -3
- data/lib/ramaze/dispatcher/directory.rb +1 -1
- data/lib/ramaze/dispatcher/error.rb +26 -5
- data/lib/ramaze/dispatcher/file.rb +13 -2
- data/lib/ramaze/gestalt.rb +3 -1
- data/lib/ramaze/global.rb +6 -3
- data/lib/ramaze/global/globalstruct.rb +3 -1
- data/lib/ramaze/helper.rb +66 -20
- data/lib/ramaze/helper/aspect.rb +25 -17
- data/lib/ramaze/helper/auth.rb +4 -3
- data/lib/ramaze/helper/cache.rb +5 -4
- data/lib/ramaze/helper/cgi.rb +11 -9
- data/lib/ramaze/helper/flash.rb +28 -3
- data/lib/ramaze/helper/formatting.rb +1 -3
- data/lib/ramaze/helper/identity.rb +2 -3
- data/lib/ramaze/helper/inform.rb +7 -6
- data/lib/ramaze/helper/link.rb +15 -17
- data/lib/ramaze/helper/markaby.rb +2 -4
- data/lib/ramaze/helper/maruku.rb +1 -1
- data/lib/ramaze/helper/nitroform.rb +4 -4
- data/lib/ramaze/helper/pager.rb +4 -6
- data/lib/ramaze/helper/partial.rb +24 -21
- data/lib/ramaze/helper/redirect.rb +8 -5
- data/lib/ramaze/helper/{file.rb → sendfile.rb} +1 -3
- data/lib/ramaze/helper/sequel.rb +1 -3
- data/lib/ramaze/helper/stack.rb +1 -3
- data/lib/ramaze/helper/tagz.rb +19 -0
- data/lib/ramaze/helper/user.rb +63 -0
- data/lib/ramaze/inform.rb +2 -24
- data/lib/ramaze/log.rb +28 -0
- data/lib/ramaze/{inform → log}/analogger.rb +3 -3
- data/lib/ramaze/{inform → log}/growl.rb +2 -2
- data/lib/ramaze/{inform → log}/hub.rb +4 -6
- data/lib/ramaze/{inform → log}/informer.rb +4 -4
- data/lib/ramaze/{inform → log}/knotify.rb +2 -2
- data/lib/ramaze/log/logger.rb +22 -0
- data/lib/ramaze/{inform/informing.rb → log/logging.rb} +16 -16
- data/lib/ramaze/{inform → log}/syslog.rb +0 -0
- data/lib/ramaze/{inform → log}/xosd.rb +2 -2
- data/lib/ramaze/route.rb +64 -36
- data/lib/ramaze/snippets/array/put_within.rb +13 -0
- data/lib/ramaze/snippets/binding/locals.rb +13 -0
- data/lib/ramaze/snippets/kernel/__dir__.rb +10 -8
- data/lib/ramaze/snippets/kernel/aquire.rb +1 -1
- data/lib/ramaze/snippets/kernel/constant.rb +1 -1
- data/lib/ramaze/snippets/object/pretty.rb +6 -0
- data/lib/ramaze/snippets/object/scope.rb +11 -0
- data/lib/ramaze/snippets/object/thread_accessor.rb +5 -0
- data/lib/ramaze/snippets/ordered_set.rb +1 -1
- data/lib/ramaze/snippets/proc/locals.rb +11 -0
- data/lib/ramaze/snippets/ramaze/thread_accessor.rb +44 -0
- data/lib/ramaze/snippets/string/esc.rb +29 -0
- data/lib/ramaze/snippets/string/start_with.rb +7 -0
- data/lib/ramaze/snippets/string/unindent.rb +6 -1
- data/lib/ramaze/snippets/struct/values_at.rb +1 -5
- data/lib/ramaze/sourcereload.rb +16 -14
- data/lib/ramaze/spec.rb +1 -0
- data/lib/ramaze/spec/helper.rb +11 -3
- data/lib/ramaze/spec/helper/browser.rb +25 -1
- data/lib/ramaze/spec/helper/pretty_output.rb +11 -11
- data/lib/ramaze/template.rb +5 -4
- data/lib/ramaze/template/amrita2.rb +2 -3
- data/lib/ramaze/template/ezamar/element.rb +2 -3
- data/lib/ramaze/template/ezamar/morpher.rb +1 -2
- data/lib/ramaze/template/ezamar/render_partial.rb +1 -1
- data/lib/ramaze/template/haml.rb +5 -2
- data/lib/ramaze/template/markaby.rb +2 -0
- data/lib/ramaze/template/tagz.rb +79 -0
- data/lib/ramaze/template/tenjin.rb +34 -0
- data/lib/ramaze/tool/create.rb +0 -3
- data/lib/ramaze/tool/localize.rb +107 -105
- data/lib/ramaze/tool/mime.rb +0 -2
- data/lib/ramaze/trinity.rb +1 -26
- data/lib/ramaze/version.rb +1 -1
- data/lib/vendor/bacon.rb +47 -41
- data/rake_tasks/conf.rake +18 -0
- data/rake_tasks/darcs.rake +5 -0
- data/rake_tasks/maintenance.rake +37 -24
- data/rake_tasks/spec.rake +1 -1
- data/spec/contrib/auto_params.rb +3 -1
- data/spec/contrib/profiling.rb +26 -0
- data/spec/examples/templates/template_redcloth.rb +1 -1
- data/spec/examples/templates/template_tenjin.rb +28 -0
- data/spec/helper.rb +0 -1
- data/spec/ramaze/action/layout.rb +28 -0
- data/spec/ramaze/controller/actionless_templates.rb +32 -0
- data/spec/ramaze/controller/template/other_wrapper.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +37 -0
- data/spec/ramaze/{trinity → current}/request.rb +12 -2
- data/spec/ramaze/current/session.rb +97 -0
- data/spec/ramaze/dispatcher/directory.rb +2 -1
- data/spec/ramaze/dispatcher/file.rb +8 -3
- data/spec/ramaze/dispatcher/public/file name.txt +1 -0
- data/spec/ramaze/gestalt.rb +11 -0
- data/spec/ramaze/helper/aspect.rb +28 -22
- data/spec/ramaze/helper/cgi.rb +2 -2
- data/spec/ramaze/helper/flash.rb +33 -15
- data/spec/ramaze/helper/formatting.rb +2 -2
- data/spec/ramaze/helper/link.rb +46 -18
- data/spec/ramaze/helper/pager.rb +8 -5
- data/spec/ramaze/helper/partial.rb +8 -1
- data/spec/ramaze/helper/template/recursive_local_ivars.xhtml +7 -0
- data/spec/ramaze/helper/user.rb +46 -0
- data/spec/ramaze/{inform → log}/informer.rb +0 -0
- data/spec/ramaze/{inform → log}/syslog.rb +1 -1
- data/spec/ramaze/request.rb +14 -10
- data/spec/ramaze/route.rb +23 -0
- data/spec/ramaze/template.rb +48 -1
- data/spec/ramaze/template/haml.rb +6 -16
- data/spec/ramaze/template/haml/locals.haml +2 -1
- data/spec/ramaze/template/tagz.rb +62 -0
- data/spec/ramaze/template/tagz/external.tagz +8 -0
- data/spec/ramaze/template/tagz/sum.tagz +1 -0
- data/spec/ramaze/template/tenjin.rb +49 -0
- data/spec/ramaze/template/tenjin/external.tenjin +1 -0
- data/spec/snippets/string/unindent.rb +15 -0
- metadata +509 -475
- data/doc/README.html +0 -729
- data/doc/changes.txt +0 -5757
- data/doc/changes.xml +0 -5759
- data/examples/blog/src/view.rb +0 -16
- data/examples/blog/template/edit.xhtml +0 -19
- data/examples/blog/template/index.xhtml +0 -19
- data/examples/blog/template/new.xhtml +0 -18
- data/examples/wiktacular/mkd/newpagename/current.mkd +0 -1
- data/examples/wiktacular/mkd/newpagename/current.mkd.bak +0 -1
- data/lib/ramaze/contrib/email.rb-darcs-backup0 +0 -81
- data/lib/ramaze/template/bijou.rb +0 -39
- data/lib/ramaze/trinity/response.rb +0 -32
- data/spec/ramaze/template/bijou.rb +0 -25
- data/spec/ramaze/trinity/session.rb +0 -29
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require 'spec/helper'
|
|
2
2
|
require 'ramaze/helper/formatting'
|
|
3
3
|
|
|
4
|
-
describe '
|
|
5
|
-
extend Ramaze::
|
|
4
|
+
describe 'Helper::Formatting' do
|
|
5
|
+
extend Ramaze::Helper::Formatting
|
|
6
6
|
|
|
7
7
|
it 'should format numbers' do
|
|
8
8
|
number_format(2_123_456).should == '2,123,456'
|
data/spec/ramaze/helper/link.rb
CHANGED
|
@@ -17,18 +17,14 @@ end
|
|
|
17
17
|
ramaze
|
|
18
18
|
|
|
19
19
|
describe "A" do
|
|
20
|
-
extend Ramaze::
|
|
21
|
-
|
|
22
|
-
before do
|
|
23
|
-
# initialize Ramaze::Controller.current for Rs()
|
|
24
|
-
Ramaze::Controller.handle('/')
|
|
25
|
-
end
|
|
20
|
+
extend Ramaze::Helper::Link
|
|
21
|
+
behaves_like 'resolve'
|
|
26
22
|
|
|
27
23
|
it 'should build links' do
|
|
28
24
|
A('title', :href => '/').should == %(<a href="/">title</a>)
|
|
29
25
|
A('title', :href => '/foo').should == %(<a href="/foo">title</a>)
|
|
30
26
|
A('title', :href => '/foo?x=y').should == %{<a href="/foo?x=y">title</a>}
|
|
31
|
-
A('/foo?x=y').should == %{<a href="/foo?x=y">/foo?x=y</a>}
|
|
27
|
+
stack('/'){ A('/foo?x=y') }.should == %{<a href="/foo?x=y">/foo?x=y</a>}
|
|
32
28
|
|
|
33
29
|
a = A('title', :href => '/foo', :class => :none)
|
|
34
30
|
a.should =~ /class="none"/
|
|
@@ -36,12 +32,40 @@ describe "A" do
|
|
|
36
32
|
end
|
|
37
33
|
|
|
38
34
|
it 'should build position independend links' do
|
|
39
|
-
A(TCLink, :foo).should == %(<a href="/foo">foo</a>)
|
|
35
|
+
stack('/'){ A(TCLink, :foo) }.should == %(<a href="/foo">foo</a>)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'should escape path' do
|
|
39
|
+
stack('/'){ A('ti tle') }.should == '<a href="/ti+tle">ti tle</a>'
|
|
40
|
+
a = A('', :href => "/foo?chunky=b\000acon")
|
|
41
|
+
a.should == '<a href="/foo?chunky=b%00acon"></a>'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'should handle text key' do
|
|
45
|
+
A(:href => '/', :text => 'text').should == '<a href="/">text</a>'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'should use last argument as first text fallback' do
|
|
49
|
+
a = A('text', :href => '/', :title => 'title')
|
|
50
|
+
a.should =~ /href="\/"/
|
|
51
|
+
a.should =~ /title="title"/
|
|
52
|
+
a.should =~ />text</
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'should use :title as second text fallback' do
|
|
56
|
+
a = A(:href => '/', :title => 'text')
|
|
57
|
+
a.should =~ /title="text"/
|
|
58
|
+
a.should =~ /href="\/"/
|
|
59
|
+
a.should =~ />text</
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'should use :href as third text fallback' do
|
|
63
|
+
A(:href => '/').should == '<a href="/">/</a>'
|
|
40
64
|
end
|
|
41
65
|
end
|
|
42
66
|
|
|
43
67
|
describe 'R' do
|
|
44
|
-
extend Ramaze::
|
|
68
|
+
extend Ramaze::Helper::Link
|
|
45
69
|
|
|
46
70
|
it 'should build urls' do
|
|
47
71
|
R(TCLink).should == '/'
|
|
@@ -52,25 +76,29 @@ describe 'R' do
|
|
|
52
76
|
end
|
|
53
77
|
|
|
54
78
|
describe 'Rs' do
|
|
55
|
-
extend Ramaze::
|
|
79
|
+
extend Ramaze::Helper::Link
|
|
56
80
|
|
|
57
|
-
|
|
58
|
-
Ramaze::Controller
|
|
59
|
-
|
|
81
|
+
def resolve(url)
|
|
82
|
+
Ramaze::Controller::resolve(url)
|
|
83
|
+
end
|
|
60
84
|
|
|
61
|
-
|
|
62
|
-
Rs(:index).should == '/index'
|
|
85
|
+
it 'should build links for current controller' do
|
|
86
|
+
resolve('/2').stack{ Rs(:index).should == '/2/index' }
|
|
87
|
+
resolve('/').stack{ Rs(:index).should == '/index' }
|
|
63
88
|
end
|
|
64
89
|
|
|
65
90
|
it 'should treat Rs() like R() when Controller given' do
|
|
66
|
-
|
|
67
|
-
|
|
91
|
+
resolve('/2').stack{ Rs(TCLink, :index).should == '/2/index' }
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it 'should treat non-controllers as strings' do
|
|
95
|
+
resolve('/2').stack{ Rs(Ramaze, :index).should == '/2/Ramaze/index' }
|
|
68
96
|
end
|
|
69
97
|
|
|
70
98
|
end
|
|
71
99
|
|
|
72
100
|
describe 'breadcrumbs' do
|
|
73
|
-
extend Ramaze::
|
|
101
|
+
extend Ramaze::Helper::Link
|
|
74
102
|
|
|
75
103
|
it 'should lay out breadcrumbs' do
|
|
76
104
|
breadcrumbs('/file/dir/listing/is/cool').
|
data/spec/ramaze/helper/pager.rb
CHANGED
|
@@ -34,7 +34,8 @@ ramaze
|
|
|
34
34
|
|
|
35
35
|
shared 'pager' do
|
|
36
36
|
behaves_like 'http'
|
|
37
|
-
|
|
37
|
+
behaves_like 'resolve'
|
|
38
|
+
extend Ramaze::Helper::Pager
|
|
38
39
|
|
|
39
40
|
def pager_key
|
|
40
41
|
Ramaze::Pager.trait[:key]
|
|
@@ -69,11 +70,13 @@ shared 'pager' do
|
|
|
69
70
|
end
|
|
70
71
|
|
|
71
72
|
it "should link to other pages" do
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
stack('/page') do
|
|
74
|
+
@pager.should.not.be.nil
|
|
75
|
+
@pager.navigation.should.not.be.nil
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
page = Hpricot(@pager.navigation)
|
|
78
|
+
(page / 'a').size.should == 4
|
|
79
|
+
end
|
|
77
80
|
end
|
|
78
81
|
end
|
|
79
82
|
|
|
@@ -5,7 +5,6 @@ require 'spec/helper'
|
|
|
5
5
|
|
|
6
6
|
class TCPartialHelperController < Ramaze::Controller
|
|
7
7
|
map '/'
|
|
8
|
-
helper :partial
|
|
9
8
|
|
|
10
9
|
def index
|
|
11
10
|
'<html><head><title>#{render_partial("/title")}</title></head></html>'
|
|
@@ -30,6 +29,10 @@ class TCPartialHelperController < Ramaze::Controller
|
|
|
30
29
|
render_template 'locals.xhtml', :say => 'Hello', :to => 'World'
|
|
31
30
|
end
|
|
32
31
|
|
|
32
|
+
def test_local_ivars
|
|
33
|
+
render_template 'recursive_local_ivars.xhtml', :n => 1
|
|
34
|
+
end
|
|
35
|
+
|
|
33
36
|
def test_without_ext
|
|
34
37
|
render_template :locals, :say => 'Hi', :to => 'World'
|
|
35
38
|
end
|
|
@@ -63,6 +66,10 @@ describe "PartialHelper" do
|
|
|
63
66
|
get('/recursive/true').body.gsub(/\s/,'').should == '{1{2{3{44}3}2}1}'
|
|
64
67
|
end
|
|
65
68
|
|
|
69
|
+
it 'should set ivars in addition to locals' do
|
|
70
|
+
get('/test_local_ivars').body.gsub(/\s/,'').should == '{1{2{3{44}3}2}1}'
|
|
71
|
+
end
|
|
72
|
+
|
|
66
73
|
it 'should not require file extension' do
|
|
67
74
|
get('/test_without_ext').body.should == 'Hi, World!'
|
|
68
75
|
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
class MockSequelUser
|
|
4
|
+
# mocks what User[:name => 'arthur', :password => '42'] would do
|
|
5
|
+
def self.[](hash)
|
|
6
|
+
name = hash[:name] || hash['name']
|
|
7
|
+
pass = hash[:password] || hash['password']
|
|
8
|
+
new if name == 'arthur' and pass == '42'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def profile
|
|
12
|
+
"Arthur Dent, fearful human in outer space!"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class HelperUser < Ramaze::Controller
|
|
17
|
+
map '/'
|
|
18
|
+
helper :user
|
|
19
|
+
trait :user_model => MockSequelUser
|
|
20
|
+
|
|
21
|
+
def status
|
|
22
|
+
user.logged_in?.to_s
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def login
|
|
26
|
+
user.login
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def profile
|
|
30
|
+
user.profile
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe Ramaze::Helper::User do
|
|
35
|
+
behaves_like 'browser'
|
|
36
|
+
ramaze :adapter => :webrick
|
|
37
|
+
|
|
38
|
+
should 'login' do
|
|
39
|
+
Browser.new '/status' do
|
|
40
|
+
get('/status').should == 'false'
|
|
41
|
+
get('/login', 'name' => 'arthur', 'password' => '42')
|
|
42
|
+
get('/status').should == 'true'
|
|
43
|
+
get('/profile').should == MockSequelUser.new.profile
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
File without changes
|
data/spec/ramaze/request.rb
CHANGED
|
@@ -36,10 +36,7 @@ class TCRequestController < Ramaze::Controller
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def test_post
|
|
39
|
-
|
|
40
|
-
request['bar']['1'],
|
|
41
|
-
request['bar']['7'],
|
|
42
|
-
].inspect
|
|
39
|
+
request.params.inspect
|
|
43
40
|
end
|
|
44
41
|
|
|
45
42
|
def test_headers
|
|
@@ -85,6 +82,19 @@ describe "Request" do
|
|
|
85
82
|
it "give me back what i gave" do
|
|
86
83
|
post("/post_inspect", 'this' => 'post').body.should == {"this" => "post"}.inspect
|
|
87
84
|
end
|
|
85
|
+
|
|
86
|
+
should "handle key[nested_key]" do
|
|
87
|
+
get('/test_get', 'foo' => 'bar').body.should == 'bar'
|
|
88
|
+
params = {'foo' => 'null', 'bar[1]' => 'eins', 'bar[7]' => 'sieben'}
|
|
89
|
+
|
|
90
|
+
eval(post('/test_post', params).body).should ==
|
|
91
|
+
{'foo' => 'null', 'bar' => {'1' => 'eins', '7' => 'sieben'}}
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
should 'handle key[nested_key][nested_nested_key]' do
|
|
95
|
+
eval(post('/test_post', 'foo[1][2]' => 'eins zwei').body).should ==
|
|
96
|
+
{'foo' => {'1' => {'2' => 'eins zwei'}}}
|
|
97
|
+
end
|
|
88
98
|
end
|
|
89
99
|
|
|
90
100
|
describe "PUT" do
|
|
@@ -133,12 +143,6 @@ describe "Request" do
|
|
|
133
143
|
it "my ip" do
|
|
134
144
|
get("/my_ip").body.should == '127.0.0.1'
|
|
135
145
|
end
|
|
136
|
-
|
|
137
|
-
it "request[key]" do
|
|
138
|
-
get('/test_get', 'foo' => 'bar').body.should == 'bar'
|
|
139
|
-
post('/test_post', 'foo' => 'null', 'bar[1]' => 'eins', 'bar[7]' => 'sieben').body.should ==
|
|
140
|
-
['null', 'eins', 'sieben'].inspect
|
|
141
|
-
end
|
|
142
146
|
end
|
|
143
147
|
|
|
144
148
|
describe "get files" do
|
data/spec/ramaze/route.rb
CHANGED
|
@@ -104,4 +104,27 @@ describe 'Route' do
|
|
|
104
104
|
r.status.should == 200
|
|
105
105
|
r.body.should == 'this is bar'
|
|
106
106
|
end
|
|
107
|
+
|
|
108
|
+
it 'should clear routes' do
|
|
109
|
+
Ramaze::Route.trait[:routes].size.should > 0
|
|
110
|
+
Ramaze::Route.clear
|
|
111
|
+
Ramaze::Route.trait[:routes].size.should == 0
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it 'should exclude existing actions' do
|
|
115
|
+
Ramaze::Route[ %r!^/(.+)$! ] = "/string/%s"
|
|
116
|
+
r = get('/hello')
|
|
117
|
+
r.status.should == 200
|
|
118
|
+
r.body.should == 'String: hello'
|
|
119
|
+
|
|
120
|
+
r = get('/bar')
|
|
121
|
+
r.status.should == 200
|
|
122
|
+
r.body.should == 'this is bar'
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it 'should not recurse given a bad route' do
|
|
126
|
+
Ramaze::Route[ %r!^/good/(.+)$! ] = "/bad/%s"
|
|
127
|
+
r = get('/good/hi')
|
|
128
|
+
r.status.should == 404
|
|
129
|
+
end
|
|
107
130
|
end
|
data/spec/ramaze/template.rb
CHANGED
|
@@ -30,6 +30,24 @@ class TCTemplateController < Ramaze::Controller
|
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
class TCMultipleTemplateRoots < Ramaze::Controller
|
|
34
|
+
map '/multiple'
|
|
35
|
+
template_root __DIR__/:helper/:template, __DIR__/:template/:ezamar
|
|
36
|
+
|
|
37
|
+
def sum
|
|
38
|
+
@num1, @num2 = 1, 2
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def num
|
|
42
|
+
@n = 3
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def render
|
|
46
|
+
@n = 3
|
|
47
|
+
render_template :num
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
33
51
|
describe "testing ramaze template" do
|
|
34
52
|
ramaze
|
|
35
53
|
|
|
@@ -75,7 +93,36 @@ describe "testing ramaze template" do
|
|
|
75
93
|
|
|
76
94
|
@file.should =~ /external\.test$/
|
|
77
95
|
@params.should == []
|
|
78
|
-
file = TCTemplateController.template_root/'external.test'
|
|
96
|
+
file = TCTemplateController.template_root.first/'external.test'
|
|
79
97
|
@file.should == file
|
|
80
98
|
end
|
|
81
99
|
end
|
|
100
|
+
|
|
101
|
+
describe 'multiple template_roots' do
|
|
102
|
+
def get(*args) Ramaze::Controller.handle(args) end
|
|
103
|
+
|
|
104
|
+
it 'should work' do
|
|
105
|
+
get('/multiple/sum').should == '3'
|
|
106
|
+
get('/multiple/num').should == '3'
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'should work with render_template' do
|
|
110
|
+
get('/multiple/render').should == '3'
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe "ramaze template engines" do
|
|
115
|
+
Ramaze::Template::AVAILABLE_ENGINES.each do |engine|
|
|
116
|
+
begin
|
|
117
|
+
Ramaze::Template.const_get(engine)
|
|
118
|
+
rescue LoadError, NameError
|
|
119
|
+
# ignore missing template engines
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it "should not have dots at beginning of template extensions" do
|
|
124
|
+
extensions = Ramaze::Template::ENGINES.map {|e,ext| ext }.flatten
|
|
125
|
+
extensions.find_all {|e| e =~ /\A\./ }.should.be.empty
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
end
|
|
@@ -21,23 +21,17 @@ class TCTemplateHamlController < Ramaze::Controller
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
class TCRamazeLocals < Ramaze::Controller
|
|
24
|
-
map '/
|
|
24
|
+
map '/locals'
|
|
25
25
|
template_root __DIR__/:haml
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def render_with_locals
|
|
27
|
+
def output
|
|
30
28
|
render_template 'locals.haml', :abc => 'def'
|
|
31
29
|
end
|
|
32
|
-
end
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
map '/locals'
|
|
36
|
-
engine :Haml
|
|
37
|
-
trait :haml_options => { :locals => { :localvar => 'abcdefg' } }
|
|
31
|
+
private
|
|
38
32
|
|
|
39
|
-
def
|
|
40
|
-
|
|
33
|
+
def sayhi
|
|
34
|
+
'hi'
|
|
41
35
|
end
|
|
42
36
|
end
|
|
43
37
|
|
|
@@ -67,10 +61,6 @@ describe "Haml templates" do
|
|
|
67
61
|
end
|
|
68
62
|
|
|
69
63
|
it 'should support locals via render_template' do
|
|
70
|
-
get('/
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it "should have access to locals defined" do
|
|
74
|
-
get('/locals/test').body.strip.should == 'abcdefg'
|
|
64
|
+
get('/locals/output').body.strip.should == "def\nhi"
|
|
75
65
|
end
|
|
76
66
|
end
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
= abc
|
|
1
|
+
= abc
|
|
2
|
+
= sayhi
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
spec_require 'tagz'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TCTemplateTagzController < Ramaze::Controller
|
|
10
|
+
map '/'
|
|
11
|
+
template_root 'spec/ramaze/template/tagz/'
|
|
12
|
+
engine :Tagz
|
|
13
|
+
|
|
14
|
+
helper :tagz
|
|
15
|
+
|
|
16
|
+
def index
|
|
17
|
+
tagz{ h1_{ "Tagz Index" } }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def links
|
|
21
|
+
tagz{
|
|
22
|
+
ul_{
|
|
23
|
+
li_{ a_(:href => R(self,:index)){ "Index page" } }
|
|
24
|
+
li_{ a_(:href => R(self,:internal)){ "Internal template" } }
|
|
25
|
+
li_{ a_(:href => R(self,:external)){ "External template" } }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def external
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def sum num1, num2
|
|
34
|
+
@num1, @num2 = num1.to_i, num2.to_i
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe "Tagz" do
|
|
39
|
+
behaves_like 'http'
|
|
40
|
+
ramaze
|
|
41
|
+
|
|
42
|
+
it "index" do
|
|
43
|
+
get('/').body.should == '<h1>Tagz Index</h1>'
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "links" do
|
|
47
|
+
get('/links').body.should == '<ul><li><a href="/index">Index page</a></li><li><a href="/internal">Internal template</a></li><li><a href="/external">External template</a></li></ul>'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "sum" do
|
|
51
|
+
get('/sum/1/2').body.should == '<div>3</div>'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "external" do
|
|
55
|
+
get('/external').body.should == "<html><head><title>Tagz Test</title></head><body><h1>Tagz Template</h1></body></html>"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should not respond to tagz" do
|
|
59
|
+
response = get('/tagz')
|
|
60
|
+
response.status.should == 404
|
|
61
|
+
end
|
|
62
|
+
end
|