ramaze 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +14 -259
- data/bin/ramaze +52 -25
- data/doc/AUTHORS +6 -0
- data/doc/CHANGELOG +1363 -42
- data/doc/INSTALL +1 -1
- data/doc/README +48 -35
- data/doc/README.html +637 -0
- data/doc/TODO +7 -16
- data/doc/allison/allison.css +6 -7
- data/doc/allison/allison.gif +0 -0
- data/doc/allison/cache/STYLE +1 -2
- data/doc/changes.txt +3375 -0
- data/doc/changes.xml +3378 -0
- data/doc/meta/announcement.txt +47 -0
- data/doc/meta/configuration.txt +179 -0
- data/doc/meta/internals.txt +111 -0
- data/doc/readme_chunks/features.txt +8 -16
- data/doc/readme_chunks/installing.txt +7 -1
- data/doc/tutorial/todolist.txt +2 -3
- data/examples/blog/main.rb +9 -8
- data/examples/blog/public/styles/blog.css +132 -0
- data/examples/blog/src/controller.rb +14 -41
- data/examples/blog/src/model.rb +12 -13
- data/examples/blog/src/view.rb +16 -0
- data/examples/blog/template/edit.xhtml +19 -8
- data/examples/blog/template/index.xhtml +14 -22
- data/examples/blog/template/new.xhtml +18 -5
- data/examples/caching.rb +5 -8
- data/examples/element.rb +3 -3
- data/examples/hello.rb +3 -5
- data/examples/simple.rb +4 -7
- data/examples/templates/template/external.haml +8 -7
- data/examples/templates/template/external.mab +11 -8
- data/examples/templates/template_amrita2.rb +4 -4
- data/examples/templates/template_erubis.rb +3 -3
- data/examples/templates/template_ezamar.rb +1 -2
- data/examples/templates/template_haml.rb +24 -23
- data/examples/templates/template_liquid.rb +3 -1
- data/examples/templates/template_markaby.rb +15 -9
- data/examples/todolist/src/element/page.rb +1 -1
- data/lib/proto/conf/benchmark.yaml +6 -20
- data/lib/proto/conf/debug.yaml +6 -19
- data/lib/proto/conf/live.yaml +7 -19
- data/lib/proto/conf/silent.yaml +6 -16
- data/lib/proto/conf/stage.yaml +6 -18
- data/lib/proto/public/error.zmr +2 -2
- data/lib/ramaze.rb +34 -72
- data/lib/ramaze/adapter.rb +21 -18
- data/lib/ramaze/adapter/mongrel.rb +0 -3
- data/lib/ramaze/adapter/webrick.rb +6 -6
- data/lib/ramaze/cache/memcached.rb +3 -0
- data/lib/ramaze/controller.rb +227 -183
- data/lib/ramaze/dispatcher.rb +34 -129
- data/lib/ramaze/dispatcher/action.rb +28 -0
- data/lib/ramaze/dispatcher/error.rb +43 -0
- data/lib/ramaze/dispatcher/file.rb +34 -0
- data/lib/ramaze/global.rb +89 -48
- data/lib/ramaze/helper/aspect.rb +8 -6
- data/lib/ramaze/helper/auth.rb +3 -3
- data/lib/ramaze/helper/cache.rb +2 -2
- data/lib/ramaze/helper/file.rb +14 -0
- data/lib/ramaze/helper/inform.rb +36 -0
- data/lib/ramaze/helper/link.rb +7 -3
- data/lib/ramaze/helper/markaby.rb +30 -0
- data/lib/ramaze/helper/redirect.rb +2 -0
- data/lib/ramaze/inform.rb +8 -182
- data/lib/ramaze/inform/analogger.rb +19 -0
- data/lib/ramaze/inform/growl.rb +28 -0
- data/lib/ramaze/inform/hub.rb +26 -0
- data/lib/ramaze/inform/informer.rb +92 -0
- data/lib/ramaze/inform/informing.rb +44 -0
- data/lib/ramaze/inform/syslog.rb +27 -0
- data/lib/ramaze/inform/xosd.rb +42 -0
- data/lib/ramaze/snippets.rb +6 -2
- data/lib/ramaze/snippets/object/traits.rb +13 -1
- data/lib/ramaze/snippets/ramaze/autoreload.rb +58 -2
- data/lib/ramaze/snippets/string/color.rb +27 -0
- data/lib/ramaze/snippets/string/each.rb +6 -0
- data/lib/ramaze/snippets/struct/fill.rb +15 -0
- data/lib/ramaze/template/ezamar.rb +13 -22
- data/lib/ramaze/template/ezamar/element.rb +12 -12
- data/lib/ramaze/template/liquid.rb +19 -18
- data/lib/ramaze/template/markaby.rb +37 -58
- data/lib/ramaze/tool/localize.rb +128 -0
- data/lib/ramaze/tool/tidy.rb +51 -21
- data/lib/ramaze/trinity.rb +3 -3
- data/lib/ramaze/trinity/request.rb +41 -23
- data/lib/ramaze/trinity/response.rb +10 -5
- data/lib/ramaze/trinity/session.rb +17 -3
- data/lib/ramaze/version.rb +2 -2
- data/rake_tasks/conf.rake +56 -0
- data/rake_tasks/gem.rake +44 -0
- data/rake_tasks/maintaince.rake +187 -0
- data/spec/all.rb +32 -0
- data/spec/examples/caching.rb +19 -0
- data/spec/examples/element.rb +15 -0
- data/spec/examples/hello.rb +11 -0
- data/spec/examples/simple.rb +51 -0
- data/spec/examples/templates/template_amrita2.rb +14 -0
- data/spec/examples/templates/template_erubis.rb +21 -0
- data/spec/examples/templates/template_ezamar.rb +22 -0
- data/spec/examples/templates/template_haml.rb +23 -0
- data/spec/examples/templates/template_liquid.rb +24 -0
- data/spec/examples/templates/template_markaby.rb +21 -0
- data/spec/helper.rb +81 -0
- data/spec/{spec_helper_context.rb → helper/context.rb} +1 -1
- data/spec/helper/layout.rb +55 -0
- data/spec/helper/mock_http.rb +66 -0
- data/spec/{spec_helper_requester.rb → helper/requester.rb} +0 -6
- data/spec/{spec_helper_simple_http.rb → helper/simple_http.rb} +57 -57
- data/spec/helper/wrap.rb +193 -0
- data/spec/{adapter_spec.rb → ramaze/adapter.rb} +7 -5
- data/spec/{tc_adapter_mongrel.rb → ramaze/adapter/mongrel.rb} +2 -2
- data/spec/{tc_adapter_webrick.rb → ramaze/adapter/webrick.rb} +2 -2
- data/spec/{tc_cache.rb → ramaze/cache.rb} +16 -16
- data/spec/ramaze/conf/locale_de.yaml +6 -0
- data/spec/ramaze/conf/locale_en.yaml +6 -0
- data/spec/ramaze/controller.rb +184 -0
- data/spec/ramaze/controller/template/greet.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +54 -0
- data/spec/ramaze/dependencies.rb +16 -0
- data/spec/{tc_element.rb → ramaze/element.rb} +21 -19
- data/spec/ramaze/error.rb +64 -0
- data/spec/{tc_gestalt.rb → ramaze/gestalt.rb} +10 -10
- data/spec/{tc_global.rb → ramaze/global.rb} +7 -7
- data/spec/{tc_helper_aspect.rb → ramaze/helper/aspect.rb} +22 -14
- data/spec/{tc_helper_auth.rb → ramaze/helper/auth.rb} +9 -7
- data/spec/{tc_helper_cache.rb → ramaze/helper/cache.rb} +14 -24
- data/spec/{tc_helper_feed.rb → ramaze/helper/feed.rb} +12 -12
- data/spec/ramaze/helper/file.rb +17 -0
- data/spec/{tc_helper_flash.rb → ramaze/helper/flash.rb} +16 -17
- data/spec/{tc_helper_form.rb → ramaze/helper/form.rb} +25 -26
- data/spec/{tc_helper_link.rb → ramaze/helper/link.rb} +9 -9
- data/spec/{tc_helper_redirect.rb → ramaze/helper/redirect.rb} +11 -10
- data/spec/{tc_helper_stack.rb → ramaze/helper/stack.rb} +10 -11
- data/spec/ramaze/inform/informer.rb +40 -0
- data/spec/ramaze/inform/syslog.rb +10 -0
- data/spec/ramaze/localize.rb +40 -0
- data/spec/ramaze/morpher.rb +82 -0
- data/spec/ramaze/params.rb +124 -0
- data/spec/{public → ramaze/public}/error404.xhtml +0 -0
- data/spec/{public → ramaze/public}/favicon.ico +0 -0
- data/spec/{public → ramaze/public}/ramaze.png +0 -0
- data/spec/{public → ramaze/public}/test_download.css +0 -0
- data/spec/ramaze/request.rb +129 -0
- data/spec/{tc_request_mongrel.rb → ramaze/request/mongrel.rb} +2 -2
- data/spec/{tc_request_webrick.rb → ramaze/request/webrick.rb} +1 -1
- data/spec/{tc_session.rb → ramaze/session.rb} +18 -18
- data/spec/{tc_store.rb → ramaze/store/default.rb} +10 -10
- data/spec/{tc_store_yaml.rb → ramaze/store/yaml.rb} +9 -9
- data/spec/ramaze/template.rb +86 -0
- data/spec/{tc_template_amrita2.rb → ramaze/template/amrita2.rb} +5 -5
- data/spec/{template → ramaze/template}/amrita2/data.amrita +0 -0
- data/spec/{template → ramaze/template}/amrita2/index.amrita +0 -0
- data/spec/{template → ramaze/template}/amrita2/sum.amrita +0 -0
- data/spec/{tc_template_erubis.rb → ramaze/template/erubis.rb} +9 -9
- data/spec/{template → ramaze/template}/erubis/sum.rhtml +0 -0
- data/spec/ramaze/template/ezamar.rb +62 -0
- data/spec/{template → ramaze/template}/ezamar/another/long/action.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/combined.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/file_only.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/index.zmr +0 -0
- data/spec/ramaze/template/ezamar/nested.zmr +1 -0
- data/spec/{template → ramaze/template}/ezamar/some__long__action.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/sum.zmr +0 -0
- data/spec/{tc_template_haml.rb → ramaze/template/haml.rb} +7 -7
- data/spec/{template → ramaze/template}/haml/index.haml +0 -0
- data/spec/{template → ramaze/template}/haml/with_vars.haml +0 -0
- data/spec/{tc_template_liquid.rb → ramaze/template/liquid.rb} +7 -7
- data/spec/{template → ramaze/template}/liquid/index.liquid +0 -0
- data/spec/{template → ramaze/template}/liquid/products.liquid +0 -0
- data/spec/ramaze/template/markaby.rb +59 -0
- data/spec/{template → ramaze/template}/markaby/external.mab +0 -0
- data/spec/{template → ramaze/template}/markaby/sum.mab +0 -0
- data/spec/ramaze/template/ramaze/external.test +1 -0
- data/spec/{tc_tidy.rb → ramaze/tidy.rb} +3 -3
- metadata +145 -81
- data/examples/blog/public/screen.css +0 -106
- data/examples/blog/src/element.rb +0 -58
- data/examples/blog/template/view.xhtml +0 -15
- data/examples/blog/test/tc_entry.rb +0 -18
- data/lib/proto/public/404.jpg +0 -0
- data/spec/request_tc_helper.rb +0 -135
- data/spec/spec_all.rb +0 -118
- data/spec/spec_helper.rb +0 -66
- data/spec/tc_controller.rb +0 -49
- data/spec/tc_dependencies.rb +0 -13
- data/spec/tc_error.rb +0 -43
- data/spec/tc_morpher.rb +0 -88
- data/spec/tc_params.rb +0 -125
- data/spec/tc_template_ezamar.rb +0 -64
- data/spec/tc_template_markaby.rb +0 -72
- data/spec/template/ezamar/nested.zmr +0 -1
@@ -0,0 +1,64 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'spec/helper'
|
5
|
+
require 'open-uri'
|
6
|
+
|
7
|
+
class TCErrorController < Ramaze::Controller
|
8
|
+
map :/
|
9
|
+
trait :public => 'spec/ramaze/public'
|
10
|
+
|
11
|
+
def index
|
12
|
+
self.class.name
|
13
|
+
end
|
14
|
+
|
15
|
+
def erroring
|
16
|
+
blah
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "Error" do
|
21
|
+
ramaze :error_page => true
|
22
|
+
|
23
|
+
describe "Throwing Error" do
|
24
|
+
it 'erroring' do
|
25
|
+
response = get('/erroring')
|
26
|
+
response.status.should == 500
|
27
|
+
regex = %r(undefined local variable or method `blah' for .*?TCErrorController)
|
28
|
+
response.body.should =~ regex
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "No Action" do
|
33
|
+
it 'default' do
|
34
|
+
response = get('/foobar')
|
35
|
+
response.status.should == 404
|
36
|
+
response.body.should =~ %r(No Action found for `/foobar' on TCErrorController)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "No Action custom" do
|
40
|
+
Ramaze::Dispatcher.trait[:handle_error] = { Exception => [500, '/error'] }
|
41
|
+
|
42
|
+
response = get('/illegal')
|
43
|
+
response.status.should == 500
|
44
|
+
response.body.should =~ %r(No Action found for `/illegal' on TCErrorController)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it "No Controller" do
|
49
|
+
Ramaze::Global.should_receive(:mapping).twice.and_return{ {} }
|
50
|
+
Ramaze::Dispatcher.trait[:handle_error].should_receive(:[]).twice.
|
51
|
+
with(Ramaze::Error::NoController).and_return{ [500, '/error'] }
|
52
|
+
response = get('/illegal')
|
53
|
+
response.status.should == 500
|
54
|
+
response.body.should =~ %r(No Controller found for `/error')
|
55
|
+
end
|
56
|
+
|
57
|
+
it "Custom Static" do
|
58
|
+
Ramaze::Dispatcher.trait[:handle_error].should_receive(:[]).twice.
|
59
|
+
with(Ramaze::Error::NoAction).and_return{ [404, '/error404'] }
|
60
|
+
response = get('/foo')
|
61
|
+
response.status.should == 404
|
62
|
+
response.body.should == '404 - not found'
|
63
|
+
end
|
64
|
+
end
|
@@ -1,28 +1,28 @@
|
|
1
1
|
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/
|
4
|
+
require 'spec/helper'
|
5
5
|
|
6
|
-
|
6
|
+
describe "Gestalt" do
|
7
7
|
def gestalt &block
|
8
8
|
Ramaze::Gestalt.new(&block).to_s
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
it "simple tag" do
|
12
12
|
gestalt{ br }.should == '<br />'
|
13
13
|
gestalt{ p }.should == '<p />'
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
it "open close tags" do
|
17
17
|
gestalt{ p{} }.should == '<p></p>'
|
18
18
|
gestalt{ div{} }.should == '<div></div>'
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
it "nested tags" do
|
22
22
|
gestalt{ p{ br } }.should == '<p><br /></p>'
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
it "deep nested tags" do
|
26
26
|
gestalt{ p do
|
27
27
|
div do
|
28
28
|
ol do
|
@@ -33,7 +33,7 @@ context "Gestalt" do
|
|
33
33
|
}.should == '<p><div><ol><li /></ol></div></p>'
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
it "deep nested tags with repetition" do
|
37
37
|
gestalt{ p do
|
38
38
|
div do
|
39
39
|
ol do
|
@@ -49,7 +49,7 @@ context "Gestalt" do
|
|
49
49
|
}.should == '<p><div><ol><li /><li /></ol><ol><li /><li /></ol></div></p>'
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
it "deep nested tags with strings" do
|
53
53
|
gestalt{
|
54
54
|
p do
|
55
55
|
div do
|
@@ -59,7 +59,7 @@ context "Gestalt" do
|
|
59
59
|
}.should == '<p><div>Hello, World</div></p>'
|
60
60
|
end
|
61
61
|
|
62
|
-
|
62
|
+
it "some simple example" do
|
63
63
|
gestalt{
|
64
64
|
html do
|
65
65
|
head do
|
@@ -76,7 +76,7 @@ context "Gestalt" do
|
|
76
76
|
}.should == '<html><head><title>Hello World</title></head><body><h1>Hello World</h1></body></html>'
|
77
77
|
end
|
78
78
|
|
79
|
-
|
79
|
+
it "now some ruby inside" do
|
80
80
|
gestalt{
|
81
81
|
table do
|
82
82
|
tr do
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/
|
4
|
+
require 'spec/helper'
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
describe "Ramaze::Global" do
|
7
|
+
it "just simple assignment and retrive" do
|
8
8
|
Ramaze::Global.some = :xxx
|
9
9
|
Ramaze::Global.some.should == :xxx
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
it "setup" do
|
13
13
|
Ramaze::Global.setup :a => :b
|
14
14
|
Ramaze::Global.a.should == :b
|
15
15
|
Ramaze::Global.some.should == :xxx
|
@@ -17,17 +17,17 @@ context "Ramaze::Global" do
|
|
17
17
|
Ramaze::Global.a.should == :c
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
it "more neat stuff" do
|
21
21
|
Ramaze::Global.update :a => :d, :foo => :bar
|
22
22
|
Ramaze::Global.a.should == :c
|
23
23
|
Ramaze::Global.foo.should == :bar
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
it "values_at" do
|
27
27
|
Ramaze::Global.values_at(:a, :foo).should == [:c, :bar]
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
it "getting thready" do
|
31
31
|
Ramaze::Global[:i] = 0
|
32
32
|
Thread.main[:i] = 0
|
33
33
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/
|
4
|
+
require 'spec/helper'
|
5
5
|
|
6
6
|
class TCAspectController < Ramaze::Controller
|
7
|
+
map '/'
|
7
8
|
helper :aspect
|
8
9
|
|
9
10
|
def pre_aspect() '<aspect>' end
|
@@ -25,6 +26,9 @@ class TCAspectController < Ramaze::Controller
|
|
25
26
|
end
|
26
27
|
|
27
28
|
class TCAspectAllController < Ramaze::Controller
|
29
|
+
map '/all'
|
30
|
+
trait :foo => :bar
|
31
|
+
|
28
32
|
helper :aspect
|
29
33
|
|
30
34
|
def pre_aspect() '<pre>' end
|
@@ -37,27 +41,31 @@ class TCAspectAllController < Ramaze::Controller
|
|
37
41
|
post :all, :post_aspect
|
38
42
|
end
|
39
43
|
|
40
|
-
|
41
|
-
ramaze(:
|
44
|
+
describe "Aspect" do
|
45
|
+
ramaze(:error_page => false)
|
46
|
+
|
47
|
+
it "shouldn't overwrite traits on inclusion" do
|
48
|
+
TCAspectAllController.trait[:foo].should == :bar
|
49
|
+
end
|
42
50
|
|
43
|
-
|
44
|
-
get('/test_pre').should == '<aspect>test pre'
|
51
|
+
it "pre" do
|
52
|
+
get('/test_pre').body.should == '<aspect>test pre'
|
45
53
|
end
|
46
54
|
|
47
|
-
|
48
|
-
get('/test_post').should == 'test post</aspect>'
|
55
|
+
it "post" do
|
56
|
+
get('/test_post').body.should == 'test post</aspect>'
|
49
57
|
end
|
50
58
|
|
51
|
-
|
52
|
-
get('/test').should == '<aspect>test</aspect>'
|
59
|
+
it "pre and post" do
|
60
|
+
get('/test').body.should == '<aspect>test</aspect>'
|
53
61
|
end
|
54
62
|
|
55
|
-
|
56
|
-
get('/test_wrap').should == '<br />test wrap<br />'
|
63
|
+
it "wrap" do
|
64
|
+
get('/test_wrap').body.should == '<br />test wrap<br />'
|
57
65
|
end
|
58
66
|
|
59
|
-
|
60
|
-
get('/all/test_all_first').should == '<pre>first</pre>'
|
61
|
-
get('/all/test_all_second').should == '<pre>second</pre>'
|
67
|
+
it ":all" do
|
68
|
+
get('/all/test_all_first').body.should == '<pre>first</pre>'
|
69
|
+
get('/all/test_all_second').body.should == '<pre>second</pre>'
|
62
70
|
end
|
63
71
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/
|
4
|
+
require 'spec/helper'
|
5
5
|
|
6
6
|
class TCAuthHelperController < Ramaze::Controller
|
7
|
+
map '/'
|
7
8
|
helper :auth
|
8
9
|
|
9
10
|
def index
|
@@ -21,12 +22,14 @@ class TCAuthHelperController < Ramaze::Controller
|
|
21
22
|
end
|
22
23
|
|
23
24
|
class TCAuthHashHelperController < TCAuthHelperController
|
25
|
+
map '/hash'
|
24
26
|
trait :auth_table => {
|
25
27
|
'manveru' => '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'
|
26
28
|
}
|
27
29
|
end
|
28
30
|
|
29
31
|
class TCAuthMethodHelperController < TCAuthHelperController
|
32
|
+
map '/method'
|
30
33
|
trait :auth_table => :auth_table
|
31
34
|
|
32
35
|
def auth_table
|
@@ -35,22 +38,21 @@ class TCAuthMethodHelperController < TCAuthHelperController
|
|
35
38
|
end
|
36
39
|
|
37
40
|
class TCAuthLambdaHelperController < TCAuthHelperController
|
41
|
+
map '/lambda'
|
38
42
|
trait :auth_table => lambda{
|
39
43
|
{ 'manveru' => '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8' }
|
40
44
|
}
|
41
45
|
end
|
42
46
|
|
43
|
-
|
44
|
-
ramaze
|
45
|
-
[
|
46
|
-
TCAuthHashHelperController,
|
47
|
+
describe "StackHelper" do
|
48
|
+
ramaze :adapter => :webrick
|
49
|
+
[ TCAuthHashHelperController,
|
47
50
|
TCAuthMethodHelperController,
|
48
51
|
TCAuthLambdaHelperController
|
49
52
|
].each do |controller|
|
50
|
-
ctx = Context.new('/', Ramaze::Global.mapping.invert[controller])
|
51
53
|
|
52
54
|
specify controller.to_s do
|
53
|
-
|
55
|
+
browser('/', Ramaze::Global.mapping.invert[controller]) do
|
54
56
|
get('/secured').should == ''
|
55
57
|
post('/login', 'username' => 'manveru', 'password' => 'password')
|
56
58
|
get('/secured').should == 'Secret content'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/
|
4
|
+
require 'spec/helper'
|
5
5
|
|
6
6
|
class TCCacheHelperController < Ramaze::Controller
|
7
7
|
helper :cache
|
@@ -35,45 +35,35 @@ class TCCacheHelperController < Ramaze::Controller
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
|
38
|
+
describe "CacheHelper" do
|
39
39
|
ramaze(:mapping => {'/' => TCCacheHelperController})
|
40
40
|
|
41
|
-
|
42
|
-
get('/').should == 'TCCacheHelperController'
|
41
|
+
it "testrun" do
|
42
|
+
get('/').body.should == 'TCCacheHelperController'
|
43
43
|
end
|
44
44
|
|
45
|
-
def cached_value() get('/cached_value') end
|
46
|
-
def uncache_value() get('/uncache_value') end
|
47
|
-
def cached_action() get('/cached_action') end
|
48
|
-
def uncache_actions() get('/uncache_actions') end
|
49
|
-
|
50
|
-
specify "cached value" do
|
51
|
-
uncached = cached_value
|
45
|
+
def cached_value() get('/cached_value').body end
|
46
|
+
def uncache_value() get('/uncache_value').body end
|
47
|
+
def cached_action() get('/cached_action').body end
|
48
|
+
def uncache_actions() get('/uncache_actions').body end
|
52
49
|
|
50
|
+
it "cached value" do
|
53
51
|
3.times do
|
54
|
-
|
52
|
+
lambda{ cached_value }.should_not change{ cached_value }
|
55
53
|
end
|
56
54
|
|
57
|
-
old = cached_value
|
58
|
-
|
59
55
|
3.times do
|
60
|
-
uncache_value
|
61
|
-
cached_value.should_not == old
|
56
|
+
lambda{ uncache_value }.should change{ cached_value }
|
62
57
|
end
|
63
58
|
end
|
64
59
|
|
65
|
-
|
66
|
-
uncached = cached_action
|
67
|
-
|
60
|
+
it "cached action" do
|
68
61
|
3.times do
|
69
|
-
cached_action.
|
62
|
+
lambda{ cached_action }.should_not change{ cached_action }
|
70
63
|
end
|
71
64
|
|
72
|
-
old = cached_action
|
73
|
-
|
74
65
|
3.times do
|
75
|
-
uncache_actions
|
76
|
-
cached_action.should_not == old
|
66
|
+
lambda{ uncache_actions }.should change{ cached_action }
|
77
67
|
end
|
78
68
|
end
|
79
69
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/
|
4
|
+
require 'spec/helper'
|
5
5
|
|
6
6
|
testcase_requires 'hpricot'
|
7
7
|
|
@@ -44,11 +44,11 @@ class User < With
|
|
44
44
|
xml_accessor :books
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
describe "ReFeed" do
|
48
|
+
describe "User" do
|
49
49
|
user = User.with :name => 'manveru', :email => 'foo@bar.com'
|
50
50
|
|
51
|
-
|
51
|
+
it "to_xml" do
|
52
52
|
xml = ( user.to_xml.hpricot/:user )
|
53
53
|
|
54
54
|
xml.size.should == 1
|
@@ -57,11 +57,11 @@ context "ReFeed" do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
|
60
|
+
describe "Book" do
|
61
61
|
book = Book.with :title => 'foo', :content => 'bar',
|
62
62
|
:isbn => 123456789012, :description => 'The Best Foo in the world!'
|
63
63
|
|
64
|
-
|
64
|
+
it "to_xml" do
|
65
65
|
xml = ( book.to_xml.hpricot/:book )
|
66
66
|
|
67
67
|
xml.size.should == 1
|
@@ -74,11 +74,11 @@ context "ReFeed" do
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
describe "Book and User" do
|
78
78
|
user = User.with :name => 'manveru', :email => 'foo@bar.com'
|
79
79
|
book = Book.with :title => 'foo', :content => 'bar', :author => user
|
80
80
|
|
81
|
-
|
81
|
+
it "to_xml" do
|
82
82
|
xml_book = ( book.to_xml.hpricot/:book )
|
83
83
|
xml_user = xml_book.at(:user)
|
84
84
|
|
@@ -90,13 +90,13 @@ context "ReFeed" do
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
|
93
|
+
describe "User and books" do
|
94
94
|
book1 = Book.with :title => 'foo', :content => 'bar'
|
95
95
|
book2 = Book.with :title => 'foz', :content => 'baz'
|
96
96
|
user = User.with :name => 'manveru', :email => 'foo@bar.com',
|
97
97
|
:books => [book1, book2]
|
98
98
|
|
99
|
-
|
99
|
+
it "to_xml" do
|
100
100
|
xml = ( user.to_xml.hpricot/:user )
|
101
101
|
books = ( xml/:book )
|
102
102
|
first = books.find{|a| a.at('title').inner_html == book1.title }
|
@@ -115,10 +115,10 @@ context "ReFeed" do
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
-
|
118
|
+
describe "User from XML" do
|
119
119
|
user = User.with :name => 'manveru', :email => 'foo@bar.com'
|
120
120
|
|
121
|
-
|
121
|
+
it "from_xml" do
|
122
122
|
new_user = User.from_xml(user.to_xml)
|
123
123
|
new_user.name.should == user.name
|
124
124
|
new_user.email.should == user.email
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
class TCFileHelper < Ramaze::Controller
|
4
|
+
map '/'
|
5
|
+
|
6
|
+
def index
|
7
|
+
send_file(__FILE__)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'FileHelper' do
|
12
|
+
ramaze
|
13
|
+
|
14
|
+
it 'serving a file' do
|
15
|
+
get('/').body.strip.should == File.read(__FILE__).strip
|
16
|
+
end
|
17
|
+
end
|