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
data/spec/spec_helper.rb
DELETED
@@ -1,66 +0,0 @@
|
|
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 'timeout'
|
5
|
-
|
6
|
-
$:.unshift File.join(File.dirname(File.expand_path(__FILE__)), '..', 'lib')
|
7
|
-
|
8
|
-
require 'ramaze'
|
9
|
-
|
10
|
-
begin
|
11
|
-
require 'rubygems'
|
12
|
-
rescue LoadError => ex
|
13
|
-
end
|
14
|
-
|
15
|
-
require 'spec'
|
16
|
-
|
17
|
-
require 'spec/spec_helper_simple_http'
|
18
|
-
require 'spec/spec_helper_requester'
|
19
|
-
require 'spec/spec_helper_context'
|
20
|
-
|
21
|
-
include Requester
|
22
|
-
|
23
|
-
module Spec::Runner::ContextEval::ModuleMethods
|
24
|
-
|
25
|
-
# start up ramaze with a given hash of options
|
26
|
-
# that will be merged with the default-options.
|
27
|
-
|
28
|
-
def ramaze_start hash = {}
|
29
|
-
options = {
|
30
|
-
:mode => :debug,
|
31
|
-
:adapter => :webrick,
|
32
|
-
:run_loose => true,
|
33
|
-
:error_page => false,
|
34
|
-
:port => 7007,
|
35
|
-
:host => '127.0.0.1',
|
36
|
-
:force => true,
|
37
|
-
:force_setup => true,
|
38
|
-
}.merge(hash)
|
39
|
-
|
40
|
-
Ramaze.start(options)
|
41
|
-
end
|
42
|
-
|
43
|
-
alias ramaze ramaze_start
|
44
|
-
|
45
|
-
# shutdown ramaze, this is not implemeted yet
|
46
|
-
# (and might never be due to limited possibilites)
|
47
|
-
|
48
|
-
def ramaze_teardown
|
49
|
-
#Ramaze.teardown
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
# require each of the following and rescue LoadError, telling you why it failed.
|
55
|
-
|
56
|
-
def testcase_requires(*following)
|
57
|
-
following.each do |file|
|
58
|
-
require(file.to_s)
|
59
|
-
end
|
60
|
-
rescue LoadError => ex
|
61
|
-
puts ex
|
62
|
-
puts "Can't run #{$0}: #{ex}"
|
63
|
-
puts "Usually you should not worry about this failure, just install the"
|
64
|
-
puts "library and try again (if you want to use that feature later on)"
|
65
|
-
exit
|
66
|
-
end
|
data/spec/tc_controller.rb
DELETED
@@ -1,49 +0,0 @@
|
|
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/spec_helper'
|
5
|
-
|
6
|
-
class TCControllerEzamarController < Ramaze::Controller
|
7
|
-
trait :template_root => 'spec/template/ezamar'
|
8
|
-
def index
|
9
|
-
@text = "World"
|
10
|
-
end
|
11
|
-
|
12
|
-
def sum first, second
|
13
|
-
@num1, @num2 = first.to_i, second.to_i
|
14
|
-
end
|
15
|
-
|
16
|
-
def some__long__action
|
17
|
-
end
|
18
|
-
|
19
|
-
def another__long__action
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def test_private
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "Testing Ezamar" do
|
29
|
-
ramaze(:mapping => {'/ezamar' => TCControllerEzamarController})
|
30
|
-
|
31
|
-
specify "simple request to index" do
|
32
|
-
get('/ezamar').should == 'Hello, World!'
|
33
|
-
end
|
34
|
-
|
35
|
-
specify "summing two values" do
|
36
|
-
get('/ezamar/sum/1/2').should == '3'
|
37
|
-
end
|
38
|
-
|
39
|
-
specify "double underscore in templates" do
|
40
|
-
get('/ezamar/some/long/action').should == 'some long action'
|
41
|
-
get('/ezamar/another/long/action').should == 'another long action'
|
42
|
-
end
|
43
|
-
|
44
|
-
specify "should not respond to private methods" do
|
45
|
-
%w[ session request response find_template handle_request trait test_private ].each do |action|
|
46
|
-
lambda{get("/ramaze/#{action}")}.should_raise
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
data/spec/tc_dependencies.rb
DELETED
@@ -1,13 +0,0 @@
|
|
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/spec_helper'
|
5
|
-
|
6
|
-
testcase_requires 'rubygems'
|
7
|
-
|
8
|
-
context "dependencies" do
|
9
|
-
specify "no gems" do
|
10
|
-
gems = $:.grep(/gems/).reject{|g| g =~ /rspec|rack/}
|
11
|
-
gems.should == []
|
12
|
-
end
|
13
|
-
end
|
data/spec/tc_error.rb
DELETED
@@ -1,43 +0,0 @@
|
|
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/spec_helper'
|
5
|
-
require 'open-uri'
|
6
|
-
|
7
|
-
class TCErrorController < Ramaze::Controller
|
8
|
-
trait :public => 'spec/public'
|
9
|
-
|
10
|
-
def index
|
11
|
-
self.class.name
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "Error" do
|
16
|
-
context "in dispatcher" do
|
17
|
-
ramaze :mapping => {'/' => TCErrorController }, :error_page => true
|
18
|
-
|
19
|
-
specify "your illegal stuff" do
|
20
|
-
Ramaze::Dispatcher.trait[:handle_error] = { Exception => '/error', }
|
21
|
-
|
22
|
-
lambda{ get('/illegal') }.should_raise RuntimeError
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "no controller" do
|
27
|
-
specify "your illegal stuff" do
|
28
|
-
Ramaze::Global.mapping = {}
|
29
|
-
Ramaze::Dispatcher.trait[:handle_error] = { Exception => '/error', }
|
30
|
-
|
31
|
-
lambda{ get('/illegal') }.should_raise RuntimeError
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "only error page (custom)" do
|
36
|
-
specify "custom static page" do
|
37
|
-
Ramaze::Global.mapping = {'/' => TCErrorController }
|
38
|
-
Ramaze::Dispatcher.trait[:handle_error] = { Exception => '/error404', }
|
39
|
-
|
40
|
-
get('/foo').should == '404 - not found'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/spec/tc_morpher.rb
DELETED
@@ -1,88 +0,0 @@
|
|
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/spec_helper'
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'hpricot'
|
8
|
-
|
9
|
-
class TCMorpherController < Ramaze::Controller
|
10
|
-
def index
|
11
|
-
self.class.name
|
12
|
-
end
|
13
|
-
|
14
|
-
def simple_if(arg = nil)
|
15
|
-
@arg = arg
|
16
|
-
%q{
|
17
|
-
<p if="@arg.nil?">orig</p>
|
18
|
-
<p if="@arg">#{@arg}</p>
|
19
|
-
}.strip
|
20
|
-
end
|
21
|
-
|
22
|
-
def simple_unless(arg = nil)
|
23
|
-
@arg = arg
|
24
|
-
%q{
|
25
|
-
<p unless="@arg">orig</p>
|
26
|
-
<p unless="@arg.nil?">#{@arg}</p>
|
27
|
-
}.strip
|
28
|
-
end
|
29
|
-
|
30
|
-
def simple_for n = 1
|
31
|
-
@n = (0..n.to_i)
|
32
|
-
%q{
|
33
|
-
<div for="i in @n">#{i}</div>
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
def simple_times n = 1
|
38
|
-
@n = n.to_i
|
39
|
-
%q{
|
40
|
-
<div times="@n">#{_t}</div>
|
41
|
-
}
|
42
|
-
end
|
43
|
-
|
44
|
-
def simple_each *elem
|
45
|
-
@elem = elem
|
46
|
-
%q{
|
47
|
-
<div each="@elem">#{_e}</div>
|
48
|
-
}
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "Morpher" do
|
53
|
-
ramaze :mapping => {'/' => TCMorpherController}
|
54
|
-
|
55
|
-
specify "testrun" do
|
56
|
-
get('/').should == 'TCMorpherController'
|
57
|
-
end
|
58
|
-
|
59
|
-
specify "if" do
|
60
|
-
get('/simple_if').should == '<p>orig</p>'
|
61
|
-
get('/simple_if/bar').should == '<p>bar</p>'
|
62
|
-
end
|
63
|
-
|
64
|
-
specify "unless" do
|
65
|
-
get('/simple_unless').should == '<p>orig</p>'
|
66
|
-
get('/simple_unless/bar').should == '<p>bar</p>'
|
67
|
-
end
|
68
|
-
|
69
|
-
specify "for" do
|
70
|
-
get('/simple_for').should == "<div>0</div><div>1</div>"
|
71
|
-
get('/simple_for/3').should == "<div>0</div><div>1</div><div>2</div><div>3</div>"
|
72
|
-
end
|
73
|
-
|
74
|
-
specify "times" do
|
75
|
-
get('/simple_times').should == "<div>0</div>"
|
76
|
-
get('/simple_times/3').should == "<div>0</div><div>1</div><div>2</div>"
|
77
|
-
end
|
78
|
-
|
79
|
-
specify "each" do
|
80
|
-
get('/simple_each').should == ''
|
81
|
-
get('/simple_each/1/2/3').should == "<div>1</div><div>2</div><div>3</div>"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
rescue LoadError => ex
|
86
|
-
puts ex
|
87
|
-
puts "Won't run #{__FILE__} unless you install hpricot"
|
88
|
-
end
|
data/spec/tc_params.rb
DELETED
@@ -1,125 +0,0 @@
|
|
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/spec_helper'
|
5
|
-
|
6
|
-
class TCParamsController < Ramaze::Controller
|
7
|
-
def index
|
8
|
-
"index"
|
9
|
-
end
|
10
|
-
|
11
|
-
def no_params
|
12
|
-
"no params"
|
13
|
-
end
|
14
|
-
|
15
|
-
def single_param param
|
16
|
-
"single param (#{param})"
|
17
|
-
end
|
18
|
-
|
19
|
-
def double_param param1, param2
|
20
|
-
"double param (#{param1}, #{param2})"
|
21
|
-
end
|
22
|
-
|
23
|
-
def all_params *params
|
24
|
-
"all params (#{params.join(', ')})"
|
25
|
-
end
|
26
|
-
|
27
|
-
def at_least_one param, *params
|
28
|
-
"at least one (#{param}, #{params.join(', ')})"
|
29
|
-
end
|
30
|
-
|
31
|
-
def one_default param = 'default'
|
32
|
-
"one_default (#{param})"
|
33
|
-
end
|
34
|
-
|
35
|
-
def cat1__cat11
|
36
|
-
'cat1: cat11'
|
37
|
-
end
|
38
|
-
|
39
|
-
def cat1__cat11__cat111
|
40
|
-
'cat1: cat11: cat111'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class TCParamsController2 < Ramaze::Controller
|
45
|
-
def add(one, two = nil, three = nil)
|
46
|
-
"#{one}:#{two}:#{three}"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "Simple Parameters" do
|
51
|
-
ramaze(
|
52
|
-
:mapping => {
|
53
|
-
'/' => TCParamsController,
|
54
|
-
'/jo' => TCParamsController2
|
55
|
-
}
|
56
|
-
)
|
57
|
-
|
58
|
-
specify "Should respond to no parameters given" do
|
59
|
-
get('/no_params').should == "no params"
|
60
|
-
end
|
61
|
-
|
62
|
-
specify "Should respond to only / with the index" do
|
63
|
-
get('/').should == "index"
|
64
|
-
end
|
65
|
-
|
66
|
-
specify "call /bar though index doesn't take params" do
|
67
|
-
lambda{ get('/bar') }.should_raise #OpenURI::HTTPError
|
68
|
-
end
|
69
|
-
|
70
|
-
specify "action that takes a single param" do
|
71
|
-
get('/single_param/foo').should == "single param (foo)"
|
72
|
-
end
|
73
|
-
|
74
|
-
specify "action that takes two params" do
|
75
|
-
get('/double_param/foo/bar').should == "double param (foo, bar)"
|
76
|
-
end
|
77
|
-
|
78
|
-
specify "action that takes two params but we give only one" do
|
79
|
-
lambda{ get('/double_param/foo') }.should_raise #OpenURI::HTTPError
|
80
|
-
end
|
81
|
-
|
82
|
-
specify "action that takes all params" do
|
83
|
-
get('/all_params/foo/bar/foobar').should == "all params (foo, bar, foobar)"
|
84
|
-
end
|
85
|
-
|
86
|
-
specify "action that takes all params but needs at least one" do
|
87
|
-
get('at_least_one/foo/bar/foobar').should == "at least one (foo, bar, foobar)"
|
88
|
-
end
|
89
|
-
|
90
|
-
specify "action that takes all params but needs at least one (not given here)" do
|
91
|
-
lambda{ get('/at_least_one') }.should_raise #OpenURI::HTTPError
|
92
|
-
end
|
93
|
-
|
94
|
-
specify "one default" do
|
95
|
-
get('/one_default').should == "one_default (default)"
|
96
|
-
end
|
97
|
-
|
98
|
-
specify "one default" do
|
99
|
-
get('/one_default/my_default').should == "one_default (my_default)"
|
100
|
-
end
|
101
|
-
|
102
|
-
specify "double underscore lookup" do
|
103
|
-
get('/cat1/cat11').should == 'cat1: cat11'
|
104
|
-
end
|
105
|
-
|
106
|
-
specify "double double underscore lookup" do
|
107
|
-
get('/cat1/cat11/cat111').should == 'cat1: cat11: cat111'
|
108
|
-
end
|
109
|
-
|
110
|
-
|
111
|
-
specify "jo/add should raise with 0 parameters" do
|
112
|
-
lambda{ get('/jo/add') }.should_raise
|
113
|
-
end
|
114
|
-
|
115
|
-
specify "add should raise with 4 parameters" do
|
116
|
-
lambda{ get('/jo/add/1/2/3/4') }.should_raise
|
117
|
-
end
|
118
|
-
|
119
|
-
specify "add should not raise with 1-3 parameters" do
|
120
|
-
get('/jo/add/1').should == '1::'
|
121
|
-
get('/jo/add/1/2').should == '1:2:'
|
122
|
-
get('/jo/add/1/2/3').should == '1:2:3'
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
data/spec/tc_template_ezamar.rb
DELETED
@@ -1,64 +0,0 @@
|
|
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/spec_helper'
|
5
|
-
|
6
|
-
class TCTemplateController < Ramaze::Controller
|
7
|
-
trait :template_root => 'spec/template/ezamar'
|
8
|
-
trait :engine => Ramaze::Template::Ezamar
|
9
|
-
|
10
|
-
def index text
|
11
|
-
@text = text
|
12
|
-
end
|
13
|
-
|
14
|
-
def sum num1, num2
|
15
|
-
@num1, @num2 = num1.to_i, num2.to_i
|
16
|
-
end
|
17
|
-
|
18
|
-
def nested key, value
|
19
|
-
@hash = {key => value}
|
20
|
-
end
|
21
|
-
|
22
|
-
def internal *args
|
23
|
-
@args = args
|
24
|
-
'<?r i = 2 ?>#{i * i} #{@args.inspect} on the table'
|
25
|
-
end
|
26
|
-
|
27
|
-
def combined
|
28
|
-
@a = 'boo'
|
29
|
-
nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
context "Ezamar" do
|
35
|
-
ramaze(:mapping => {'/' => TCTemplateController})
|
36
|
-
|
37
|
-
specify "hello world" do
|
38
|
-
get('/World').should == 'Hello, World!'
|
39
|
-
get('/You').should == 'Hello, You!'
|
40
|
-
end
|
41
|
-
|
42
|
-
specify "summing" do
|
43
|
-
get('/sum/1/2').should == '3'
|
44
|
-
end
|
45
|
-
|
46
|
-
specify "nasty nested stuff" do
|
47
|
-
get('/nested/foo/bar').should == 'bar'
|
48
|
-
end
|
49
|
-
|
50
|
-
specify "template inside controller" do
|
51
|
-
get('/internal').should == '4 [] on the table'
|
52
|
-
get('/internal/foo').should == '4 ["foo"] on the table'
|
53
|
-
end
|
54
|
-
|
55
|
-
specify "without method" do
|
56
|
-
get('/file_only').should == "This is only the file"
|
57
|
-
end
|
58
|
-
|
59
|
-
specify "combined" do
|
60
|
-
100.times do
|
61
|
-
get('/combined').should == 'boo'
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|