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
@@ -73,31 +73,35 @@ end
73
73
  describe "Element" do
74
74
  ramaze(:mapping => {'/' => TCElementController})
75
75
 
76
+ def retrieve(*url)
77
+ Ramaze::Controller.handle(*url).strip
78
+ end
79
+
76
80
  it "simple request" do
77
- get('/').body.should == "The index"
81
+ retrieve('/').should == "The index"
78
82
  end
79
83
 
80
84
  it "with element" do
81
- get('/elementy').body.should == "<wrap> The index </wrap>"
85
+ retrieve('/elementy').should == "<wrap> The index </wrap>"
82
86
  end
83
87
 
84
88
  it "nested element" do
85
- get('/nested').body.should == "<wrap> some stuff <wrap> The index </wrap> more stuff </wrap>"
89
+ retrieve('/nested').should == "<wrap> some stuff <wrap> The index </wrap> more stuff </wrap>"
86
90
  end
87
91
 
88
92
  it "with_params" do
89
- get('/with_params/one/two').body.should == {'@one' => 'two'}.inspect
93
+ retrieve('/with_params/one/two').should == {'@one' => 'two'}.inspect
90
94
  end
91
95
 
92
96
  it "little" do
93
- get('/little').body.should == 'little'
97
+ retrieve('/little').should == 'little'
94
98
  end
95
99
 
96
100
  it "little params" do
97
- get('/little_params/one/eins').body.should == {'@one' => 'eins'}.inspect
101
+ retrieve('/little_params/one/eins').should == {'@one' => 'eins'}.inspect
98
102
  end
99
103
 
100
104
  it "templating" do
101
- get('/templating/10').body.should == (1..10).to_a.join(', ')
105
+ retrieve('/templating/10').should == (1..10).to_a.join(', ')
102
106
  end
103
107
  end
@@ -6,7 +6,7 @@ require 'open-uri'
6
6
 
7
7
  class TCErrorController < Ramaze::Controller
8
8
  map :/
9
- trait :public => 'spec/ramaze/public'
9
+ public_root 'spec/ramaze/public'
10
10
 
11
11
  def index
12
12
  self.class.name
@@ -3,6 +3,8 @@
3
3
 
4
4
  require 'spec/helper'
5
5
 
6
+ testcase_requires 'ramaze/gestalt'
7
+
6
8
  describe "Gestalt" do
7
9
  def gestalt &block
8
10
  Ramaze::Gestalt.new(&block).to_s
@@ -5,49 +5,57 @@ require 'spec/helper'
5
5
 
6
6
  class TCAspectController < Ramaze::Controller
7
7
  map '/'
8
+ trait :foo => :bar
8
9
  helper :aspect
9
10
 
10
- def pre_aspect() '<aspect>' end
11
- def post_aspect() '</aspect>' end
12
- def wrap_aspect() '<br />' end
13
-
14
- def test() 'test' end
15
- pre :test, :pre_aspect
16
- post :test, :post_aspect
17
-
18
- def test_pre() 'test pre' end
19
- pre :test_pre, :pre_aspect
11
+ def test_before() 'test before' end
12
+ before(:test_before){ '<aspect>' }
20
13
 
21
- def test_post() 'test post' end
22
- post :test_post, :post_aspect
14
+ def test_after() 'test after' end
15
+ after(:test_after){ '</aspect>' }
23
16
 
24
17
  def test_wrap() 'test wrap' end
25
- wrap :test_wrap, :wrap_aspect
18
+ wrap(:test_wrap){ '<br />' }
26
19
  end
27
20
 
28
21
  class TCAspectAllController < Ramaze::Controller
29
22
  map '/all'
30
- trait :foo => :bar
31
23
 
32
24
  helper :aspect
33
25
 
34
- def pre_aspect() '<pre>' end
35
- def post_aspect() '</pre>' end
36
-
37
26
  def test_all_first() 'first' end
38
27
  def test_all_second() 'second' end
39
28
 
40
- pre :all, :pre_aspect
41
- post :all, :post_aspect
29
+ before_all{ '<pre>' }
30
+ after_all{ '</pre>' }
42
31
  end
43
32
 
44
- describe "Aspect" do
33
+ describe "AspectHelper" do
45
34
  ramaze(:error_page => false)
46
35
 
47
36
  it "shouldn't overwrite traits on inclusion" do
48
- TCAspectAllController.trait[:foo].should == :bar
37
+ TCAspectController.trait[:foo].should == :bar
38
+ end
39
+
40
+ it 'should use before' do
41
+ get('/test_before').body.should == '<aspect>test before'
42
+ end
43
+
44
+ it 'should use after' do
45
+ get('/test_after').body.should == 'test after</aspect>'
49
46
  end
50
47
 
48
+ it 'should use wrap' do
49
+ get('/test_wrap').body.should == '<br />test wrap<br />'
50
+ end
51
+
52
+ it 'should before_all and after_all' do
53
+ get('/all/test_all_first').body.should == '<pre>first</pre>'
54
+ get('/all/test_all_second').body.should == '<pre>second</pre>'
55
+ end
56
+ end
57
+
58
+ =begin
51
59
  it "pre" do
52
60
  get('/test_pre').body.should == '<aspect>test pre'
53
61
  end
@@ -69,3 +77,4 @@ describe "Aspect" do
69
77
  get('/all/test_all_second').body.should == '<pre>second</pre>'
70
78
  end
71
79
  end
80
+ =end
@@ -18,7 +18,7 @@ class TCAuthHelperController < Ramaze::Controller
18
18
  def secured
19
19
  "Secret content"
20
20
  end
21
- pre :secured, :login_required
21
+ before(:secured){ login_required }
22
22
  end
23
23
 
24
24
  class TCAuthHashHelperController < TCAuthHelperController
@@ -4,6 +4,7 @@
4
4
  require 'spec/helper'
5
5
 
6
6
  class TCCacheHelperController < Ramaze::Controller
7
+ map '/'
7
8
  helper :cache
8
9
 
9
10
  trait :actions_cached => [:cached_action]
@@ -36,7 +37,7 @@ class TCCacheHelperController < Ramaze::Controller
36
37
  end
37
38
 
38
39
  describe "CacheHelper" do
39
- ramaze(:mapping => {'/' => TCCacheHelperController})
40
+ ramaze
40
41
 
41
42
  it "testrun" do
42
43
  get('/').body.should == 'TCCacheHelperController'
@@ -26,6 +26,7 @@ Logger.send(:class_variable_set, "@@global_logger", Ramaze::Informer.new)
26
26
  Og.start :destroy => true
27
27
 
28
28
  class TCFormHelperEntryController < Ramaze::Controller
29
+ map '/'
29
30
  helper :form
30
31
 
31
32
  def index
@@ -54,6 +55,7 @@ class TCFormHelperEntryController < Ramaze::Controller
54
55
  end
55
56
 
56
57
  class TCFormHelperEntryTimestampedController < Ramaze::Controller
58
+ map '/entry_timestamped'
57
59
  helper :form
58
60
 
59
61
  def index
@@ -66,6 +68,7 @@ class TCFormHelperEntryTimestampedController < Ramaze::Controller
66
68
  end
67
69
 
68
70
  class TCFormHelperEntryDatedController < Ramaze::Controller
71
+ map '/entry_dated'
69
72
  helper :form
70
73
 
71
74
  def index
@@ -79,40 +82,38 @@ end
79
82
 
80
83
  describe "FormHelper" do
81
84
  describe "Entry" do
82
- ramaze :mapping => {'/entry' => TCFormHelperEntryController}
85
+ ramaze
83
86
 
84
87
  it "testrun" do
85
- get('/entry/').body.should == 'FormHelper Entry'
88
+ get('/').body.should == 'FormHelper Entry'
86
89
  end
87
90
 
88
91
  it "with submit" do
89
- get('/entry/form_with_submit').body.should ==
92
+ get('/form_with_submit').body.should ==
90
93
  %{title: <input type="text" name="title" value="" /><br />\n<input type="submit" />}
91
94
  end
92
95
 
93
96
  it "without submit" do
94
- get('/entry/form_without_submit').body.should ==
97
+ get('/form_without_submit').body.should ==
95
98
  %{title: <input type="text" name="title" value="" />}
96
99
  end
97
100
 
98
101
  it "with title" do
99
- get('/entry/form_with_title').body.should ==
102
+ get('/form_with_title').body.should ==
100
103
  %{Title: <input type="text" name="title" value="" /><br />\n<input type="submit" />}
101
104
  end
102
105
 
103
106
  it "without title" do
104
- get('/entry/form_without_title').body.should ==
107
+ get('/form_without_title').body.should ==
105
108
  %{<input type="text" name="title" value="" /><br />\n<input type="submit" />}
106
109
  end
107
110
 
108
111
  it "with oid" do
109
- get('/entry/form_with_oid').body.should ==
112
+ get('/form_with_oid').body.should ==
110
113
  %{title: <input type="text" name="title" value="" /><br />\noid: <input type="text" name="oid" value="0" /><br />\n<input type="submit" />}
111
114
  end
112
115
 
113
116
  describe "EntryTimestamped" do
114
- ramaze :fake_start => true, :mapping => {'/entry_timestamped' => TCFormHelperEntryTimestampedController}
115
-
116
117
  it "testrun" do
117
118
  get('/entry_timestamped/').body.should == "FormHelper EntryTimestamped"
118
119
  end
@@ -124,8 +125,6 @@ describe "FormHelper" do
124
125
  end
125
126
 
126
127
  describe "EntryDated" do
127
- ramaze :fake_start => true, :mapping => {'/entry_dated' => TCFormHelperEntryDatedController}
128
-
129
128
  it "testrun" do
130
129
  get('/entry_dated').body.should ==
131
130
  "FormHelper Dated"
@@ -139,5 +138,9 @@ describe "FormHelper" do
139
138
  result.should =~ /<input type="submit" \/>/
140
139
  end
141
140
  end
141
+
142
+ after :all do
143
+ FileUtils.rm('data.db')
144
+ end
142
145
  end
143
146
  end
@@ -2,55 +2,32 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  require 'spec/helper'
5
+ require 'ramaze/helper/link'
5
6
 
6
- class TCLinkHelperController < Ramaze::Controller
7
- helper :link
8
-
9
- def index
10
- link self
11
- end
12
-
13
- def index_with_title
14
- link self, :title => 'Foo'
15
- end
7
+ class TCLink < Ramaze::Controller
8
+ map '/'
16
9
  end
17
10
 
18
-
19
- describe "LinkHelper" do
20
- ramaze(:mapping => {'/' => TCLinkHelperController})
21
-
11
+ describe "A" do
22
12
  include Ramaze::LinkHelper
23
13
 
24
- this = TCLinkHelperController
14
+ it 'should build links' do
15
+ A('title', :href => '/').should == %(<a href="/">title</a>)
16
+ A('title', :href => '/foo').should == %(<a href="/foo">title</a>)
25
17
 
26
- it "testrun" do
27
- get('/').body.should == %{<a href="/">index</a>}
28
- get('/index_with_title').body.should == %{<a href="/">Foo</a>}
29
- end
30
-
31
- it "link" do
32
- link(:foo).should == %{<a href="foo">foo</a>}
33
- link(:foo, :bar).should == %{<a href="foo/bar">bar</a>}
34
- link(this, :bar).should == %{<a href="/bar">bar</a>}
35
- link('/foo/bar').should == %{<a href="/foo/bar">bar</a>}
36
- end
37
-
38
- it "link with title" do
39
- link(:foo, :title => 'bar').should == %{<a href="foo">bar</a>}
18
+ a = A('title', :href => '/foo', :class => :none)
19
+ a.should =~ /class="none"/
20
+ a.should =~ /href="\/foo"/
40
21
  end
22
+ end
41
23
 
42
- it "link with get-parameters" do
43
- link(:foo, :first => :bar, :title => 'bar').should == %{<a href="foo?first=bar">bar</a>}
44
- l = link(:foo, :first => :bar, :second => :foobar)
45
- m = l.match(%r{<a href="foo\?(.*?)=(.*?);(.*?)=(.*?)">(.*?)</a>}).to_a
46
- m.shift
47
- m.pop.should == 'foo'
48
- Hash[*m].should == {'first' => 'bar', 'second' => 'foobar'}
49
- end
24
+ describe 'R' do
25
+ include Ramaze::LinkHelper
50
26
 
51
- it "R" do
52
- R(this).should == '/'
53
- R(this, :foo).should == '/foo'
54
- R(this, :foo, :bar => :one).should == '/foo?bar=one'
27
+ it 'should build urls' do
28
+ R(TCLink).should == '/'
29
+ R(TCLink, :foo).should == '/foo'
30
+ R(TCLink, :foo, :bar).should == '/foo/bar'
31
+ R(TCLink, :foo, :bar => :baz).should == '/foo?bar=baz'
55
32
  end
56
33
  end
@@ -12,7 +12,7 @@ Ramaze::Tool::Localize.trait :enable => true,
12
12
  Ramaze::Dispatcher::Action.trait[:filter] << Ramaze::Tool::Localize
13
13
 
14
14
  class TCLocalize < Ramaze::Controller
15
- trait :map => '/'
15
+ map '/'
16
16
 
17
17
  def hello lang = 'en'
18
18
  session[:LOCALE] = lang
@@ -26,7 +26,30 @@ class TCLocalize < Ramaze::Controller
26
26
  end
27
27
 
28
28
  describe "Localize" do
29
- ramaze
29
+ before :all do
30
+ @dir = File.join(File.dirname(__FILE__), 'conf')
31
+ FileUtils.mkdir_p(@dir)
32
+
33
+ dict = {
34
+ :de => {
35
+ 'hello' => 'Hallo, Welt!',
36
+ 'this' => 'Das',
37
+ 'is' => 'ist',
38
+ 'a' => 'ein',
39
+ 'test' => 'Test',
40
+ },
41
+ :en => {
42
+ 'hello' => 'Hello, World!',
43
+ 'this' => 'this',
44
+ 'is' => 'is',
45
+ 'a' => 'a',
46
+ 'test' => 'test',
47
+ } }
48
+ dict.each do |lang, dic|
49
+ File.open(@dir/"locale_#{lang}.yaml", 'w+'){|fp| fp.print(dic.to_yaml)}
50
+ end
51
+ ramaze
52
+ end
30
53
 
31
54
  it "hello world" do
32
55
  get('/hello').body.should == 'Hello, World!'
@@ -37,4 +60,8 @@ describe "Localize" do
37
60
  get('/advanced').body.should == 'this is a test'
38
61
  get('/advanced/de').body.should == 'Das ist ein Test'
39
62
  end
63
+
64
+ after :all do
65
+ FileUtils.rm_rf(@dir)
66
+ end
40
67
  end
@@ -6,6 +6,8 @@ require 'spec/helper'
6
6
  testcase_requires 'hpricot'
7
7
 
8
8
  class TCMorpherController < Ramaze::Controller
9
+ map '/'
10
+
9
11
  def index
10
12
  self.class.name
11
13
  end
@@ -49,34 +51,43 @@ class TCMorpherController < Ramaze::Controller
49
51
  end
50
52
 
51
53
  describe "Morpher" do
52
- ramaze :mapping => {'/' => TCMorpherController}
54
+ before :all do
55
+ ramaze
56
+ Ramaze::Template::Ezamar.trait[:transform_pipeline] = [
57
+ Ezamar::Element, Ezamar::Morpher, Ezamar::Template
58
+ ]
59
+ end
60
+
61
+ def clean_get(*url)
62
+ get(*url).body.split("\n").join.strip
63
+ end
53
64
 
54
65
  it "testrun" do
55
- get('/').body.should == 'TCMorpherController'
66
+ clean_get('/').should == 'TCMorpherController'
56
67
  end
57
68
 
58
69
  it "if" do
59
- get('/simple_if').body.should == '<p>orig</p>'
60
- get('/simple_if/bar').body.should == '<p>bar</p>'
70
+ clean_get('/simple_if').should == '<p>orig</p>'
71
+ clean_get('/simple_if/bar').should == '<p>bar</p>'
61
72
  end
62
73
 
63
74
  it "unless" do
64
- get('/simple_unless').body.should == '<p>orig</p>'
65
- get('/simple_unless/bar').body.should == '<p>bar</p>'
75
+ clean_get('/simple_unless').should == '<p>orig</p>'
76
+ clean_get('/simple_unless/bar').should == '<p>bar</p>'
66
77
  end
67
78
 
68
79
  it "for" do
69
- get('/simple_for').body.should == "<div>0</div><div>1</div>"
70
- get('/simple_for/3').body.should == "<div>0</div><div>1</div><div>2</div><div>3</div>"
80
+ clean_get('/simple_for').should == "<div>0</div><div>1</div>"
81
+ clean_get('/simple_for/3').should == "<div>0</div><div>1</div><div>2</div><div>3</div>"
71
82
  end
72
83
 
73
84
  it "times" do
74
- get('/simple_times').body.should == "<div>0</div>"
75
- get('/simple_times/3').body.should == "<div>0</div><div>1</div><div>2</div>"
85
+ clean_get('/simple_times').should == "<div>0</div>"
86
+ clean_get('/simple_times/3').should == "<div>0</div><div>1</div><div>2</div>"
76
87
  end
77
88
 
78
89
  it "each" do
79
- get('/simple_each').body.should == ''
80
- get('/simple_each/1/2/3').body.should == "<div>1</div><div>2</div><div>3</div>"
90
+ clean_get('/simple_each').should == ''
91
+ clean_get('/simple_each/1/2/3').should == "<div>1</div><div>2</div><div>3</div>"
81
92
  end
82
93
  end