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
@@ -4,10 +4,10 @@
4
4
  require 'spec/helper'
5
5
 
6
6
  class TCCacheHelperController < Ramaze::Controller
7
- map '/'
8
- helper :cache
7
+ map :/
9
8
 
10
- trait :actions_cached => [:cached_action]
9
+ helper :cache
10
+ cache :cached_action
11
11
 
12
12
  def index
13
13
  self.class.name
@@ -36,35 +36,100 @@ class TCCacheHelperController < Ramaze::Controller
36
36
  end
37
37
  end
38
38
 
39
+ class TCCacheHelperTTLController < Ramaze::Controller
40
+ map '/ttl'
41
+
42
+ helper :cache
43
+ cache :index, :ttl => 1
44
+
45
+ def cached_list
46
+ actions_cached.inspect
47
+ end
48
+
49
+ def index
50
+ rand
51
+ end
52
+ end
53
+
54
+ class TCCacheHelperKeyController < Ramaze::Controller
55
+ map '/key'
56
+
57
+ helper :cache
58
+ cache :name, :key => lambda{ request['name'] }
59
+
60
+ def cached_list
61
+ actions_cached.inspect
62
+ end
63
+
64
+ def name
65
+ "hi #{request['name']} #{rand}"
66
+ end
67
+ end
68
+
69
+ class TCCacheHelperOldController < Ramaze::Controller
70
+ map '/old'
71
+
72
+ helper :cache
73
+ trait :actions_cached => [:index, :action]
74
+
75
+ def index
76
+ rand
77
+ end
78
+
79
+ def action with, param
80
+ with + param + rand.to_s
81
+ end
82
+ end
83
+
39
84
  describe "CacheHelper" do
40
85
  ramaze
41
86
 
87
+ def req(path='/', *args) get(path, *args).body end
88
+
42
89
  it "testrun" do
43
- get('/').body.should == 'TCCacheHelperController'
90
+ req.should == 'TCCacheHelperController'
44
91
  end
45
92
 
46
- def cached_value() get('/cached_value').body end
47
- def uncache_value() get('/uncache_value').body end
48
- def cached_action() get('/cached_action').body end
49
- def uncache_actions() get('/uncache_actions').body end
50
-
51
93
  it "cached value" do
52
94
  3.times do
53
- lambda{ cached_value }.should_not change{ cached_value }
95
+ lambda{ req('/cached_value') }.should_not change{ req('/cached_value') }
54
96
  end
55
97
 
56
98
  3.times do
57
- lambda{ uncache_value }.should change{ cached_value }
99
+ lambda{ req('/uncache_value') }.should change{ req('/cached_value') }
58
100
  end
59
101
  end
60
102
 
61
103
  it "cached action" do
62
104
  3.times do
63
- lambda{ cached_action }.should_not change{ cached_action }
105
+ lambda{ req('/cached_action') }.should_not change{ req('/cached_action') }
64
106
  end
65
107
 
66
108
  3.times do
67
- lambda{ uncache_actions }.should change{ cached_action }
109
+ lambda{ req('/uncache_actions') }.should change{ req('/cached_action') }
68
110
  end
69
111
  end
112
+
113
+ it "should support options" do
114
+ req('/ttl/cached_list').should == { :index => { :ttl => 1 } }.inspect
115
+ req('/key/cached_list').should =~ /^\{:name=>\{:key=>/
116
+ end
117
+
118
+ it "should expire cache after time-to-live" do
119
+ orig_value = get('/ttl').body
120
+ req('/ttl').should == orig_value
121
+ sleep 1
122
+ req('/ttl').should_not == orig_value
123
+ end
124
+
125
+ it "should cache using key lambda if provided" do
126
+ lambda{ req('/key/name', {:name=>'Aman'}) }.should_not change{ req('/key/name', {:name=>'Aman'}) }
127
+ req('/key/name', {:name=>'Bob'}).should =~ /^hi Bob/
128
+ end
129
+
130
+ it "should remain backwards compatible" do
131
+ lambda{ req('/old') }.should_not change{ req('/old') }
132
+ lambda{ req('/old/action/one/two') }.should_not change{ req('/old/action/one/two') }
133
+ req('/old/action/two/three').should =~ /^twothree/
134
+ end
70
135
  end
@@ -0,0 +1,20 @@
1
+ require 'spec/helper'
2
+ require 'ramaze/helper/formatting'
3
+
4
+ describe 'FormattingHelper' do
5
+ include Ramaze::FormattingHelper
6
+
7
+ it 'should format numbers' do
8
+ number_format(2_123_456).should == '2,123,456'
9
+ number_format(1234.567).should == '1,234.567'
10
+ number_format(123456.789, '.').should == '123.456,789'
11
+ number_format(123456.789123, '.').should == '123.456,789123'
12
+ number_format(132123456.789123, '.').should == '132.123.456,789123'
13
+ end
14
+
15
+ it 'should return difference in time as a string' do
16
+ time_diff(Time.now-29).should == 'less than a minute'
17
+ time_diff(Time.now-60).should == '1 minute'
18
+ time_diff(Time.now, Time.now+29, true).should == 'half a minute'
19
+ end
20
+ end
@@ -14,6 +14,8 @@ describe "A" do
14
14
  it 'should build links' do
15
15
  A('title', :href => '/').should == %(<a href="/">title</a>)
16
16
  A('title', :href => '/foo').should == %(<a href="/foo">title</a>)
17
+ A('title', :href => '/foo?x=y').should == %{<a href="/foo?x=y">title</a>}
18
+ A('/foo?x=y').should == %{<a href="/foo?x=y">/foo?x=y</a>}
17
19
 
18
20
  a = A('title', :href => '/foo', :class => :none)
19
21
  a.should =~ /class="none"/
@@ -6,7 +6,6 @@ require 'spec/helper'
6
6
  class TCPartialHelperController < Ramaze::Controller
7
7
  map '/'
8
8
  helper :partial
9
- template_root(__DIR__/:template)
10
9
 
11
10
  def index
12
11
  '<html><head><title>#{render_partial("/title")}</title></head></html>'
@@ -21,6 +20,10 @@ class TCPartialHelperController < Ramaze::Controller
21
20
  'From Action | ' +
22
21
  render_template("partial.xhtml")
23
22
  end
23
+
24
+ def recursive
25
+ @n = 1
26
+ end
24
27
  end
25
28
 
26
29
  describe "PartialHelper" do
@@ -35,4 +38,12 @@ describe "PartialHelper" do
35
38
  it 'should be able to render a template in the current scope' do
36
39
  get('/composed').body.should == 'From Action | From Partial there'
37
40
  end
41
+
42
+ it 'should render_template in a loop' do
43
+ get('/loop').body.gsub(/\s/,'').should == '12345'
44
+ end
45
+
46
+ it 'should work recursively' do
47
+ get('/recursive').body.gsub(/\s/,'').should == '{1{2{3{44}4}3}2}'
48
+ end
38
49
  end
@@ -5,7 +5,6 @@ require 'spec/helper'
5
5
 
6
6
  class TCRedirectHelperController < Ramaze::Controller
7
7
  map :/
8
- helper :redirect
9
8
 
10
9
  def index
11
10
  self.class.name
@@ -36,10 +35,27 @@ class TCRedirectHelperController < Ramaze::Controller
36
35
  catch(:redirect){ double_redirection }
37
36
  'bar'
38
37
  end
38
+
39
+ def redirect_method
40
+ redirect Rs(:noop)
41
+ end
42
+
43
+ def absolute_uri_redirect
44
+ redirect 'http://localhost:7007/noop'
45
+ end
46
+
47
+ def loop
48
+ respond 'no loop'
49
+ 'loop'
50
+ end
51
+
52
+ def respond_with_status
53
+ respond 'not found', 404
54
+ end
39
55
  end
40
56
 
41
57
  describe "RedirectHelper" do
42
- ramaze(:adapter => :webrick)
58
+ ramaze(:adapter => :mongrel)
43
59
 
44
60
  b = Browser.new
45
61
 
@@ -47,21 +63,41 @@ describe "RedirectHelper" do
47
63
  b.get('/').should == "TCRedirectHelperController"
48
64
  end
49
65
 
50
- it "calls" do
66
+ it "should do redirection" do
51
67
  b.story do
52
- get('/redirection').should == "TCRedirectHelperController"
68
+ get('/redirection').should == "TCRedirectHelperController"
53
69
  get('/double_redirection').should == "TCRedirectHelperController"
54
- get('/no_actual_redirect').should == 'foo'
70
+ end
71
+ end
72
+
73
+ it 'should be possible to catch a redirect' do
74
+ b.story do
75
+ get('/no_actual_redirect').should == 'foo'
55
76
  get('/no_actual_double_redirect').should == 'bar'
56
77
  end
57
78
  end
58
79
 
59
- it "redirect to referer" do
80
+ it "should redirect to referer" do
60
81
  b.story do
61
- get('/').should == 'TCRedirectHelperController'
82
+ get('/').should == "TCRedirectHelperController"
62
83
  get('/redirect_referer_action').should == 'TCRedirectHelperController'
63
- get('/noop').should == 'noop'
84
+ get('/noop').should == 'noop'
64
85
  get('/redirect_referer_action').should == 'noop'
65
86
  end
66
87
  end
88
+
89
+ it "should work with R()" do
90
+ b.get('/redirect_method').should == 'noop'
91
+ end
92
+
93
+ it "should work with absolute uris" do
94
+ b.get('/absolute_uri_redirect').should == 'noop'
95
+ end
96
+
97
+ it 'should allow respond() that ignores return values and templates' do
98
+ get('/loop').body.should == 'no loop'
99
+ page = get('/respond_with_status')
100
+ page.status.should == 404
101
+ page.body.should == 'not found'
102
+ end
67
103
  end
@@ -56,15 +56,15 @@ describe "StackHelper" do
56
56
  it "indirect login" do
57
57
  browser do
58
58
  get('/foo').should == 'logged in'
59
- get('/foo').should == 'logged in'
60
- eget('/').should == {:logged_in => true, :STACK => []}
59
+ get('/secure').should == 'secret content'
60
+ eget('/').should == {:logged_in => true}
61
61
  end
62
62
  end
63
63
 
64
64
  it "indirect login with params" do
65
65
  browser do
66
66
  eget('/bar', 'x' => 'y').should == {'x' => 'y'}
67
- eget('/').should == {:logged_in => true, :STACK => []}
67
+ eget('/').should == {:logged_in => true}
68
68
  end
69
69
  end
70
70
  end
@@ -0,0 +1,3 @@
1
+ <?r (1..5).each do |@n| ?>
2
+ #{render_template 'num.xhtml'}
3
+ <?r end ?>
@@ -0,0 +1,8 @@
1
+ {
2
+ #@n
3
+ <?r if @n < 4 ?>
4
+ <?r @n += 1 ?>
5
+ #{render_template('recursive.xhtml')}
6
+ <?r end ?>
7
+ #@n
8
+ }
@@ -4,6 +4,7 @@
4
4
  require 'spec/helper'
5
5
 
6
6
  testcase_requires 'hpricot'
7
+ require 'ramaze/template/ezamar/morpher'
7
8
 
8
9
  class TCMorpherController < Ramaze::Controller
9
10
  map '/'
@@ -48,6 +49,20 @@ class TCMorpherController < Ramaze::Controller
48
49
  <div each="@elem">#{_e}</div>
49
50
  }
50
51
  end
52
+
53
+ def complex_one
54
+ %q{
55
+ <html>
56
+ <head>
57
+ <title>test morph</title>
58
+ </head>
59
+ <body>
60
+ <a if="1" href="foo">foo</a>
61
+ <a unless="1" href="bar">bar</a>
62
+ </body>
63
+ </html>
64
+ }
65
+ end
51
66
  end
52
67
 
53
68
  describe "Morpher" do
@@ -62,32 +77,36 @@ describe "Morpher" do
62
77
  get(*url).body.split("\n").join.strip
63
78
  end
64
79
 
65
- it "testrun" do
80
+ it "should do a testrun" do
66
81
  clean_get('/').should == 'TCMorpherController'
67
82
  end
68
83
 
69
- it "if" do
84
+ it "should morph if" do
70
85
  clean_get('/simple_if').should == '<p>orig</p>'
71
86
  clean_get('/simple_if/bar').should == '<p>bar</p>'
72
87
  end
73
88
 
74
- it "unless" do
89
+ it "should morph unless" do
75
90
  clean_get('/simple_unless').should == '<p>orig</p>'
76
91
  clean_get('/simple_unless/bar').should == '<p>bar</p>'
77
92
  end
78
93
 
79
- it "for" do
94
+ it "should morph for" do
80
95
  clean_get('/simple_for').should == "<div>0</div><div>1</div>"
81
96
  clean_get('/simple_for/3').should == "<div>0</div><div>1</div><div>2</div><div>3</div>"
82
97
  end
83
98
 
84
- it "times" do
99
+ it "should morph times" do
85
100
  clean_get('/simple_times').should == "<div>0</div>"
86
101
  clean_get('/simple_times/3').should == "<div>0</div><div>1</div><div>2</div>"
87
102
  end
88
103
 
89
- it "each" do
104
+ it "should morph each" do
90
105
  clean_get('/simple_each').should == ''
91
106
  clean_get('/simple_each/1/2/3').should == "<div>1</div><div>2</div><div>3</div>"
92
107
  end
108
+
109
+ it 'should morph a more complex document' do
110
+ clean_get('/complex_one').should == '<html> <head> <title>test morph</title> </head> <body> <a href="foo">foo</a> </body></html>'
111
+ end
93
112
  end
@@ -55,7 +55,7 @@ class TCParamsController3 < Ramaze::Controller
55
55
  map '/ma'
56
56
 
57
57
  def index(*args)
58
- request.params['foo'].inspect
58
+ request.params['foo'].to_s.dump
59
59
  end
60
60
  end
61
61
 
@@ -141,6 +141,10 @@ describe "Simple Parameters" do
141
141
  end
142
142
 
143
143
  it 'params should have no content without params' do
144
- get('/ma').body.should == 'nil'
144
+ get('/ma').body.should == '""'
145
+ end
146
+
147
+ it 'should have a parameter via QUERY_PARAMS' do
148
+ get('/ma', 'foo' => 'bar').body.should == '"bar"'
145
149
  end
146
150
  end
@@ -20,6 +20,9 @@ class TCRequestController < Ramaze::Controller
20
20
  end
21
21
 
22
22
  def put_inspect(file)
23
+ # referencing request.rack_params breaks this test
24
+ # request.params is hacked to return {} on PUT requests
25
+ request.params
23
26
  request.body.read.inspect
24
27
  end
25
28
 
@@ -66,7 +69,7 @@ describe "Request" do
66
69
  end
67
70
 
68
71
  describe "PUT" do
69
- it "put a ressource" do
72
+ it "put a resource" do
70
73
  image = 'favicon.ico'
71
74
  image_path = File.join('spec', 'ramaze', 'public', image)
72
75
  address = "/put_inspect/#{image}"
@@ -79,7 +82,7 @@ describe "Request" do
79
82
  end
80
83
 
81
84
  describe "DELETE" do
82
- it "delete a ressource" do
85
+ it "delete a resource" do
83
86
  delete('/is_delete').body.should == 'true'
84
87
  end
85
88
  end
@@ -17,6 +17,14 @@ class TCSessionController < Ramaze::Controller
17
17
  session.merge! request.params
18
18
  index
19
19
  end
20
+
21
+ def test_set(n)
22
+ session[:n] = n
23
+ end
24
+
25
+ def test_result
26
+ session[:n]
27
+ end
20
28
  end
21
29
 
22
30
  describe "Session" do
@@ -67,6 +75,17 @@ describe "Session" do
67
75
  it "snooping a bit around" do
68
76
  b.cookie.split('=').size.should == 3
69
77
  end
78
+
79
+ it 'should not hit IP_COUNT_LIMIT for the same session/ip' do
80
+ class Ramaze::Session
81
+ remove_const :IP_COUNT_LIMIT
82
+ const_set(:IP_COUNT_LIMIT, 2)
83
+ end
84
+ (0..Ramaze::Session::IP_COUNT_LIMIT * 2).each do |n|
85
+ b.get("/test_set/#{n}")
86
+ b.get("/test_result").should == n.to_s
87
+ end
88
+ end
70
89
  end
71
90
  end
72
91
  end