ramaze 0.1.4 → 0.2.0

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