ramaze 0.3.5 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -116,6 +116,28 @@ class TCLayoutInstanceVars < Ramaze::Controller
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
+
class TCActionTwoLevelLayout < Ramaze::Controller
|
120
|
+
map '/twolevel'
|
121
|
+
layout :wrapper
|
122
|
+
layout :wrapper2 => [:foo]
|
123
|
+
|
124
|
+
def wrapper
|
125
|
+
"<pre>#@content</pre>"
|
126
|
+
end
|
127
|
+
|
128
|
+
def wrapper2
|
129
|
+
"<code>#@content</code>"
|
130
|
+
end
|
131
|
+
|
132
|
+
def index
|
133
|
+
'Hello, World!'
|
134
|
+
end
|
135
|
+
|
136
|
+
def foo
|
137
|
+
"bar"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
119
141
|
describe 'Action rendering' do
|
120
142
|
behaves_like 'http'
|
121
143
|
ramaze
|
@@ -159,4 +181,10 @@ describe 'Action rendering' do
|
|
159
181
|
get('/reuse').body.should == "<pre>hi</pre>"
|
160
182
|
get('/reuse_instance').body.should == "hello: world"
|
161
183
|
end
|
184
|
+
|
185
|
+
it 'should be able to override :all' do
|
186
|
+
get('/twolevel/index').body.should == '<pre>Hello, World!</pre>'
|
187
|
+
get('/twolevel/foo').body.should == '<code>bar</code>'
|
188
|
+
end
|
189
|
+
|
162
190
|
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 MainController < Ramaze::Controller
|
7
|
+
template :non_existant_method, :list
|
8
|
+
end
|
9
|
+
|
10
|
+
class TCActionOtherLayout < Ramaze::Controller
|
11
|
+
map '/other'
|
12
|
+
layout '/other_wrapper'
|
13
|
+
template_root __DIR__/:template
|
14
|
+
|
15
|
+
def index
|
16
|
+
"Others Hello"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "Testing Actionless Templates" do
|
21
|
+
behaves_like 'http'
|
22
|
+
ramaze :actionless_templates => false
|
23
|
+
|
24
|
+
it "should not find template file for non existant method" do
|
25
|
+
get('/non_existant_method').status.should == 404
|
26
|
+
get('/non_existant_method2').status.should == 404
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should render layout(without method) for normal action" do
|
30
|
+
get('/other/index').body.should == '<p>Others Hello</p>'
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<p>#@content</p>
|
@@ -43,6 +43,31 @@ class OtherController < MainController
|
|
43
43
|
|
44
44
|
end
|
45
45
|
|
46
|
+
class AnotherController < Ramaze::Controller
|
47
|
+
|
48
|
+
Root = File.expand_path(
|
49
|
+
MainController.template_root || Ramaze::Global.template_root
|
50
|
+
)
|
51
|
+
Absolute = lambda{|path| File.join Root, path}
|
52
|
+
Relative = lambda{|path| path}
|
53
|
+
|
54
|
+
def greet_absolute(type, message = "Message")
|
55
|
+
@greet = "#{type} : #{message}"
|
56
|
+
end
|
57
|
+
template :greet_absolute, :file => Absolute["greet.xhtml"]
|
58
|
+
|
59
|
+
def greet_relative(type, message = "Message")
|
60
|
+
@greet = "#{type} : #{message}"
|
61
|
+
end
|
62
|
+
template :greet_relative, :file => Relative["greet.xhtml"]
|
63
|
+
|
64
|
+
def greet_controller_action(type, message = "Message")
|
65
|
+
@greet = "#{type} : #{message}"
|
66
|
+
end
|
67
|
+
template :greet_controller_action, :controller => MainController, :action => "greet"
|
68
|
+
|
69
|
+
end
|
70
|
+
|
46
71
|
describe "Testing Template overriding" do
|
47
72
|
behaves_like 'http'
|
48
73
|
ramaze
|
@@ -75,4 +100,16 @@ describe "Testing Template overriding" do
|
|
75
100
|
it "should use template overrides for non-existant actions" do
|
76
101
|
get('/non_existant_method').body.should == '<html></html>'
|
77
102
|
end
|
103
|
+
|
104
|
+
it "should allow template overrides to be specified by absolute path" do
|
105
|
+
get('/another/greet_absolute/asdf').body.should == '<html>asdf : Message</html>'
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should allow template overrides to be specified by relative path" do
|
109
|
+
get('/another/greet_relative/asdf').body.should == '<html>asdf : Message</html>'
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should allow template overrides to be specified by named controller and action" do
|
113
|
+
get('/another/greet_controller_action/asdf').body.should == '<html>asdf : Message</html>'
|
114
|
+
end
|
78
115
|
end
|
@@ -5,16 +5,26 @@ describe 'Ramaze::Request' do
|
|
5
5
|
Ramaze::Request.new(env)
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
should 'provide #request_uri' do
|
9
9
|
request('REQUEST_URI' => '/?a=b').request_uri.should == '/?a=b'
|
10
10
|
request( 'PATH_INFO' => '/' ).request_uri.should == '/'
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
should 'provide #local_net?' do
|
14
14
|
request.local_net?('192.168.0.1').to_s.should == '192.168.0.0'
|
15
15
|
request.local_net?('252.168.0.1').should == nil
|
16
16
|
request.local_net?('unknown').should == nil
|
17
17
|
request('REMOTE_ADDR' => '211.3.129.47, 66.249.85.131').local_net?.should == nil
|
18
18
|
request('REMOTE_ADDR' => '211.3.129.47').local_net?.should == nil
|
19
19
|
end
|
20
|
+
|
21
|
+
should 'provide #subset' do
|
22
|
+
params = {'a' => 'b', 'c' => 'd', 'e' => 'f'}
|
23
|
+
env = { 'rack.request.form_hash' => params }
|
24
|
+
req = request(env)
|
25
|
+
|
26
|
+
req.params.should == params
|
27
|
+
req.subset(:a).should == {'a' => 'b'}
|
28
|
+
req.subset(:a, :c).should == {'a' => 'b', 'c' => 'd'}
|
29
|
+
end
|
20
30
|
end
|
@@ -0,0 +1,97 @@
|
|
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 TrinitySessionController < Ramaze::Controller
|
7
|
+
map :/
|
8
|
+
|
9
|
+
def index
|
10
|
+
"nothing"
|
11
|
+
end
|
12
|
+
|
13
|
+
def val
|
14
|
+
session.client[:val]
|
15
|
+
end
|
16
|
+
|
17
|
+
def set
|
18
|
+
session.client[:val] = 789
|
19
|
+
end
|
20
|
+
|
21
|
+
def del
|
22
|
+
session.client.delete(:val)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "Session" do
|
27
|
+
behaves_like 'http'
|
28
|
+
ramaze :sessions => false
|
29
|
+
|
30
|
+
it 'should work without sessions' do
|
31
|
+
class Ramaze::Session
|
32
|
+
remove_const :IP_COUNT_LIMIT
|
33
|
+
const_set(:IP_COUNT_LIMIT, 2)
|
34
|
+
end
|
35
|
+
(Ramaze::Session::IP_COUNT_LIMIT + 2).times do
|
36
|
+
r = get('/')
|
37
|
+
r.body.should == "nothing"
|
38
|
+
r.headers.should == {'Content-Type' => 'text/html'}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "Session cookie store" do
|
44
|
+
behaves_like 'http'
|
45
|
+
ramaze :sessions => true
|
46
|
+
|
47
|
+
Ramaze::Session::SESSION_KEY.replace('sess')
|
48
|
+
@secret = Ramaze::Session.trait[:secret] = 'abc'
|
49
|
+
|
50
|
+
# Marshal a session hash into safe cookie data. Include an integrity hash.
|
51
|
+
def marshal(session)
|
52
|
+
data = [ Marshal.dump(session) ].pack('m').chop
|
53
|
+
"#{data}--#{generate_digest(data)}"
|
54
|
+
end
|
55
|
+
|
56
|
+
# Unmarshal cookie data to a hash and verify its integrity.
|
57
|
+
def unmarshal(cookie)
|
58
|
+
if cookie
|
59
|
+
data, digest = cookie.split('--')
|
60
|
+
return {} unless digest == generate_digest(data)
|
61
|
+
Marshal.load(data.unpack('m').first)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Generate the inline SHA512 message digest. Larger (128 bytes) than SHA256
|
66
|
+
# (64 bytes) or RMD160 (40 bytes), but small relative to the 4096 byte
|
67
|
+
# max cookie size.
|
68
|
+
def generate_digest(data)
|
69
|
+
Digest::SHA512.hexdigest "#{data}#{@secret}"
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should use session data from cookies' do
|
73
|
+
r = get('/val', :cookie => "sess-client="+marshal({ :val => 123 }))
|
74
|
+
r.body.should == '123'
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should use new values from session cookie' do
|
78
|
+
r = get('/val', :cookie => "sess-client="+marshal({ :val => 456 }))
|
79
|
+
r.body.should == '456'
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should set session values in the cookie' do
|
83
|
+
r = get('/set')
|
84
|
+
r.headers['Set-Cookie'].should == "sess-client=#{CGI.escape(marshal({:val => 789}))}; path=/"
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'bad cookie should be ignored' do
|
88
|
+
r = get('/val', :cookie => marshal({ :val => 456 }) + 'wrong')
|
89
|
+
r.body.should.not == '456'
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should allow removing the last key/value pair' do
|
93
|
+
r = get('/del', :cookie => "sess-client="+marshal({ :val => 456 }))
|
94
|
+
r.body.should == '456'
|
95
|
+
r.headers['Set-Cookie'].should == "sess-client=#{CGI.escape(marshal({}))}; path=/"
|
96
|
+
end
|
97
|
+
end
|
@@ -36,7 +36,8 @@ describe 'Dispatcher::Directory' do
|
|
36
36
|
it 'should dry serve root directory' do
|
37
37
|
files = [
|
38
38
|
["/../", "Parent Directory"], ["/test", "test/"],
|
39
|
-
["/favicon.ico", "favicon.ico"], ["/
|
39
|
+
["/favicon.ico", "favicon.ico"], ["/file name.txt", "file name.txt"],
|
40
|
+
["/test_download.css", "test_download.css"]
|
40
41
|
]
|
41
42
|
|
42
43
|
check '/', 'Directory listing of /', files
|
@@ -22,10 +22,16 @@ describe 'Dispatcher::File' do
|
|
22
22
|
get('/favicon.ico').body.should == original
|
23
23
|
end
|
24
24
|
|
25
|
+
it 'should work on files with spaces' do
|
26
|
+
res = get('/file%20name.txt')
|
27
|
+
res.status.should == 200
|
28
|
+
res.body.should == 'hi'
|
29
|
+
end
|
30
|
+
|
25
31
|
it 'should send ETag' do
|
26
32
|
res = get '/test_download.css'
|
27
33
|
res.headers['ETag'].should.not.be == nil
|
28
|
-
res.headers['ETag'].length.should == 34 # "32 hash"
|
34
|
+
res.headers['ETag'].length.should == 34 # "32 hash"
|
29
35
|
end
|
30
36
|
|
31
37
|
it 'should send Last-Modified' do
|
@@ -51,5 +57,4 @@ describe 'Dispatcher::File' do
|
|
51
57
|
res.status.should == 304
|
52
58
|
res.body.should == ''
|
53
59
|
end
|
54
|
-
|
55
|
-
end
|
60
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
hi
|
data/spec/ramaze/gestalt.rb
CHANGED
@@ -117,4 +117,15 @@ describe "Gestalt" do
|
|
117
117
|
input.should =~ /type="text"/
|
118
118
|
input.should =~ /value="one"/
|
119
119
|
end
|
120
|
+
|
121
|
+
it 'tags with prefix' do
|
122
|
+
gestalt{tag "prefix:local"}.should == '<prefix:local />'
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'tags with a variety of characters' do
|
126
|
+
# with "-"
|
127
|
+
gestalt{tag "hello-world"}.should == '<hello-world />'
|
128
|
+
# with Hiragana
|
129
|
+
gestalt{tag "あいうえお"}.should == '<あいうえお />'
|
130
|
+
end
|
120
131
|
end
|
@@ -8,14 +8,14 @@ class TCAspectController < Ramaze::Controller
|
|
8
8
|
trait :foo => :bar
|
9
9
|
helper :aspect
|
10
10
|
|
11
|
-
def test_before()
|
12
|
-
before(:test_before){
|
11
|
+
def test_before() request[:before] += 2 end
|
12
|
+
before(:test_before){ request[:before] = 40 }
|
13
13
|
|
14
|
-
def test_after()
|
15
|
-
after(:test_after){
|
14
|
+
def test_after() request[:after] = 40 end
|
15
|
+
after(:test_after){ request[:after] += 2 }
|
16
16
|
|
17
|
-
def test_wrap()
|
18
|
-
wrap(:test_wrap){
|
17
|
+
def test_wrap() end
|
18
|
+
wrap(:test_wrap){ request[:wrap] ||= 0; request[:wrap] += 21 }
|
19
19
|
|
20
20
|
wrap(:test_template) { '<aspect>' }
|
21
21
|
end
|
@@ -23,14 +23,14 @@ end
|
|
23
23
|
class TCAspectAllController < Ramaze::Controller
|
24
24
|
map '/all'
|
25
25
|
|
26
|
-
helper :aspect
|
26
|
+
helper :aspect
|
27
27
|
template_root __DIR__/:template
|
28
28
|
|
29
29
|
def test_all_first() 'first' end
|
30
30
|
def test_all_second() 'second' end
|
31
31
|
|
32
|
-
before_all{
|
33
|
-
after_all{
|
32
|
+
before_all{ request[:all] = 40 }
|
33
|
+
after_all{ request[:all] += 2 }
|
34
34
|
|
35
35
|
def test_all_after() 'after' end
|
36
36
|
|
@@ -42,45 +42,51 @@ end
|
|
42
42
|
describe "AspectHelper" do
|
43
43
|
behaves_like 'http'
|
44
44
|
ramaze :error_page => false
|
45
|
+
extend Ramaze::Trinity
|
45
46
|
|
46
47
|
it "shouldn't overwrite traits on inclusion" do
|
47
48
|
TCAspectController.trait[:foo].should == :bar
|
48
49
|
end
|
49
50
|
|
50
51
|
it 'should use before' do
|
51
|
-
get('/test_before')
|
52
|
+
get('/test_before')
|
53
|
+
request[:before].should == 42
|
52
54
|
end
|
53
55
|
|
54
56
|
it 'should use after' do
|
55
|
-
get('/test_after')
|
57
|
+
get('/test_after')
|
58
|
+
request[:after].should == 42
|
56
59
|
end
|
57
60
|
|
58
61
|
it 'should use wrap' do
|
59
|
-
get('/test_wrap')
|
60
|
-
|
61
|
-
|
62
|
-
it 'should wrap templates' do
|
63
|
-
get('/test_template').body.should == '<aspect>I am a template.<aspect>'
|
62
|
+
get('/test_wrap')
|
63
|
+
request[:wrap].should == 42
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'should before_all and after_all' do
|
67
|
-
get('/all/test_all_first')
|
68
|
-
|
67
|
+
get('/all/test_all_first')
|
68
|
+
request[:all].should == 42
|
69
|
+
get('/all/test_all_second')
|
70
|
+
request[:all].should == 42
|
69
71
|
end
|
70
72
|
|
71
73
|
it 'should before_all and after_all for templates' do
|
72
|
-
get('/all/test_template')
|
74
|
+
get('/all/test_template')
|
75
|
+
request[:all].should == 42
|
73
76
|
end
|
74
77
|
|
75
78
|
it 'should before_all and after_all for all defined actions' do
|
76
|
-
get('/all/test_all_after')
|
79
|
+
get('/all/test_all_after')
|
80
|
+
request[:all].should == 42
|
77
81
|
end
|
78
82
|
|
79
83
|
it 'should not apply aspects to render_template' do
|
80
|
-
get('/all/loop').body.gsub(/\s/,'').should == '
|
84
|
+
get('/all/loop').body.gsub(/\s/,'').should == '12345'
|
85
|
+
request[:all].should == 42
|
81
86
|
end
|
82
87
|
|
83
88
|
it 'should not apply aspects to layouts' do
|
84
|
-
get('/all/loop_with_layout').body.gsub(/\s/,'').should == '<div
|
89
|
+
get('/all/loop_with_layout').body.gsub(/\s/,'').should == '<div>12345</div>'
|
90
|
+
request[:all].should == 42
|
85
91
|
end
|
86
92
|
end
|
data/spec/ramaze/helper/cgi.rb
CHANGED
@@ -9,7 +9,7 @@ class TCLink < Ramaze::Controller
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "url encode" do
|
12
|
-
extend Ramaze::
|
12
|
+
extend Ramaze::Helper::CGI
|
13
13
|
|
14
14
|
it 'should url_encode strings' do
|
15
15
|
# ok, I believe that the web is dumb for this
|
@@ -28,7 +28,7 @@ describe "url encode" do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe 'html escape' do
|
31
|
-
extend Ramaze::
|
31
|
+
extend Ramaze::Helper::CGI
|
32
32
|
|
33
33
|
it 'should escape html' do
|
34
34
|
html_escape('& < >').should == '& < >'
|
data/spec/ramaze/helper/flash.rb
CHANGED
@@ -18,6 +18,17 @@ class TCFlashHelperFirstController < Ramaze::Controller
|
|
18
18
|
def then_here
|
19
19
|
flash[:first].to_s
|
20
20
|
end
|
21
|
+
|
22
|
+
def set(*hash)
|
23
|
+
Hash[*hash].each do |key, value|
|
24
|
+
flash[key] = value
|
25
|
+
end
|
26
|
+
hash.inspect
|
27
|
+
end
|
28
|
+
|
29
|
+
def box
|
30
|
+
flashbox
|
31
|
+
end
|
21
32
|
end
|
22
33
|
|
23
34
|
class TCFlashHelperSecondController < Ramaze::Controller
|
@@ -57,46 +68,53 @@ class TCFlashHelperThirdController < Ramaze::Controller
|
|
57
68
|
end
|
58
69
|
end
|
59
70
|
|
60
|
-
describe
|
71
|
+
describe Ramaze::Helper::Flash do
|
61
72
|
behaves_like 'browser'
|
62
73
|
ramaze :adapter => :webrick
|
63
74
|
|
64
|
-
|
75
|
+
should "set and forget flash twice" do
|
65
76
|
Browser.new('/') do
|
66
77
|
get('/first_here')
|
67
78
|
get('/then_here').should == 'hey'
|
68
|
-
get('/then_here').should
|
69
|
-
get('/then_here').should == ''
|
79
|
+
2.times{ get('/then_here').should.be.empty }
|
70
80
|
get('/first_here')
|
71
81
|
get('/then_here').should == 'hey'
|
72
|
-
get('/then_here').should
|
82
|
+
get('/then_here').should.be.empty
|
73
83
|
end
|
74
84
|
end
|
75
85
|
|
76
|
-
|
86
|
+
should "work over multiple controllers" do
|
77
87
|
Browser.new do
|
78
88
|
get('/first_here')
|
79
89
|
get('/second/then_here').should == 'hey'
|
80
|
-
get('/then_here').should
|
81
|
-
get('/second/then_here').should
|
90
|
+
get('/then_here').should.be.empty
|
91
|
+
get('/second/then_here').should.be.empty
|
82
92
|
get('/second/first_here')
|
83
93
|
get('/then_here').should == 'hey'
|
84
|
-
get('/second/then_here').should
|
94
|
+
get('/second/then_here').should.be.empty
|
85
95
|
end
|
86
96
|
end
|
87
97
|
|
88
|
-
|
98
|
+
should "set and retrieve custom value" do
|
89
99
|
Browser.new do
|
90
100
|
get('/third/set/foo').should == 'foo'
|
101
|
+
get('/third/retrieve').should == 'foo'
|
102
|
+
2.times{ get('/third/retrieve').should.be.empty }
|
91
103
|
end
|
92
104
|
end
|
93
105
|
|
94
|
-
|
106
|
+
should "show a flashbox" do
|
95
107
|
Browser.new do
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
get('/
|
108
|
+
error_div = "<div class='flash' id='flash_error'>stuff failed</div>"
|
109
|
+
success_div = "<div class='flash' id='flash_success'>other things worked</div>"
|
110
|
+
|
111
|
+
get('/set/error/stuff%20failed')
|
112
|
+
get('/box').should == error_div
|
113
|
+
|
114
|
+
get('/set/error/stuff%20failed/success/other%20things%20worked')
|
115
|
+
get('/box').should == [error_div, success_div].join("\n")
|
116
|
+
|
117
|
+
get('/box').should.be.empty
|
100
118
|
end
|
101
119
|
end
|
102
120
|
end
|