ramaze 0.1.0 → 0.1.1

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 (195) hide show
  1. data/Rakefile +4 -12
  2. data/bin/ramaze +95 -171
  3. data/doc/CHANGELOG +387 -4
  4. data/doc/README +81 -13
  5. data/doc/meta/announcement.txt +51 -8
  6. data/doc/meta/configuration.txt +17 -34
  7. data/doc/meta/internals.txt +34 -4
  8. data/doc/migrate/1110_to_1111.txt +131 -0
  9. data/doc/readme_chunks/features.txt +81 -12
  10. data/doc/readme_chunks/installing.txt +0 -1
  11. data/doc/tutorial/todolist.html +293 -65
  12. data/doc/tutorial/{todolist.txt → todolist.mkd} +251 -51
  13. data/examples/blog/main.rb +1 -1
  14. data/examples/blog/src/model.rb +0 -1
  15. data/examples/hello.rb +2 -5
  16. data/examples/templates/template/external.haml +5 -5
  17. data/examples/templates/template/external.liquid +1 -1
  18. data/examples/templates/template/external.mab +8 -8
  19. data/examples/templates/template/external.rem +30 -0
  20. data/examples/templates/template/external.rhtml +6 -7
  21. data/examples/templates/template/external.zmr +13 -9
  22. data/examples/templates/template_amrita2.rb +8 -8
  23. data/examples/templates/template_erubis.rb +11 -11
  24. data/examples/templates/template_ezamar.rb +9 -11
  25. data/examples/templates/template_haml.rb +13 -13
  26. data/examples/templates/template_liquid.rb +10 -10
  27. data/examples/templates/template_markaby.rb +13 -10
  28. data/examples/templates/template_remarkably.rb +59 -0
  29. data/examples/todolist/main.rb +1 -7
  30. data/examples/todolist/src/controller/main.rb +26 -13
  31. data/examples/todolist/src/element/page.rb +5 -0
  32. data/examples/whywiki/main.rb +1 -1
  33. data/lib/proto/main.rb +0 -8
  34. data/lib/proto/public/css/ramaze_error.css +12 -4
  35. data/lib/proto/public/error.zmr +6 -25
  36. data/lib/ramaze.rb +35 -245
  37. data/lib/ramaze/action.rb +21 -0
  38. data/lib/ramaze/adapter.rb +94 -29
  39. data/lib/ramaze/adapter/base.rb +57 -0
  40. data/lib/ramaze/adapter/mongrel.rb +12 -19
  41. data/lib/ramaze/adapter/webrick.rb +21 -20
  42. data/lib/ramaze/cache.rb +47 -3
  43. data/lib/ramaze/cache/memcached.rb +22 -0
  44. data/lib/ramaze/cache/yaml_store.rb +19 -0
  45. data/lib/ramaze/controller.rb +47 -271
  46. data/lib/ramaze/controller/error.rb +43 -0
  47. data/lib/ramaze/controller/render.rb +90 -0
  48. data/lib/ramaze/controller/resolve.rb +147 -0
  49. data/lib/ramaze/dispatcher.rb +41 -9
  50. data/lib/ramaze/dispatcher/file.rb +1 -1
  51. data/lib/ramaze/global.rb +73 -158
  52. data/lib/ramaze/global/dsl.rb +29 -0
  53. data/lib/ramaze/global/globalstruct.rb +90 -0
  54. data/lib/ramaze/helper.rb +1 -1
  55. data/lib/ramaze/helper/aspect.rb +39 -179
  56. data/lib/ramaze/helper/cache.rb +8 -9
  57. data/lib/ramaze/helper/cgi.rb +23 -0
  58. data/lib/ramaze/helper/file.rb +3 -0
  59. data/lib/ramaze/helper/inform.rb +3 -0
  60. data/lib/ramaze/helper/link.rb +56 -63
  61. data/lib/ramaze/helper/nitroform.rb +4 -0
  62. data/lib/ramaze/helper/redirect.rb +1 -1
  63. data/lib/ramaze/inform.rb +6 -2
  64. data/lib/ramaze/inform/analogger.rb +5 -1
  65. data/lib/ramaze/inform/hub.rb +1 -1
  66. data/lib/ramaze/inform/informing.rb +7 -0
  67. data/lib/ramaze/snippets/kernel/aquire.rb +2 -0
  68. data/lib/ramaze/snippets/kernel/constant.rb +2 -0
  69. data/lib/ramaze/snippets/kernel/pretty_inspect.rb +2 -0
  70. data/lib/ramaze/snippets/object/traits.rb +4 -0
  71. data/lib/ramaze/snippets/openstruct/temp.rb +3 -0
  72. data/lib/ramaze/snippets/string/DIVIDE.rb +2 -0
  73. data/lib/ramaze/snippets/string/camel_case.rb +2 -0
  74. data/lib/ramaze/snippets/string/color.rb +2 -0
  75. data/lib/ramaze/snippets/string/each.rb +2 -0
  76. data/lib/ramaze/snippets/string/snake_case.rb +3 -0
  77. data/lib/ramaze/snippets/struct/fill.rb +8 -2
  78. data/lib/ramaze/snippets/struct/values_at.rb +16 -0
  79. data/lib/ramaze/snippets/symbol/to_proc.rb +3 -0
  80. data/lib/ramaze/sourcereload.rb +89 -0
  81. data/lib/ramaze/template.rb +21 -12
  82. data/lib/ramaze/template/amrita2.rb +6 -6
  83. data/lib/ramaze/template/erubis.rb +4 -9
  84. data/lib/ramaze/template/ezamar.rb +13 -57
  85. data/lib/ramaze/template/ezamar/element.rb +10 -12
  86. data/lib/ramaze/template/ezamar/engine.rb +40 -101
  87. data/lib/ramaze/template/ezamar/morpher.rb +3 -3
  88. data/lib/ramaze/template/haml.rb +3 -6
  89. data/lib/ramaze/template/liquid.rb +4 -9
  90. data/lib/ramaze/template/markaby.rb +16 -22
  91. data/lib/ramaze/template/remarkably.rb +28 -0
  92. data/lib/ramaze/tool/mime.rb +2 -0
  93. data/lib/ramaze/tool/record.rb +6 -0
  94. data/lib/ramaze/trinity/request.rb +44 -54
  95. data/lib/ramaze/trinity/response.rb +1 -1
  96. data/lib/ramaze/trinity/session.rb +15 -37
  97. data/lib/ramaze/version.rb +1 -1
  98. data/rake_tasks/gem.rake +2 -2
  99. data/rake_tasks/maintaince.rake +42 -1
  100. data/rake_tasks/spec.rake +45 -0
  101. data/spec/examples/caching.rb +1 -1
  102. data/spec/examples/simple.rb +1 -1
  103. data/spec/examples/templates/template_amrita2.rb +1 -0
  104. data/spec/examples/templates/template_erubis.rb +2 -1
  105. data/spec/examples/templates/template_ezamar.rb +1 -1
  106. data/spec/examples/templates/template_haml.rb +2 -1
  107. data/spec/examples/templates/template_liquid.rb +2 -1
  108. data/spec/examples/templates/template_markaby.rb +2 -1
  109. data/spec/examples/templates/template_remarkably.rb +22 -0
  110. data/spec/examples/todolist.rb +125 -0
  111. data/spec/helper.rb +2 -23
  112. data/spec/helper/minimal.rb +20 -0
  113. data/spec/helper/mock_http.rb +24 -30
  114. data/spec/helper/simple_http.rb +2 -2
  115. data/spec/helper/wrap.rb +6 -9
  116. data/spec/ramaze/adapter.rb +1 -1
  117. data/spec/ramaze/adapter/record.rb +31 -0
  118. data/spec/ramaze/cache.rb +41 -54
  119. data/spec/ramaze/controller.rb +121 -137
  120. data/spec/ramaze/controller/template/list.xhtml +1 -0
  121. data/spec/ramaze/controller/template/other/greet/other.xhtml +1 -0
  122. data/spec/ramaze/controller/template_resolving.rb +27 -3
  123. data/spec/ramaze/element.rb +11 -7
  124. data/spec/ramaze/error.rb +1 -1
  125. data/spec/ramaze/gestalt.rb +2 -0
  126. data/spec/ramaze/helper/aspect.rb +30 -21
  127. data/spec/ramaze/helper/auth.rb +1 -1
  128. data/spec/ramaze/helper/cache.rb +2 -1
  129. data/spec/ramaze/helper/form.rb +14 -11
  130. data/spec/ramaze/helper/link.rb +18 -41
  131. data/spec/ramaze/localize.rb +29 -2
  132. data/spec/ramaze/morpher.rb +23 -12
  133. data/spec/ramaze/params.rb +46 -24
  134. data/spec/ramaze/request.rb +6 -2
  135. data/spec/ramaze/store/yaml.rb +5 -0
  136. data/spec/ramaze/template.rb +22 -27
  137. data/spec/ramaze/template/amrita2.rb +1 -2
  138. data/spec/ramaze/template/erubis.rb +1 -1
  139. data/spec/ramaze/template/ezamar.rb +1 -2
  140. data/spec/ramaze/template/haml.rb +2 -2
  141. data/spec/ramaze/template/haml/with_vars.haml +1 -1
  142. data/spec/ramaze/template/liquid.rb +1 -1
  143. data/spec/ramaze/template/markaby.rb +1 -1
  144. data/spec/ramaze/template/remarkably.rb +56 -0
  145. data/spec/ramaze/template/remarkably/external.rem +8 -0
  146. data/spec/ramaze/template/remarkably/sum.rem +1 -0
  147. metadata +38 -63
  148. data/doc/README.html +0 -637
  149. data/doc/allison/LICENSE +0 -184
  150. data/doc/allison/README +0 -37
  151. data/doc/allison/allison.css +0 -299
  152. data/doc/allison/allison.gif +0 -0
  153. data/doc/allison/allison.js +0 -307
  154. data/doc/allison/allison.rb +0 -287
  155. data/doc/allison/cache/BODY +0 -588
  156. data/doc/allison/cache/CLASS_INDEX +0 -4
  157. data/doc/allison/cache/CLASS_PAGE +0 -1
  158. data/doc/allison/cache/FILE_INDEX +0 -4
  159. data/doc/allison/cache/FILE_PAGE +0 -1
  160. data/doc/allison/cache/FONTS +0 -1
  161. data/doc/allison/cache/FR_INDEX_BODY +0 -1
  162. data/doc/allison/cache/IMGPATH +0 -1
  163. data/doc/allison/cache/INDEX +0 -1
  164. data/doc/allison/cache/JAVASCRIPT +0 -307
  165. data/doc/allison/cache/METHOD_INDEX +0 -4
  166. data/doc/allison/cache/METHOD_LIST +0 -1
  167. data/doc/allison/cache/SRC_PAGE +0 -1
  168. data/doc/allison/cache/STYLE +0 -321
  169. data/doc/allison/cache/URL +0 -1
  170. data/doc/changes.txt +0 -3375
  171. data/doc/changes.xml +0 -3378
  172. data/examples/todolist/conf/benchmark.yaml +0 -35
  173. data/examples/todolist/conf/debug.yaml +0 -34
  174. data/examples/todolist/conf/live.yaml +0 -33
  175. data/examples/todolist/conf/silent.yaml +0 -31
  176. data/examples/todolist/conf/stage.yaml +0 -33
  177. data/examples/todolist/public/css/coderay.css +0 -105
  178. data/examples/todolist/public/css/ramaze_error.css +0 -42
  179. data/lib/proto/conf/benchmark.yaml +0 -21
  180. data/lib/proto/conf/debug.yaml +0 -21
  181. data/lib/proto/conf/live.yaml +0 -21
  182. data/lib/proto/conf/silent.yaml +0 -21
  183. data/lib/proto/conf/stage.yaml +0 -21
  184. data/lib/proto/public/css/coderay.css +0 -105
  185. data/lib/ramaze/http_status.rb +0 -66
  186. data/lib/ramaze/snippets/hash/keys_to_sym.rb +0 -19
  187. data/lib/ramaze/snippets/kernel/method.rb +0 -26
  188. data/lib/ramaze/snippets/method/name.rb +0 -22
  189. data/lib/ramaze/snippets/ramaze/autoreload.rb +0 -135
  190. data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +0 -65
  191. data/spec/all.rb +0 -32
  192. data/spec/ramaze/conf/locale_de.yaml +0 -6
  193. data/spec/ramaze/conf/locale_en.yaml +0 -6
  194. data/spec/ramaze/dependencies.rb +0 -16
  195. data/spec/ramaze/global.rb +0 -44
@@ -0,0 +1,31 @@
1
+ require 'spec/helper'
2
+
3
+ class TCRecordController < Ramaze::Controller
4
+ map '/'
5
+
6
+ def index
7
+ 'The index'
8
+ end
9
+
10
+ def foo
11
+ 'The foo'
12
+ end
13
+ end
14
+
15
+ describe 'Adapter recording' do
16
+ setup do
17
+ ramaze :adapter => :webrick, :record => lambda{|request|
18
+ request.remote_addr == '127.0.0.1'
19
+ }
20
+
21
+ @record = Ramaze::Record
22
+ end
23
+
24
+ it 'should record' do
25
+ get('/').body.should == 'The index'
26
+ get('/foo').body.should == 'The foo'
27
+ @record.should have(2).requests
28
+ @record.first.path_info.should == '/'
29
+ @record.last.path_info.should == '/foo'
30
+ end
31
+ end
@@ -3,75 +3,62 @@
3
3
 
4
4
  require 'spec/helper'
5
5
 
6
- describe "MemoryCache" do
7
- cache = Ramaze::MemoryCache.new
6
+ caches = {:memory => 'Hash', :yaml => 'Ramaze::YAMLStoreCache'}
8
7
 
9
- it "delete" do
10
- cache.delete(:one)
11
- cache.delete(:two)
12
- end
13
-
14
- it "set keys" do
15
- (cache[:one] = 'eins').should == "eins"
16
- (cache[:two] = 'zwei').should == "zwei"
17
- end
18
-
19
- it "read keys" do
20
- cache[:one].should == 'eins'
21
- cache[:two].should == 'zwei'
22
- end
23
-
24
- it "values_at" do
25
- cache.values_at(:one, :two).should == %w[eins zwei]
26
- end
8
+ begin
9
+ require 'memcache'
10
+ caches[:memcached] = 'Ramaze::MemcachedCache'
11
+ rescue LoadError
12
+ puts "skipping memcached"
27
13
  end
28
14
 
29
- describe "YAMLStoreCache" do
30
- cache = Ramaze::YAMLStoreCache.new
31
-
32
- it "delete" do
33
- cache.delete(:one)
34
- cache.delete(:two)
35
- end
15
+ caches.each do |cache, name|
16
+ describe "#{name} setup" do
17
+ it "should be assignable to Global" do
18
+ Ramaze::Global.cache = cache
19
+ Ramaze::Global.cache.to_s.should == name
20
+ end
36
21
 
37
- it "set keys" do
38
- (cache[:one] = 'eins').should == "eins"
39
- (cache[:two] = 'zwei').should == "zwei"
22
+ it "should do .new" do
23
+ @cache = Ramaze::Global.cache.new
24
+ @cache.class.name.should == name
25
+ end
40
26
  end
41
27
 
42
- it "read keys" do
43
- cache[:one].should == 'eins'
44
- cache[:two].should == 'zwei'
45
- end
28
+ describe "#{name} modification" do
29
+ setup do
30
+ Ramaze::Global.cache = cache
31
+ @cache = Ramaze::Global.cache.new
32
+ end
46
33
 
47
- it "values_at" do
48
- cache.values_at(:one, :two).should == %w[eins zwei]
49
- end
50
- end
34
+ after :each do
35
+ @cache.clear
36
+ end
51
37
 
52
- begin
53
- describe "MemcachedCache" do
54
- cache = Ramaze::MemcachedCache.new
38
+ after :all do
39
+ FileUtils.rm(@cache.file) if cache == :yaml
40
+ end
55
41
 
56
- it "delete" do
57
- cache.delete(:one)
58
- cache.delete(:two)
42
+ it "should be assignable with #[]=" do
43
+ @cache[:foo] = :bar
44
+ @cache[:foo].should == :bar
59
45
  end
60
46
 
61
- it "set keys" do
62
- (cache[:one] = 'eins').should == "eins"
63
- (cache[:two] = 'zwei').should == "zwei"
47
+ it "should be retrievable with #[]" do
48
+ @cache[:yoh] = :bar
49
+ @cache[:yoh].should == :bar
64
50
  end
65
51
 
66
- it "read keys" do
67
- cache[:one].should == 'eins'
68
- cache[:two].should == 'zwei'
52
+ it "should delete keys" do
53
+ @cache[:bar] = :duh
54
+ @cache.delete(:bar)
55
+ @cache[:bar].should be_nil
69
56
  end
70
57
 
71
- it "values_at" do
72
- cache.values_at(:one, :two).should == %w[eins zwei]
58
+ it "should show values for multiple keys" do
59
+ @cache[:baz] = :foo
60
+ @cache[:beh] = :feh
61
+ @cache.values_at(:baz, :beh).should == [:foo, :feh]
73
62
  end
74
63
  end
75
- rescue LoadError
76
- puts "cannot run test for memcached"
77
64
  end
@@ -5,7 +5,7 @@ require 'spec/helper'
5
5
 
6
6
  class TCControllerController < Ramaze::Controller
7
7
  map '/'
8
- trait :template_root => 'spec/ramaze/template/ezamar'
8
+ template_root 'spec/ramaze/template/ezamar'
9
9
 
10
10
  def index
11
11
  @text = "World"
@@ -28,157 +28,141 @@ class TCControllerController < Ramaze::Controller
28
28
  end
29
29
 
30
30
  describe "Controller" do
31
- ramaze :error_page => false
32
-
33
- describe 'dry specs' do
34
- describe 'pattern_for' do
35
- hash = {
36
- '/' => [
37
- ["/", 'index', []]
38
- ],
39
-
40
- '/foo' => [
41
- ["/foo", 'index',[]],
42
- ['/', 'foo', []],
43
- ["/", 'index', ["foo"]],
44
- ],
45
-
46
- '/foo/bar' => [
47
- ["/foo__bar", "index", []],
48
- ["/foo/bar", "index", []],
49
-
50
- ["/foo", "bar", []],
51
- ["/foo", "index", ["bar"]],
52
-
53
- ["/", "foo__bar", []],
54
- ["/", "foo", ["bar"]],
55
- ["/", "index", ["foo", "bar"]],
56
- ],
57
-
58
- '/foo/bar/baz' => [
59
-
60
- ['/foo__bar__baz', 'index', []],
61
- ['/foo/bar/baz', 'index', []],
62
-
63
- ['/foo__bar', 'baz', []],
64
- ['/foo__bar', 'index', ['baz']],
65
-
66
- ['/foo/bar', 'baz', []],
67
- ['/foo/bar', 'index', ['baz']],
68
-
69
- ['/foo', 'bar__baz', []],
70
- ['/foo', 'bar', ['baz']],
71
- ['/foo', 'index', ['bar', 'baz']],
72
-
73
- ['/', 'foo__bar__baz', []],
74
- ['/', 'foo__bar', ['baz']],
75
- ['/', 'foo', ['bar', 'baz']],
76
- ['/', 'index', ['foo', 'bar', 'baz']],
77
- ],
78
-
79
- '/foo/bar/baz/oof' => [
80
- ['/foo__bar__baz__oof', 'index', []],
81
-
82
- ['/foo/bar/baz/oof', 'index', []],
83
-
84
- ['/foo__bar__baz', 'oof', []],
85
- ['/foo__bar__baz', 'index', ['oof']],
86
-
87
- ['/foo/bar/baz', 'oof', []],
88
- ['/foo/bar/baz', 'index', ['oof']],
89
-
90
- ['/foo__bar', 'baz__oof', []],
91
- ['/foo__bar', 'baz', ['oof']],
92
- ['/foo__bar', 'index', ['baz', 'oof']],
93
-
94
- ['/foo/bar', 'baz__oof', []],
95
- ['/foo/bar', 'baz', ['oof']],
96
- ['/foo/bar', 'index', ['baz', 'oof']],
97
-
98
- ['/foo', 'bar__baz__oof', []],
99
- ['/foo', 'bar__baz', ['oof']],
100
- ['/foo', 'bar', ['baz', 'oof']],
101
- ['/foo', 'index', ['bar', 'baz', 'oof']],
102
-
103
- ['/', 'foo__bar__baz__oof', []],
104
- ['/', 'foo__bar__baz', ['oof']],
105
- ['/', 'foo__bar', ['baz', 'oof']],
106
- ['/', 'foo', ['bar', 'baz', 'oof']],
107
- ['/', 'index', ['foo', 'bar', 'baz', 'oof']],
108
- ]
109
- }
110
-
111
- hash.each do |path, correct|
112
- describe path do
113
- patterns = Ramaze::Controller.pattern_for(path)
114
-
115
- describe path do
116
- =begin
117
- puts
118
- patterns.zip(correct).each do |pa, co|
119
- p :pa => pa
120
- p :co => co
121
- puts
122
- end
123
- puts
124
- =end
125
- it(path){ patterns.should == correct }
126
- correct.zip(patterns).each do |(cc,cm,cp),(pc,pm,pp)|
127
- {cc,pc,cm,pm,cp,pp}.each{|a,b| a.should == b}
128
- end
129
- end
130
- end
131
- end
132
- end
31
+ def handle(*args)
32
+ Ramaze::Controller.handle(*args)
133
33
  end
134
34
 
135
- describe 'resolve' do
136
- def resolve(path)
137
- TCControllerController.resolve(path)
138
- end
35
+ def resolve(*args)
36
+ Ramaze::Controller.resolve(*args)
37
+ end
139
38
 
140
- it '/' do
141
- resolve('/').last.should ==
142
- Ramaze::Action.new('index', [],'spec/ramaze/template/ezamar/index.zmr')
143
- end
39
+ def values(*url)
40
+ resolve(*url).last.values_at(:method, :params, :template)
41
+ end
144
42
 
145
- it '/sum/1/2' do
146
- resolve('/sum/1/2').last.should ==
147
- Ramaze::Action.new('sum', ['1', '2'],'spec/ramaze/template/ezamar/sum.zmr')
148
- end
43
+ before :all do
44
+ ramaze :error_page => false
45
+ @hash = {
46
+ '/' => [
47
+ ["/", 'index', []]
48
+ ],
149
49
 
150
- it '/another/long/action' do
151
- resolve('/another/long/action').last.should ==
152
- Ramaze::Action.new('another__long__action', [], 'spec/ramaze/template/ezamar/another/long/action.zmr')
153
- end
154
- it '/some/long/action' do
155
- resolve('/some/long/action').last.should ==
156
- Ramaze::Action.new('some__long__action', [], 'spec/ramaze/template/ezamar/some__long__action.zmr')
50
+ '/foo' => [
51
+ ["/foo", 'index',[]],
52
+ ['/', 'foo', []],
53
+ ["/", 'index', ["foo"]],
54
+ ],
55
+
56
+ '/foo/bar' => [
57
+ ["/foo__bar", "index", []],
58
+ ["/foo/bar", "index", []],
59
+
60
+ ["/foo", "bar", []],
61
+ ["/foo", "index", ["bar"]],
62
+
63
+ ["/", "foo__bar", []],
64
+ ["/", "foo", ["bar"]],
65
+ ["/", "index", ["foo", "bar"]],
66
+ ],
67
+
68
+ '/foo/bar/baz' => [
69
+
70
+ ['/foo__bar__baz', 'index', []],
71
+ ['/foo/bar/baz', 'index', []],
72
+
73
+ ['/foo__bar', 'baz', []],
74
+ ['/foo__bar', 'index', ['baz']],
75
+
76
+ ['/foo/bar', 'baz', []],
77
+ ['/foo/bar', 'index', ['baz']],
78
+
79
+ ['/foo', 'bar__baz', []],
80
+ ['/foo', 'bar', ['baz']],
81
+ ['/foo', 'index', ['bar', 'baz']],
82
+
83
+ ['/', 'foo__bar__baz', []],
84
+ ['/', 'foo__bar', ['baz']],
85
+ ['/', 'foo', ['bar', 'baz']],
86
+ ['/', 'index', ['foo', 'bar', 'baz']],
87
+ ],
88
+
89
+ '/foo/bar/baz/oof' => [
90
+ ['/foo__bar__baz__oof', 'index', []],
91
+
92
+ ['/foo/bar/baz/oof', 'index', []],
93
+
94
+ ['/foo__bar__baz', 'oof', []],
95
+ ['/foo__bar__baz', 'index', ['oof']],
96
+
97
+ ['/foo/bar/baz', 'oof', []],
98
+ ['/foo/bar/baz', 'index', ['oof']],
99
+
100
+ ['/foo__bar', 'baz__oof', []],
101
+ ['/foo__bar', 'baz', ['oof']],
102
+ ['/foo__bar', 'index', ['baz', 'oof']],
103
+
104
+ ['/foo/bar', 'baz__oof', []],
105
+ ['/foo/bar', 'baz', ['oof']],
106
+ ['/foo/bar', 'index', ['baz', 'oof']],
107
+
108
+ ['/foo', 'bar__baz__oof', []],
109
+ ['/foo', 'bar__baz', ['oof']],
110
+ ['/foo', 'bar', ['baz', 'oof']],
111
+ ['/foo', 'index', ['bar', 'baz', 'oof']],
112
+
113
+ ['/', 'foo__bar__baz__oof', []],
114
+ ['/', 'foo__bar__baz', ['oof']],
115
+ ['/', 'foo__bar', ['baz', 'oof']],
116
+ ['/', 'foo', ['bar', 'baz', 'oof']],
117
+ ['/', 'index', ['foo', 'bar', 'baz', 'oof']],
118
+ ]
119
+ }
120
+ end
121
+
122
+ it "dry pattern_for" do
123
+ @hash.each do |path, correct|
124
+ patterns = Ramaze::Controller.pattern_for(path)
125
+ patterns.should == correct
157
126
  end
158
127
  end
159
128
 
129
+ it '/' do
130
+ values('/').should ==
131
+ ['index', [], 'spec/ramaze/template/ezamar/index.zmr']
132
+ end
133
+
134
+ it '/sum/1/2' do
135
+ values('/sum/1/2').should ==
136
+ ['sum', ['1', '2'],'spec/ramaze/template/ezamar/sum.zmr']
137
+ end
138
+
139
+ it '/another/long/action' do
140
+ values('/another/long/action').should ==
141
+ ['another__long__action', [], 'spec/ramaze/template/ezamar/another/long/action.zmr']
142
+ end
143
+ it '/some/long/action' do
144
+ values('/some/long/action').should ==
145
+ ['some__long__action', [], 'spec/ramaze/template/ezamar/some__long__action.zmr']
146
+ end
147
+
160
148
  it "simple request to index" do
161
- get('/').body.should == 'Hello, World!'
149
+ handle('/').should == 'Hello, World!'
162
150
  end
163
151
 
164
152
  it "summing two values" do
165
- get('/sum/1/2').body.should == '3'
153
+ handle('/sum/1/2').should == '3'
166
154
  end
167
155
 
168
156
  it "double underscore in templates" do
169
- get('/some/long/action').body.should == 'some long action'
170
- get('/another/long/action').body.should == 'another long action'
171
- end
172
-
173
- describe "should not respond to private methods" do
174
- TCControllerController.private_methods.sort.each do |action|
175
- next if action =~ /\?$/ or action == '`'
176
- it action do
177
- path = "/#{action}"
178
- response = get(path)
179
- response.body.should =~ %r(No Action found for `#{path}' on TCControllerControlle)
180
- response.status.should == 404
181
- end
157
+ handle('/some/long/action').should == 'some long action'
158
+ handle('/another/long/action').should == 'another long action'
159
+ end
160
+
161
+ TCControllerController.private_methods.sort.each do |action|
162
+ it action do
163
+ path = "/#{action}"
164
+ message = "No Action found for `#{path}' on TCControllerController"
165
+ lambda{ resolve(path) }.should raise_error(Ramaze::Error::NoAction, message)
182
166
  end
183
167
  end
184
168
  end
@@ -0,0 +1 @@
1
+ <html>#{@obj}</html>
@@ -0,0 +1 @@
1
+ <html>Other: #{@greet}</html>
@@ -4,21 +4,32 @@
4
4
  require 'spec/helper'
5
5
 
6
6
  class MainController < Ramaze::Controller
7
- trait :template_root => "#{File.expand_path(File.dirname(__FILE__))}/template"
7
+ template_root "#{File.expand_path(File.dirname(__FILE__))}/template"
8
8
 
9
9
  def greet(type, message = "Message")
10
10
  @greet = "#{type} : #{message}"
11
11
  end
12
+
13
+ def list
14
+ @obj = @action.method
15
+ end
16
+ alias_method :index, :list
17
+ template :index, 'list'
18
+
12
19
  end
13
20
 
14
21
  class OtherController < MainController
15
- trait :template_root => "#{File.expand_path(File.dirname(__FILE__))}/template/other"
22
+ template_root "#{File.expand_path(File.dirname(__FILE__))}/template/other"
16
23
 
17
24
  def greet__mom(message = "Moms are cool!")
18
25
  greet('Mom', message)
19
26
  end
27
+ template :greet__mom, MainController, :greet
20
28
 
21
- trait :greet__mom_template => '/greet'
29
+ def greet__other(one, two)
30
+ @greet = "Other"
31
+ end
32
+ template :greet__other, 'greet/other'
22
33
 
23
34
  def partial_stuff
24
35
  render_partial('/greet/the/world', :foo => :bar)
@@ -44,6 +55,19 @@ describe "Testing Template overriding" do
44
55
  it "referencing template from MainController" do
45
56
  get('/other/greet/mom').body.should == '<html>Mom : Moms are cool!</html>'
46
57
  end
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>'
61
+ end
62
+
63
+ it "setting template for non-existant :index action should not arbitrary parameters" do
64
+ get('/list').body.should == '<html>list</html>'
65
+
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)
69
+ end
70
+
47
71
  end
48
72
 
49
73
  describe "render_partial" do