ramaze 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (304) hide show
  1. data/Rakefile +20 -3
  2. data/bin/ramaze +1 -4
  3. data/doc/AUTHORS +2 -1
  4. data/doc/CHANGELOG +539 -32
  5. data/doc/LEGAL +4 -0
  6. data/doc/meta/announcement.txt +79 -47
  7. data/examples/blog/README +2 -2
  8. data/examples/blog/spec/blog.rb +33 -48
  9. data/examples/blog/src/controller.rb +15 -13
  10. data/examples/blog/src/model.rb +28 -10
  11. data/examples/blog/start.rb +0 -10
  12. data/examples/blog/template/edit.xhtml +1 -1
  13. data/examples/blog/template/index.xhtml +2 -2
  14. data/examples/facebook.rb +152 -0
  15. data/examples/linking.rb +28 -0
  16. data/examples/ramaise.rb +4 -11
  17. data/examples/rammit/spec/rammit.rb +30 -0
  18. data/examples/rammit/src/controller/main.rb +3 -0
  19. data/examples/rammit/src/controller/page.rb +16 -0
  20. data/examples/rammit/src/model.rb +33 -0
  21. data/examples/rammit/start.rb +7 -0
  22. data/examples/rammit/template/index.xhtml +14 -0
  23. data/examples/rammit/template/page/view.xhtml +4 -0
  24. data/examples/rapaste/Rakefile +28 -0
  25. data/examples/rapaste/public/css/active4d.css +114 -0
  26. data/examples/rapaste/public/css/all_hallows_eve.css +72 -0
  27. data/examples/rapaste/public/css/amy.css +147 -0
  28. data/examples/rapaste/public/css/blackboard.css +88 -0
  29. data/examples/rapaste/public/css/brilliance_black.css +605 -0
  30. data/examples/rapaste/public/css/brilliance_dull.css +599 -0
  31. data/examples/rapaste/public/css/cobalt.css +149 -0
  32. data/examples/rapaste/public/css/dawn.css +121 -0
  33. data/examples/rapaste/public/css/display.css +179 -0
  34. data/examples/rapaste/public/css/eiffel.css +121 -0
  35. data/examples/rapaste/public/css/espresso_libre.css +109 -0
  36. data/examples/rapaste/public/css/idle.css +62 -0
  37. data/examples/rapaste/public/css/iplastic.css +80 -0
  38. data/examples/rapaste/public/css/lazy.css +73 -0
  39. data/examples/rapaste/public/css/mac_classic.css +123 -0
  40. data/examples/rapaste/public/css/magicwb_amiga.css +104 -0
  41. data/examples/rapaste/public/css/pastels_on_dark.css +188 -0
  42. data/examples/rapaste/public/css/slush_poppies.css +85 -0
  43. data/examples/rapaste/public/css/spacecadet.css +51 -0
  44. data/examples/rapaste/public/css/sunburst.css +180 -0
  45. data/examples/rapaste/public/css/twilight.css +137 -0
  46. data/examples/rapaste/public/css/zenburnesque.css +91 -0
  47. data/examples/rapaste/public/js/jquery.js +11 -0
  48. data/examples/rapaste/rapaste.sqlite +0 -0
  49. data/examples/rapaste/spec/rapaste.rb +49 -0
  50. data/examples/rapaste/src/controller.rb +69 -0
  51. data/examples/rapaste/src/model.rb +61 -0
  52. data/examples/rapaste/start.rb +20 -0
  53. data/examples/rapaste/template/copy.xhtml +10 -0
  54. data/examples/rapaste/template/index.xhtml +9 -0
  55. data/examples/rapaste/template/layout.xhtml +22 -0
  56. data/examples/rapaste/template/list.xhtml +28 -0
  57. data/examples/rapaste/template/view.xhtml +37 -0
  58. data/examples/sourceview/sourceview.rb +3 -3
  59. data/examples/templates/template_amrita2.rb +1 -3
  60. data/examples/todolist/spec/todolist.rb +15 -18
  61. data/examples/whywiki/spec/whywiki.rb +15 -20
  62. data/examples/whywiki/start.rb +0 -1
  63. data/examples/wikore/spec/wikore.rb +14 -19
  64. data/examples/wiktacular/spec/wiktacular.rb +8 -15
  65. data/lib/proto/{src/controller → controller}/main.rb +4 -4
  66. data/lib/proto/public/css/ramaze_error.css +39 -3
  67. data/lib/proto/public/js/jquery.js +2039 -1020
  68. data/lib/proto/spec/main.rb +27 -0
  69. data/lib/proto/start.rb +5 -5
  70. data/lib/proto/view/error.xhtml +62 -0
  71. data/lib/proto/view/index.xhtml +34 -0
  72. data/lib/proto/view/page.xhtml +15 -0
  73. data/lib/ramaze.rb +9 -7
  74. data/lib/ramaze/action.rb +7 -3
  75. data/lib/ramaze/action/render.rb +15 -5
  76. data/lib/ramaze/adapter.rb +5 -5
  77. data/lib/ramaze/adapter/base.rb +2 -2
  78. data/lib/ramaze/adapter/cgi.rb +1 -1
  79. data/lib/ramaze/adapter/evented_mongrel.rb +1 -1
  80. data/lib/ramaze/adapter/fcgi.rb +2 -2
  81. data/lib/ramaze/adapter/mongrel.rb +1 -1
  82. data/lib/ramaze/adapter/swiftiplied_mongrel.rb +1 -1
  83. data/lib/ramaze/adapter/thin.rb +25 -0
  84. data/lib/ramaze/adapter/webrick.rb +1 -1
  85. data/lib/ramaze/cache.rb +3 -2
  86. data/lib/ramaze/cache/memcached.rb +1 -1
  87. data/lib/ramaze/cache/memory.rb +1 -1
  88. data/lib/ramaze/cache/yaml_store.rb +1 -1
  89. data/lib/ramaze/contrib.rb +1 -1
  90. data/lib/ramaze/contrib/auto_params.rb +12 -5
  91. data/lib/ramaze/contrib/auto_params/get_args.rb +1 -0
  92. data/lib/ramaze/contrib/facebook.rb +23 -0
  93. data/lib/ramaze/contrib/facebook/facebook.rb +168 -0
  94. data/lib/ramaze/contrib/gettext.rb +111 -0
  95. data/lib/ramaze/contrib/gettext/mo.rb +155 -0
  96. data/lib/ramaze/contrib/gettext/po.rb +109 -0
  97. data/lib/ramaze/contrib/gzip_filter.rb +1 -1
  98. data/lib/ramaze/contrib/route.rb +15 -5
  99. data/lib/ramaze/contrib/sequel/fill.rb +1 -1
  100. data/lib/ramaze/controller.rb +10 -4
  101. data/lib/ramaze/controller/error.rb +5 -13
  102. data/lib/ramaze/controller/main.rb +2 -0
  103. data/lib/ramaze/controller/resolve.rb +18 -10
  104. data/lib/ramaze/dispatcher.rb +1 -1
  105. data/lib/ramaze/dispatcher/action.rb +1 -1
  106. data/lib/ramaze/dispatcher/directory.rb +3 -2
  107. data/lib/ramaze/dispatcher/error.rb +5 -5
  108. data/lib/ramaze/dispatcher/file.rb +13 -2
  109. data/lib/ramaze/error.rb +1 -1
  110. data/lib/ramaze/gestalt.rb +2 -2
  111. data/lib/ramaze/global.rb +5 -5
  112. data/lib/ramaze/global/dsl.rb +1 -1
  113. data/lib/ramaze/global/globalstruct.rb +11 -5
  114. data/lib/ramaze/helper.rb +1 -1
  115. data/lib/ramaze/helper/aspect.rb +1 -1
  116. data/lib/ramaze/helper/auth.rb +2 -2
  117. data/lib/ramaze/helper/cache.rb +1 -1
  118. data/lib/ramaze/helper/cgi.rb +1 -1
  119. data/lib/ramaze/helper/file.rb +1 -1
  120. data/lib/ramaze/helper/flash.rb +1 -1
  121. data/lib/ramaze/helper/formatting.rb +1 -1
  122. data/lib/ramaze/helper/identity.rb +1 -1
  123. data/lib/ramaze/helper/inform.rb +1 -1
  124. data/lib/ramaze/helper/link.rb +4 -4
  125. data/lib/ramaze/helper/markaby.rb +1 -1
  126. data/lib/ramaze/helper/nitroform.rb +1 -1
  127. data/lib/ramaze/helper/pager.rb +2 -1
  128. data/lib/ramaze/helper/partial.rb +1 -1
  129. data/lib/ramaze/helper/redirect.rb +6 -1
  130. data/lib/ramaze/helper/sequel.rb +54 -0
  131. data/lib/ramaze/helper/stack.rb +1 -1
  132. data/lib/ramaze/inform.rb +1 -1
  133. data/lib/ramaze/inform/analogger.rb +1 -1
  134. data/lib/ramaze/inform/growl.rb +1 -1
  135. data/lib/ramaze/inform/hub.rb +1 -1
  136. data/lib/ramaze/inform/informer.rb +1 -1
  137. data/lib/ramaze/inform/informing.rb +2 -2
  138. data/lib/ramaze/inform/knotify.rb +1 -1
  139. data/lib/ramaze/inform/syslog.rb +1 -1
  140. data/lib/ramaze/inform/xosd.rb +1 -1
  141. data/lib/ramaze/snippets.rb +1 -1
  142. data/lib/ramaze/snippets/array/put_within.rb +1 -1
  143. data/lib/ramaze/snippets/blankslate.rb +7 -0
  144. data/lib/ramaze/snippets/dictionary.rb +6 -1
  145. data/lib/ramaze/snippets/divide.rb +1 -1
  146. data/lib/ramaze/snippets/kernel/__dir__.rb +1 -1
  147. data/lib/ramaze/snippets/kernel/acquire.rb +39 -0
  148. data/lib/ramaze/snippets/kernel/aquire.rb +1 -34
  149. data/lib/ramaze/snippets/kernel/constant.rb +1 -1
  150. data/lib/ramaze/snippets/kernel/pretty_inspect.rb +1 -1
  151. data/lib/ramaze/snippets/numeric/filesize_format.rb +1 -1
  152. data/lib/ramaze/snippets/object/traits.rb +1 -1
  153. data/lib/ramaze/snippets/ordered_set.rb +12 -7
  154. data/lib/ramaze/snippets/ramaze/caller_info.rb +1 -1
  155. data/lib/ramaze/snippets/ramaze/caller_lines.rb +1 -1
  156. data/lib/ramaze/snippets/string/camel_case.rb +1 -1
  157. data/lib/ramaze/snippets/string/color.rb +2 -4
  158. data/lib/ramaze/snippets/string/each.rb +1 -1
  159. data/lib/ramaze/snippets/string/ord.rb +15 -0
  160. data/lib/ramaze/snippets/string/snake_case.rb +1 -1
  161. data/lib/ramaze/snippets/struct/fill.rb +4 -2
  162. data/lib/ramaze/snippets/struct/values_at.rb +2 -2
  163. data/lib/ramaze/snippets/symbol/to_proc.rb +15 -8
  164. data/lib/ramaze/snippets/thread/into.rb +1 -1
  165. data/lib/ramaze/sourcereload.rb +4 -3
  166. data/lib/ramaze/spec/helper.rb +85 -32
  167. data/lib/ramaze/spec/helper/bacon.rb +7 -0
  168. data/lib/ramaze/spec/helper/browser.rb +1 -2
  169. data/lib/ramaze/spec/helper/mock_http.rb +1 -1
  170. data/lib/ramaze/spec/helper/pretty_output.rb +70 -0
  171. data/lib/ramaze/spec/helper/requester.rb +1 -1
  172. data/lib/ramaze/spec/helper/simple_http.rb +5 -4
  173. data/lib/ramaze/spec/helper/snippets.rb +6 -0
  174. data/lib/ramaze/store/default.rb +1 -1
  175. data/lib/ramaze/template.rb +1 -1
  176. data/lib/ramaze/template/amrita2.rb +6 -5
  177. data/lib/ramaze/template/erubis.rb +1 -1
  178. data/lib/ramaze/template/ezamar.rb +1 -1
  179. data/lib/ramaze/template/ezamar/element.rb +1 -1
  180. data/lib/ramaze/template/ezamar/engine.rb +1 -1
  181. data/lib/ramaze/template/ezamar/morpher.rb +1 -1
  182. data/lib/ramaze/template/ezamar/render_partial.rb +1 -1
  183. data/lib/ramaze/template/haml.rb +1 -1
  184. data/lib/ramaze/template/liquid.rb +1 -1
  185. data/lib/ramaze/template/markaby.rb +1 -1
  186. data/lib/ramaze/template/nagoro.rb +4 -6
  187. data/lib/ramaze/template/none.rb +1 -1
  188. data/lib/ramaze/template/remarkably.rb +1 -1
  189. data/lib/ramaze/template/sass.rb +1 -1
  190. data/lib/ramaze/tool.rb +1 -1
  191. data/lib/ramaze/tool/create.rb +7 -1
  192. data/lib/ramaze/tool/localize.rb +7 -14
  193. data/lib/ramaze/tool/mime.rb +1 -1
  194. data/lib/ramaze/tool/record.rb +1 -1
  195. data/lib/ramaze/trinity.rb +1 -1
  196. data/lib/ramaze/trinity/request.rb +4 -2
  197. data/lib/ramaze/trinity/response.rb +1 -1
  198. data/lib/ramaze/trinity/session.rb +7 -1
  199. data/lib/ramaze/version.rb +3 -3
  200. data/lib/vendor/bacon.rb +317 -0
  201. data/rake_tasks/conf.rake +1 -1
  202. data/rake_tasks/maintenance.rake +7 -5
  203. data/rake_tasks/spec.rake +54 -40
  204. data/spec/contrib/auto_params.rb +21 -4
  205. data/spec/contrib/route.rb +31 -4
  206. data/spec/contrib/sequel/fill.rb +3 -4
  207. data/spec/examples/caching.rb +5 -2
  208. data/spec/examples/css.rb +5 -2
  209. data/spec/examples/element.rb +5 -4
  210. data/spec/examples/hello.rb +1 -0
  211. data/spec/examples/linking.rb +18 -0
  212. data/spec/examples/simple.rb +13 -18
  213. data/spec/examples/templates/template_amrita2.rb +3 -2
  214. data/spec/examples/templates/template_erubis.rb +3 -2
  215. data/spec/examples/templates/template_ezamar.rb +2 -1
  216. data/spec/examples/templates/template_haml.rb +3 -2
  217. data/spec/examples/templates/template_liquid.rb +3 -2
  218. data/spec/examples/templates/template_markaby.rb +3 -2
  219. data/spec/examples/templates/template_remarkably.rb +3 -2
  220. data/spec/ramaze/action/basics.rb +4 -4
  221. data/spec/ramaze/action/cache.rb +11 -13
  222. data/spec/ramaze/action/layout.rb +47 -3
  223. data/spec/ramaze/action/render.rb +3 -3
  224. data/spec/ramaze/action/template/instancevars/layout.xhtml +1 -0
  225. data/spec/ramaze/adapter.rb +7 -7
  226. data/spec/ramaze/adapter/mongrel.rb +1 -1
  227. data/spec/ramaze/adapter/record.rb +7 -7
  228. data/spec/ramaze/adapter/webrick.rb +1 -1
  229. data/spec/ramaze/cache.rb +6 -8
  230. data/spec/ramaze/controller.rb +77 -65
  231. data/spec/ramaze/controller/resolve.rb +2 -1
  232. data/spec/ramaze/controller/template_resolving.rb +3 -4
  233. data/spec/ramaze/dispatcher.rb +3 -4
  234. data/spec/ramaze/dispatcher/directory.rb +35 -35
  235. data/spec/ramaze/dispatcher/file.rb +8 -5
  236. data/spec/ramaze/element.rb +4 -4
  237. data/spec/ramaze/error.rb +13 -11
  238. data/spec/ramaze/gestalt.rb +1 -1
  239. data/spec/ramaze/helper/aspect.rb +2 -1
  240. data/spec/ramaze/helper/auth.rb +4 -2
  241. data/spec/ramaze/helper/cache.rb +10 -9
  242. data/spec/ramaze/helper/cgi.rb +2 -2
  243. data/spec/ramaze/helper/file.rb +1 -0
  244. data/spec/ramaze/helper/flash.rb +5 -4
  245. data/spec/ramaze/helper/formatting.rb +1 -1
  246. data/spec/ramaze/helper/link.rb +3 -3
  247. data/spec/ramaze/helper/pager.rb +44 -80
  248. data/spec/ramaze/helper/partial.rb +2 -3
  249. data/spec/ramaze/helper/redirect.rb +10 -1
  250. data/spec/ramaze/helper/stack.rb +4 -3
  251. data/spec/ramaze/helper/template/loop.xhtml +2 -1
  252. data/spec/ramaze/inform/informer.rb +2 -2
  253. data/spec/ramaze/inform/syslog.rb +1 -1
  254. data/spec/ramaze/localize.rb +26 -26
  255. data/spec/ramaze/morpher.rb +6 -7
  256. data/spec/ramaze/params.rb +7 -8
  257. data/spec/ramaze/request.rb +27 -6
  258. data/spec/ramaze/request/mongrel.rb +1 -1
  259. data/spec/ramaze/request/thin.rb +9 -0
  260. data/spec/ramaze/session.rb +2 -1
  261. data/spec/ramaze/store/default.rb +14 -17
  262. data/spec/ramaze/template.rb +5 -7
  263. data/spec/ramaze/template/amrita2.rb +4 -1
  264. data/spec/ramaze/template/erubis.rb +2 -1
  265. data/spec/ramaze/template/ezamar.rb +2 -3
  266. data/spec/ramaze/template/ezamar/other__index.xhtml +1 -0
  267. data/spec/ramaze/template/haml.rb +2 -1
  268. data/spec/ramaze/template/liquid.rb +4 -2
  269. data/spec/ramaze/template/markaby.rb +4 -2
  270. data/spec/ramaze/template/nagoro.rb +3 -4
  271. data/spec/ramaze/template/remarkably.rb +4 -2
  272. data/spec/ramaze/template/sass.rb +3 -2
  273. data/spec/ramaze/template/xslt.rb +4 -7
  274. data/spec/ramaze/trinity/request.rb +4 -3
  275. data/spec/ramaze/trinity/session.rb +6 -4
  276. data/spec/snippets/array/put_within.rb +3 -2
  277. data/spec/snippets/divide.rb +1 -4
  278. data/spec/snippets/kernel/__dir__.rb +1 -1
  279. data/spec/snippets/kernel/acquire.rb +71 -0
  280. data/spec/snippets/kernel/constant.rb +4 -8
  281. data/spec/snippets/numeric/filesize_format.rb +1 -1
  282. data/spec/snippets/ordered_set.rb +9 -2
  283. data/spec/snippets/ramaze/caller_info.rb +3 -3
  284. data/spec/snippets/ramaze/caller_lines.rb +3 -3
  285. data/spec/snippets/string/camel_case.rb +1 -1
  286. data/spec/snippets/string/color.rb +2 -2
  287. data/spec/snippets/string/snake_case.rb +5 -1
  288. data/spec/snippets/string/unindent.rb +1 -1
  289. data/spec/snippets/struct/fill.rb +14 -15
  290. data/spec/snippets/struct/values_at.rb +15 -10
  291. data/spec/snippets/symbol/to_proc.rb +13 -0
  292. data/spec/snippets/thread/into.rb +3 -4
  293. metadata +458 -386
  294. data/doc/README.html +0 -729
  295. data/doc/changes.txt +0 -5044
  296. data/doc/changes.xml +0 -5046
  297. data/lib/proto/public/error.zmr +0 -61
  298. data/lib/proto/src/element/page.rb +0 -17
  299. data/lib/proto/src/model.rb +0 -6
  300. data/lib/proto/template/index.xhtml +0 -15
  301. data/lib/ramaze/spec/helper/layout.rb +0 -58
  302. data/lib/ramaze/spec/helper/minimal.rb +0 -23
  303. data/lib/ramaze/spec/helper/wrap.rb +0 -198
  304. data/spec/snippets/kernel/aquire.rb +0 -71
@@ -14,6 +14,7 @@ class MainController < Ramaze::Controller
14
14
  end
15
15
 
16
16
  describe 'Controller resolving' do
17
+ behaves_like 'http'
17
18
  ramaze
18
19
 
19
20
  it 'should work with .' do
@@ -28,4 +29,4 @@ describe 'Controller resolving' do
28
29
  it 'should find templates' do
29
30
  get('/other/greet/other').body.should == '<html>Other: hi</html>'
30
31
  end
31
- end
32
+ end
@@ -44,9 +44,8 @@ class OtherController < MainController
44
44
  end
45
45
 
46
46
  describe "Testing Template overriding" do
47
- before(:all) do
48
- ramaze
49
- end
47
+ behaves_like 'http'
48
+ ramaze
50
49
 
51
50
  it "simple request to greet" do
52
51
  get('/greet/asdf').body.should == '<html>asdf : Message</html>'
@@ -76,4 +75,4 @@ describe "Testing Template overriding" do
76
75
  it "should use template overrides for non-existant actions" do
77
76
  get('/non_existant_method').body.should == '<html></html>'
78
77
  end
79
- end
78
+ end
@@ -12,10 +12,9 @@ class TCDispatcherController < Ramaze::Controller
12
12
  end
13
13
 
14
14
  describe "Dispatcher" do
15
- before :all do
16
- ramaze :ignore => ['/favicon.ico', '/robots.txt'],
17
- :ignore_body => 'File not found'
18
- end
15
+ behaves_like 'http'
16
+ ramaze :ignore => ['/favicon.ico', '/robots.txt'],
17
+ :ignore_body => 'File not found'
19
18
 
20
19
  it 'should resolve a normal request' do
21
20
  page = get('/')
@@ -1,54 +1,54 @@
1
1
  require 'spec/helper'
2
2
 
3
- testcase_requires 'hpricot'
3
+ spec_require 'hpricot'
4
4
 
5
5
  describe 'Dispatcher::Directory' do
6
- before :all do
7
- ramaze
8
-
9
- @hierarchy = %w[
10
- /test/deep/hierarchy/one.txt
11
- /test/deep/hierarchy/two.txt
12
- /test/deep/three.txt
13
- /test/deep/four.txt
14
- /test/five.txt
15
- /test/six.txt ]
16
-
17
- @hierarchy.each do |path|
18
- FileUtils.mkdir_p(__DIR__/:public/File.dirname(path))
19
- FileUtils.touch(__DIR__/:public/path)
20
- end
6
+ @hierarchy = %w[
7
+ /test/deep/hierarchy/one.txt
8
+ /test/deep/hierarchy/two.txt
9
+ /test/deep/three.txt
10
+ /test/deep/four.txt
11
+ /test/five.txt
12
+ /test/six.txt ]
13
+
14
+ @hierarchy.each do |path|
15
+ FileUtils.mkdir_p(__DIR__/:public/File.dirname(path))
16
+ FileUtils.touch(__DIR__/:public/path)
21
17
  end
22
18
 
23
19
  def build_listing(path)
24
20
  Ramaze::Dispatcher::Directory.build_listing(path)
25
21
  end
26
22
 
27
- it 'should dry serve root directory' do
28
- body, status, header = build_listing('/')
23
+ def check(url, title, list)
24
+ body, status, header = build_listing(url)
29
25
  status.should == 200
30
26
  header['Content-Type'].should == 'text/html'
27
+
31
28
  doc = Hpricot(body)
32
- doc.at(:title).inner_text.should == 'Directory listing of /'
33
- files = doc.search("//td[@class='n']")
34
- links = files.map{|td| a = td.at(:a); [a['href'], a.inner_text]}
35
- links.should == [["/../", "Parent Directory"], ["/test", "test/"],
36
- ["/favicon.ico", "favicon.ico"], ["/test_download.css", "test_download.css"]]
29
+ doc.at(:title).inner_text.should == title
30
+ doc.search("//td[@class='n']").map{|td|
31
+ a = td.at(:a)
32
+ [ a[:href], a.inner_text ]
33
+ }.should == list
37
34
  end
38
35
 
39
- it 'should serve hierarchies' do
40
- body, status, header = build_listing('/test')
41
- status.should == 200
42
- header['Content-Type'].should == 'text/html'
43
- doc = Hpricot(body)
44
- doc.at(:title).inner_text.should == 'Directory listing of /test'
45
- files = doc.search("//td[@class='n']")
46
- links = files.map{|td| a = td.at(:a); [a['href'], a.inner_text]}
47
- links.should == [["/test/../", "Parent Directory"], ["/test/deep", "deep/"],
48
- ["/test/five.txt", "five.txt"], ["/test/six.txt", "six.txt"]]
36
+ it 'should dry serve root directory' do
37
+ files = [
38
+ ["/../", "Parent Directory"], ["/test", "test/"],
39
+ ["/favicon.ico", "favicon.ico"], ["/test_download.css", "test_download.css"]
40
+ ]
41
+
42
+ check '/', 'Directory listing of /', files
49
43
  end
50
44
 
51
- after :all do
52
- FileUtils.rm_rf(__DIR__/:public/:test)
45
+ it 'should serve hierarchies' do
46
+ files = [
47
+ ["/test/../", "Parent Directory"], ["/test/deep", "deep/"],
48
+ ["/test/five.txt", "five.txt"], ["/test/six.txt", "six.txt"]
49
+ ]
50
+ check '/test', 'Directory listing of /test', files
53
51
  end
52
+
53
+ FileUtils.rm_rf(__DIR__/:public/:test)
54
54
  end
@@ -1,10 +1,9 @@
1
1
  require 'spec/helper'
2
2
 
3
3
  describe 'Dispatcher::File' do
4
- before :all do
5
- ramaze
6
- @public_root = Ramaze::Global.public_root = 'spec/ramaze/dispatcher/public'
7
- end
4
+ behaves_like 'http'
5
+ @public_root = 'spec/ramaze/dispatcher/public'
6
+ ramaze :public_root => @public_root
8
7
 
9
8
  it 'should serve from Global.public_root' do
10
9
  css = File.read(@public_root/'test_download.css')
@@ -15,7 +14,11 @@ describe 'Dispatcher::File' do
15
14
 
16
15
  it 'should give priority to Global.public_root' do
17
16
  file = (@public_root/'favicon.ico')
18
- original = File.read(file)
17
+ if RUBY_VERSION >= '1.9.0'
18
+ original = File.open(file, 'r:ASCII'){|f| f.read}
19
+ else
20
+ original = File.read(file)
21
+ end
19
22
  get('/favicon.ico').body.should == original
20
23
  end
21
24
  end
@@ -46,8 +46,8 @@ end
46
46
 
47
47
  class PageWithParams < Ezamar::Element
48
48
  def render
49
- ivs = (instance_variables - ['@content'])
50
- ivs.inject({}){|s,v| s.merge(v => instance_variable_get(v)) }.inspect
49
+ ivs = (instance_variables - ['@content', :@content])
50
+ ivs.inject({}){|s,v| s.merge(v.to_s => instance_variable_get(v)) }.inspect
51
51
  end
52
52
  end
53
53
 
@@ -59,8 +59,8 @@ end
59
59
 
60
60
  class PageLittleWithParams < Ezamar::Element
61
61
  def render
62
- ivs = (instance_variables - ['@content'])
63
- ivs.inject({}){|s,v| s.merge(v => instance_variable_get(v)) }.inspect
62
+ ivs = (instance_variables - ['@content', :@content])
63
+ ivs.inject({}){|s,v| s.merge(v.to_s => instance_variable_get(v)) }.inspect
64
64
  end
65
65
  end
66
66
 
@@ -29,16 +29,18 @@ class TCErrorCustomController < Ramaze::Controller
29
29
  end
30
30
 
31
31
  describe "Error" do
32
- ramaze :error_page => true, :public_root => 'spec/ramaze/public'
32
+ behaves_like 'http'
33
+ ramaze :error_page => true,
34
+ :template_root => 'spec/ramaze/public'
33
35
 
34
- before :all do
35
- require 'ramaze/dispatcher/error'
36
- @handle_error = Ramaze::Dispatcher::Error::HANDLE_ERROR
37
- end
36
+ @handle_error = Ramaze::Dispatcher::Error::HANDLE_ERROR
37
+ @orig_handle_error = @handle_error.dup
38
38
 
39
- before :each do
39
+ before do
40
40
  Ramaze::Cache.resolved.clear
41
41
  Ramaze::Cache.patterns.clear
42
+ @handle_error.clear
43
+ @handle_error.merge!(@orig_handle_error)
42
44
  end
43
45
 
44
46
  it 'should resolve custom error pages per controller' do
@@ -67,8 +69,7 @@ describe "Error" do
67
69
  end
68
70
 
69
71
  it "should give custom status when no action is found" do
70
- @handle_error.should_receive(:[]).twice.
71
- with(Ramaze::Error::NoAction).and_return{ [707, '/error'] }
72
+ @handle_error[Ramaze::Error::NoAction] = [707, '/error']
72
73
 
73
74
  response = get('/illegal1')
74
75
  response.status.should == 707
@@ -76,15 +77,16 @@ describe "Error" do
76
77
  end
77
78
 
78
79
  it "should give 404 when no controller is found" do
79
- Ramaze::Global.should_receive(:mapping).exactly(6).times.and_return{ {} }
80
+ old_mapping = Ramaze::Global.mapping.dup
81
+ Ramaze::Global.mapping.clear
80
82
  response = get('/illegal2')
81
83
  response.status.should == 404
82
84
  response.body.should =~ %r(No Controller found for `/error')
85
+ Ramaze::Global.mapping = old_mapping
83
86
  end
84
87
 
85
88
  it "should return custom error page" do
86
- @handle_error.should_receive(:[]).twice.
87
- with(Ramaze::Error::NoAction).and_return{ [404, '/error404'] }
89
+ @handle_error[Ramaze::Error::NoAction] = [404, '/error404']
88
90
  response = get('/illegal3')
89
91
  response.status.should == 404
90
92
  response.body.should == '404 - not found'
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'spec/helper'
5
5
 
6
- testcase_requires 'ramaze/gestalt'
6
+ spec_require 'ramaze/gestalt'
7
7
 
8
8
  describe "Gestalt" do
9
9
  # This is useful for any controller using Gestalt,
@@ -40,7 +40,8 @@ class TCAspectAllController < Ramaze::Controller
40
40
  end
41
41
 
42
42
  describe "AspectHelper" do
43
- ramaze(:error_page => false)
43
+ behaves_like 'http'
44
+ ramaze :error_page => false
44
45
 
45
46
  it "shouldn't overwrite traits on inclusion" do
46
47
  TCAspectController.trait[:foo].should == :bar
@@ -45,14 +45,16 @@ class TCAuthLambdaHelperController < TCAuthHelperController
45
45
  end
46
46
 
47
47
  describe "StackHelper" do
48
+ behaves_like 'browser'
49
+
48
50
  ramaze :adapter => :webrick
49
51
  [ TCAuthHashHelperController,
50
52
  TCAuthMethodHelperController,
51
53
  TCAuthLambdaHelperController
52
54
  ].each do |controller|
53
55
 
54
- specify controller.to_s do
55
- browser('/', Ramaze::Global.mapping.invert[controller]) do
56
+ it controller.to_s do
57
+ Browser.new('/', Ramaze::Global.mapping.invert[controller]) do
56
58
  get('/secured').should == ''
57
59
  post('/login', 'username' => 'manveru', 'password' => 'password')
58
60
  get('/secured').should == 'Secret content'
@@ -87,6 +87,7 @@ class TCCacheHelperOldController < Ramaze::Controller
87
87
  end
88
88
 
89
89
  describe "CacheHelper" do
90
+ behaves_like 'http'
90
91
  ramaze
91
92
 
92
93
  def req(path='/', *args) get(path, *args).body end
@@ -97,23 +98,23 @@ describe "CacheHelper" do
97
98
 
98
99
  it "cached value" do
99
100
  3.times do
100
- lambda{ req('/cached_value') }.should_not change{ req('/cached_value') }
101
+ lambda{ req('/cached_value') }.should.not.change{ req('/cached_value') }
101
102
  end
102
103
 
103
104
  3.times do
104
- lambda{ req('/uncache_values') }.should change{ req('/cached_value') }
105
+ lambda{ req('/uncache_values') }.should.change{ req('/cached_value') }
105
106
  end
106
107
 
107
- lambda{ req('/uncache_values') }.should change{ req('/alt_cached_value') }
108
+ lambda{ req('/uncache_values') }.should.change{ req('/alt_cached_value') }
108
109
  end
109
110
 
110
111
  it "cached action" do
111
112
  3.times do
112
- lambda{ req('/cached_action') }.should_not change{ req('/cached_action') }
113
+ lambda{ req('/cached_action') }.should.not.change{ req('/cached_action') }
113
114
  end
114
115
 
115
116
  3.times do
116
- lambda{ req('/uncache_actions') }.should change{ req('/cached_action') }
117
+ lambda{ req('/uncache_actions') }.should.change{ req('/cached_action') }
117
118
  end
118
119
  end
119
120
 
@@ -126,17 +127,17 @@ describe "CacheHelper" do
126
127
  orig_value = req('/ttl')
127
128
  req('/ttl').should == orig_value
128
129
  sleep 1
129
- req('/ttl').should_not == orig_value
130
+ req('/ttl').should.not == orig_value
130
131
  end
131
132
 
132
133
  it "should cache using key lambda if provided" do
133
- lambda{ req('/key/name', :name=>'Aman') }.should_not change{ req('/key/name', :name=>'Aman') }
134
+ lambda{ req('/key/name', :name=>'Aman') }.should.not.change{ req('/key/name', :name=>'Aman') }
134
135
  req('/key/name', :name=>'Bob').should =~ /^hi Bob/
135
136
  end
136
137
 
137
138
  it "should remain backwards compatible" do
138
- lambda{ req('/old') }.should_not change{ req('/old') }
139
- lambda{ req('/old/action/two/three') }.should_not change{ req('/old/action/one/two') }
139
+ lambda{ req('/old') }.should.not.change{ req('/old') }
140
+ lambda{ req('/old/action/two/three') }.should.not.change{ req('/old/action/one/two') }
140
141
  req('/old/action/two/three').should =~ /^twothree/
141
142
  end
142
143
  end
@@ -9,7 +9,7 @@ class TCLink < Ramaze::Controller
9
9
  end
10
10
 
11
11
  describe "url encode" do
12
- include Ramaze::CgiHelper
12
+ extend Ramaze::CgiHelper
13
13
 
14
14
  it 'should url_encode strings' do
15
15
  # ok, I believe that the web is dumb for this
@@ -28,7 +28,7 @@ describe "url encode" do
28
28
  end
29
29
 
30
30
  describe 'html escape' do
31
- include Ramaze::CgiHelper
31
+ extend Ramaze::CgiHelper
32
32
 
33
33
  it 'should escape html' do
34
34
  html_escape('& < >').should == '&amp; &lt; &gt;'
@@ -9,6 +9,7 @@ class TCFileHelper < Ramaze::Controller
9
9
  end
10
10
 
11
11
  describe 'FileHelper' do
12
+ behaves_like 'http'
12
13
  ramaze
13
14
 
14
15
  it 'serving a file' do
@@ -58,10 +58,11 @@ class TCFlashHelperThirdController < Ramaze::Controller
58
58
  end
59
59
 
60
60
  describe "FlashHelper" do
61
+ behaves_like 'browser'
61
62
  ramaze :adapter => :webrick
62
63
 
63
64
  it "twice" do
64
- browser '/' do
65
+ Browser.new('/') do
65
66
  get('/first_here')
66
67
  get('/then_here').should == 'hey'
67
68
  get('/then_here').should == ''
@@ -73,7 +74,7 @@ describe "FlashHelper" do
73
74
  end
74
75
 
75
76
  it "over seperate controllers" do
76
- browser do
77
+ Browser.new do
77
78
  get('/first_here')
78
79
  get('/second/then_here').should == 'hey'
79
80
  get('/then_here').should == ''
@@ -85,13 +86,13 @@ describe "FlashHelper" do
85
86
  end
86
87
 
87
88
  it "single" do
88
- browser do
89
+ Browser.new do
89
90
  get('/third/set/foo').should == 'foo'
90
91
  end
91
92
  end
92
93
 
93
94
  it "single" do
94
- browser do
95
+ Browser.new do
95
96
  get('/third/set/foo').should == 'foo'
96
97
  get('/third/retrieve').should == 'foo'
97
98
  get('/third/retrieve').should == ''
@@ -2,7 +2,7 @@ require 'spec/helper'
2
2
  require 'ramaze/helper/formatting'
3
3
 
4
4
  describe 'FormattingHelper' do
5
- include Ramaze::FormattingHelper
5
+ extend Ramaze::FormattingHelper
6
6
 
7
7
  it 'should format numbers' do
8
8
  number_format(2_123_456).should == '2,123,456'
@@ -9,7 +9,7 @@ class TCLink < Ramaze::Controller
9
9
  end
10
10
 
11
11
  describe "A" do
12
- include Ramaze::LinkHelper
12
+ extend Ramaze::LinkHelper
13
13
 
14
14
  it 'should build links' do
15
15
  A('title', :href => '/').should == %(<a href="/">title</a>)
@@ -24,7 +24,7 @@ describe "A" do
24
24
  end
25
25
 
26
26
  describe 'R' do
27
- include Ramaze::LinkHelper
27
+ extend Ramaze::LinkHelper
28
28
 
29
29
  it 'should build urls' do
30
30
  R(TCLink).should == '/'
@@ -35,7 +35,7 @@ describe 'R' do
35
35
  end
36
36
 
37
37
  describe 'breadcrumbs' do
38
- include Ramaze::LinkHelper
38
+ extend Ramaze::LinkHelper
39
39
 
40
40
  it 'should lay out breadcrumbs' do
41
41
  breadcrumbs('/file/dir/listing/is/cool').
@@ -3,7 +3,18 @@
3
3
 
4
4
  require 'spec/helper'
5
5
 
6
- testcase_requires 'hpricot'
6
+ spec_require 'hpricot'
7
+
8
+ module Og
9
+ class Mock
10
+ def initialize(*a); @a = a; end
11
+ def all(o) @a[(o[:offset]||0),o[:limit]] end
12
+ def count(*a) @a.size end
13
+ alias reload all
14
+ end
15
+ module Mixin; end
16
+ module Collection; end
17
+ end
7
18
 
8
19
  class TCPagerController < Ramaze::Controller
9
20
  map '/'
@@ -19,114 +30,67 @@ class TCPagerController < Ramaze::Controller
19
30
 
20
31
  end
21
32
 
22
- describe "PagerHelper" do
23
- include Ramaze::PagerHelper
33
+ ramaze
24
34
 
25
- before(:all){ ramaze }
35
+ shared 'pager' do
36
+ behaves_like 'http'
37
+ extend Ramaze::PagerHelper
26
38
 
27
- # Used internally in Pager to get parameters like: ?_page=1
39
+ def pager_key
40
+ Ramaze::Pager.trait[:key]
41
+ end
28
42
 
43
+ # Used internally in Pager to get parameters like: ?_page=1
29
44
  def request
30
- req = mock("Request")
31
- req.should_receive(:params).with(no_args).
32
- any_number_of_times.
33
- and_return(Ramaze::Pager.trait[:key] => 1)
45
+ req = Object.new
46
+ def req.params
47
+ {Ramaze::Pager.trait[:key] => 1}
48
+ end
34
49
  req
35
50
  end
36
51
 
37
- it "should be paginated" do
38
- get('/page').body.should == '[1, 2]'
39
- get("/page", Ramaze::Pager.trait[:key] => '2').body.should == '[3, 4]'
40
- end
41
-
42
- it "should link to other pages" do
43
- stuff = [1, 2, 3, 4, 5, 6, 7, 8, 9]
44
-
45
- items, pager = paginate(stuff, :limit => 2)
46
- page = Hpricot(pager.navigation)
47
- (page / 'a').size.should == 6
52
+ before do
53
+ @items, @pager = paginate(@stuff, :limit => 2)
48
54
  end
49
55
 
50
- end
51
-
52
- describe "Pager", :shared => true do
53
- include Ramaze::PagerHelper
54
-
55
- def request
56
- req = mock("Request")
57
- req.should_receive(:params).with(no_args).
58
- any_number_of_times.
59
- and_return(Ramaze::Pager.trait[:key] => 1)
60
- req
56
+ it 'should be paginated' do
57
+ get('/page').body.should == [1, 2].inspect
58
+ get('/page', pager_key => '2').body.should == [3, 4].inspect
61
59
  end
62
60
 
63
61
  it "should report the number of articles as Pager#total_count" do
64
- @pager.should_not be_nil
65
- @pager.total_count.should == 5
62
+ @pager.should.not.be.nil
63
+ @pager.total_count.should.equal 5
66
64
  end
67
65
 
68
66
  it "should return the same number of items as passed to :per_page" do
69
- @items.should_not be_nil
70
- @items.size.should == 2
67
+ @items.should.not.be.nil
68
+ @items.size.should.equal 2
71
69
  end
72
70
 
73
71
  it "should link to other pages" do
74
- @pager.should_not be_nil
75
- @pager.navigation.should_not be_nil
72
+ @pager.should.not.be.nil
73
+ @pager.navigation.should.not.be.nil
76
74
 
77
- require 'hpricot'
78
75
  page = Hpricot(@pager.navigation)
79
76
  (page / 'a').size.should == 4
80
77
  end
81
-
82
78
  end
83
79
 
84
- describe "OgPager" do
85
- it_should_behave_like "Pager"
86
-
87
- module Og; end
88
- module Og::Mixin; end
89
- module Og::Collection; end
90
-
91
- before do
92
- person = mock("Person")
93
- person.should_receive(:count).with(any_args).and_return(5)
94
- person.should_receive(:all).with(any_args).and_return([1,2])
95
- person.should_receive(:is_a?).any_number_of_times do |x|
96
- x.inspect =~ /Og::Mixin/
97
- end
98
-
99
- @items, @pager = paginate(person, :limit => 2)
100
- end
80
+ describe "Array Pager" do
81
+ @stuff = (1..5).to_a
101
82
 
83
+ behaves_like "pager"
102
84
  end
103
85
 
104
- describe "OgCollectionPager" do
105
- it_should_behave_like "Pager"
106
-
107
- module Og; end
108
- module Og::Mixin; end
109
- module Og::Collection; end
110
-
111
- before do
112
- collection = mock("Og::HasMany.new")
113
- collection.should_receive(:count).with(any_args).and_return(5)
114
- collection.should_receive(:reload).with(any_args).and_return([1,2])
115
- collection.should_receive(:is_a?).any_number_of_times do |x|
116
- x.inspect =~ /Og::Collection/
117
- end
118
-
119
- @items, @pager = paginate(collection, :limit => 2)
120
- end
86
+ describe "OgPager" do
87
+ @stuff = Og::Mock.new(1,2,3,4,5).extend(Og::Mixin)
121
88
 
89
+ behaves_like "pager"
122
90
  end
123
91
 
124
- describe "ArrayPager" do
125
- it_should_behave_like "Pager"
126
-
127
- before do
128
- stuff = [1, 2, 3, 4, 5]
129
- @items, @pager = paginate(stuff, :limit => 2)
130
- end
92
+ describe "OgCollectionPager" do
93
+ @stuff = Og::Mock.new(1,2,3,4,5).extend(Og::Collection)
131
94
 
95
+ behaves_like "pager"
132
96
  end