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.
Files changed (204) hide show
  1. data/Rakefile +5 -20
  2. data/bin/ramaze +0 -4
  3. data/doc/AUTHORS +5 -0
  4. data/doc/meta/announcement.txt +2 -1
  5. data/doc/tutorial/todolist.html +20 -21
  6. data/doc/tutorial/todolist.mkd +10 -9
  7. data/examples/blog/{src/controller.rb → controller/main.rb} +2 -0
  8. data/examples/blog/{src/model.rb → model/entry.rb} +0 -0
  9. data/examples/blog/spec/blog.rb +3 -3
  10. data/examples/blog/start.rb +2 -3
  11. data/examples/blog/view/edit.xhtml +17 -0
  12. data/examples/blog/view/index.xhtml +17 -0
  13. data/examples/blog/view/layout.xhtml +11 -0
  14. data/examples/blog/view/new.xhtml +16 -0
  15. data/examples/facebook.rb +15 -8
  16. data/examples/identity.rb +1 -1
  17. data/examples/memleak_detector.rb +1 -1
  18. data/examples/rammit/src/model.rb +1 -1
  19. data/examples/rapaste/controller/paste.rb +7 -7
  20. data/examples/rapaste/model/paste.rb +1 -3
  21. data/examples/rapaste/public/css/display.css +2 -1
  22. data/examples/rapaste/start.rb +2 -3
  23. data/examples/sourceview/sourceview.rb +1 -1
  24. data/examples/templates/template/external.tenjin +28 -0
  25. data/examples/templates/template_amrita2.rb +0 -3
  26. data/examples/templates/template_tenjin.rb +57 -0
  27. data/examples/todolist/spec/todolist.rb +13 -2
  28. data/examples/todolist/src/controller/main.rb +1 -1
  29. data/examples/todolist/template/index.xhtml +1 -1
  30. data/examples/wiktacular/spec/wiktacular.rb +18 -0
  31. data/examples/wiktacular/src/controller.rb +2 -2
  32. data/examples/wiktacular/src/model.rb +8 -2
  33. data/lib/proto/public/css/ramaze_error.css +4 -0
  34. data/lib/proto/public/dispatch.fcgi +11 -0
  35. data/lib/proto/spec/main.rb +1 -1
  36. data/lib/proto/start.ru +8 -0
  37. data/lib/proto/view/error.xhtml +2 -0
  38. data/lib/ramaze.rb +28 -5
  39. data/lib/ramaze/action.rb +9 -2
  40. data/lib/ramaze/action/render.rb +40 -24
  41. data/lib/ramaze/adapter.rb +10 -17
  42. data/lib/ramaze/adapter/base.rb +8 -12
  43. data/lib/ramaze/adapter/cgi.rb +14 -13
  44. data/lib/ramaze/adapter/ebb.rb +34 -0
  45. data/lib/ramaze/adapter/evented_mongrel.rb +1 -1
  46. data/lib/ramaze/adapter/fcgi.rb +14 -14
  47. data/lib/ramaze/adapter/lsws.rb +15 -11
  48. data/lib/ramaze/adapter/mongrel.rb +2 -1
  49. data/lib/ramaze/adapter/scgi.rb +24 -0
  50. data/lib/ramaze/adapter/swiftiplied_mongrel.rb +1 -1
  51. data/lib/ramaze/adapter/thin.rb +4 -5
  52. data/lib/ramaze/adapter/webrick.rb +5 -5
  53. data/lib/ramaze/cache.rb +1 -1
  54. data/lib/ramaze/cache/memcached.rb +1 -1
  55. data/lib/ramaze/contrib.rb +70 -10
  56. data/lib/ramaze/contrib/auto_params.rb +1 -1
  57. data/lib/ramaze/contrib/email.rb +15 -15
  58. data/lib/ramaze/contrib/facebook.rb +2 -2
  59. data/lib/ramaze/contrib/facebook/facebook.rb +7 -4
  60. data/lib/ramaze/contrib/file_cache.rb +65 -0
  61. data/lib/ramaze/contrib/gettext.rb +56 -55
  62. data/lib/ramaze/contrib/profiling.rb +36 -0
  63. data/lib/ramaze/contrib/sequel_cache.rb +92 -0
  64. data/lib/ramaze/controller.rb +80 -47
  65. data/lib/ramaze/controller/error.rb +10 -5
  66. data/lib/ramaze/controller/resolve.rb +36 -48
  67. data/lib/ramaze/current.rb +70 -0
  68. data/lib/ramaze/{trinity → current}/request.rb +62 -15
  69. data/lib/ramaze/current/response.rb +19 -0
  70. data/lib/ramaze/{trinity → current}/session.rb +32 -110
  71. data/lib/ramaze/current/session/flash.rb +67 -0
  72. data/lib/ramaze/current/session/hash.rb +65 -0
  73. data/lib/ramaze/dispatcher.rb +1 -28
  74. data/lib/ramaze/dispatcher/action.rb +6 -3
  75. data/lib/ramaze/dispatcher/directory.rb +1 -1
  76. data/lib/ramaze/dispatcher/error.rb +26 -5
  77. data/lib/ramaze/dispatcher/file.rb +13 -2
  78. data/lib/ramaze/gestalt.rb +3 -1
  79. data/lib/ramaze/global.rb +6 -3
  80. data/lib/ramaze/global/globalstruct.rb +3 -1
  81. data/lib/ramaze/helper.rb +66 -20
  82. data/lib/ramaze/helper/aspect.rb +25 -17
  83. data/lib/ramaze/helper/auth.rb +4 -3
  84. data/lib/ramaze/helper/cache.rb +5 -4
  85. data/lib/ramaze/helper/cgi.rb +11 -9
  86. data/lib/ramaze/helper/flash.rb +28 -3
  87. data/lib/ramaze/helper/formatting.rb +1 -3
  88. data/lib/ramaze/helper/identity.rb +2 -3
  89. data/lib/ramaze/helper/inform.rb +7 -6
  90. data/lib/ramaze/helper/link.rb +15 -17
  91. data/lib/ramaze/helper/markaby.rb +2 -4
  92. data/lib/ramaze/helper/maruku.rb +1 -1
  93. data/lib/ramaze/helper/nitroform.rb +4 -4
  94. data/lib/ramaze/helper/pager.rb +4 -6
  95. data/lib/ramaze/helper/partial.rb +24 -21
  96. data/lib/ramaze/helper/redirect.rb +8 -5
  97. data/lib/ramaze/helper/{file.rb → sendfile.rb} +1 -3
  98. data/lib/ramaze/helper/sequel.rb +1 -3
  99. data/lib/ramaze/helper/stack.rb +1 -3
  100. data/lib/ramaze/helper/tagz.rb +19 -0
  101. data/lib/ramaze/helper/user.rb +63 -0
  102. data/lib/ramaze/inform.rb +2 -24
  103. data/lib/ramaze/log.rb +28 -0
  104. data/lib/ramaze/{inform → log}/analogger.rb +3 -3
  105. data/lib/ramaze/{inform → log}/growl.rb +2 -2
  106. data/lib/ramaze/{inform → log}/hub.rb +4 -6
  107. data/lib/ramaze/{inform → log}/informer.rb +4 -4
  108. data/lib/ramaze/{inform → log}/knotify.rb +2 -2
  109. data/lib/ramaze/log/logger.rb +22 -0
  110. data/lib/ramaze/{inform/informing.rb → log/logging.rb} +16 -16
  111. data/lib/ramaze/{inform → log}/syslog.rb +0 -0
  112. data/lib/ramaze/{inform → log}/xosd.rb +2 -2
  113. data/lib/ramaze/route.rb +64 -36
  114. data/lib/ramaze/snippets/array/put_within.rb +13 -0
  115. data/lib/ramaze/snippets/binding/locals.rb +13 -0
  116. data/lib/ramaze/snippets/kernel/__dir__.rb +10 -8
  117. data/lib/ramaze/snippets/kernel/aquire.rb +1 -1
  118. data/lib/ramaze/snippets/kernel/constant.rb +1 -1
  119. data/lib/ramaze/snippets/object/pretty.rb +6 -0
  120. data/lib/ramaze/snippets/object/scope.rb +11 -0
  121. data/lib/ramaze/snippets/object/thread_accessor.rb +5 -0
  122. data/lib/ramaze/snippets/ordered_set.rb +1 -1
  123. data/lib/ramaze/snippets/proc/locals.rb +11 -0
  124. data/lib/ramaze/snippets/ramaze/thread_accessor.rb +44 -0
  125. data/lib/ramaze/snippets/string/esc.rb +29 -0
  126. data/lib/ramaze/snippets/string/start_with.rb +7 -0
  127. data/lib/ramaze/snippets/string/unindent.rb +6 -1
  128. data/lib/ramaze/snippets/struct/values_at.rb +1 -5
  129. data/lib/ramaze/sourcereload.rb +16 -14
  130. data/lib/ramaze/spec.rb +1 -0
  131. data/lib/ramaze/spec/helper.rb +11 -3
  132. data/lib/ramaze/spec/helper/browser.rb +25 -1
  133. data/lib/ramaze/spec/helper/pretty_output.rb +11 -11
  134. data/lib/ramaze/template.rb +5 -4
  135. data/lib/ramaze/template/amrita2.rb +2 -3
  136. data/lib/ramaze/template/ezamar/element.rb +2 -3
  137. data/lib/ramaze/template/ezamar/morpher.rb +1 -2
  138. data/lib/ramaze/template/ezamar/render_partial.rb +1 -1
  139. data/lib/ramaze/template/haml.rb +5 -2
  140. data/lib/ramaze/template/markaby.rb +2 -0
  141. data/lib/ramaze/template/tagz.rb +79 -0
  142. data/lib/ramaze/template/tenjin.rb +34 -0
  143. data/lib/ramaze/tool/create.rb +0 -3
  144. data/lib/ramaze/tool/localize.rb +107 -105
  145. data/lib/ramaze/tool/mime.rb +0 -2
  146. data/lib/ramaze/trinity.rb +1 -26
  147. data/lib/ramaze/version.rb +1 -1
  148. data/lib/vendor/bacon.rb +47 -41
  149. data/rake_tasks/conf.rake +18 -0
  150. data/rake_tasks/darcs.rake +5 -0
  151. data/rake_tasks/maintenance.rake +37 -24
  152. data/rake_tasks/spec.rake +1 -1
  153. data/spec/contrib/auto_params.rb +3 -1
  154. data/spec/contrib/profiling.rb +26 -0
  155. data/spec/examples/templates/template_redcloth.rb +1 -1
  156. data/spec/examples/templates/template_tenjin.rb +28 -0
  157. data/spec/helper.rb +0 -1
  158. data/spec/ramaze/action/layout.rb +28 -0
  159. data/spec/ramaze/controller/actionless_templates.rb +32 -0
  160. data/spec/ramaze/controller/template/other_wrapper.xhtml +1 -0
  161. data/spec/ramaze/controller/template_resolving.rb +37 -0
  162. data/spec/ramaze/{trinity → current}/request.rb +12 -2
  163. data/spec/ramaze/current/session.rb +97 -0
  164. data/spec/ramaze/dispatcher/directory.rb +2 -1
  165. data/spec/ramaze/dispatcher/file.rb +8 -3
  166. data/spec/ramaze/dispatcher/public/file name.txt +1 -0
  167. data/spec/ramaze/gestalt.rb +11 -0
  168. data/spec/ramaze/helper/aspect.rb +28 -22
  169. data/spec/ramaze/helper/cgi.rb +2 -2
  170. data/spec/ramaze/helper/flash.rb +33 -15
  171. data/spec/ramaze/helper/formatting.rb +2 -2
  172. data/spec/ramaze/helper/link.rb +46 -18
  173. data/spec/ramaze/helper/pager.rb +8 -5
  174. data/spec/ramaze/helper/partial.rb +8 -1
  175. data/spec/ramaze/helper/template/recursive_local_ivars.xhtml +7 -0
  176. data/spec/ramaze/helper/user.rb +46 -0
  177. data/spec/ramaze/{inform → log}/informer.rb +0 -0
  178. data/spec/ramaze/{inform → log}/syslog.rb +1 -1
  179. data/spec/ramaze/request.rb +14 -10
  180. data/spec/ramaze/route.rb +23 -0
  181. data/spec/ramaze/template.rb +48 -1
  182. data/spec/ramaze/template/haml.rb +6 -16
  183. data/spec/ramaze/template/haml/locals.haml +2 -1
  184. data/spec/ramaze/template/tagz.rb +62 -0
  185. data/spec/ramaze/template/tagz/external.tagz +8 -0
  186. data/spec/ramaze/template/tagz/sum.tagz +1 -0
  187. data/spec/ramaze/template/tenjin.rb +49 -0
  188. data/spec/ramaze/template/tenjin/external.tenjin +1 -0
  189. data/spec/snippets/string/unindent.rb +15 -0
  190. metadata +509 -475
  191. data/doc/README.html +0 -729
  192. data/doc/changes.txt +0 -5757
  193. data/doc/changes.xml +0 -5759
  194. data/examples/blog/src/view.rb +0 -16
  195. data/examples/blog/template/edit.xhtml +0 -19
  196. data/examples/blog/template/index.xhtml +0 -19
  197. data/examples/blog/template/new.xhtml +0 -18
  198. data/examples/wiktacular/mkd/newpagename/current.mkd +0 -1
  199. data/examples/wiktacular/mkd/newpagename/current.mkd.bak +0 -1
  200. data/lib/ramaze/contrib/email.rb-darcs-backup0 +0 -81
  201. data/lib/ramaze/template/bijou.rb +0 -39
  202. data/lib/ramaze/trinity/response.rb +0 -32
  203. data/spec/ramaze/template/bijou.rb +0 -25
  204. 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
- it 'should show request_uri' do
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
- it 'should show local_net?' do
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"], ["/test_download.css", "test_download.css"]
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
@@ -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() 'test before' end
12
- before(:test_before){ '<aspect>' }
11
+ def test_before() request[:before] += 2 end
12
+ before(:test_before){ request[:before] = 40 }
13
13
 
14
- def test_after() 'test after' end
15
- after(:test_after){ '</aspect>' }
14
+ def test_after() request[:after] = 40 end
15
+ after(:test_after){ request[:after] += 2 }
16
16
 
17
- def test_wrap() 'test wrap' end
18
- wrap(:test_wrap){ '<br />' }
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, :partial
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{ '<pre>' }
33
- after_all{ '</pre>' }
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').body.should == '<aspect>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').body.should == 'test after</aspect>'
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').body.should == '<br />test wrap<br />'
60
- end
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').body.should == '<pre>first</pre>'
68
- get('/all/test_all_second').body.should == '<pre>second</pre>'
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').body.should == '<pre>I am a template.</pre>'
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').body.should == '<pre>after</pre>'
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 == '<pre>12345</pre>'
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><pre>12345</pre></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
@@ -9,7 +9,7 @@ class TCLink < Ramaze::Controller
9
9
  end
10
10
 
11
11
  describe "url encode" do
12
- extend Ramaze::CgiHelper
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::CgiHelper
31
+ extend Ramaze::Helper::CGI
32
32
 
33
33
  it 'should escape html' do
34
34
  html_escape('& < >').should == '&amp; &lt; &gt;'
@@ -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 "FlashHelper" do
71
+ describe Ramaze::Helper::Flash do
61
72
  behaves_like 'browser'
62
73
  ramaze :adapter => :webrick
63
74
 
64
- it "twice" do
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
- it "over seperate controllers" do
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
- it "single" do
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
- it "single" do
106
+ should "show a flashbox" do
95
107
  Browser.new do
96
- get('/third/set/foo').should == 'foo'
97
- get('/third/retrieve').should == 'foo'
98
- get('/third/retrieve').should == ''
99
- get('/third/retrieve').should == ''
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