ramaze 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +20 -3
- data/bin/ramaze +1 -4
- data/doc/AUTHORS +2 -1
- data/doc/CHANGELOG +539 -32
- data/doc/LEGAL +4 -0
- data/doc/meta/announcement.txt +79 -47
- data/examples/blog/README +2 -2
- data/examples/blog/spec/blog.rb +33 -48
- data/examples/blog/src/controller.rb +15 -13
- data/examples/blog/src/model.rb +28 -10
- data/examples/blog/start.rb +0 -10
- data/examples/blog/template/edit.xhtml +1 -1
- data/examples/blog/template/index.xhtml +2 -2
- data/examples/facebook.rb +152 -0
- data/examples/linking.rb +28 -0
- data/examples/ramaise.rb +4 -11
- data/examples/rammit/spec/rammit.rb +30 -0
- data/examples/rammit/src/controller/main.rb +3 -0
- data/examples/rammit/src/controller/page.rb +16 -0
- data/examples/rammit/src/model.rb +33 -0
- data/examples/rammit/start.rb +7 -0
- data/examples/rammit/template/index.xhtml +14 -0
- data/examples/rammit/template/page/view.xhtml +4 -0
- data/examples/rapaste/Rakefile +28 -0
- data/examples/rapaste/public/css/active4d.css +114 -0
- data/examples/rapaste/public/css/all_hallows_eve.css +72 -0
- data/examples/rapaste/public/css/amy.css +147 -0
- data/examples/rapaste/public/css/blackboard.css +88 -0
- data/examples/rapaste/public/css/brilliance_black.css +605 -0
- data/examples/rapaste/public/css/brilliance_dull.css +599 -0
- data/examples/rapaste/public/css/cobalt.css +149 -0
- data/examples/rapaste/public/css/dawn.css +121 -0
- data/examples/rapaste/public/css/display.css +179 -0
- data/examples/rapaste/public/css/eiffel.css +121 -0
- data/examples/rapaste/public/css/espresso_libre.css +109 -0
- data/examples/rapaste/public/css/idle.css +62 -0
- data/examples/rapaste/public/css/iplastic.css +80 -0
- data/examples/rapaste/public/css/lazy.css +73 -0
- data/examples/rapaste/public/css/mac_classic.css +123 -0
- data/examples/rapaste/public/css/magicwb_amiga.css +104 -0
- data/examples/rapaste/public/css/pastels_on_dark.css +188 -0
- data/examples/rapaste/public/css/slush_poppies.css +85 -0
- data/examples/rapaste/public/css/spacecadet.css +51 -0
- data/examples/rapaste/public/css/sunburst.css +180 -0
- data/examples/rapaste/public/css/twilight.css +137 -0
- data/examples/rapaste/public/css/zenburnesque.css +91 -0
- data/examples/rapaste/public/js/jquery.js +11 -0
- data/examples/rapaste/rapaste.sqlite +0 -0
- data/examples/rapaste/spec/rapaste.rb +49 -0
- data/examples/rapaste/src/controller.rb +69 -0
- data/examples/rapaste/src/model.rb +61 -0
- data/examples/rapaste/start.rb +20 -0
- data/examples/rapaste/template/copy.xhtml +10 -0
- data/examples/rapaste/template/index.xhtml +9 -0
- data/examples/rapaste/template/layout.xhtml +22 -0
- data/examples/rapaste/template/list.xhtml +28 -0
- data/examples/rapaste/template/view.xhtml +37 -0
- data/examples/sourceview/sourceview.rb +3 -3
- data/examples/templates/template_amrita2.rb +1 -3
- data/examples/todolist/spec/todolist.rb +15 -18
- data/examples/whywiki/spec/whywiki.rb +15 -20
- data/examples/whywiki/start.rb +0 -1
- data/examples/wikore/spec/wikore.rb +14 -19
- data/examples/wiktacular/spec/wiktacular.rb +8 -15
- data/lib/proto/{src/controller → controller}/main.rb +4 -4
- data/lib/proto/public/css/ramaze_error.css +39 -3
- data/lib/proto/public/js/jquery.js +2039 -1020
- data/lib/proto/spec/main.rb +27 -0
- data/lib/proto/start.rb +5 -5
- data/lib/proto/view/error.xhtml +62 -0
- data/lib/proto/view/index.xhtml +34 -0
- data/lib/proto/view/page.xhtml +15 -0
- data/lib/ramaze.rb +9 -7
- data/lib/ramaze/action.rb +7 -3
- data/lib/ramaze/action/render.rb +15 -5
- data/lib/ramaze/adapter.rb +5 -5
- data/lib/ramaze/adapter/base.rb +2 -2
- data/lib/ramaze/adapter/cgi.rb +1 -1
- data/lib/ramaze/adapter/evented_mongrel.rb +1 -1
- data/lib/ramaze/adapter/fcgi.rb +2 -2
- data/lib/ramaze/adapter/mongrel.rb +1 -1
- data/lib/ramaze/adapter/swiftiplied_mongrel.rb +1 -1
- data/lib/ramaze/adapter/thin.rb +25 -0
- data/lib/ramaze/adapter/webrick.rb +1 -1
- data/lib/ramaze/cache.rb +3 -2
- data/lib/ramaze/cache/memcached.rb +1 -1
- data/lib/ramaze/cache/memory.rb +1 -1
- data/lib/ramaze/cache/yaml_store.rb +1 -1
- data/lib/ramaze/contrib.rb +1 -1
- data/lib/ramaze/contrib/auto_params.rb +12 -5
- data/lib/ramaze/contrib/auto_params/get_args.rb +1 -0
- data/lib/ramaze/contrib/facebook.rb +23 -0
- data/lib/ramaze/contrib/facebook/facebook.rb +168 -0
- data/lib/ramaze/contrib/gettext.rb +111 -0
- data/lib/ramaze/contrib/gettext/mo.rb +155 -0
- data/lib/ramaze/contrib/gettext/po.rb +109 -0
- data/lib/ramaze/contrib/gzip_filter.rb +1 -1
- data/lib/ramaze/contrib/route.rb +15 -5
- data/lib/ramaze/contrib/sequel/fill.rb +1 -1
- data/lib/ramaze/controller.rb +10 -4
- data/lib/ramaze/controller/error.rb +5 -13
- data/lib/ramaze/controller/main.rb +2 -0
- data/lib/ramaze/controller/resolve.rb +18 -10
- data/lib/ramaze/dispatcher.rb +1 -1
- data/lib/ramaze/dispatcher/action.rb +1 -1
- data/lib/ramaze/dispatcher/directory.rb +3 -2
- data/lib/ramaze/dispatcher/error.rb +5 -5
- data/lib/ramaze/dispatcher/file.rb +13 -2
- data/lib/ramaze/error.rb +1 -1
- data/lib/ramaze/gestalt.rb +2 -2
- data/lib/ramaze/global.rb +5 -5
- data/lib/ramaze/global/dsl.rb +1 -1
- data/lib/ramaze/global/globalstruct.rb +11 -5
- data/lib/ramaze/helper.rb +1 -1
- data/lib/ramaze/helper/aspect.rb +1 -1
- data/lib/ramaze/helper/auth.rb +2 -2
- data/lib/ramaze/helper/cache.rb +1 -1
- data/lib/ramaze/helper/cgi.rb +1 -1
- data/lib/ramaze/helper/file.rb +1 -1
- data/lib/ramaze/helper/flash.rb +1 -1
- data/lib/ramaze/helper/formatting.rb +1 -1
- data/lib/ramaze/helper/identity.rb +1 -1
- data/lib/ramaze/helper/inform.rb +1 -1
- data/lib/ramaze/helper/link.rb +4 -4
- data/lib/ramaze/helper/markaby.rb +1 -1
- data/lib/ramaze/helper/nitroform.rb +1 -1
- data/lib/ramaze/helper/pager.rb +2 -1
- data/lib/ramaze/helper/partial.rb +1 -1
- data/lib/ramaze/helper/redirect.rb +6 -1
- data/lib/ramaze/helper/sequel.rb +54 -0
- data/lib/ramaze/helper/stack.rb +1 -1
- data/lib/ramaze/inform.rb +1 -1
- data/lib/ramaze/inform/analogger.rb +1 -1
- data/lib/ramaze/inform/growl.rb +1 -1
- data/lib/ramaze/inform/hub.rb +1 -1
- data/lib/ramaze/inform/informer.rb +1 -1
- data/lib/ramaze/inform/informing.rb +2 -2
- data/lib/ramaze/inform/knotify.rb +1 -1
- data/lib/ramaze/inform/syslog.rb +1 -1
- data/lib/ramaze/inform/xosd.rb +1 -1
- data/lib/ramaze/snippets.rb +1 -1
- data/lib/ramaze/snippets/array/put_within.rb +1 -1
- data/lib/ramaze/snippets/blankslate.rb +7 -0
- data/lib/ramaze/snippets/dictionary.rb +6 -1
- data/lib/ramaze/snippets/divide.rb +1 -1
- data/lib/ramaze/snippets/kernel/__dir__.rb +1 -1
- data/lib/ramaze/snippets/kernel/acquire.rb +39 -0
- data/lib/ramaze/snippets/kernel/aquire.rb +1 -34
- data/lib/ramaze/snippets/kernel/constant.rb +1 -1
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +1 -1
- data/lib/ramaze/snippets/numeric/filesize_format.rb +1 -1
- data/lib/ramaze/snippets/object/traits.rb +1 -1
- data/lib/ramaze/snippets/ordered_set.rb +12 -7
- data/lib/ramaze/snippets/ramaze/caller_info.rb +1 -1
- data/lib/ramaze/snippets/ramaze/caller_lines.rb +1 -1
- data/lib/ramaze/snippets/string/camel_case.rb +1 -1
- data/lib/ramaze/snippets/string/color.rb +2 -4
- data/lib/ramaze/snippets/string/each.rb +1 -1
- data/lib/ramaze/snippets/string/ord.rb +15 -0
- data/lib/ramaze/snippets/string/snake_case.rb +1 -1
- data/lib/ramaze/snippets/struct/fill.rb +4 -2
- data/lib/ramaze/snippets/struct/values_at.rb +2 -2
- data/lib/ramaze/snippets/symbol/to_proc.rb +15 -8
- data/lib/ramaze/snippets/thread/into.rb +1 -1
- data/lib/ramaze/sourcereload.rb +4 -3
- data/lib/ramaze/spec/helper.rb +85 -32
- data/lib/ramaze/spec/helper/bacon.rb +7 -0
- data/lib/ramaze/spec/helper/browser.rb +1 -2
- data/lib/ramaze/spec/helper/mock_http.rb +1 -1
- data/lib/ramaze/spec/helper/pretty_output.rb +70 -0
- data/lib/ramaze/spec/helper/requester.rb +1 -1
- data/lib/ramaze/spec/helper/simple_http.rb +5 -4
- data/lib/ramaze/spec/helper/snippets.rb +6 -0
- data/lib/ramaze/store/default.rb +1 -1
- data/lib/ramaze/template.rb +1 -1
- data/lib/ramaze/template/amrita2.rb +6 -5
- data/lib/ramaze/template/erubis.rb +1 -1
- data/lib/ramaze/template/ezamar.rb +1 -1
- data/lib/ramaze/template/ezamar/element.rb +1 -1
- data/lib/ramaze/template/ezamar/engine.rb +1 -1
- data/lib/ramaze/template/ezamar/morpher.rb +1 -1
- data/lib/ramaze/template/ezamar/render_partial.rb +1 -1
- data/lib/ramaze/template/haml.rb +1 -1
- data/lib/ramaze/template/liquid.rb +1 -1
- data/lib/ramaze/template/markaby.rb +1 -1
- data/lib/ramaze/template/nagoro.rb +4 -6
- data/lib/ramaze/template/none.rb +1 -1
- data/lib/ramaze/template/remarkably.rb +1 -1
- data/lib/ramaze/template/sass.rb +1 -1
- data/lib/ramaze/tool.rb +1 -1
- data/lib/ramaze/tool/create.rb +7 -1
- data/lib/ramaze/tool/localize.rb +7 -14
- data/lib/ramaze/tool/mime.rb +1 -1
- data/lib/ramaze/tool/record.rb +1 -1
- data/lib/ramaze/trinity.rb +1 -1
- data/lib/ramaze/trinity/request.rb +4 -2
- data/lib/ramaze/trinity/response.rb +1 -1
- data/lib/ramaze/trinity/session.rb +7 -1
- data/lib/ramaze/version.rb +3 -3
- data/lib/vendor/bacon.rb +317 -0
- data/rake_tasks/conf.rake +1 -1
- data/rake_tasks/maintenance.rake +7 -5
- data/rake_tasks/spec.rake +54 -40
- data/spec/contrib/auto_params.rb +21 -4
- data/spec/contrib/route.rb +31 -4
- data/spec/contrib/sequel/fill.rb +3 -4
- data/spec/examples/caching.rb +5 -2
- data/spec/examples/css.rb +5 -2
- data/spec/examples/element.rb +5 -4
- data/spec/examples/hello.rb +1 -0
- data/spec/examples/linking.rb +18 -0
- data/spec/examples/simple.rb +13 -18
- data/spec/examples/templates/template_amrita2.rb +3 -2
- data/spec/examples/templates/template_erubis.rb +3 -2
- data/spec/examples/templates/template_ezamar.rb +2 -1
- data/spec/examples/templates/template_haml.rb +3 -2
- data/spec/examples/templates/template_liquid.rb +3 -2
- data/spec/examples/templates/template_markaby.rb +3 -2
- data/spec/examples/templates/template_remarkably.rb +3 -2
- data/spec/ramaze/action/basics.rb +4 -4
- data/spec/ramaze/action/cache.rb +11 -13
- data/spec/ramaze/action/layout.rb +47 -3
- data/spec/ramaze/action/render.rb +3 -3
- data/spec/ramaze/action/template/instancevars/layout.xhtml +1 -0
- data/spec/ramaze/adapter.rb +7 -7
- data/spec/ramaze/adapter/mongrel.rb +1 -1
- data/spec/ramaze/adapter/record.rb +7 -7
- data/spec/ramaze/adapter/webrick.rb +1 -1
- data/spec/ramaze/cache.rb +6 -8
- data/spec/ramaze/controller.rb +77 -65
- data/spec/ramaze/controller/resolve.rb +2 -1
- data/spec/ramaze/controller/template_resolving.rb +3 -4
- data/spec/ramaze/dispatcher.rb +3 -4
- data/spec/ramaze/dispatcher/directory.rb +35 -35
- data/spec/ramaze/dispatcher/file.rb +8 -5
- data/spec/ramaze/element.rb +4 -4
- data/spec/ramaze/error.rb +13 -11
- data/spec/ramaze/gestalt.rb +1 -1
- data/spec/ramaze/helper/aspect.rb +2 -1
- data/spec/ramaze/helper/auth.rb +4 -2
- data/spec/ramaze/helper/cache.rb +10 -9
- data/spec/ramaze/helper/cgi.rb +2 -2
- data/spec/ramaze/helper/file.rb +1 -0
- data/spec/ramaze/helper/flash.rb +5 -4
- data/spec/ramaze/helper/formatting.rb +1 -1
- data/spec/ramaze/helper/link.rb +3 -3
- data/spec/ramaze/helper/pager.rb +44 -80
- data/spec/ramaze/helper/partial.rb +2 -3
- data/spec/ramaze/helper/redirect.rb +10 -1
- data/spec/ramaze/helper/stack.rb +4 -3
- data/spec/ramaze/helper/template/loop.xhtml +2 -1
- data/spec/ramaze/inform/informer.rb +2 -2
- data/spec/ramaze/inform/syslog.rb +1 -1
- data/spec/ramaze/localize.rb +26 -26
- data/spec/ramaze/morpher.rb +6 -7
- data/spec/ramaze/params.rb +7 -8
- data/spec/ramaze/request.rb +27 -6
- data/spec/ramaze/request/mongrel.rb +1 -1
- data/spec/ramaze/request/thin.rb +9 -0
- data/spec/ramaze/session.rb +2 -1
- data/spec/ramaze/store/default.rb +14 -17
- data/spec/ramaze/template.rb +5 -7
- data/spec/ramaze/template/amrita2.rb +4 -1
- data/spec/ramaze/template/erubis.rb +2 -1
- data/spec/ramaze/template/ezamar.rb +2 -3
- data/spec/ramaze/template/ezamar/other__index.xhtml +1 -0
- data/spec/ramaze/template/haml.rb +2 -1
- data/spec/ramaze/template/liquid.rb +4 -2
- data/spec/ramaze/template/markaby.rb +4 -2
- data/spec/ramaze/template/nagoro.rb +3 -4
- data/spec/ramaze/template/remarkably.rb +4 -2
- data/spec/ramaze/template/sass.rb +3 -2
- data/spec/ramaze/template/xslt.rb +4 -7
- data/spec/ramaze/trinity/request.rb +4 -3
- data/spec/ramaze/trinity/session.rb +6 -4
- data/spec/snippets/array/put_within.rb +3 -2
- data/spec/snippets/divide.rb +1 -4
- data/spec/snippets/kernel/__dir__.rb +1 -1
- data/spec/snippets/kernel/acquire.rb +71 -0
- data/spec/snippets/kernel/constant.rb +4 -8
- data/spec/snippets/numeric/filesize_format.rb +1 -1
- data/spec/snippets/ordered_set.rb +9 -2
- data/spec/snippets/ramaze/caller_info.rb +3 -3
- data/spec/snippets/ramaze/caller_lines.rb +3 -3
- data/spec/snippets/string/camel_case.rb +1 -1
- data/spec/snippets/string/color.rb +2 -2
- data/spec/snippets/string/snake_case.rb +5 -1
- data/spec/snippets/string/unindent.rb +1 -1
- data/spec/snippets/struct/fill.rb +14 -15
- data/spec/snippets/struct/values_at.rb +15 -10
- data/spec/snippets/symbol/to_proc.rb +13 -0
- data/spec/snippets/thread/into.rb +3 -4
- metadata +458 -386
- data/doc/README.html +0 -729
- data/doc/changes.txt +0 -5044
- data/doc/changes.xml +0 -5046
- data/lib/proto/public/error.zmr +0 -61
- data/lib/proto/src/element/page.rb +0 -17
- data/lib/proto/src/model.rb +0 -6
- data/lib/proto/template/index.xhtml +0 -15
- data/lib/ramaze/spec/helper/layout.rb +0 -58
- data/lib/ramaze/spec/helper/minimal.rb +0 -23
- data/lib/ramaze/spec/helper/wrap.rb +0 -198
- 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
|
-
|
48
|
-
|
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
|
data/spec/ramaze/dispatcher.rb
CHANGED
@@ -12,10 +12,9 @@ class TCDispatcherController < Ramaze::Controller
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "Dispatcher" do
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
3
|
+
spec_require 'hpricot'
|
4
4
|
|
5
5
|
describe 'Dispatcher::Directory' do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
/
|
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
|
-
|
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 ==
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
52
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
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
|
data/spec/ramaze/element.rb
CHANGED
@@ -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
|
|
data/spec/ramaze/error.rb
CHANGED
@@ -29,16 +29,18 @@ class TCErrorCustomController < Ramaze::Controller
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "Error" do
|
32
|
-
|
32
|
+
behaves_like 'http'
|
33
|
+
ramaze :error_page => true,
|
34
|
+
:template_root => 'spec/ramaze/public'
|
33
35
|
|
34
|
-
|
35
|
-
|
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
|
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
|
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.
|
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
|
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'
|
data/spec/ramaze/gestalt.rb
CHANGED
@@ -40,7 +40,8 @@ class TCAspectAllController < Ramaze::Controller
|
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "AspectHelper" do
|
43
|
-
|
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
|
data/spec/ramaze/helper/auth.rb
CHANGED
@@ -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
|
-
|
55
|
-
|
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'
|
data/spec/ramaze/helper/cache.rb
CHANGED
@@ -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') }.
|
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
|
105
|
+
lambda{ req('/uncache_values') }.should.change{ req('/cached_value') }
|
105
106
|
end
|
106
107
|
|
107
|
-
lambda{ req('/uncache_values') }.should
|
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') }.
|
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
|
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').
|
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') }.
|
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') }.
|
139
|
-
lambda{ req('/old/action/two/three') }.
|
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
|
data/spec/ramaze/helper/cgi.rb
CHANGED
@@ -9,7 +9,7 @@ class TCLink < Ramaze::Controller
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "url encode" do
|
12
|
-
|
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
|
-
|
31
|
+
extend Ramaze::CgiHelper
|
32
32
|
|
33
33
|
it 'should escape html' do
|
34
34
|
html_escape('& < >').should == '& < >'
|
data/spec/ramaze/helper/file.rb
CHANGED
data/spec/ramaze/helper/flash.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 == ''
|
data/spec/ramaze/helper/link.rb
CHANGED
@@ -9,7 +9,7 @@ class TCLink < Ramaze::Controller
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "A" do
|
12
|
-
|
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
|
-
|
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
|
-
|
38
|
+
extend Ramaze::LinkHelper
|
39
39
|
|
40
40
|
it 'should lay out breadcrumbs' do
|
41
41
|
breadcrumbs('/file/dir/listing/is/cool').
|
data/spec/ramaze/helper/pager.rb
CHANGED
@@ -3,7 +3,18 @@
|
|
3
3
|
|
4
4
|
require 'spec/helper'
|
5
5
|
|
6
|
-
|
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
|
-
|
23
|
-
include Ramaze::PagerHelper
|
33
|
+
ramaze
|
24
34
|
|
25
|
-
|
35
|
+
shared 'pager' do
|
36
|
+
behaves_like 'http'
|
37
|
+
extend Ramaze::PagerHelper
|
26
38
|
|
27
|
-
|
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 =
|
31
|
-
req.
|
32
|
-
|
33
|
-
|
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
|
-
|
38
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
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.
|
65
|
-
@pager.total_count.should
|
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.
|
70
|
-
@items.size.should
|
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.
|
75
|
-
@pager.navigation.
|
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 "
|
85
|
-
|
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 "
|
105
|
-
|
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 "
|
125
|
-
|
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
|