ramaze 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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
@@ -27,9 +27,8 @@ class TCPartialHelperController < Ramaze::Controller
27
27
  end
28
28
 
29
29
  describe "PartialHelper" do
30
- before :all do
31
- ramaze
32
- end
30
+ behaves_like 'http'
31
+ ramaze
33
32
 
34
33
  it "should render partials" do
35
34
  get('/').body.should == '<html><head><title>Title</title></head></html>'
@@ -52,10 +52,15 @@ class TCRedirectHelperController < Ramaze::Controller
52
52
  def respond_with_status
53
53
  respond 'not found', 404
54
54
  end
55
+
56
+ def redirect_unmodified
57
+ raw_redirect '/noop'
58
+ end
55
59
  end
56
60
 
57
61
  describe "RedirectHelper" do
58
- ramaze(:adapter => :mongrel)
62
+ behaves_like 'http', 'browser'
63
+ ramaze(:adapter => :webrick)
59
64
 
60
65
  b = Browser.new
61
66
 
@@ -100,4 +105,8 @@ describe "RedirectHelper" do
100
105
  page.status.should == 404
101
106
  page.body.should == 'not found'
102
107
  end
108
+
109
+ it 'should redirect without modifying the target' do
110
+ get('/redirect_unmodified').headers['Location'].should == '/noop'
111
+ end
103
112
  end
@@ -42,10 +42,11 @@ class TCStackHelperController < Ramaze::Controller
42
42
  end
43
43
 
44
44
  describe "StackHelper" do
45
+ behaves_like 'browser'
45
46
  ramaze(:adapter => :webrick)
46
47
 
47
48
  it "conventional login" do
48
- browser do
49
+ Browser.new do
49
50
  get('/secure').should == 'please login'
50
51
  get('/login')
51
52
  get('/secure').should == 'secret content'
@@ -54,7 +55,7 @@ describe "StackHelper" do
54
55
  end
55
56
 
56
57
  it "indirect login" do
57
- browser do
58
+ Browser.new do
58
59
  get('/foo').should == 'logged in'
59
60
  get('/secure').should == 'secret content'
60
61
  eget('/').should == {:logged_in => true}
@@ -62,7 +63,7 @@ describe "StackHelper" do
62
63
  end
63
64
 
64
65
  it "indirect login with params" do
65
- browser do
66
+ Browser.new do
66
67
  eget('/bar', 'x' => 'y').should == {'x' => 'y'}
67
68
  eget('/').should == {:logged_in => true}
68
69
  end
@@ -1,3 +1,4 @@
1
- <?r (1..5).each do |@n| ?>
1
+ <?r (1..5).each do |n| ?>
2
+ <?r @n = n ?>
2
3
  #{render_template 'num.xhtml'}
3
4
  <?r end ?>
@@ -1,7 +1,7 @@
1
1
  require 'spec/helper'
2
2
 
3
3
  describe 'Informer' do
4
- before(:each) do
4
+ before do
5
5
  @out = []
6
6
  def @out.puts(*args) push(*args) end
7
7
  Ramaze::Informer.trait[:colorize] = false
@@ -61,7 +61,7 @@ describe 'Informer' do
61
61
  begin
62
62
  i = Ramaze::Informer.new('tmp.dummy')
63
63
  out = i.out
64
- out.should be_an_instance_of(File)
64
+ out.should.be.instance_of(File)
65
65
  out.path.should == 'tmp.dummy'
66
66
  ensure
67
67
  out.close
@@ -5,6 +5,6 @@ require 'ramaze/inform/syslog'
5
5
  describe 'Syslog' do
6
6
  it 'should do something' do
7
7
  syslog = Ramaze::Syslog.new
8
- syslog.send(:ident).should =~ /#{__FILE__}$/
8
+ syslog.send(:ident).should =~ /#{Regexp.escape(__FILE__)}$/
9
9
  end
10
10
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'spec/helper'
5
5
 
6
- testcase_requires 'ya2yaml', 'ramaze/tool/localize'
6
+ spec_require 'ya2yaml', 'ramaze/tool/localize'
7
7
 
8
8
  Ramaze::Tool::Localize.trait :enable => true,
9
9
  :file => 'spec/ramaze/conf/locale_%s.yaml'.freeze,
@@ -26,31 +26,33 @@ class TCLocalize < Ramaze::Controller
26
26
  end
27
27
 
28
28
  describe "Localize" do
29
- before :all do
30
- @dir = __DIR__ / :conf
31
- FileUtils.mkdir_p(@dir)
29
+ behaves_like 'http'
32
30
 
33
- dict = {
34
- :de => {
35
- 'hello' => 'Hallo, Welt!',
36
- 'this' => 'Das',
37
- 'is' => 'ist',
38
- 'a' => 'ein',
39
- 'test' => 'Test',
40
- },
41
- :en => {
42
- 'hello' => 'Hello, World!',
43
- 'this' => 'this',
44
- 'is' => 'is',
45
- 'a' => 'a',
46
- 'test' => 'test',
47
- } }
48
- dict.each do |lang, dic|
49
- File.open(@dir/"locale_#{lang}.yaml", 'w+'){|fp| fp.print(dic.to_yaml)}
50
- end
51
- ramaze
31
+ @dir = __DIR__ / :conf
32
+ FileUtils.mkdir_p(@dir)
33
+
34
+ dict = {
35
+ :de => {
36
+ 'hello' => 'Hallo, Welt!',
37
+ 'this' => 'Das',
38
+ 'is' => 'ist',
39
+ 'a' => 'ein',
40
+ 'test' => 'Test',
41
+ },
42
+ :en => {
43
+ 'hello' => 'Hello, World!',
44
+ 'this' => 'this',
45
+ 'is' => 'is',
46
+ 'a' => 'a',
47
+ 'test' => 'test',
48
+ } }
49
+
50
+ dict.each do |lang, dic|
51
+ File.open(@dir/"locale_#{lang}.yaml", 'w+'){|fp| fp.print(dic.to_yaml)}
52
52
  end
53
53
 
54
+ ramaze
55
+
54
56
  it "hello world" do
55
57
  get('/hello').body.should == 'Hello, World!'
56
58
  get('/hello/de').body.should == 'Hallo, Welt!'
@@ -61,7 +63,5 @@ describe "Localize" do
61
63
  get('/advanced/de').body.should == 'Das ist ein Test'
62
64
  end
63
65
 
64
- after :all do
65
- FileUtils.rm_rf(@dir)
66
- end
66
+ FileUtils.rm_rf(@dir)
67
67
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'spec/helper'
5
5
 
6
- testcase_requires 'hpricot'
6
+ spec_require 'hpricot'
7
7
  require 'ramaze/template/ezamar/morpher'
8
8
 
9
9
  class TCMorpherController < Ramaze::Controller
@@ -66,12 +66,11 @@ class TCMorpherController < Ramaze::Controller
66
66
  end
67
67
 
68
68
  describe "Morpher" do
69
- before :all do
70
- ramaze
71
- pipeline = Ramaze::Template::Ezamar::TRANSFORM_PIPELINE
72
- pipeline.clear
73
- pipeline.push(Ezamar::Element, Ezamar::Morpher)
74
- end
69
+ behaves_like 'http'
70
+ ramaze
71
+ pipeline = Ramaze::Template::Ezamar::TRANSFORM_PIPELINE
72
+ pipeline.clear
73
+ pipeline.push(Ezamar::Element, Ezamar::Morpher)
75
74
 
76
75
  def clean_get(*url)
77
76
  get(*url).body.split("\n").join.strip
@@ -60,9 +60,8 @@ class TCParamsController3 < Ramaze::Controller
60
60
  end
61
61
 
62
62
  describe "Simple Parameters" do
63
- before :all do
64
- ramaze
65
- end
63
+ behaves_like 'http'
64
+ ramaze
66
65
 
67
66
  def handle(*url)
68
67
  Ramaze::Controller.handle(*url)
@@ -78,7 +77,7 @@ describe "Simple Parameters" do
78
77
 
79
78
  it "call /bar though index doesn't take params" do
80
79
  lambda{ handle('/bar') }.
81
- should raise_error(Ramaze::Error::NoAction)
80
+ should.raise(Ramaze::Error::NoAction)
82
81
  end
83
82
 
84
83
  it "action that takes a single param" do
@@ -91,7 +90,7 @@ describe "Simple Parameters" do
91
90
 
92
91
  it "action that takes two params but we give only one" do
93
92
  lambda{ handle('/double_param/foo') }.
94
- should raise_error(Ramaze::Error::NoAction)
93
+ should.raise(Ramaze::Error::NoAction)
95
94
  end
96
95
 
97
96
  it "action that takes all params" do
@@ -104,7 +103,7 @@ describe "Simple Parameters" do
104
103
 
105
104
  it "action that takes all params but needs at least one (not given here)" do
106
105
  lambda{ handle('/at_least_one') }.
107
- should raise_error(ArgumentError)
106
+ should.raise(ArgumentError)
108
107
  end
109
108
 
110
109
  it "one default" do
@@ -126,12 +125,12 @@ describe "Simple Parameters" do
126
125
 
127
126
  it "jo/add should raise with 0 parameters" do
128
127
  lambda{ handle('/jo/add') }.
129
- should raise_error(ArgumentError)
128
+ should.raise(ArgumentError)
130
129
  end
131
130
 
132
131
  it "add should raise with 4 parameters" do
133
132
  lambda{ handle('/jo/add/1/2/3/4') }.
134
- should raise_error(ArgumentError)
133
+ should.raise(ArgumentError)
135
134
  end
136
135
 
137
136
  it "add should not raise with 1-3 parameters" do
@@ -5,6 +5,7 @@ require 'spec/helper'
5
5
 
6
6
  class TCRequestController < Ramaze::Controller
7
7
  map '/'
8
+ engine :None
8
9
 
9
10
  def is_post() request.post?.to_s end
10
11
  def is_get() request.get?.to_s end
@@ -23,7 +24,7 @@ class TCRequestController < Ramaze::Controller
23
24
  # referencing request.rack_params breaks this test
24
25
  # request.params is hacked to return {} on PUT requests
25
26
  request.params
26
- request.body.read.inspect
27
+ request.body.read
27
28
  end
28
29
 
29
30
  def get_inspect
@@ -49,11 +50,15 @@ class TCRequestController < Ramaze::Controller
49
50
  end
50
51
  end
51
52
 
53
+ options = ramaze_options rescue {}
54
+ ramaze options.merge(:public_root => 'spec/ramaze/public')
55
+
52
56
  describe "Request" do
53
- options = ramaze_options rescue {}
54
- ramaze options.merge(:public_root => 'spec/ramaze/public')
57
+ behaves_like 'http'
55
58
 
56
59
  describe "POST" do
60
+ behaves_like 'http'
61
+
57
62
  it "give me the result of request.post?" do
58
63
  post("/is_post").body.should == 'true'
59
64
  end
@@ -69,25 +74,35 @@ describe "Request" do
69
74
  end
70
75
 
71
76
  describe "PUT" do
77
+ behaves_like 'http'
78
+
72
79
  it "put a resource" do
73
80
  image = 'favicon.ico'
74
81
  image_path = File.join('spec', 'ramaze', 'public', image)
75
82
  address = "/put_inspect/#{image}"
76
83
 
77
- file = File.read(image_path)
84
+ if RUBY_VERSION >= '1.9.0'
85
+ file = File.open(image_path, 'r:ASCII'){|f| f.read}
86
+ else
87
+ file = File.read(image_path)
88
+ end
78
89
 
79
90
  response = put(address, :input => file)
80
- response.body[1..-2].should == file
91
+ response.body.dump.should == file.dump
81
92
  end
82
93
  end
83
94
 
84
95
  describe "DELETE" do
96
+ behaves_like 'http'
97
+
85
98
  it "delete a resource" do
86
99
  delete('/is_delete').body.should == 'true'
87
100
  end
88
101
  end
89
102
 
90
103
  describe "GET" do
104
+ behaves_like 'http'
105
+
91
106
  it "give me the result of request.post?" do
92
107
  get("/is_post").body.should == 'false'
93
108
  end
@@ -113,9 +128,15 @@ describe "Request" do
113
128
  end
114
129
 
115
130
  describe "get files" do
131
+ behaves_like 'http'
132
+
116
133
  it "binary" do
117
134
  image_path = '/favicon.ico'
118
- static_image = File.read("spec/ramaze/public#{image_path}")
135
+ if RUBY_VERSION >= '1.9.0'
136
+ static_image = File.open("spec/ramaze/public#{image_path}", 'r:ASCII'){|f| f.read}
137
+ else
138
+ static_image = File.read("spec/ramaze/public#{image_path}")
139
+ end
119
140
 
120
141
  response = get(image_path)
121
142
  response.status.should == 200
@@ -1,6 +1,6 @@
1
1
  require 'spec/helper'
2
2
 
3
- testcase_requires 'mongrel'
3
+ spec_require 'mongrel'
4
4
 
5
5
  def ramaze_options
6
6
  { :adapter => :mongrel }
@@ -0,0 +1,9 @@
1
+ require 'spec/helper'
2
+
3
+ spec_require 'thin'
4
+
5
+ def ramaze_options
6
+ { :adapter => :thin }
7
+ end
8
+
9
+ require 'spec/ramaze/request'
@@ -28,6 +28,7 @@ class TCSessionController < Ramaze::Controller
28
28
  end
29
29
 
30
30
  describe "Session" do
31
+ behaves_like 'http', 'browser'
31
32
  ramaze(:adapter => :webrick, :mapping => {'/' => TCSessionController})
32
33
 
33
34
  { :MemoryCache => :memory,
@@ -41,7 +42,7 @@ describe "Session" do
41
42
  next
42
43
  end
43
44
 
44
- context cache.to_s do
45
+ describe cache.to_s do
45
46
 
46
47
  Ramaze::Global.cache = cache
47
48
  Thread.main[:session_cache] = nil
@@ -4,36 +4,39 @@
4
4
  require 'spec/helper'
5
5
  require 'ramaze/store/default'
6
6
 
7
- describe "initialize an Store" do
7
+ describe "Store::Default" do
8
8
  db = 'db.yaml'
9
9
 
10
+ after do
11
+ FileUtils.rm db
12
+ end
13
+
10
14
  def add hash = {}
11
15
  Books.merge!(hash)
12
16
  end
13
17
 
14
- it "Store::Default.new" do
18
+ it "should initialize Store::Default" do
15
19
  Books = Ramaze::Store::Default.new(db)
16
20
  Books.db.should.is_a?(YAML::Store)
17
21
  end
18
22
 
19
- it "store and retrieve something" do
23
+ it "should store and retrieve key/value" do
20
24
  add 'Pickaxe' => 'good book'
21
25
  Books['Pickaxe'].should == 'good book'
22
26
  end
23
27
 
24
- it "empty?" do
28
+ it "be empty after #clear" do
25
29
  add 'Pickaxe' => 'good book'
26
30
 
27
- Books.empty?.should == false
31
+ Books.should.not.be.empty
28
32
  Books.clear
29
- Books.empty?.should == true
33
+ Books.should.be.empty
30
34
  end
31
35
 
32
- it "size" do
36
+ it "should have right size" do
33
37
  Books.size.should == 0
34
38
 
35
- {
36
- 'Pickaxe' => 'good book',
39
+ { 'Pickaxe' => 'good book',
37
40
  '1984' => 'scary',
38
41
  'Brave new World' => 'interesting',
39
42
  }.each_with_index do |(title, content), i|
@@ -42,7 +45,7 @@ describe "initialize an Store" do
42
45
  end
43
46
  end
44
47
 
45
- it "Enumerable" do
48
+ it "should be Enumerable" do
46
49
  add 'Pickaxe' => 'good book', '1984' => 'scary'
47
50
 
48
51
  Books.each do |title, content|
@@ -51,24 +54,18 @@ describe "initialize an Store" do
51
54
  end
52
55
  end
53
56
 
54
- it "merge and merge!" do
57
+ it "should merge and merge!" do
55
58
  books = {'Pickaxe' => 'good book', '1984' => 'scary'}
56
59
  add books
57
60
 
58
61
  bnw = {'Brave new World' => 'interesting'}
59
62
 
60
63
  Books.merge(bnw).should == books.merge(bnw)
61
-
62
64
  Books[bnw.keys.first].should == nil
63
65
 
64
66
  Books.merge!(bnw).should == books.merge(bnw)
65
-
66
67
  Books[bnw.keys.first].should == bnw.values.first
67
68
 
68
69
  Books.size.should == 3
69
70
  end
70
-
71
- after(:each) do
72
- FileUtils.rm db
73
- end
74
71
  end