ramaze 0.0.7 → 0.0.8

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 (193) hide show
  1. data/Rakefile +52 -19
  2. data/bin/ramaze +19 -6
  3. data/doc/CHANGELOG +33 -0
  4. data/doc/COPYING +1 -1
  5. data/doc/FAQ +92 -0
  6. data/doc/GPL +340 -0
  7. data/doc/INSTALL +34 -0
  8. data/doc/ProjectInfo +53 -0
  9. data/doc/README +187 -110
  10. data/doc/readme_chunks/appendix.txt +13 -0
  11. data/doc/readme_chunks/examples.txt +38 -0
  12. data/doc/readme_chunks/features.txt +82 -0
  13. data/doc/readme_chunks/getting_help.txt +5 -0
  14. data/doc/readme_chunks/getting_started.txt +18 -0
  15. data/doc/readme_chunks/installing.txt +41 -0
  16. data/doc/readme_chunks/introduction.txt +18 -0
  17. data/doc/readme_chunks/principles.txt +41 -0
  18. data/doc/readme_chunks/thanks.txt +59 -0
  19. data/doc/tutorial/todolist.txt +546 -0
  20. data/examples/blog/main.rb +1 -1
  21. data/examples/blog/src/controller.rb +13 -11
  22. data/examples/blog/src/element.rb +11 -6
  23. data/examples/blog/src/model.rb +8 -23
  24. data/examples/blog/template/edit.xhtml +3 -1
  25. data/examples/blog/template/index.xhtml +4 -4
  26. data/examples/caching.rb +4 -4
  27. data/examples/element.rb +10 -7
  28. data/examples/hello.rb +3 -4
  29. data/examples/simple.rb +5 -3
  30. data/examples/templates/template/external.amrita +19 -0
  31. data/examples/templates/template/{external.rmze → external.zmr} +2 -2
  32. data/examples/templates/template_amrita2.rb +48 -0
  33. data/examples/templates/template_erubis.rb +5 -2
  34. data/examples/templates/{template_ramaze.rb → template_ezamar.rb} +13 -7
  35. data/examples/templates/template_haml.rb +4 -1
  36. data/examples/templates/template_liquid.rb +2 -1
  37. data/examples/templates/template_markaby.rb +2 -1
  38. data/examples/todolist/conf/benchmark.yaml +35 -0
  39. data/examples/todolist/conf/debug.yaml +34 -0
  40. data/examples/todolist/conf/live.yaml +33 -0
  41. data/examples/todolist/conf/silent.yaml +31 -0
  42. data/examples/todolist/conf/stage.yaml +33 -0
  43. data/examples/todolist/main.rb +18 -0
  44. data/examples/todolist/public/404.jpg +0 -0
  45. data/examples/todolist/public/css/coderay.css +105 -0
  46. data/examples/todolist/public/css/ramaze_error.css +42 -0
  47. data/{lib/proto → examples/todolist}/public/error.xhtml +0 -0
  48. data/examples/todolist/public/favicon.ico +0 -0
  49. data/examples/todolist/public/js/jquery.js +1923 -0
  50. data/examples/todolist/public/ramaze.png +0 -0
  51. data/examples/todolist/src/controller/main.rb +56 -0
  52. data/examples/todolist/src/element/page.rb +26 -0
  53. data/examples/todolist/src/model.rb +14 -0
  54. data/examples/todolist/template/index.xhtml +17 -0
  55. data/examples/todolist/template/new.xhtml +7 -0
  56. data/examples/todolist/todolist.db +9 -0
  57. data/examples/whywiki/main.rb +3 -8
  58. data/examples/whywiki/template/show.xhtml +4 -0
  59. data/lib/proto/public/error.zmr +77 -0
  60. data/lib/proto/src/controller/main.rb +2 -1
  61. data/lib/proto/src/element/page.rb +2 -1
  62. data/lib/proto/src/model.rb +3 -2
  63. data/lib/ramaze.rb +7 -9
  64. data/lib/ramaze/adapter.rb +51 -0
  65. data/lib/ramaze/adapter/cgi.rb +23 -0
  66. data/lib/ramaze/adapter/fcgi.rb +22 -0
  67. data/lib/ramaze/adapter/mongrel.rb +7 -86
  68. data/lib/ramaze/adapter/webrick.rb +14 -133
  69. data/lib/ramaze/cache/memcached.rb +6 -0
  70. data/lib/ramaze/cache/yaml_store.rb +3 -1
  71. data/lib/ramaze/controller.rb +292 -2
  72. data/lib/ramaze/dispatcher.rb +85 -213
  73. data/lib/ramaze/error.rb +10 -0
  74. data/lib/ramaze/global.rb +8 -0
  75. data/lib/ramaze/helper/aspect.rb +30 -7
  76. data/lib/ramaze/helper/auth.rb +16 -9
  77. data/lib/ramaze/helper/cache.rb +40 -35
  78. data/lib/ramaze/helper/feed.rb +1 -1
  79. data/lib/ramaze/helper/flash.rb +34 -0
  80. data/lib/ramaze/helper/link.rb +8 -2
  81. data/lib/ramaze/helper/openid.rb +63 -0
  82. data/lib/ramaze/helper/redirect.rb +12 -11
  83. data/lib/ramaze/helper/stack.rb +5 -7
  84. data/lib/ramaze/inform.rb +12 -1
  85. data/lib/ramaze/snippets/kernel/aquire.rb +1 -1
  86. data/lib/ramaze/snippets/kernel/{self_method.rb → method.rb} +3 -18
  87. data/lib/ramaze/snippets/kernel/{rescue_require.rb → pretty_inspect.rb} +7 -6
  88. data/lib/ramaze/snippets/method/name.rb +22 -0
  89. data/lib/ramaze/snippets/{kernel → ramaze}/autoreload.rb +0 -0
  90. data/lib/ramaze/snippets/ramaze/caller_info.rb +14 -0
  91. data/lib/ramaze/snippets/{kernel → ramaze}/caller_lines.rb +3 -10
  92. data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +49 -23
  93. data/lib/ramaze/snippets/string/DIVIDE.rb +0 -1
  94. data/lib/ramaze/store/default.rb +58 -2
  95. data/lib/ramaze/store/yaml.rb +161 -0
  96. data/lib/ramaze/template.rb +27 -86
  97. data/lib/ramaze/template/amrita2.rb +14 -19
  98. data/lib/ramaze/template/erubis.rb +15 -38
  99. data/lib/ramaze/template/ezamar.rb +100 -0
  100. data/lib/ramaze/template/ezamar/element.rb +166 -0
  101. data/lib/ramaze/template/ezamar/engine.rb +124 -0
  102. data/lib/ramaze/template/ezamar/morpher.rb +155 -0
  103. data/lib/ramaze/template/haml.rb +16 -43
  104. data/lib/ramaze/template/liquid.rb +11 -51
  105. data/lib/ramaze/template/markaby.rb +44 -42
  106. data/lib/ramaze/tool/mime.rb +18 -0
  107. data/lib/ramaze/tool/mime_types.yaml +615 -0
  108. data/lib/ramaze/trinity/request.rb +20 -196
  109. data/lib/ramaze/trinity/response.rb +4 -33
  110. data/lib/ramaze/trinity/session.rb +150 -72
  111. data/lib/ramaze/version.rb +1 -1
  112. data/spec/adapter_spec.rb +20 -0
  113. data/spec/public/favicon.ico +0 -0
  114. data/spec/public/ramaze.png +0 -0
  115. data/spec/public/test_download.css +141 -0
  116. data/spec/{tc_request.rb → request_tc_helper.rb} +45 -21
  117. data/spec/spec_all.rb +77 -34
  118. data/spec/spec_helper.rb +8 -157
  119. data/spec/spec_helper_context.rb +72 -0
  120. data/spec/spec_helper_requester.rb +52 -0
  121. data/spec/spec_helper_simple_http.rb +433 -0
  122. data/spec/tc_adapter_mongrel.rb +3 -15
  123. data/spec/tc_adapter_webrick.rb +4 -14
  124. data/spec/tc_cache.rb +3 -5
  125. data/spec/tc_controller.rb +22 -12
  126. data/spec/tc_dependencies.rb +13 -0
  127. data/spec/tc_element.rb +8 -7
  128. data/spec/tc_error.rb +13 -7
  129. data/spec/tc_global.rb +16 -18
  130. data/spec/tc_helper_aspect.rb +2 -4
  131. data/spec/tc_helper_auth.rb +15 -14
  132. data/spec/tc_helper_cache.rb +5 -7
  133. data/spec/tc_helper_feed.rb +0 -2
  134. data/spec/tc_helper_flash.rb +103 -0
  135. data/spec/tc_helper_form.rb +4 -6
  136. data/spec/tc_helper_link.rb +1 -3
  137. data/spec/tc_helper_redirect.rb +23 -8
  138. data/spec/tc_helper_stack.rb +31 -15
  139. data/spec/tc_morpher.rb +1 -3
  140. data/spec/tc_params.rb +48 -7
  141. data/spec/tc_request_mongrel.rb +9 -0
  142. data/spec/tc_request_webrick.rb +5 -0
  143. data/spec/tc_session.rb +41 -25
  144. data/spec/tc_store.rb +55 -6
  145. data/spec/tc_store_yaml.rb +71 -0
  146. data/spec/tc_template_amrita2.rb +3 -3
  147. data/spec/tc_template_erubis.rb +2 -3
  148. data/spec/{tc_template_ramaze.rb → tc_template_ezamar.rb} +15 -5
  149. data/spec/tc_template_haml.rb +4 -3
  150. data/spec/tc_template_liquid.rb +3 -4
  151. data/spec/tc_template_markaby.rb +4 -6
  152. data/spec/tc_tidy.rb +1 -3
  153. data/spec/template/amrita2/{data.html → data.amrita} +0 -0
  154. data/spec/template/amrita2/{index.html → index.amrita} +0 -0
  155. data/spec/template/amrita2/{sum.html → sum.amrita} +0 -0
  156. data/spec/template/ezamar/another/long/action.zmr +1 -0
  157. data/spec/template/ezamar/combined.zmr +1 -0
  158. data/spec/template/{ramaze/file_only.rmze → ezamar/file_only.zmr} +0 -0
  159. data/spec/template/{ramaze/index.rmze → ezamar/index.zmr} +0 -0
  160. data/spec/template/{ramaze/nested.rmze → ezamar/nested.zmr} +0 -0
  161. data/spec/template/ezamar/some__long__action.zmr +1 -0
  162. data/spec/template/{ramaze/sum.rmze → ezamar/sum.zmr} +0 -0
  163. metadata +181 -123
  164. data/doc/allison/LICENSE +0 -184
  165. data/doc/allison/README +0 -37
  166. data/doc/allison/allison.css +0 -300
  167. data/doc/allison/allison.gif +0 -0
  168. data/doc/allison/allison.js +0 -307
  169. data/doc/allison/allison.rb +0 -287
  170. data/doc/allison/cache/BODY +0 -588
  171. data/doc/allison/cache/CLASS_INDEX +0 -4
  172. data/doc/allison/cache/CLASS_PAGE +0 -1
  173. data/doc/allison/cache/FILE_INDEX +0 -4
  174. data/doc/allison/cache/FILE_PAGE +0 -1
  175. data/doc/allison/cache/FONTS +0 -1
  176. data/doc/allison/cache/FR_INDEX_BODY +0 -1
  177. data/doc/allison/cache/IMGPATH +0 -1
  178. data/doc/allison/cache/INDEX +0 -1
  179. data/doc/allison/cache/JAVASCRIPT +0 -307
  180. data/doc/allison/cache/METHOD_INDEX +0 -4
  181. data/doc/allison/cache/METHOD_LIST +0 -1
  182. data/doc/allison/cache/SRC_PAGE +0 -1
  183. data/doc/allison/cache/STYLE +0 -322
  184. data/doc/allison/cache/URL +0 -1
  185. data/doc/changes.txt +0 -2021
  186. data/doc/changes.xml +0 -2024
  187. data/lib/ramaze/snippets/kernel/silently.rb +0 -13
  188. data/lib/ramaze/snippets/thread/deadQUESTIONMARK.rb +0 -11
  189. data/lib/ramaze/template/haml/actionview_stub.rb +0 -20
  190. data/lib/ramaze/template/ramaze.rb +0 -177
  191. data/lib/ramaze/template/ramaze/element.rb +0 -166
  192. data/lib/ramaze/template/ramaze/morpher.rb +0 -156
  193. data/spec/tc_test.rb +0 -17
@@ -5,20 +5,8 @@ require 'spec/spec_helper'
5
5
 
6
6
  testcase_requires 'mongrel'
7
7
 
8
- include Ramaze
9
-
10
- class TCAdapterController < Template::Ramaze
11
- def index
12
- "The index"
13
- end
8
+ def ramaze_options
9
+ { :adapter => :mongrel }
14
10
  end
15
11
 
16
- context "Mongrel" do
17
- context "multiple" do
18
- ramaze :mapping => {'/' => TCAdapterController}, :port => '7001..7003', :adapter => :mongrel
19
-
20
- specify "simple request" do
21
- get('/').should == "The index"
22
- end
23
- end
24
- end
12
+ require 'spec/adapter_spec'
@@ -3,20 +3,10 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
6
+ testcase_requires 'webrick'
7
7
 
8
- class TCAdapterController < Template::Ramaze
9
- def index
10
- "The index"
11
- end
8
+ def ramaze_options
9
+ { :adapter => :webrick }
12
10
  end
13
11
 
14
- context "WEBrick" do
15
- context "multiple" do
16
- ramaze :mapping => {'/' => TCAdapterController}, :port => '7001..7003', :adapter => :webrick
17
-
18
- specify "simple request" do
19
- get('/').should == "The index"
20
- end
21
- end
22
- end
12
+ require 'spec/adapter_spec'
@@ -3,10 +3,8 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
7
-
8
6
  context "MemoryCache" do
9
- cache = MemoryCache.new
7
+ cache = Ramaze::MemoryCache.new
10
8
 
11
9
  specify "delete" do
12
10
  cache.delete(:one)
@@ -29,7 +27,7 @@ context "MemoryCache" do
29
27
  end
30
28
 
31
29
  context "YAMLStoreCache" do
32
- cache = YAMLStoreCache.new
30
+ cache = Ramaze::YAMLStoreCache.new
33
31
 
34
32
  specify "delete" do
35
33
  cache.delete(:one)
@@ -53,7 +51,7 @@ end
53
51
 
54
52
  begin
55
53
  context "MemcachedCache" do
56
- cache = MemcachedCache.new
54
+ cache = Ramaze::MemcachedCache.new
57
55
 
58
56
  specify "delete" do
59
57
  cache.delete(:one)
@@ -3,15 +3,20 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
7
-
8
- class TCControllerRamazeController < Template::Ramaze
6
+ class TCControllerEzamarController < Ramaze::Controller
7
+ trait :template_root => 'spec/template/ezamar'
9
8
  def index
10
- "The index"
9
+ @text = "World"
11
10
  end
12
11
 
13
12
  def sum first, second
14
- first.to_i + second.to_i
13
+ @num1, @num2 = first.to_i, second.to_i
14
+ end
15
+
16
+ def some__long__action
17
+ end
18
+
19
+ def another__long__action
15
20
  end
16
21
 
17
22
  private
@@ -20,20 +25,25 @@ class TCControllerRamazeController < Template::Ramaze
20
25
  end
21
26
  end
22
27
 
23
- context "Testing Ramaze" do
24
- ramaze(:mapping => {'/ramaze' => TCControllerRamazeController})
28
+ context "Testing Ezamar" do
29
+ ramaze(:mapping => {'/ezamar' => TCControllerEzamarController})
25
30
 
26
31
  specify "simple request to index" do
27
- get('/ramaze').should == 'The index'
32
+ get('/ezamar').should == 'Hello, World!'
28
33
  end
29
34
 
30
35
  specify "summing two values" do
31
- get('/ramaze/sum/1/2').should == '3'
36
+ get('/ezamar/sum/1/2').should == '3'
37
+ end
38
+
39
+ specify "double underscore in templates" do
40
+ get('/ezamar/some/long/action').should == 'some long action'
41
+ get('/ezamar/another/long/action').should == 'another long action'
32
42
  end
33
43
 
34
44
  specify "should not respond to private methods" do
35
- %w[ session request response find_template handle_request trait test_private ].each do |action|
36
- lambda{get("/ramaze/#{action}")}.should_raise OpenURI::HTTPError
37
- end
45
+ %w[ session request response find_template handle_request trait test_private ].each do |action|
46
+ lambda{get("/ramaze/#{action}")}.should_raise
47
+ end
38
48
  end
39
49
  end
@@ -0,0 +1,13 @@
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/spec_helper'
5
+
6
+ testcase_requires 'rubygems'
7
+
8
+ context "dependencies" do
9
+ specify "no gems" do
10
+ gems = $:.grep(/gems/).reject{|g| g =~ /rspec|rack/}
11
+ gems.should == []
12
+ end
13
+ end
@@ -3,9 +3,9 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
6
+ class TCElementController < Ramaze::Controller
7
+ trait :engine => Ramaze::Template::Ezamar
7
8
 
8
- class TCElementController < Template::Ramaze
9
9
  def index
10
10
  "The index"
11
11
  end
@@ -37,31 +37,32 @@ class TCElementController < Template::Ramaze
37
37
  end
38
38
  end
39
39
 
40
- class Page < Element
40
+ class Page < Ezamar::Element
41
41
  def render
42
42
  %{ <wrap> #{content} </wrap> }
43
43
  end
44
44
  end
45
45
 
46
- class PageWithParams < Element
46
+
47
+ class PageWithParams < Ezamar::Element
47
48
  def render
48
49
  @hash.inspect
49
50
  end
50
51
  end
51
52
 
52
- class PageLittle < Element
53
+ class PageLittle < Ezamar::Element
53
54
  def render
54
55
  "little"
55
56
  end
56
57
  end
57
58
 
58
- class PageLittleWithParams < Element
59
+ class PageLittleWithParams < Ezamar::Element
59
60
  def render
60
61
  @hash.inspect
61
62
  end
62
63
  end
63
64
 
64
- class PageWithTemplating < Element
65
+ class PageWithTemplating < Ezamar::Element
65
66
  def render
66
67
  (1..@hash['times']).to_a.join(', ')
67
68
  end
@@ -2,10 +2,9 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  require 'spec/spec_helper'
5
+ require 'open-uri'
5
6
 
6
- include Ramaze
7
-
8
- class TCErrorController < Template::Ramaze
7
+ class TCErrorController < Ramaze::Controller
9
8
  def index
10
9
  self.class.name
11
10
  end
@@ -13,11 +12,18 @@ end
13
12
 
14
13
  context "Error" do
15
14
  context "in dispatcher" do
16
- ramaze :mapping => {'/' => TCErrorController}, :error_page => true
15
+ ramaze :mapping => {'/' => TCErrorController }, :error_page => true
16
+
17
+ specify "your illegal stuff" do
18
+ lambda{ get('/def/illegal') }.should_raise RuntimeError, /Net::HTTPNotFound/
19
+ end
20
+ end
21
+
22
+ context "no controller" do
23
+ Ramaze::Global.mapping = {}
17
24
 
18
- specify "wrong parameter" do
19
- get('/').should == 'TCErrorController'
20
- get('/1').should =~ /NoAction/
25
+ specify "your illegal stuff" do
26
+ lambda{ get('/def/illegal') }.should_raise RuntimeError, /Net::HTTPNotFound/
21
27
  end
22
28
  end
23
29
  end
@@ -3,44 +3,42 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
7
-
8
- context "Global" do
6
+ context "Ramaze::Global" do
9
7
  specify "just simple assignment and retrive" do
10
- Global.some = :xxx
11
- Global.some.should == :xxx
8
+ Ramaze::Global.some = :xxx
9
+ Ramaze::Global.some.should == :xxx
12
10
  end
13
11
 
14
12
  specify "setup" do
15
- Global.setup :a => :b
16
- Global.a.should == :b
17
- Global.some.should == :xxx
18
- Global.setup :a => :c
19
- Global.a.should == :c
13
+ Ramaze::Global.setup :a => :b
14
+ Ramaze::Global.a.should == :b
15
+ Ramaze::Global.some.should == :xxx
16
+ Ramaze::Global.setup :a => :c
17
+ Ramaze::Global.a.should == :c
20
18
  end
21
19
 
22
20
  specify "more neat stuff" do
23
- Global.update :a => :d, :foo => :bar
24
- Global.a.should == :c
25
- Global.foo.should == :bar
21
+ Ramaze::Global.update :a => :d, :foo => :bar
22
+ Ramaze::Global.a.should == :c
23
+ Ramaze::Global.foo.should == :bar
26
24
  end
27
25
 
28
26
  specify "values_at" do
29
- Global.values_at(:a, :foo).should == [:c, :bar]
27
+ Ramaze::Global.values_at(:a, :foo).should == [:c, :bar]
30
28
  end
31
29
 
32
30
  specify "getting thready" do
33
- Global[:i] = 0
31
+ Ramaze::Global[:i] = 0
34
32
  Thread.main[:i] = 0
35
33
 
36
34
  (1..10).each do |i|
37
35
  Thread.new do
38
- Global[:i] += i
36
+ Ramaze::Global[:i] += i
39
37
  Thread.main[:i] += i
40
38
  end
41
39
  end
42
40
 
43
- Global[:i].should == Thread.main[:i]
44
- Global[:i].should == 55
41
+ Ramaze::Global[:i].should == Thread.main[:i]
42
+ Ramaze::Global[:i].should == 55
45
43
  end
46
44
  end
@@ -3,9 +3,7 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
7
-
8
- class TCAspectController < Template::Ramaze
6
+ class TCAspectController < Ramaze::Controller
9
7
  helper :aspect
10
8
 
11
9
  def pre_aspect() '<aspect>' end
@@ -26,7 +24,7 @@ class TCAspectController < Template::Ramaze
26
24
  wrap :test_wrap, :wrap_aspect
27
25
  end
28
26
 
29
- class TCAspectAllController < Template::Ramaze
27
+ class TCAspectAllController < Ramaze::Controller
30
28
  helper :aspect
31
29
 
32
30
  def pre_aspect() '<pre>' end
@@ -3,11 +3,13 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
7
-
8
- class TCAuthHelperController < Template::Ramaze
6
+ class TCAuthHelperController < Ramaze::Controller
9
7
  helper :auth
10
8
 
9
+ def index
10
+ self.class.name
11
+ end
12
+
11
13
  def session_inspect
12
14
  session.inspect
13
15
  end
@@ -45,17 +47,16 @@ context "StackHelper" do
45
47
  TCAuthMethodHelperController,
46
48
  TCAuthLambdaHelperController
47
49
  ].each do |controller|
48
- p controller
49
- ctx = Context.new('/session_inspect', Global.mapping.invert[controller])
50
-
51
- specify "checking security" do
52
- ctx.get('secured').should == ''
53
- ctx.get('secured').should == ''
54
- ctx.post('login', :username => 'manveru', :password => 'password').should == 'Secret content'
55
- ctx.get('secured').should == 'Secret content'
56
- ctx.get('secured').should == 'Secret content'
57
- ctx.get('logout').should == ''
58
- ctx.get('secured').should == ''
50
+ ctx = Context.new('/', Ramaze::Global.mapping.invert[controller])
51
+
52
+ specify controller.to_s do
53
+ Context.new('/', Ramaze::Global.mapping.invert[controller]) do
54
+ get('/secured').should == ''
55
+ post('/login', 'username' => 'manveru', 'password' => 'password')
56
+ get('/secured').should == 'Secret content'
57
+ get('/logout')
58
+ get('/secured').should == ''
59
+ end
59
60
  end
60
61
  end
61
62
  end
@@ -3,11 +3,11 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
7
-
8
- class TCCacheHelperController < Template::Ramaze
6
+ class TCCacheHelperController < Ramaze::Controller
9
7
  helper :cache
10
8
 
9
+ trait :actions_cached => [:cached_action]
10
+
11
11
  def index
12
12
  self.class.name
13
13
  end
@@ -17,7 +17,7 @@ class TCCacheHelperController < Template::Ramaze
17
17
  end
18
18
 
19
19
  def uncache_value
20
- value_cache.delete(:time)
20
+ value_cache.delete :time
21
21
  end
22
22
 
23
23
  def cached_action
@@ -25,11 +25,9 @@ class TCCacheHelperController < Template::Ramaze
25
25
  end
26
26
 
27
27
  def uncache_actions
28
- uncache_all
28
+ action_cache.clear
29
29
  end
30
30
 
31
- cache_actions :cached_action
32
-
33
31
  private
34
32
 
35
33
  def random
@@ -26,8 +26,6 @@ class With
26
26
  end
27
27
  end
28
28
 
29
- include Ramaze
30
-
31
29
  class Book < With
32
30
  include ReFeed
33
31
 
@@ -0,0 +1,103 @@
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/spec_helper'
5
+
6
+ class TCFlashHelperFirstController < Ramaze::Controller
7
+ helper :flash
8
+
9
+ def index
10
+ self.class.name
11
+ end
12
+
13
+ def first_here
14
+ flash[:first] = 'hey'
15
+ end
16
+
17
+ def then_here
18
+ flash[:first].to_s
19
+ end
20
+ end
21
+
22
+ class TCFlashHelperSecondController < Ramaze::Controller
23
+ helper :flash
24
+
25
+ def index
26
+ self.class.name
27
+ end
28
+
29
+ def first_here
30
+ flash[:first] = 'hey'
31
+ end
32
+
33
+ def then_here
34
+ flash[:first].to_s
35
+ end
36
+ end
37
+
38
+ class TCFlashHelperThirdController < Ramaze::Controller
39
+ helper :flash
40
+
41
+ def index
42
+ end
43
+
44
+ def noop
45
+ 'noop'
46
+ end
47
+
48
+ def set par
49
+ flash[:e] = par
50
+ end
51
+
52
+ def retrieve
53
+ flash[:e]
54
+ end
55
+ end
56
+
57
+ context "FlashHelper" do
58
+ ramaze :adapter => :mongrel,
59
+ :mapping => {
60
+ '/' => TCFlashHelperFirstController,
61
+ '/second' => TCFlashHelperSecondController,
62
+ '/third' => TCFlashHelperThirdController
63
+ }
64
+
65
+ specify "twice" do
66
+ Context.new('/') do
67
+ get('/first_here')
68
+ get('/then_here').should == 'hey'
69
+ get('/then_here').should == ''
70
+ get('/then_here').should == ''
71
+ get('/first_here')
72
+ get('/then_here').should == 'hey'
73
+ get('/then_here').should == ''
74
+ end
75
+ end
76
+
77
+ specify "over seperate controllers" do
78
+ Context.new do
79
+ get('/first_here')
80
+ get('/second/then_here').should == 'hey'
81
+ get('/then_here').should == ''
82
+ get('/second/then_here').should == ''
83
+ get('/second/first_here')
84
+ get('/then_here').should == 'hey'
85
+ get('/second/then_here').should == ''
86
+ end
87
+ end
88
+
89
+ specify "single" do
90
+ Context.new do
91
+ get('/third/set/foo').should == 'foo'
92
+ end
93
+ end
94
+
95
+ specify "single" do
96
+ Context.new do
97
+ get('/third/set/foo').should == 'foo'
98
+ get('/third/retrieve').should == 'foo'
99
+ get('/third/retrieve').should == ''
100
+ get('/third/retrieve').should == ''
101
+ end
102
+ end
103
+ end