ramaze 0.1.3 → 0.1.4
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.
- data/bin/ramaze +58 -26
- data/doc/AUTHORS +2 -0
- data/doc/CHANGELOG +401 -0
- data/doc/README +14 -9
- data/doc/README.html +737 -0
- data/doc/TODO +14 -14
- data/doc/changes.txt +401 -0
- data/doc/changes.xml +401 -0
- data/doc/meta/announcement.txt +28 -15
- data/doc/meta/configuration.txt +3 -3
- data/doc/meta/internals.txt +2 -2
- data/doc/meta/users.kml +62 -0
- data/doc/readme_chunks/examples.txt +1 -1
- data/doc/readme_chunks/features.txt +13 -8
- data/doc/tutorial/todolist.html +2 -2
- data/doc/tutorial/todolist.mkd +2 -2
- data/examples/blog/README +3 -0
- data/examples/blog/spec/blog.rb +101 -0
- data/examples/blog/{main.rb → start.rb} +0 -0
- data/examples/caching.rb +16 -5
- data/examples/layout.rb +41 -0
- data/examples/templates/template_amrita2.rb +1 -1
- data/examples/templates/template_erubis.rb +1 -1
- data/examples/templates/template_ezamar.rb +1 -1
- data/examples/templates/template_haml.rb +1 -1
- data/examples/templates/template_liquid.rb +1 -1
- data/examples/templates/template_markaby.rb +1 -1
- data/examples/templates/template_remarkably.rb +1 -1
- data/examples/todolist/README +1 -0
- data/{spec/examples → examples/todolist/spec}/todolist.rb +3 -3
- data/examples/todolist/{main.rb → start.rb} +0 -0
- data/examples/whywiki/{main.rb → start.rb} +0 -0
- data/examples/wiktacular/README +2 -0
- data/examples/wiktacular/spec/wiktacular.rb +146 -0
- data/examples/wiktacular/src/controller.rb +11 -0
- data/examples/wiktacular/src/model.rb +5 -1
- data/examples/wiktacular/{main.rb → start.rb} +0 -1
- data/examples/wiktacular/template/edit.xhtml +1 -2
- data/examples/wiktacular/template/html_layout.xhtml +27 -0
- data/examples/wiktacular/template/index.xhtml +8 -10
- data/examples/wiktacular/template/new.xhtml +1 -2
- data/lib/proto/{main.rb → start.rb} +0 -0
- data/lib/proto/template/index.xhtml +1 -1
- data/lib/ramaze/action/render.rb +58 -4
- data/lib/ramaze/action.rb +20 -0
- data/lib/ramaze/adapter/cgi.rb +7 -4
- data/lib/ramaze/adapter/fcgi.rb +6 -4
- data/lib/ramaze/adapter/mongrel.rb +4 -0
- data/lib/ramaze/adapter/webrick.rb +20 -9
- data/lib/ramaze/adapter.rb +3 -1
- data/lib/ramaze/cache/memcached.rb +2 -26
- data/lib/ramaze/cache.rb +8 -4
- data/lib/ramaze/controller/resolve.rb +26 -8
- data/lib/ramaze/controller.rb +44 -7
- data/lib/ramaze/dispatcher/action.rb +5 -1
- data/lib/ramaze/dispatcher/directory.rb +115 -0
- data/lib/ramaze/dispatcher/error.rb +19 -5
- data/lib/ramaze/dispatcher/file.rb +2 -2
- data/lib/ramaze/dispatcher.rb +52 -39
- data/lib/ramaze/global/dsl.rb +3 -2
- data/lib/ramaze/global/globalstruct.rb +26 -4
- data/lib/ramaze/global.rb +20 -11
- data/lib/ramaze/helper/aspect.rb +29 -11
- data/lib/ramaze/helper/auth.rb +2 -2
- data/lib/ramaze/helper/cache.rb +2 -0
- data/lib/ramaze/helper/identity.rb +21 -6
- data/lib/ramaze/helper/link.rb +1 -1
- data/lib/ramaze/helper/pager.rb +158 -100
- data/lib/ramaze/helper/partial.rb +22 -0
- data/lib/ramaze/helper/redirect.rb +1 -2
- data/lib/ramaze/helper/stack.rb +1 -1
- data/lib/ramaze/inform/informer.rb +20 -0
- data/lib/ramaze/inform/syslog.rb +5 -0
- data/lib/ramaze/snippets/kernel/__dir__.rb +21 -0
- data/lib/ramaze/snippets/kernel/aquire.rb +22 -12
- data/lib/ramaze/snippets/numeric/human_readable_filesize_format.rb +33 -0
- data/lib/ramaze/snippets/ramaze/caller_lines.rb +1 -1
- data/lib/ramaze/snippets/struct/values_at.rb +11 -4
- data/lib/ramaze/sourcereload.rb +29 -1
- data/{spec → lib/ramaze/spec}/helper/context.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/layout.rb +1 -1
- data/{spec → lib/ramaze/spec}/helper/minimal.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/mock_http.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/requester.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/simple_http.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/wrap.rb +0 -0
- data/lib/ramaze/spec/helper.rb +60 -0
- data/lib/ramaze/store/default.rb +3 -0
- data/lib/ramaze/template/ezamar/render_partial.rb +3 -0
- data/lib/ramaze/template/sass.rb +45 -0
- data/lib/ramaze/template.rb +1 -1
- data/lib/ramaze/tool/create.rb +5 -5
- data/lib/ramaze/tool/localize.rb +26 -5
- data/lib/ramaze/tool/mime.rb +7 -0
- data/lib/ramaze/trinity/response.rb +15 -0
- data/lib/ramaze/trinity/session.rb +1 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze.rb +5 -0
- data/rake_tasks/conf.rake +4 -4
- data/rake_tasks/maintaince.rake +12 -7
- data/rake_tasks/spec.rake +7 -4
- data/spec/examples/caching.rb +6 -8
- data/spec/helper.rb +3 -60
- data/spec/ramaze/action/basics.rb +17 -0
- data/spec/ramaze/action/cache.rb +28 -0
- data/spec/ramaze/action/layout.rb +110 -0
- data/spec/ramaze/action/render.rb +14 -0
- data/spec/ramaze/action/template/bar.xhtml +1 -0
- data/spec/ramaze/action/template/other_wrapper.xhtml +1 -0
- data/spec/ramaze/action/template/single_wrapper.xhtml +1 -0
- data/spec/ramaze/controller/template/edit/content.xhtml +1 -0
- data/spec/ramaze/controller/template/edit.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +2 -2
- data/spec/ramaze/dispatcher/directory.rb +53 -0
- data/spec/ramaze/dispatcher/file.rb +0 -3
- data/spec/ramaze/error.rb +17 -2
- data/spec/ramaze/helper/aspect.rb +14 -20
- data/spec/ramaze/helper/pager.rb +83 -1
- data/spec/ramaze/helper/partial.rb +1 -1
- data/spec/ramaze/helper/template/test_template.xhtml +1 -0
- data/spec/ramaze/inform/informer.rb +37 -5
- data/spec/ramaze/localize.rb +1 -1
- data/spec/ramaze/template/haml.rb +5 -5
- data/spec/ramaze/template/sass/file.css.sass +5 -0
- data/spec/ramaze/template/sass.rb +46 -0
- data/spec/ramaze/template.rb +1 -1
- data/spec/ramaze/trinity/session.rb +27 -0
- data/spec/snippets/kernel/__dir__.rb +8 -0
- data/spec/snippets/kernel/aquire.rb +71 -0
- data/spec/snippets/kernel/constant.rb +27 -0
- data/spec/snippets/numeric/human_readable_filesize_format.rb +11 -0
- data/spec/snippets/ramaze/caller_info.rb +39 -0
- data/spec/snippets/ramaze/caller_lines.rb +27 -0
- data/spec/snippets/string/DIVIDE.rb +18 -0
- data/spec/snippets/string/camel_case.rb +25 -0
- data/spec/snippets/string/color.rb +11 -0
- data/spec/snippets/string/snake_case.rb +17 -0
- data/spec/snippets/struct/fill.rb +27 -0
- data/spec/snippets/struct/values_at.rb +39 -0
- metadata +71 -31
- data/examples/todolist/todolist.db +0 -5
- data/examples/wiktacular/src/page.rb +0 -66
- data/lib/ramaze/helper/feed.rb +0 -135
- data/lib/ramaze/helper/form.rb +0 -204
- data/lib/ramaze/snippets/openstruct/temp.rb +0 -13
- data/lib/ramaze/store/yaml.rb +0 -170
- data/spec/ramaze/helper/feed.rb +0 -127
- data/spec/ramaze/helper/form.rb +0 -146
- data/spec/ramaze/store/yaml.rb +0 -76
|
@@ -16,4 +16,21 @@ describe 'Action() basics' do
|
|
|
16
16
|
action.params.should == ['1', '2', ' ']
|
|
17
17
|
action.method.should == 'foo'
|
|
18
18
|
end
|
|
19
|
+
|
|
20
|
+
it 'should be transformable in an hash' do
|
|
21
|
+
# we need to supply a :controller because internal accessor methods
|
|
22
|
+
# will use it to build some defaults.
|
|
23
|
+
# TODO: in Action.new() raise on init :controller or use a default
|
|
24
|
+
hsh = Ramaze::Action(:controller=>Object).to_hash
|
|
25
|
+
hsh[:method].should == nil
|
|
26
|
+
hsh[:binding].should be_an_instance_of(Binding)
|
|
27
|
+
hsh[:controller].should == Object
|
|
28
|
+
hsh[:engine].should == Ramaze::Template::Ezamar
|
|
29
|
+
hsh[:params].should == []
|
|
30
|
+
hsh[:path].should == nil
|
|
31
|
+
hsh[:instance].should be_an_instance_of(Object)
|
|
32
|
+
hsh[:template].should == nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
19
36
|
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
class TCActionCache < Ramaze::Controller
|
|
4
|
+
map '/'
|
|
5
|
+
helper :cache
|
|
6
|
+
|
|
7
|
+
def index
|
|
8
|
+
rand
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
trait :actions_cached => [:index]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe 'Action rendering' do
|
|
15
|
+
before :all do
|
|
16
|
+
@public_root = __DIR__ / :public
|
|
17
|
+
FileUtils.mkdir_p @public_root
|
|
18
|
+
ramaze :action_file_cached => true, :public_root => @public_root
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
after :all do
|
|
22
|
+
FileUtils.rm_rf @public_root
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'should render' do
|
|
26
|
+
lambda{ get('/') }.should_not change{ get('/').body }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
class TCActionLayout < Ramaze::Controller
|
|
4
|
+
map '/'
|
|
5
|
+
layout :wrapper
|
|
6
|
+
template_root __DIR__ / :template
|
|
7
|
+
|
|
8
|
+
def wrapper
|
|
9
|
+
"<pre>#@content</pre>"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def index
|
|
13
|
+
'Hello, World!'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def foo
|
|
17
|
+
"bar"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class TCActionOtherLayout < Ramaze::Controller
|
|
22
|
+
map '/other'
|
|
23
|
+
layout :other_wrapper
|
|
24
|
+
template_root __DIR__ / :template
|
|
25
|
+
|
|
26
|
+
def index
|
|
27
|
+
"Others Hello"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class TCActionSingleLayout < Ramaze::Controller
|
|
32
|
+
map '/single'
|
|
33
|
+
template_root __DIR__ / :template
|
|
34
|
+
layout :single_wrapper => :index
|
|
35
|
+
|
|
36
|
+
def index
|
|
37
|
+
"Single Hello"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def without
|
|
41
|
+
"Without wrapper"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class TCActionDenyLayout < Ramaze::Controller
|
|
46
|
+
map '/deny'
|
|
47
|
+
template_root __DIR__/:template
|
|
48
|
+
layout :single_wrapper
|
|
49
|
+
deny_layout :without
|
|
50
|
+
|
|
51
|
+
def index
|
|
52
|
+
"Single Hello"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def without
|
|
56
|
+
"Without wrapper"
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class TCActionMultiLayout < Ramaze::Controller
|
|
61
|
+
map '/multi'
|
|
62
|
+
template_root __DIR__/:template
|
|
63
|
+
layout :single_wrapper => [:index, :second]
|
|
64
|
+
p trait
|
|
65
|
+
|
|
66
|
+
def index
|
|
67
|
+
"Single Hello"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def second
|
|
71
|
+
"Second with layout"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def without
|
|
75
|
+
"Without wrapper"
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe 'Action rendering' do
|
|
80
|
+
before :all do
|
|
81
|
+
ramaze
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'should work with layouts' do
|
|
85
|
+
get('/').body.should == "<pre>Hello, World!</pre>"
|
|
86
|
+
get('/foo').body.should == "<pre>bar</pre>"
|
|
87
|
+
get('/bar').body.should == "<pre>Hello from bar</pre>"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'should work with layout from file' do
|
|
91
|
+
get('/other').body.should == "<p>Others Hello</p>"
|
|
92
|
+
get('/other/bar').body.should == "<p>Hello from bar</p>"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'should apply single layout' do
|
|
96
|
+
get('/single').body.should == "<b>Single Hello</b>"
|
|
97
|
+
get('/single/without').body.should == "Without wrapper"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it 'should deny a single action' do
|
|
101
|
+
get('/deny').body.should == "<b>Single Hello</b>"
|
|
102
|
+
get('/deny/without').body.should == "Without wrapper"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'should apply layout to a list of actions' do
|
|
106
|
+
get('/multi').body.should == "<b>Single Hello</b>"
|
|
107
|
+
get('/multi/second').body.should == "<b>Second with layout</b>"
|
|
108
|
+
get('/multi/without').body.should == "Without wrapper"
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
require 'spec/helper'
|
|
2
2
|
|
|
3
3
|
class TCActionOne < Ramaze::Controller
|
|
4
|
+
map '/'
|
|
5
|
+
|
|
4
6
|
def index
|
|
5
7
|
'Hello, World!'
|
|
6
8
|
end
|
|
9
|
+
|
|
10
|
+
def foo
|
|
11
|
+
Ramaze::Action(:controller => self.class, :method => :bar).render
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def bar
|
|
15
|
+
"yo from bar"
|
|
16
|
+
end
|
|
7
17
|
end
|
|
8
18
|
|
|
9
19
|
describe 'Action rendering' do
|
|
@@ -15,4 +25,8 @@ describe 'Action rendering' do
|
|
|
15
25
|
action = Ramaze::Action(:method => :index, :controller => TCActionOne)
|
|
16
26
|
action.render.should == 'Hello, World!'
|
|
17
27
|
end
|
|
28
|
+
|
|
29
|
+
it 'should render inside the controller' do
|
|
30
|
+
get('/foo').body.should == 'yo from bar'
|
|
31
|
+
end
|
|
18
32
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Hello from bar
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<p>#@content</p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<b>#@content</b>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
- #@oid
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#@what - #@oid
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
require 'spec/helper'
|
|
5
5
|
|
|
6
6
|
class MainController < Ramaze::Controller
|
|
7
|
-
template_root
|
|
7
|
+
template_root __DIR__ / :template
|
|
8
8
|
|
|
9
9
|
def greet(type, message = "Message")
|
|
10
10
|
@greet = "#{type} : #{message}"
|
|
@@ -19,7 +19,7 @@ class MainController < Ramaze::Controller
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
class OtherController < MainController
|
|
22
|
-
template_root "
|
|
22
|
+
template_root __DIR__ / "template/other"
|
|
23
23
|
|
|
24
24
|
def greet__mom(message = "Moms are cool!")
|
|
25
25
|
greet('Mom', message)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
testcase_requires 'hpricot'
|
|
4
|
+
|
|
5
|
+
describe 'Dispatcher::Directory' do
|
|
6
|
+
before :all do
|
|
7
|
+
ramaze :public_root => __DIR__/:public
|
|
8
|
+
@hierarchy = %w[
|
|
9
|
+
/test/deep/hierarchy/one.txt
|
|
10
|
+
/test/deep/hierarchy/two.txt
|
|
11
|
+
/test/deep/three.txt
|
|
12
|
+
/test/deep/four.txt
|
|
13
|
+
/test/five.txt
|
|
14
|
+
/test/six.txt ]
|
|
15
|
+
|
|
16
|
+
@hierarchy.each do |path|
|
|
17
|
+
FileUtils.mkdir_p(__DIR__/:public/File.dirname(path))
|
|
18
|
+
FileUtils.touch(__DIR__/:public/path)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def build_listing(path)
|
|
23
|
+
Ramaze::Dispatcher::Directory.build_listing(path)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should dry serve root directory' do
|
|
27
|
+
body, status, header = build_listing('/')
|
|
28
|
+
status.should == 200
|
|
29
|
+
header['Content-Type'].should == 'text/html'
|
|
30
|
+
doc = Hpricot(body)
|
|
31
|
+
doc.at(:title).inner_text.should == 'Directory listing of /'
|
|
32
|
+
files = doc.search("//td[@class='n']")
|
|
33
|
+
links = files.map{|td| a = td.at(:a); [a['href'], a.inner_text]}
|
|
34
|
+
links.should == [["/../", "Parent Directory"], ["/test", "test/"],
|
|
35
|
+
["/favicon.ico", "favicon.ico"], ["/test_download.css", "test_download.css"]]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'should serve hierarchies' do
|
|
39
|
+
body, status, header = build_listing('/test')
|
|
40
|
+
status.should == 200
|
|
41
|
+
header['Content-Type'].should == 'text/html'
|
|
42
|
+
doc = Hpricot(body)
|
|
43
|
+
doc.at(:title).inner_text.should == 'Directory listing of /test'
|
|
44
|
+
files = doc.search("//td[@class='n']")
|
|
45
|
+
links = files.map{|td| a = td.at(:a); [a['href'], a.inner_text]}
|
|
46
|
+
links.should == [["/test/../", "Parent Directory"], ["/test/deep", "deep/"],
|
|
47
|
+
["/test/five.txt", "five.txt"], ["/test/six.txt", "six.txt"]]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
after :all do
|
|
51
|
+
FileUtils.rm_rf(__DIR__/:public/:test)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -6,9 +6,6 @@ describe 'Dispatcher::File' do
|
|
|
6
6
|
@public_root = Ramaze::Global.public_root = 'spec/ramaze/dispatcher/public'
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
it 'should serve from proto/public' do
|
|
10
|
-
end
|
|
11
|
-
|
|
12
9
|
it 'should serve from Global.public_root' do
|
|
13
10
|
css = File.read(@public_root/'test_download.css')
|
|
14
11
|
re_css = get('/test_download.css')
|
data/spec/ramaze/error.rb
CHANGED
|
@@ -22,6 +22,10 @@ class TCErrorCustomController < Ramaze::Controller
|
|
|
22
22
|
def error
|
|
23
23
|
"The error page of custom"
|
|
24
24
|
end
|
|
25
|
+
|
|
26
|
+
def erroring
|
|
27
|
+
bluh
|
|
28
|
+
end
|
|
25
29
|
end
|
|
26
30
|
|
|
27
31
|
describe "Error" do
|
|
@@ -32,6 +36,11 @@ describe "Error" do
|
|
|
32
36
|
@handle_error = Ramaze::Dispatcher::Error::HANDLE_ERROR
|
|
33
37
|
end
|
|
34
38
|
|
|
39
|
+
before :each do
|
|
40
|
+
Ramaze::Cache.resolved.clear
|
|
41
|
+
Ramaze::Cache.patterns.clear
|
|
42
|
+
end
|
|
43
|
+
|
|
35
44
|
it 'should resolve custom error pages per controller' do
|
|
36
45
|
response = get("/custom/does_not_exist")
|
|
37
46
|
response.status.should == 404
|
|
@@ -45,6 +54,12 @@ describe "Error" do
|
|
|
45
54
|
response.body.should =~ regex
|
|
46
55
|
end
|
|
47
56
|
|
|
57
|
+
it 'should throw errors from rendering' do
|
|
58
|
+
response = get('/custom/erroring')
|
|
59
|
+
response.status.should == 500
|
|
60
|
+
response.body.should == "The error page of custom"
|
|
61
|
+
end
|
|
62
|
+
|
|
48
63
|
it 'should give 404 when no action is found' do
|
|
49
64
|
response = get('/foobar')
|
|
50
65
|
response.status.should == 404
|
|
@@ -61,10 +76,10 @@ describe "Error" do
|
|
|
61
76
|
end
|
|
62
77
|
|
|
63
78
|
it "should give 404 when no controller is found" do
|
|
64
|
-
Ramaze::Global.should_receive(:mapping).exactly(
|
|
79
|
+
Ramaze::Global.should_receive(:mapping).exactly(6).times.and_return{ {} }
|
|
65
80
|
response = get('/illegal2')
|
|
66
81
|
response.status.should == 404
|
|
67
|
-
response.body.should =~ %r(No Controller found for `/
|
|
82
|
+
response.body.should =~ %r(No Controller found for `/error')
|
|
68
83
|
end
|
|
69
84
|
|
|
70
85
|
it "should return custom error page" do
|
|
@@ -7,6 +7,7 @@ class TCAspectController < Ramaze::Controller
|
|
|
7
7
|
map '/'
|
|
8
8
|
trait :foo => :bar
|
|
9
9
|
helper :aspect
|
|
10
|
+
template_root(__DIR__/:template)
|
|
10
11
|
|
|
11
12
|
def test_before() 'test before' end
|
|
12
13
|
before(:test_before){ '<aspect>' }
|
|
@@ -16,18 +17,23 @@ class TCAspectController < Ramaze::Controller
|
|
|
16
17
|
|
|
17
18
|
def test_wrap() 'test wrap' end
|
|
18
19
|
wrap(:test_wrap){ '<br />' }
|
|
20
|
+
|
|
21
|
+
wrap(:test_template) { '<aspect>' }
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
class TCAspectAllController < Ramaze::Controller
|
|
22
25
|
map '/all'
|
|
23
26
|
|
|
24
27
|
helper :aspect
|
|
28
|
+
template_root(__DIR__/:template)
|
|
25
29
|
|
|
26
30
|
def test_all_first() 'first' end
|
|
27
31
|
def test_all_second() 'second' end
|
|
28
32
|
|
|
29
33
|
before_all{ '<pre>' }
|
|
30
34
|
after_all{ '</pre>' }
|
|
35
|
+
|
|
36
|
+
def test_all_after() 'after' end
|
|
31
37
|
end
|
|
32
38
|
|
|
33
39
|
describe "AspectHelper" do
|
|
@@ -49,32 +55,20 @@ describe "AspectHelper" do
|
|
|
49
55
|
get('/test_wrap').body.should == '<br />test wrap<br />'
|
|
50
56
|
end
|
|
51
57
|
|
|
58
|
+
it 'should wrap templates' do
|
|
59
|
+
get('/test_template').body.should == '<aspect>I am a template.<aspect>'
|
|
60
|
+
end
|
|
61
|
+
|
|
52
62
|
it 'should before_all and after_all' do
|
|
53
63
|
get('/all/test_all_first').body.should == '<pre>first</pre>'
|
|
54
64
|
get('/all/test_all_second').body.should == '<pre>second</pre>'
|
|
55
65
|
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
=begin
|
|
59
|
-
it "pre" do
|
|
60
|
-
get('/test_pre').body.should == '<aspect>test pre'
|
|
61
|
-
end
|
|
62
66
|
|
|
63
|
-
it
|
|
64
|
-
get('/
|
|
67
|
+
it 'should before_all and after_all for templates' do
|
|
68
|
+
get('/all/test_template').body.should == '<pre>I am a template.</pre>'
|
|
65
69
|
end
|
|
66
70
|
|
|
67
|
-
it
|
|
68
|
-
get('/
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "wrap" do
|
|
72
|
-
get('/test_wrap').body.should == '<br />test wrap<br />'
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it ":all" do
|
|
76
|
-
get('/all/test_all_first').body.should == '<pre>first</pre>'
|
|
77
|
-
get('/all/test_all_second').body.should == '<pre>second</pre>'
|
|
71
|
+
it 'should before_all and after_all for all defined actions' do
|
|
72
|
+
get('/all/test_all_after').body.should == '<pre>after</pre>'
|
|
78
73
|
end
|
|
79
74
|
end
|
|
80
|
-
=end
|
data/spec/ramaze/helper/pager.rb
CHANGED
|
@@ -29,7 +29,7 @@ describe "PagerHelper" do
|
|
|
29
29
|
def request
|
|
30
30
|
req = mock("Request")
|
|
31
31
|
req.should_receive(:params).with(no_args).
|
|
32
|
-
|
|
32
|
+
any_number_of_times.
|
|
33
33
|
and_return(Ramaze::Pager.trait[:key] => 1)
|
|
34
34
|
req
|
|
35
35
|
end
|
|
@@ -48,3 +48,85 @@ describe "PagerHelper" do
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
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
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should report the number of articles as Pager#total_count" do
|
|
64
|
+
@pager.should_not be_nil
|
|
65
|
+
@pager.total_count.should == 5
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
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
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should link to other pages" do
|
|
74
|
+
@pager.should_not be_nil
|
|
75
|
+
@pager.navigation.should_not be_nil
|
|
76
|
+
|
|
77
|
+
require 'hpricot'
|
|
78
|
+
page = Hpricot(@pager.navigation)
|
|
79
|
+
(page / 'a').size.should == 4
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
|
83
|
+
|
|
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
|
|
101
|
+
|
|
102
|
+
end
|
|
103
|
+
|
|
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
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
|
|
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
|
|
131
|
+
|
|
132
|
+
end
|