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,96 @@
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__)
5
+ require "ramaze/tool/bin"
6
+
7
+ require "pathname"
8
+
9
+ module Ramaze
10
+ BINPATH = Pathname(Ramaze::ROOT).join("../bin/ramaze").expand_path
11
+ end
12
+
13
+ USAGE = <<TXT
14
+
15
+ Usage:
16
+ ramaze <start [PIDFILE]|stop [PIDFILE]|restart [PIDFILE]|status [PIDFILE]|create PROJECT|console> [ruby/rack options]
17
+
18
+ Commands:
19
+
20
+ * All commands which take an optional PIDFILE (defaults to PROJECT.pid otherwise).
21
+ * All commands which start a ramaze instance will default to webrick on port 7000
22
+ unless you supply the rack options -p/--port PORT and/or * -s/--server SERVER.
23
+
24
+ start - Starts an instance of this application.
25
+
26
+ stop - Stops a running instance of this application.
27
+
28
+ restart - Stops running instance of this application, then starts it back up. Pidfile
29
+ (if supplied) is used for both stop and start.
30
+
31
+ status - Gives status of a running ramaze instance
32
+
33
+ create - Creates a new prototype Ramaze application in a directory named PROJECT in
34
+ the current directory. ramaze create foo would make ./foo containing an
35
+ application prototype. Rack options are ignored here.
36
+
37
+ console - Starts an irb console with app.rb (and irb completion) loaded. This command
38
+ ignores rack options, ARGV is passed on to IRB.
39
+
40
+
41
+ Ruby options:
42
+ -e, --eval LINE evaluate a LINE of code
43
+ -d, --debug set debugging flags (set $DEBUG to true)
44
+ -w, --warn turn warnings on for your script
45
+ -I, --include PATH specify $LOAD_PATH (may be used more than once)
46
+ -r, --require LIBRARY require the library, before executing your script
47
+
48
+ Rack options:
49
+ -s, --server SERVER serve using SERVER (webrick/mongrel)
50
+ -o, --host HOST listen on HOST (default: 0.0.0.0)
51
+ -p, --port PORT use PORT (default: 9292)
52
+ -E, --env ENVIRONMENT use ENVIRONMENT for defaults (default: development)
53
+ -D, --daemonize run daemonized in the background
54
+ -P, --pid FILE file to store PID (default: rack.pid)
55
+
56
+ Common options:
57
+ -h, --help Show this message
58
+ --version Show version
59
+ TXT
60
+
61
+ describe "bin/ramaze command" do
62
+ it "Can find the ramaze binary" do
63
+ Ramaze::BINPATH.file?.should == true
64
+ end
65
+
66
+ it "Shows command line help" do
67
+ output = `#{Ramaze::BINPATH} -h`
68
+ output.should == USAGE
69
+ end
70
+
71
+ it "Shows the correct version" do
72
+ output = %x{#{Ramaze::BINPATH} --version}
73
+ output.strip.should == Ramaze::VERSION
74
+ end
75
+
76
+ it "Can create a new tree from prototype" do
77
+ require "fileutils"
78
+ root = Pathname.new("/tmp/test_tree")
79
+ raise "#{root} already exists, please move it out of the way before running this test" if root.directory?
80
+ begin
81
+ output = %x{#{Ramaze::BINPATH} create #{root}}
82
+ root.directory?.should.be.true
83
+ root.join("config.ru").file?.should.be.true
84
+ root.join("start.rb").file?.should.be.true
85
+ root.join("controller").directory?.should.be.true
86
+ root.join("controller", "init.rb").file?.should.be.true
87
+ root.join("view").directory?.should.be.true
88
+ root.join("model").directory?.should.be.true
89
+ root.join("model", "init.rb").file?.should.be.true
90
+ ensure
91
+ FileUtils.rm_rf(root)
92
+ end
93
+ end
94
+
95
+ end
96
+
@@ -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 'localmemcache'
6
6
 
7
7
  describe Ramaze::Cache::LocalMemCache 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
 
6
6
  spec_precondition 'memcached is running' do
7
7
  require 'memcache'
@@ -45,6 +45,12 @@ describe Ramaze::Cache::MemCache do
45
45
  cache.fetch(:hello).should == nil
46
46
  end
47
47
 
48
+ should 'amend the ttl if it is too high' do
49
+ ttl = Ramaze::Cache::MemCache::MAX_TTL + 1
50
+ cache.store(:hello, @hello, :ttl => ttl)
51
+ cache.fetch(:hello).should == @hello
52
+ end
53
+
48
54
  should 'clear' do
49
55
  cache.store(:hello, @hello)
50
56
  cache.fetch(:hello).should == @hello
@@ -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 'sequel'
6
6
 
7
7
  DB = Sequel.sqlite
@@ -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
  Ramaze::App.options.merge!(:layouts => 'view')
7
7
 
@@ -23,7 +23,7 @@ class SpecActionlessTemplatesLayout < Ramaze::Controller
23
23
  end
24
24
 
25
25
  describe "Testing Actionless Templates" do
26
- behaves_like :mock
26
+ behaves_like :rack_test
27
27
 
28
28
  it "should not find template file for non existant method" do
29
29
  get('/list').status.should == 404
@@ -0,0 +1,18 @@
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__)
5
+
6
+ class SpecHello < Ramaze::Controller
7
+ def index
8
+ 'automatically mapped'
9
+ end
10
+ end
11
+
12
+ describe 'Lonely Controller automap' do
13
+ behaves_like :rack_test
14
+
15
+ it 'automatically creates an app and maps the controller into it' do
16
+ get('/').body.should == 'automatically mapped'
17
+ end
18
+ 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
  describe 'Controller::generate_mapping' do
4
7
  def gen(klass)
@@ -41,17 +44,3 @@ describe 'Controller::generate_mapping' do
41
44
  gen(Class.new.name).should == nil
42
45
  end
43
46
  end
44
-
45
- class SpecControllerMapping < Ramaze::Controller
46
- def index
47
- 'automatically mapped'
48
- end
49
- end
50
-
51
- describe 'Controller automap' do
52
- behaves_like :mock
53
-
54
- it 'automatically creates an app and maps the controller into it' do
55
- get('/spec_controller_mapping').body.should == 'automatically mapped'
56
- end
57
- 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 SpecControllerInheritedMain < Ramaze::Controller
4
7
  Ramaze.node('/')
@@ -25,7 +28,7 @@ class SpecControllerInheritedYetAnother < SpecControllerInheritedAnother
25
28
  end
26
29
 
27
30
  describe 'Ramaze::Controller#self.inherited' do
28
- behaves_like :mock
31
+ behaves_like :rack_test
29
32
 
30
33
  should 'default renders nagoro' do
31
34
  get('/').body.should == "<p>Main is nagoro</p>"
@@ -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 MainController < Ramaze::Controller
7
7
  map '/'
@@ -13,7 +13,7 @@ class MainController < Ramaze::Controller
13
13
  end
14
14
 
15
15
  describe 'Controller resolving' do
16
- behaves_like :mock
16
+ behaves_like :rack_test
17
17
 
18
18
  it 'should work with .' do
19
19
  get('/file.ext').body.should == 'file.ext'
@@ -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 BaseController < Ramaze::Controller
7
7
  alias_view :foo, :bar
@@ -14,7 +14,7 @@ class MainController < BaseController
14
14
  end
15
15
 
16
16
  describe 'Controller' do
17
- behaves_like :mock
17
+ behaves_like :rack_test
18
18
 
19
19
  it 'allows sub-classing MainController' do
20
20
  get('/test').body.should == 'test'
@@ -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 SpecViewAlias < Ramaze::Controller
7
7
  map '/'
@@ -44,7 +44,7 @@ class SpecViewAlias2 < SpecViewAlias
44
44
  end
45
45
 
46
46
  describe "Template aliasing" do
47
- behaves_like :mock
47
+ behaves_like :rack_test
48
48
 
49
49
  it 'serves normal template' do
50
50
  get('/greet/asdf').body.should == '<html>asdf : Message</html>'
@@ -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
  spec_require 'hpricot'
4
7
 
@@ -10,7 +13,7 @@ module Ramaze
10
13
  end
11
14
 
12
15
  describe 'Directory listing' do
13
- behaves_like :mock
16
+ behaves_like :rack_test
14
17
 
15
18
  @hierarchy = %w[
16
19
  /test/deep/hierarchy/one.txt
@@ -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
  # This spec more or less tries to ensure that we integrate with rack and
7
7
  # rack-contrib in regards to static file serving.
@@ -9,61 +9,63 @@ require 'spec/helper'
9
9
  module Ramaze
10
10
  # minimal middleware, no exception handling
11
11
  middleware!(:spec){|m|
12
- m.apps(Rack::ETag, Rack::ConditionalGet)
12
+ m.apps Rack::ConditionalGet, Rack::ETag
13
13
  m.innate
14
14
  }
15
15
  end
16
16
 
17
17
  describe 'Serving static files' do
18
- behaves_like :mock
18
+ behaves_like :rack_test
19
19
 
20
- Ramaze.map('/', lambda{|env| [200, {}, 'nothing']})
20
+ Ramaze.map('/', lambda{|env| [200, {}, ['nothing']]})
21
21
 
22
22
  it 'serves from public root' do
23
23
  css = File.read(__DIR__('public/test_download.css'))
24
- got = get('/test_download.css')
25
- got.body.should == css
26
- got.status.should == 200
24
+ get '/test_download.css'
25
+ last_response.body.should == css
26
+ last_response.status.should == 200
27
27
  end
28
28
 
29
29
  it 'serves files with spaces' do
30
- got = get('/file%20name.txt')
31
- got.status.should == 200
32
- got.body.should == 'hi'
30
+ get '/file%20name.txt'
31
+ last_response.status.should == 200
32
+ last_response.body.should == 'hi'
33
33
  end
34
34
 
35
- it 'sends ETag for string bodies' do
36
- got = get('/')
37
- got['ETag'].size.should == 34
35
+ it 'sends Etag for string bodies' do
36
+ get '/'
37
+ last_response['Etag'].size.should > 1
38
38
  end
39
39
 
40
40
  it 'sends Last-Modified for file bodies' do
41
- got = get('/test_download.css')
41
+ get '/test_download.css'
42
42
 
43
43
  mtime = File.mtime(__DIR__('public/test_download.css'))
44
44
 
45
- got['Last-Modified'].should == mtime.httpdate
45
+ last_response['Last-Modified'].should == mtime.httpdate
46
46
  end
47
47
 
48
- it 'respects ETag with HTTP_IF_NONE_MATCH' do
49
- got = get('/')
48
+ it 'respects Etag with HTTP_IF_NONE_MATCH' do
49
+ get '/'
50
50
 
51
- etag = got['ETag']
51
+ etag = last_response['Etag']
52
52
  etag.should.not.be.nil
53
53
 
54
- got = get('/', 'HTTP_IF_NONE_MATCH' => etag)
55
- got.status.should == 304
56
- got.body.should == ''
54
+ header 'HTTP_IF_NONE_MATCH', etag
55
+ get '/'
56
+ last_response.status.should == 304
57
+ last_response.body.should == ''
57
58
  end
58
59
 
59
60
  it 'respects Last-Modified with HTTP_IF_MODIFIED_SINCE' do
60
- got = get('/test_download.css')
61
+ get '/test_download.css'
61
62
 
62
- mtime = got['Last-Modified']
63
+ mtime = last_response['Last-Modified']
63
64
  mtime.should.not.be.nil
64
65
 
65
- got = get('/test_download.css', 'HTTP_IF_MODIFIED_SINCE' => mtime)
66
- got.status.should == 304
67
- got.body.should == ''
66
+ header 'HTTP_IF_MODIFIED_SINCE', mtime
67
+ get '/test_download.css'
68
+ last_response.status.should == 304
69
+ last_response.body.should == ''
68
70
  end
69
71
  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
  require 'rexml/document'
6
6
  require 'rexml/xpath'
7
7
 
@@ -35,7 +35,7 @@ class SpecErrorHandling < SpecError
35
35
  end
36
36
 
37
37
  describe 'Error handling' do
38
- behaves_like :mock
38
+ behaves_like :rack_test
39
39
 
40
40
  Ramaze.options.mode = :dev
41
41
 
@@ -66,7 +66,7 @@ describe 'Error handling' do
66
66
  end
67
67
 
68
68
  it 'uses Rack::RouteExceptions when a route is set' do
69
- Rack::RouteExceptions[NameError] = '/handle/name_error'
69
+ Rack::RouteExceptions.route(NameError, '/handle/name_error')
70
70
 
71
71
  got = get('/raises')
72
72
  [got.status, got['Content-Type']].should == [200, 'text/html']
@@ -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 SpecFilesCore < Ramaze::Controller
4
7
  map '/', :core
@@ -17,7 +20,7 @@ Ramaze::App[:other].options.publics = 'files/public_2'
17
20
  Ramaze.middleware!(:spec){|m| m.run(Ramaze::AppMap) }
18
21
 
19
22
  describe Ramaze::Files do
20
- behaves_like :mock
23
+ behaves_like :rack_test
21
24
 
22
25
  it 'serves files for core app from public_1' do
23
26
  get('/plain.txt').body.should == "Just some text in a file\n"
@@ -1,6 +1,9 @@
1
1
  # * Encoding: UTF-8
2
+ #
3
+ # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
4
+ # All files in this distribution are subject to the terms of the Ruby license.
2
5
 
3
- require 'spec/helper'
6
+ require File.expand_path('../../../spec/helper', __FILE__)
4
7
  require 'ramaze/gestalt'
5
8
 
6
9
  describe "Gestalt" do
@@ -26,38 +29,38 @@ describe "Gestalt" do
26
29
 
27
30
  it "deep nested tags" do
28
31
  gestalt{ p do
29
- div do
30
- ol do
31
- li
32
+ div do
33
+ ol do
34
+ li
35
+ end
32
36
  end
33
37
  end
34
- end
35
38
  }.should == '<p><div><ol><li /></ol></div></p>'
36
39
  end
37
40
 
38
41
  it "deep nested tags with repetition" do
39
42
  gestalt{ p do
40
- div do
41
- ol do
42
- li
43
- li
44
- end
45
- ol do
46
- li
47
- li
43
+ div do
44
+ ol do
45
+ li
46
+ li
47
+ end
48
+ ol do
49
+ li
50
+ li
51
+ end
48
52
  end
49
53
  end
50
- end
51
54
  }.should == '<p><div><ol><li /><li /></ol><ol><li /><li /></ol></div></p>'
52
55
  end
53
56
 
54
57
  it "deep nested tags with strings" do
55
58
  gestalt{
56
59
  p do
57
- div do
58
- 'Hello, World'
60
+ div do
61
+ 'Hello, World'
62
+ end
59
63
  end
60
- end
61
64
  }.should == '<p><div>Hello, World</div></p>'
62
65
  end
63
66
 
@@ -109,6 +112,12 @@ describe "Gestalt" do
109
112
  }.should == '<a href="http://example.org/?a=one&amp;b=two">Click here</a>'
110
113
  end
111
114
 
115
+ it 'takes text and attributes' do
116
+ gestalt {
117
+ a('Click here', :href => "http://example.org/?a=one&b=two")
118
+ }.should == '<a href="http://example.org/?a=one&amp;b=two">Click here</a>'
119
+ end
120
+
112
121
  it 'should accept symbols as attributes' do
113
122
  input = gestalt{ input(:type => :text, :value => :one) }
114
123