Pistos-ramaze 2009.04.08 → 2009.06.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. data/.gitignore +3 -0
  2. data/MANIFEST +37 -22
  3. data/{README.markdown → README.md} +5 -24
  4. data/Rakefile +33 -26
  5. data/benchmark/bench_templates/bench.rb +67 -0
  6. data/benchmark/bench_templates/view/large.erb +79 -0
  7. data/benchmark/bench_templates/view/large.haml +41 -0
  8. data/benchmark/bench_templates/view/large.xhtml +79 -0
  9. data/benchmark/bench_templates/view/small.erb +21 -0
  10. data/benchmark/bench_templates/view/small.haml +12 -0
  11. data/benchmark/bench_templates/view/small.xhtml +21 -0
  12. data/benchmark/run.rb +14 -21
  13. data/benchmark/suite/minimal.rb +3 -5
  14. data/benchmark/suite/no_informer.rb +0 -2
  15. data/benchmark/suite/no_sessions.rb +3 -4
  16. data/benchmark/suite/no_template.rb +1 -3
  17. data/benchmark/suite/simple.rb +1 -3
  18. data/benchmark/suite/template_erubis.rb +0 -2
  19. data/benchmark/suite/template_etanni.rb +8 -0
  20. data/benchmark/suite/template_ezamar.rb +1 -3
  21. data/benchmark/suite/template_haml.rb +0 -2
  22. data/benchmark/suite/template_liquid.rb +0 -2
  23. data/benchmark/suite/template_markaby.rb +0 -2
  24. data/benchmark/suite/template_nagoro.rb +1 -3
  25. data/benchmark/suite/template_redcloth.rb +0 -2
  26. data/benchmark/suite/template_tenjin.rb +0 -2
  27. data/bin/ramaze +11 -163
  28. data/doc/AUTHORS +15 -8
  29. data/doc/CHANGELOG +10094 -12262
  30. data/doc/meta/announcement.txt +93 -46
  31. data/doc/tutorial/todolist.html +22 -58
  32. data/doc/tutorial/todolist.txt +20 -39
  33. data/examples/app/auth/layout/{auth.nag → auth.xhtml} +0 -0
  34. data/examples/app/auth/view/{index.nag → index.xhtml} +0 -0
  35. data/examples/app/auth/view/{login.nag → login.xhtml} +0 -0
  36. data/examples/app/auth/view/{secret.nag → secret.xhtml} +0 -0
  37. data/examples/app/blog/app.rb +1 -1
  38. data/examples/app/blog/controller/comment.rb +1 -1
  39. data/examples/app/blog/controller/entry.rb +12 -3
  40. data/examples/app/blog/model/init.rb +5 -0
  41. data/examples/app/blog/model/tag.rb +2 -2
  42. data/examples/app/blog/view/entry/index.nag +3 -3
  43. data/examples/app/blog/view/feed.atom.nag +1 -1
  44. data/examples/app/blog/view/feed.rss.nag +1 -1
  45. data/examples/app/blog/view/index.nag +1 -1
  46. data/examples/app/blog/view/tag/index.nag +1 -1
  47. data/examples/app/chat/layout/{default.nag → default.xhtml} +0 -0
  48. data/examples/app/chat/view/{chat.nag → chat.xhtml} +0 -0
  49. data/examples/app/chat/view/{index.nag → index.xhtml} +0 -0
  50. data/examples/app/localization/locale/de.yaml +5 -0
  51. data/examples/app/localization/locale/en.yaml +5 -0
  52. data/examples/app/localization/locale/ja.yaml +5 -0
  53. data/examples/app/localization/start.rb +33 -20
  54. data/examples/app/wikore/spec/wikore.rb +4 -6
  55. data/examples/app/wikore/src/controller.rb +9 -11
  56. data/examples/app/wikore/src/model.rb +7 -10
  57. data/examples/app/wikore/start.rb +1 -1
  58. data/examples/app/wikore/{template → view}/index.xhtml +0 -0
  59. data/examples/helpers/cache.rb +6 -4
  60. data/examples/misc/css.rb +6 -12
  61. data/examples/misc/rapp.rb +28 -17
  62. data/lib/proto/app.rb +14 -0
  63. data/lib/proto/config.ru +8 -5
  64. data/lib/proto/controller/init.rb +3 -3
  65. data/lib/proto/spec/main.rb +9 -11
  66. data/lib/proto/start.rb +6 -10
  67. data/lib/ramaze.rb +8 -9
  68. data/lib/ramaze/app.rb +4 -3
  69. data/lib/ramaze/cache/localmemcache.rb +2 -2
  70. data/lib/ramaze/cache/memcache.rb +26 -1
  71. data/lib/ramaze/cache/sequel.rb +24 -9
  72. data/lib/ramaze/contrib/addressable_route.rb +56 -0
  73. data/lib/ramaze/contrib/email.rb +2 -0
  74. data/lib/ramaze/contrib/facebook/facebook.rb +4 -4
  75. data/lib/ramaze/contrib/sequel/create_join.rb +1 -0
  76. data/lib/ramaze/contrib/sequel/form_field.rb +4 -4
  77. data/lib/ramaze/contrib/sequel/image.rb +9 -11
  78. data/lib/ramaze/contrib/sequel/relation.rb +17 -3
  79. data/lib/ramaze/controller.rb +26 -18
  80. data/lib/ramaze/gestalt.rb +4 -1
  81. data/lib/ramaze/helper.rb +1 -0
  82. data/lib/ramaze/helper/auth.rb +0 -5
  83. data/lib/ramaze/helper/cache.rb +65 -25
  84. data/lib/ramaze/helper/form.rb +14 -2
  85. data/lib/ramaze/helper/formatting.rb +3 -1
  86. data/lib/ramaze/helper/gestalt.rb +32 -0
  87. data/lib/ramaze/helper/identity.rb +3 -3
  88. data/lib/ramaze/helper/layout.rb +97 -0
  89. data/lib/ramaze/helper/link.rb +6 -25
  90. data/lib/ramaze/helper/localize.rb +13 -3
  91. data/lib/ramaze/helper/paginate.rb +4 -2
  92. data/lib/ramaze/helper/ultraviolet.rb +2 -0
  93. data/lib/ramaze/helper/user.rb +3 -3
  94. data/lib/ramaze/log/rotatinginformer.rb +10 -10
  95. data/lib/ramaze/request.rb +3 -5
  96. data/lib/ramaze/setup.rb +22 -9
  97. data/lib/ramaze/spec.rb +8 -12
  98. data/lib/ramaze/spec/bacon.rb +34 -0
  99. data/lib/ramaze/spec/helper/template_examples.rb +15 -22
  100. data/lib/ramaze/tool/bin.rb +340 -0
  101. data/lib/ramaze/tool/project_creator.rb +1 -1
  102. data/lib/ramaze/version.rb +1 -1
  103. data/lib/ramaze/view.rb +6 -11
  104. data/lib/ramaze/view/erubis.rb +2 -2
  105. data/lib/ramaze/view/ezamar.rb +2 -2
  106. data/lib/ramaze/view/gestalt.rb +14 -0
  107. data/lib/ramaze/view/haml.rb +2 -1
  108. data/lib/ramaze/view/liquid.rb +45 -11
  109. data/lib/ramaze/view/maruku.rb +2 -1
  110. data/lib/ramaze/view/nagoro/render_partial.rb +9 -9
  111. data/lib/ramaze/view/sass.rb +1 -1
  112. data/lib/ramaze/view/tenjin.rb +7 -4
  113. data/lib/vendor/etag.rb +4 -2
  114. data/lib/vendor/route_exceptions.rb +9 -15
  115. data/ramaze.gemspec +56 -9
  116. data/spec/contrib/addressable_route.rb +30 -0
  117. data/spec/contrib/rest.rb +2 -2
  118. data/spec/examples/caching.rb +5 -7
  119. data/spec/examples/css.rb +3 -3
  120. data/spec/examples/element.rb +4 -3
  121. data/spec/examples/hello.rb +3 -3
  122. data/spec/examples/helpers/httpdigest.rb +44 -69
  123. data/spec/examples/linking.rb +3 -3
  124. data/spec/examples/simple.rb +3 -3
  125. data/spec/examples/templates/template_erubis.rb +8 -4
  126. data/spec/examples/templates/template_ezamar.rb +9 -4
  127. data/spec/examples/templates/template_haml.rb +8 -4
  128. data/spec/examples/templates/template_liquid.rb +8 -4
  129. data/spec/examples/templates/template_markaby.rb +9 -5
  130. data/spec/examples/templates/template_nagoro.rb +9 -5
  131. data/spec/examples/templates/template_redcloth.rb +8 -4
  132. data/spec/examples/templates/template_remarkably.rb +8 -4
  133. data/spec/examples/templates/template_tenjin.rb +8 -4
  134. data/spec/helper.rb +1 -2
  135. data/spec/ramaze/action/render.rb +4 -1
  136. data/spec/ramaze/app.rb +5 -2
  137. data/spec/ramaze/bin/ramaze.rb +96 -0
  138. data/spec/ramaze/cache/localmemcache.rb +1 -1
  139. data/spec/ramaze/cache/memcache.rb +7 -1
  140. data/spec/ramaze/cache/sequel.rb +1 -1
  141. data/spec/ramaze/controller/actionless_templates.rb +2 -2
  142. data/spec/ramaze/controller/lonely_mapping.rb +18 -0
  143. data/spec/ramaze/controller/mapping.rb +4 -15
  144. data/spec/ramaze/controller/provide_inheritance.rb +5 -2
  145. data/spec/ramaze/controller/resolve.rb +2 -2
  146. data/spec/ramaze/controller/subclass.rb +2 -2
  147. data/spec/ramaze/controller/template_resolving.rb +2 -2
  148. data/spec/ramaze/dispatcher/directory.rb +5 -2
  149. data/spec/ramaze/dispatcher/file.rb +28 -26
  150. data/spec/ramaze/error.rb +3 -3
  151. data/spec/ramaze/files.rb +5 -2
  152. data/spec/ramaze/gestalt.rb +26 -17
  153. data/spec/ramaze/helper/auth.rb +30 -41
  154. data/spec/ramaze/helper/bench.rb +6 -2
  155. data/spec/ramaze/helper/cache.rb +45 -5
  156. data/spec/ramaze/helper/flash.rb +11 -15
  157. data/spec/ramaze/helper/form.rb +6 -3
  158. data/spec/ramaze/helper/formatting.rb +4 -1
  159. data/spec/ramaze/helper/gestalt.rb +4 -1
  160. data/spec/ramaze/helper/gravatar.rb +4 -1
  161. data/spec/ramaze/helper/httpdigest.rb +51 -66
  162. data/spec/ramaze/helper/layout.rb +79 -0
  163. data/spec/ramaze/helper/layout/default.xhtml +5 -0
  164. data/spec/ramaze/helper/link.rb +33 -12
  165. data/spec/ramaze/helper/localize.rb +9 -4
  166. data/spec/ramaze/helper/maruku.rb +5 -2
  167. data/spec/ramaze/helper/pager.rb +2 -2
  168. data/spec/ramaze/helper/paginate.rb +5 -2
  169. data/spec/ramaze/helper/request_accessor.rb +5 -2
  170. data/spec/ramaze/helper/sequel_form.rb +7 -2
  171. data/spec/ramaze/helper/simple_captcha.rb +10 -14
  172. data/spec/ramaze/helper/stack.rb +32 -40
  173. data/spec/ramaze/helper/user.rb +19 -14
  174. data/spec/ramaze/helper/xhtml.rb +4 -1
  175. data/spec/ramaze/log/informer.rb +1 -1
  176. data/spec/ramaze/log/logging.rb +4 -1
  177. data/spec/ramaze/log/syslog.rb +6 -6
  178. data/spec/ramaze/params.rb +5 -6
  179. data/spec/ramaze/request.rb +16 -1
  180. data/spec/ramaze/session/memcache.rb +66 -0
  181. data/spec/ramaze/struct.rb +4 -1
  182. data/spec/ramaze/view.rb +2 -2
  183. data/spec/ramaze/view/erubis.rb +2 -2
  184. data/spec/ramaze/view/ezamar.rb +2 -2
  185. data/spec/ramaze/view/gestalt.rb +94 -0
  186. data/spec/ramaze/view/gestalt/external.ges +8 -0
  187. data/spec/ramaze/view/haml.rb +2 -2
  188. data/spec/ramaze/view/liquid.rb +2 -2
  189. data/spec/ramaze/view/nagoro.rb +2 -2
  190. data/spec/ramaze/view/redcloth.rb +2 -2
  191. data/spec/ramaze/view/remarkably.rb +2 -2
  192. data/spec/ramaze/view/sass.rb +2 -2
  193. data/spec/ramaze/view/tagz.rb +2 -2
  194. data/spec/ramaze/view/tenjin.rb +2 -2
  195. data/spec/snippets/array/put_within.rb +30 -25
  196. data/spec/snippets/binding/locals.rb +4 -1
  197. data/spec/snippets/numeric/filesize_format.rb +4 -1
  198. data/spec/snippets/numeric/time.rb +5 -2
  199. data/spec/snippets/object/__dir__.rb +4 -1
  200. data/spec/snippets/ordered_set.rb +4 -1
  201. data/spec/snippets/ramaze/acquire.rb +4 -1
  202. data/spec/snippets/ramaze/dictionary.rb +4 -1
  203. data/spec/snippets/ramaze/struct.rb +4 -1
  204. data/spec/snippets/string/camel_case.rb +4 -1
  205. data/spec/snippets/string/color.rb +4 -1
  206. data/spec/snippets/string/snake_case.rb +4 -1
  207. data/spec/snippets/string/unindent.rb +4 -1
  208. data/spec/snippets/thread/into.rb +4 -1
  209. data/tasks/bacon.rake +5 -3
  210. data/tasks/changelog.rake +3 -1
  211. data/tasks/{gem_installer.rake → gem_setup.rake} +45 -22
  212. data/tasks/release.rake +12 -27
  213. data/tasks/setup.rake +6 -0
  214. data/tasks/todo.rake +2 -4
  215. metadata +205 -31
  216. data/CHANGELOG +0 -16546
  217. data/benchmark/suite/template_builder.rb +0 -12
  218. data/doc/tutorial/todolist.mkd +0 -787
  219. data/examples/helpers/provide.rb +0 -23
  220. data/lib/proto/view/page.xhtml +0 -27
  221. data/lib/ramaze/snippets/divide.rb +0 -22
  222. data/lib/ramaze/snippets/kernel/constant.rb +0 -41
  223. data/lib/ramaze/snippets/object/acquire.rb +0 -37
  224. data/lib/ramaze/snippets/string/each.rb +0 -19
  225. data/spec/ramaze/helper/partial.rb +0 -40
  226. data/spec/snippets/kernel/constant.rb +0 -23
  227. data/tasks/install_dependencies.rake +0 -6
@@ -0,0 +1,5 @@
1
+ <em>laid out</em>
2
+
3
+ <div id="content">
4
+ #@content
5
+ </div>
@@ -1,8 +1,7 @@
1
1
  # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
- require 'spec/helper'
5
- require 'ramaze/helper/link'
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
6
5
 
7
6
  class SpecHelperLink < Ramaze::Controller
8
7
  map '/'
@@ -12,18 +11,18 @@ class SpecHelperLinkTwo < Ramaze::Controller
12
11
  map '/two'
13
12
  end
14
13
 
15
- describe Ramaze::Helper::Link do
16
- extend Ramaze::Helper::Link
14
+ class SpecHelperApp < Ramaze::Controller
15
+ map '/', :other
16
+ end
17
17
 
18
- it 'builds routes' do
19
- R(SpecHelperLink, :foo).should == '/foo'
20
- SpecHelperLink.Rs(:foo).should == '/foo'
21
- end
18
+ class SpecHelperAppTwo < Ramaze::Controller
19
+ map '/two', :other
20
+ end
22
21
 
23
- it 'builds links' do
24
- SpecHelperLink.A(:foo).should == '<a href="/foo">foo</a>'
25
- SpecHelperLink.A(:foo, :bar).should == '<a href="/bar">foo</a>'
26
- end
22
+ Ramaze::App[:other].location = '/other'
23
+
24
+ describe Ramaze::Helper::Link do
25
+ extend Ramaze::Helper::Link
27
26
 
28
27
  it 'lays out breadcrumbs' do
29
28
  SpecHelperLink.breadcrumbs('/file/dir/listing/is/cool').
@@ -46,4 +45,26 @@ describe Ramaze::Helper::Link do
46
45
  '<a href="/prefix/path/file/dir/listing/is/cool">cool</a>'
47
46
  ].join('/')
48
47
  end
48
+
49
+ it "builds routes and links to other applications" do
50
+ SpecHelperApp.r(:foo).to_s.should == '/other/foo'
51
+ SpecHelperApp.a(:foo, :bar).should == '<a href="/other/bar">foo</a>'
52
+ SpecHelperAppTwo.r(:foo).to_s.should == '/other/two/foo'
53
+ SpecHelperAppTwo.a(:foo, :bar).should == '<a href="/other/two/bar">foo</a>'
54
+ end
55
+ it "builds routes when Ramaze.options.prefix is present" do
56
+ Ramaze.options.prefix = '/prfx'
57
+ SpecHelperLink.r(:foo).to_s.should == '/prfx/foo'
58
+ SpecHelperLinkTwo.r(:foo).to_s.should == '/prfx/two/foo'
59
+ SpecHelperApp.r(:foo).to_s.should == '/prfx/other/foo'
60
+ SpecHelperAppTwo.r(:foo).to_s.should == '/prfx/other/two/foo'
61
+
62
+ end
63
+ it "builds links when Ramaze.options.prefix is present" do
64
+ Ramaze.options.prefix = '/prfx'
65
+ SpecHelperLink.a(:foo, :bar).should == '<a href="/prfx/bar">foo</a>'
66
+ SpecHelperLinkTwo.a(:foo, :bar).should == '<a href="/prfx/two/bar">foo</a>'
67
+ SpecHelperApp.a(:foo, :bar).should == '<a href="/prfx/other/bar">foo</a>'
68
+ SpecHelperAppTwo.a(:foo, :bar).should == '<a href="/prfx/other/two/bar">foo</a>'
69
+ end
49
70
  end
@@ -1,6 +1,9 @@
1
1
  # * Encoding: UTF-8
2
- $KCODE = 'u' if //.respond_to?(:kcode)
3
- require 'spec/helper'
2
+ # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
3
+ # All files in this distribution are subject to the terms of the Ruby license.
4
+
5
+ $KCODE = 'u' if /regexp/.respond_to?(:kcode)
6
+ require File.expand_path('../../../../spec/helper', __FILE__)
4
7
  spec_requires 'locale/tag', 'locale'
5
8
 
6
9
  class SpecHelperLocalize < Ramaze::Controller
@@ -28,7 +31,7 @@ DICTIONARY.load(:de, :hash => {'one' => 'eins', 'two' => 'zwei'})
28
31
  DICTIONARY.load(:ja, :hash => {'one' => '一', 'three' => '三'})
29
32
 
30
33
  describe Ramaze::Helper::Localize do
31
- behaves_like :mock
34
+ behaves_like :rack_test
32
35
 
33
36
  should 'default to a language' do
34
37
  get('/').body.should == 'en'
@@ -39,7 +42,9 @@ describe Ramaze::Helper::Localize do
39
42
  end
40
43
 
41
44
  should 'override language by cookie' do
42
- get('/', 'HTTP_COOKIE' => 'lang=ja').body.should == 'ja'
45
+ set_cookie('lang=ja')
46
+ get('/').body.should == 'ja'
47
+ clear_cookies
43
48
  end
44
49
 
45
50
  should 'not fail if language is invalid' do
@@ -1,4 +1,7 @@
1
- require 'spec/helper'
1
+ # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
2
5
  spec_require 'maruku'
3
6
 
4
7
  class SpecHelperMaruku < Ramaze::Controller
@@ -11,7 +14,7 @@ class SpecHelperMaruku < Ramaze::Controller
11
14
  end
12
15
 
13
16
  describe Ramaze::Helper::Maruku do
14
- behaves_like :mock
17
+ behaves_like :rack_test
15
18
 
16
19
  it 'converts a markdown string to html' do
17
20
  get('/').body.should =~ /<h1 id=["']hello["']>Hello<\/h1>/
@@ -1,7 +1,7 @@
1
1
  # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
- require 'spec/helper'
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
5
5
  spec_require 'hpricot'
6
6
 
7
7
  module Og
@@ -29,7 +29,7 @@ class TCPagerController < Ramaze::Controller
29
29
  end
30
30
 
31
31
  shared 'pager' do
32
- behaves_like :mock
32
+ behaves_like :rack_test
33
33
  extend Ramaze::Helper::Pager
34
34
 
35
35
  def pager_key
@@ -1,4 +1,7 @@
1
- require 'spec/helper'
1
+ # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
2
5
  spec_require 'hpricot'
3
6
 
4
7
  class SpecHelperPaginateArray < Ramaze::Controller
@@ -23,7 +26,7 @@ end
23
26
 
24
27
  describe Ramaze::Helper::Paginate do
25
28
  describe 'Array' do
26
- behaves_like :mock
29
+ behaves_like :rack_test
27
30
 
28
31
  it 'shows navigation for page 1' do
29
32
  doc = Hpricot(get("/array/navigation").body)
@@ -1,4 +1,7 @@
1
- require 'spec/helper'
1
+ # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
2
5
 
3
6
  class SpecHelperRequestAccessor < Ramaze::Controller
4
7
  map '/'
@@ -10,7 +13,7 @@ class SpecHelperRequestAccessor < Ramaze::Controller
10
13
  end
11
14
 
12
15
  describe 'Ramaze::Helper::RequestAccessor' do
13
- behaves_like :mock
16
+ behaves_like :rack_test
14
17
 
15
18
  it 'gives direct access to methods in Request' do
16
19
  get('/').body.should == 'GET'
@@ -1,10 +1,15 @@
1
- require 'spec/helper'
1
+ # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
2
5
 
3
6
  spec_requires 'hpricot', 'sequel'
4
7
 
5
8
  DB = Sequel.sqlite
6
9
 
7
10
  class User < Sequel::Model(:user)
11
+ plugin :schema
12
+
8
13
  set_schema do
9
14
  primary_key :id
10
15
 
@@ -41,7 +46,7 @@ class FormController < Ramaze::Controller
41
46
  end
42
47
 
43
48
  describe Ramaze::Helper::SequelForm do
44
- behaves_like :mock
49
+ behaves_like :rack_test
45
50
 
46
51
  def hget(uri)
47
52
  got = get(uri)
@@ -1,7 +1,7 @@
1
1
  # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
- require 'spec/helper'
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
5
5
 
6
6
  class SpecSimpleCaptcha < Ramaze::Controller
7
7
  helper :simple_captcha
@@ -25,25 +25,21 @@ class SpecCustomCaptcha < SpecSimpleCaptcha
25
25
  end
26
26
 
27
27
  describe Ramaze::Helper::SimpleCaptcha do
28
- behaves_like :session
28
+ behaves_like :rack_test
29
29
 
30
30
  should 'ask question' do
31
- session do |mock|
32
- question = mock.get('/ask_question').body
33
- question.should =~ /^\d+ [+-] \d+$/
31
+ get('/ask_question')
32
+ question = last_response.body
33
+ question.should =~ /^\d+ [+-] \d+$/
34
34
 
35
- lh, m, rh = question.split
36
- answer = lh.to_i.send(m, rh.to_i)
35
+ lh, m, rh = question.split
36
+ answer = lh.to_i.send(m, rh.to_i)
37
37
 
38
- mock.get("/answer_question/#{answer}").body.should == 'correct'
39
- end
38
+ get("/answer_question/#{answer}").body.should == 'correct'
40
39
  end
41
40
 
42
41
  should 'ask custom question' do
43
- session do |mock|
44
- question = mock.get('/fish/ask_question')
45
- question.body.should == 'the answer to everything'
46
- mock.get('/fish/answer_question/42').body.should == 'correct'
47
- end
42
+ get('/fish/ask_question').body.should == 'the answer to everything'
43
+ get('/fish/answer_question/42').body.should == 'correct'
48
44
  end
49
45
  end
@@ -1,7 +1,7 @@
1
1
  # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
- require 'spec/helper'
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
5
5
 
6
6
  class SpecStackHelper < Ramaze::Controller
7
7
  map '/'
@@ -39,56 +39,48 @@ class SpecStackHelper < Ramaze::Controller
39
39
  end
40
40
 
41
41
  describe Ramaze::Helper::Stack do
42
- behaves_like :session
42
+ behaves_like :rack_test
43
43
  @uri = 'http://example.org'
44
44
 
45
45
  should 'login directly' do
46
- session do |mock|
47
- mock.get('/secure').body.should == 'please login'
46
+ get('/secure').body.should == 'please login'
48
47
 
49
- got = mock.get('/login')
50
- got.status.should == 302
51
- got['Location'].should == "#@uri/secure"
48
+ get('/login').status.should == 302
49
+ last_response['Location'].should == "#@uri/secure"
52
50
 
53
- got = mock.get('/secure')
54
- got.status.should == 200
55
- got.body.should == 'secret content'
51
+ get('/secure').status.should == 200
52
+ last_response.body.should == 'secret content'
56
53
 
57
- mock.get('/secure').body.should == 'secret content'
58
- mock.get('/logout')
59
- mock.get('/secure').body.should == 'please login'
60
- end
54
+ get('/secure').body.should == 'secret content'
55
+ get('/logout')
56
+ get('/secure').body.should == 'please login'
61
57
  end
62
58
 
63
59
  should 'login via redirects' do
64
- session do |mock|
65
- got = mock.get('/logged_in_page')
66
- got.status.should == 302
67
- got['Location'].should == 'http://example.org/login'
68
-
69
- got = mock.get('/login')
70
- got.status.should == 302
71
- got['Location'].should == 'http://example.org/logged_in_page'
72
-
73
- got = mock.get('/logged_in_page')
74
- got.status.should == 200
75
- got.body.should == 'the logged in page'
76
- end
60
+ get('/logged_in_page').status.should == 302
61
+ last_response['Location'].should == 'http://example.org/login'
62
+
63
+ get('/login').status.should == 302
64
+ last_response['Location'].should == 'http://example.org/logged_in_page'
65
+
66
+ get('/logged_in_page').status.should == 200
67
+ last_response.body.should == 'the logged in page'
68
+
69
+ get('/logout')
70
+ get('/secure').body.should == 'please login'
77
71
  end
78
72
 
79
73
  should 'login with params via redirects' do
80
- session do |mock|
81
- got = mock.get('/logged_in_params?x=y')
82
- got.status.should == 302
83
- got['Location'].should == 'http://example.org/login'
84
-
85
- got = mock.get('/login')
86
- got.status.should == 302
87
- got['Location'].should == 'http://example.org/logged_in_params?x=y'
88
-
89
- got = mock.get('/logged_in_params?x=y')
90
- got.status.should == 200
91
- got.body.should == {'x' => 'y'}.inspect
92
- end
74
+ get('/logged_in_params?x=y').status.should == 302
75
+ last_response['Location'].should == 'http://example.org/login'
76
+
77
+ get('/login').status.should == 302
78
+ last_response['Location'].should == 'http://example.org/logged_in_params?x=y'
79
+
80
+ get('/logged_in_params?x=y').status.should == 200
81
+ last_response.body.should == {'x' => 'y'}.inspect
82
+
83
+ get('/logout')
84
+ get('/secure').body.should == 'please login'
93
85
  end
94
86
  end
@@ -1,4 +1,7 @@
1
- require 'spec/helper'
1
+ # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
2
5
 
3
6
  class MockSequelUser
4
7
  def profile
@@ -23,6 +26,10 @@ class SpecUserHelper < Ramaze::Controller
23
26
  user_login ? 'logged in' : 'failed login'
24
27
  end
25
28
 
29
+ def logout
30
+ user_logout
31
+ end
32
+
26
33
  def profile
27
34
  user.profile
28
35
  end
@@ -48,23 +55,21 @@ class SpecUserHelperCallback < SpecUserHelper
48
55
  end
49
56
 
50
57
  describe Ramaze::Helper::User do
51
- behaves_like :session
58
+ behaves_like :rack_test
52
59
 
53
60
  should 'login' do
54
- session do |mock|
55
- mock.get('/status').body.should == 'no'
56
- mock.get('/login?name=arthur&password=42').body.should == 'logged in'
57
- mock.get('/status').body.should == 'yes'
58
- mock.get('/profile').body.should == MockSequelUser.new.profile
59
- end
61
+ get('/status').body.should == 'no'
62
+ get('/login?name=arthur&password=42').body.should == 'logged in'
63
+ get('/status').body.should == 'yes'
64
+ get('/profile').body.should == MockSequelUser.new.profile
65
+ get('/logout').status.should == 200
60
66
  end
61
67
 
62
68
  should 'login via the callback' do
63
- session do |mock|
64
- mock.get('/callback/status').body.should == 'no'
65
- mock.get('/callback/login?name=arthur&password=42').body.should == 'logged in'
66
- mock.get('/callback/status').body.should == 'yes'
67
- mock.get('/callback/profile').body.should == MockSequelUser.new.profile
68
- end
69
+ get('/callback/status').body.should == 'no'
70
+ get('/callback/login?name=arthur&password=42').body.should == 'logged in'
71
+ get('/callback/status').body.should == 'yes'
72
+ get('/callback/profile').body.should == MockSequelUser.new.profile
73
+ get('/logout').status.should == 200
69
74
  end
70
75
  end
@@ -1,4 +1,7 @@
1
- require 'spec/helper'
1
+ # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
2
5
  require 'ramaze/helper/xhtml'
3
6
 
4
7
  describe Ramaze::Helper::XHTML do
@@ -1,7 +1,7 @@
1
1
  # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
- require 'spec/helper'
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
5
5
  require 'ramaze/log/informer'
6
6
 
7
7
  describe 'Informer' do
@@ -1,4 +1,7 @@
1
- require 'spec/helper'
1
+ # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
2
5
 
3
6
  class SpecLogger
4
7
  include Ramaze::Logging
@@ -1,14 +1,14 @@
1
1
  # Copyright (c) 2008 rob@rebeltechnologies.nl
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
- require 'spec/helper'
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
5
5
 
6
6
  require 'ramaze/log/syslog'
7
7
 
8
8
  describe 'Syslog' do
9
9
 
10
10
  # close the syslog, if it was open for some reason before we
11
- # start a test.
11
+ # start a test.
12
12
  before do
13
13
  if ( Syslog.opened? )
14
14
  ::Syslog.close
@@ -24,8 +24,8 @@ describe 'Syslog' do
24
24
  end
25
25
 
26
26
  it 'should handle non default initialization' do
27
- syslog = Ramaze::Logger::Syslog.new( 'ramaze_syslog_test',
28
- ::Syslog::LOG_NDELAY | ::Syslog::LOG_NOWAIT,
27
+ syslog = Ramaze::Logger::Syslog.new( 'ramaze_syslog_test',
28
+ ::Syslog::LOG_NDELAY | ::Syslog::LOG_NOWAIT,
29
29
  ::Syslog::LOG_DAEMON )
30
30
  ::Syslog.opened?.should == true
31
31
  ::Syslog.ident.should == 'ramaze_syslog_test'
@@ -43,7 +43,7 @@ describe 'Syslog' do
43
43
  child = fork {
44
44
  logpipe[0].close
45
45
  STDERR.reopen(logpipe[1])
46
- syslog = Ramaze::Logger::Syslog.new( 'ramaze_syslog_test',
46
+ syslog = Ramaze::Logger::Syslog.new( 'ramaze_syslog_test',
47
47
  ::Syslog::LOG_PID | ::Syslog::LOG_NDELAY | ::Syslog::LOG_PERROR,
48
48
  ::Syslog::LOG_USER )
49
49
  syslog.send priority, msg
@@ -54,7 +54,7 @@ describe 'Syslog' do
54
54
 
55
55
  logpipe[0].gets.should == "ramaze_syslog_test[#{child}]: #{msg}\n"
56
56
  end
57
-
57
+
58
58
  it 'should handle debug' do
59
59
  test_log_msg :direct, :debug, "Hello Debug World"
60
60
  end