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
@@ -26,9 +26,7 @@ Logger.send(:class_variable_set, "@@global_logger", gulp_class.new)
26
26
 
27
27
  Og.start :destroy => true
28
28
 
29
- include Ramaze
30
-
31
- class TCFormHelperEntryController < Template::Ramaze
29
+ class TCFormHelperEntryController < Ramaze::Controller
32
30
  helper :form
33
31
 
34
32
  def index
@@ -56,7 +54,7 @@ class TCFormHelperEntryController < Template::Ramaze
56
54
  end
57
55
  end
58
56
 
59
- class TCFormHelperEntryTimestampedController < Template::Ramaze
57
+ class TCFormHelperEntryTimestampedController < Ramaze::Controller
60
58
  helper :form
61
59
 
62
60
  def index
@@ -68,7 +66,7 @@ class TCFormHelperEntryTimestampedController < Template::Ramaze
68
66
  end
69
67
  end
70
68
 
71
- class TCFormHelperEntryDated < Template::Ramaze
69
+ class TCFormHelperEntryDatedController < Ramaze::Controller
72
70
  helper :form
73
71
 
74
72
  def index
@@ -127,7 +125,7 @@ context "FormHelper" do
127
125
  end
128
126
 
129
127
  context "EntryDated" do
130
- ramaze :fake_start => true, :mapping => {'/entry_dated' => TCFormHelperEntryDated}
128
+ ramaze :fake_start => true, :mapping => {'/entry_dated' => TCFormHelperEntryDatedController}
131
129
 
132
130
  specify "testrun" do
133
131
  get('/entry_dated').should ==
@@ -3,9 +3,7 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
7
-
8
- class TCLinkHelperController < Template::Ramaze
6
+ class TCLinkHelperController < Ramaze::Controller
9
7
  helper :link
10
8
 
11
9
  def index
@@ -3,9 +3,7 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
7
-
8
- class TCRedirectHelperController < Template::Ramaze
6
+ class TCRedirectHelperController < Ramaze::Controller
9
7
  helper :redirect
10
8
 
11
9
  def index
@@ -27,6 +25,16 @@ class TCRedirectHelperController < Template::Ramaze
27
25
  def redirect_referer_action
28
26
  redirect_referer
29
27
  end
28
+
29
+ def no_actual_redirect
30
+ catch(:redirect){ redirection }
31
+ 'foo'
32
+ end
33
+
34
+ def no_actual_double_redirect
35
+ catch(:redirect){ double_redirection }
36
+ 'bar'
37
+ end
30
38
  end
31
39
 
32
40
  context "RedirectHelper" do
@@ -39,13 +47,20 @@ context "RedirectHelper" do
39
47
  end
40
48
 
41
49
  specify "calls" do
42
- ctx.get('/redirection').should == "TCRedirectHelperController"
43
- ctx.get('/double_redirection').should == "TCRedirectHelperController"
50
+ ctx.story do
51
+ get('/redirection').should == "TCRedirectHelperController"
52
+ get('/double_redirection').should == "TCRedirectHelperController"
53
+ get('/no_actual_redirect').should == 'foo'
54
+ get('/no_actual_double_redirect').should == 'bar'
55
+ end
44
56
  end
45
57
 
46
58
  specify "redirect to referer" do
47
- ctx.get('/redirect_referer_action').should == 'TCRedirectHelperController'
48
- ctx.get('/noop').should == 'noop'
49
- ctx.get('/redirect_referer_action').should == 'noop'
59
+ ctx.story do
60
+ get('/').should == 'TCRedirectHelperController'
61
+ get('/redirect_referer_action').should == 'TCRedirectHelperController'
62
+ get('/noop').should == 'noop'
63
+ get('/redirect_referer_action').should == 'noop'
64
+ end
50
65
  end
51
66
  end
@@ -3,30 +3,36 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
7
-
8
- class TCStackHelperController < Template::Ramaze
9
- helper :stack
6
+ class TCStackHelperController < Ramaze::Controller
7
+ helper :stack, :aspect
10
8
 
11
9
  def index
12
10
  session.inspect
13
11
  end
14
12
 
15
13
  def foo
16
- call :login unless logged_in?
14
+ call Rs(:login) unless logged_in?
17
15
  "logged in"
18
16
  end
19
17
 
20
18
  def bar
21
- call :login unless logged_in?
19
+ call Rs(:login) unless logged_in?
22
20
  request.params.inspect
23
21
  end
24
22
 
23
+ def secure
24
+ logged_in? ? 'secret content' : 'please login'
25
+ end
26
+
25
27
  def login
26
28
  session[:logged_in] = true
27
29
  answer
28
30
  end
29
31
 
32
+ def logout
33
+ session.clear
34
+ end
35
+
30
36
  private
31
37
 
32
38
  def logged_in?
@@ -37,19 +43,29 @@ end
37
43
  context "StackHelper" do
38
44
  ramaze(:mapping => {'/' => TCStackHelperController})
39
45
 
40
- ctx = Context.new
46
+ specify "conventional login" do
47
+ =begin
48
+ Context.new do
49
+ get('/secure').should == 'please login'
50
+ get('/login')
51
+ get('/secure').should == 'secret content'
52
+ get('/logout')
53
+ end
54
+ =end
55
+ end
41
56
 
42
57
  specify "indirect login" do
43
- ctx.get('/foo').should == 'logged in'
44
- ctx.eget('/').should == {:logged_in => true, :STACK => []}
58
+ Context.new do
59
+ get('/foo').should == 'logged in'
60
+ get('/foo').should == 'logged in'
61
+ eget('/').should == {:logged_in => true, :STACK => []}
62
+ end
45
63
  end
46
64
 
47
65
  specify "indirect login with params" do
48
- ctx.eget('/bar?x=y').should == {'x' => 'y'}
49
- ctx.eget('/').should == {:logged_in => true, :STACK => []}
50
- end
51
-
52
- specify "indirect posting fun" do
53
- ctx.epost('/bar', :x => :y)['x'].should == 'y'
66
+ Context.new do
67
+ eget('/bar', 'x' => 'y').should == {'x' => 'y'}
68
+ eget('/').should == {:logged_in => true, :STACK => []}
69
+ end
54
70
  end
55
71
  end
@@ -3,12 +3,10 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
7
-
8
6
  begin
9
7
  require 'hpricot'
10
8
 
11
- class TCMorpherController < Template::Ramaze
9
+ class TCMorpherController < Ramaze::Controller
12
10
  def index
13
11
  self.class.name
14
12
  end
@@ -3,9 +3,7 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
7
-
8
- class TCParamsController < Template::Ramaze
6
+ class TCParamsController < Ramaze::Controller
9
7
  def index
10
8
  "index"
11
9
  end
@@ -33,10 +31,29 @@ class TCParamsController < Template::Ramaze
33
31
  def one_default param = 'default'
34
32
  "one_default (#{param})"
35
33
  end
34
+
35
+ def cat1__cat11
36
+ 'cat1: cat11'
37
+ end
38
+
39
+ def cat1__cat11__cat111
40
+ 'cat1: cat11: cat111'
41
+ end
42
+ end
43
+
44
+ class TCParamsController2 < Ramaze::Controller
45
+ def add(one, two = nil, three = nil)
46
+ "#{one}:#{two}:#{three}"
47
+ end
36
48
  end
37
49
 
38
50
  context "Simple Parameters" do
39
- ramaze(:mapping => {'/' => TCParamsController})
51
+ ramaze(
52
+ :mapping => {
53
+ '/' => TCParamsController,
54
+ '/jo' => TCParamsController2
55
+ }
56
+ )
40
57
 
41
58
  specify "Should respond to no parameters given" do
42
59
  get('/no_params').should == "no params"
@@ -47,7 +64,7 @@ context "Simple Parameters" do
47
64
  end
48
65
 
49
66
  specify "call /bar though index doesn't take params" do
50
- lambda{ p get('/bar') }.should_raise #OpenURI::HTTPError
67
+ lambda{ get('/bar') }.should_raise #OpenURI::HTTPError
51
68
  end
52
69
 
53
70
  specify "action that takes a single param" do
@@ -59,7 +76,7 @@ context "Simple Parameters" do
59
76
  end
60
77
 
61
78
  specify "action that takes two params but we give only one" do
62
- lambda{ p get('/double_param/foo') }.should_raise #OpenURI::HTTPError
79
+ lambda{ get('/double_param/foo') }.should_raise #OpenURI::HTTPError
63
80
  end
64
81
 
65
82
  specify "action that takes all params" do
@@ -71,7 +88,7 @@ context "Simple Parameters" do
71
88
  end
72
89
 
73
90
  specify "action that takes all params but needs at least one (not given here)" do
74
- lambda{ p get('/at_least_one') }.should_raise #OpenURI::HTTPError
91
+ lambda{ get('/at_least_one') }.should_raise #OpenURI::HTTPError
75
92
  end
76
93
 
77
94
  specify "one default" do
@@ -81,4 +98,28 @@ context "Simple Parameters" do
81
98
  specify "one default" do
82
99
  get('/one_default/my_default').should == "one_default (my_default)"
83
100
  end
101
+
102
+ specify "double underscore lookup" do
103
+ get('/cat1/cat11').should == 'cat1: cat11'
104
+ end
105
+
106
+ specify "double double underscore lookup" do
107
+ get('/cat1/cat11/cat111').should == 'cat1: cat11: cat111'
108
+ end
109
+
110
+
111
+ specify "jo/add should raise with 0 parameters" do
112
+ lambda{ get('/jo/add') }.should_raise
113
+ end
114
+
115
+ specify "add should raise with 4 parameters" do
116
+ lambda{ get('/jo/add/1/2/3/4') }.should_raise
117
+ end
118
+
119
+ specify "add should not raise with 1-3 parameters" do
120
+ get('/jo/add/1').should == '1::'
121
+ get('/jo/add/1/2').should == '1:2:'
122
+ get('/jo/add/1/2/3').should == '1:2:3'
123
+ end
124
+
84
125
  end
@@ -0,0 +1,9 @@
1
+ require 'spec/spec_helper'
2
+
3
+ testcase_requires 'mongrel'
4
+
5
+ def ramaze_options
6
+ { :adapter => :mongrel }
7
+ end
8
+
9
+ require 'spec/request_tc_helper'
@@ -0,0 +1,5 @@
1
+ def ramaze_options
2
+ { :adapter => :webrick }
3
+ end
4
+
5
+ require 'spec/request_tc_helper'
@@ -3,9 +3,7 @@
3
3
 
4
4
  require 'spec/spec_helper'
5
5
 
6
- include Ramaze
7
-
8
- class TCSessionController < Template::Ramaze
6
+ class TCSessionController < Ramaze::Controller
9
7
  def index
10
8
  session.inspect
11
9
  end
@@ -21,36 +19,54 @@ class TCSessionController < Template::Ramaze
21
19
  end
22
20
  end
23
21
 
24
- context "usual Session" do
22
+ context "Session" do
25
23
  ramaze(:mapping => {'/' => TCSessionController})
26
24
 
27
- ctx = Context.new
25
+ { :MemoryCache => :memory,
26
+ :YAMLStoreCache => :yaml_store,
27
+ :MemcachedCache => :memcached,
28
+ }.each do |cache, requirement|
29
+ begin
30
+ require "ramaze/cache/#{requirement}"
31
+ rescue LoadError => ex
32
+ puts ex
33
+ next
34
+ end
28
35
 
29
- specify "Should give me an empty session" do
30
- ctx.eget.should == {}
31
- end
36
+ context cache.to_s do
32
37
 
33
- specify "set some session-parameters" do
34
- ctx.eget('/set_session/foo/bar').should == {'foo' => 'bar'}
35
- end
38
+ Ramaze::Global.cache = cache
39
+ Thread.main[:session_cache] = nil
36
40
 
37
- specify "inspect session again" do
38
- ctx.eget('/').should == {'foo' => 'bar'}
39
- end
41
+ ctx = Context.new
40
42
 
41
- specify "change the session" do
42
- ctx.eget('/set_session/foo/foobar').should == {'foo' => 'foobar'}
43
- end
43
+ specify "Should give me an empty session" do
44
+ ctx.eget.should == {}
45
+ end
44
46
 
45
- specify "inspect the changed session" do
46
- ctx.eget('/').should == {'foo' => 'foobar'}
47
- end
47
+ specify "set some session-parameters" do
48
+ ctx.eget('/set_session/foo/bar').should == {'foo' => 'bar'}
49
+ end
48
50
 
49
- specify "now a little bit with POST" do
50
- ctx.epost('/post_set_session', :x => :y)['x'].should == 'y'
51
- end
51
+ specify "inspect session again" do
52
+ ctx.eget('/').should == {'foo' => 'bar'}
53
+ end
54
+
55
+ specify "change the session" do
56
+ ctx.eget('/set_session/foo/foobar')['foo'].should == 'foobar'
57
+ end
58
+
59
+ specify "inspect the changed session" do
60
+ ctx.eget('/')['foo'].should == 'foobar'
61
+ end
62
+
63
+ specify "now a little bit with POST" do
64
+ ctx.epost('/post_set_session', 'x' => 'y')['x'].should == 'y'
65
+ end
52
66
 
53
- specify "snooping a bit around" do
54
- ctx.cookie.split('=').size.should == 2
67
+ specify "snooping a bit around" do
68
+ ctx.cookie.split('=').size.should == 3
69
+ end
70
+ end
55
71
  end
56
72
  end
@@ -4,19 +4,68 @@
4
4
  require 'spec/spec_helper'
5
5
  require 'ramaze/store/default'
6
6
 
7
- include Ramaze
8
-
9
7
  context "initialize an Store" do
10
8
  db = 'db.yaml'
11
9
 
10
+ def add hash = {}
11
+ Books.merge!(hash)
12
+ end
13
+
12
14
  specify "Store::Default.new" do
13
- Db = Store::Default.new(db)
14
- Db.db.should.is_a?(YAML::Store)
15
+ Books = Ramaze::Store::Default.new(db)
16
+ Books.db.should.is_a?(YAML::Store)
15
17
  end
16
18
 
17
19
  specify "store and retrieve something" do
18
- (Db[:foo] = :bar).should == :bar
19
- Db[:foo].should == :bar
20
+ add 'Pickaxe' => 'good book'
21
+ Books['Pickaxe'].should == 'good book'
22
+ end
23
+
24
+ specify "empty?" do
25
+ add 'Pickaxe' => 'good book'
26
+
27
+ Books.empty?.should == false
28
+ Books.clear
29
+ Books.empty?.should == true
30
+ end
31
+
32
+ specify "size" do
33
+ Books.size.should == 0
34
+
35
+ {
36
+ 'Pickaxe' => 'good book',
37
+ '1984' => 'scary',
38
+ 'Brave new World' => 'interesting',
39
+ }.each_with_index do |(title, content), i|
40
+ add title => content
41
+ Books.size.should == i + 1
42
+ end
43
+ end
44
+
45
+ specify "Enumerable" do
46
+ add 'Pickaxe' => 'good book', '1984' => 'scary'
47
+
48
+ Books.each do |title, content|
49
+ [title, content].compact.empty?.should == false
50
+ Books[title].should == content
51
+ end
52
+ end
53
+
54
+ specify "merge and merge!" do
55
+ books = {'Pickaxe' => 'good book', '1984' => 'scary'}
56
+ add books
57
+
58
+ bnw = {'Brave new World' => 'interesting'}
59
+
60
+ Books.merge(bnw).should == books.merge(bnw)
61
+
62
+ Books[bnw.keys.first].should == nil
63
+
64
+ Books.merge!(bnw).should == books.merge(bnw)
65
+
66
+ Books[bnw.keys.first].should == bnw.values.first
67
+
68
+ Books.size.should == 3
20
69
  end
21
70
 
22
71
  teardown do