Pistos-ramaze 2009.04.08 → 2009.06.12
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/MANIFEST +37 -22
- data/{README.markdown → README.md} +5 -24
- data/Rakefile +33 -26
- data/benchmark/bench_templates/bench.rb +67 -0
- data/benchmark/bench_templates/view/large.erb +79 -0
- data/benchmark/bench_templates/view/large.haml +41 -0
- data/benchmark/bench_templates/view/large.xhtml +79 -0
- data/benchmark/bench_templates/view/small.erb +21 -0
- data/benchmark/bench_templates/view/small.haml +12 -0
- data/benchmark/bench_templates/view/small.xhtml +21 -0
- data/benchmark/run.rb +14 -21
- data/benchmark/suite/minimal.rb +3 -5
- data/benchmark/suite/no_informer.rb +0 -2
- data/benchmark/suite/no_sessions.rb +3 -4
- data/benchmark/suite/no_template.rb +1 -3
- data/benchmark/suite/simple.rb +1 -3
- data/benchmark/suite/template_erubis.rb +0 -2
- data/benchmark/suite/template_etanni.rb +8 -0
- data/benchmark/suite/template_ezamar.rb +1 -3
- data/benchmark/suite/template_haml.rb +0 -2
- data/benchmark/suite/template_liquid.rb +0 -2
- data/benchmark/suite/template_markaby.rb +0 -2
- data/benchmark/suite/template_nagoro.rb +1 -3
- data/benchmark/suite/template_redcloth.rb +0 -2
- data/benchmark/suite/template_tenjin.rb +0 -2
- data/bin/ramaze +11 -163
- data/doc/AUTHORS +15 -8
- data/doc/CHANGELOG +10094 -12262
- data/doc/meta/announcement.txt +93 -46
- data/doc/tutorial/todolist.html +22 -58
- data/doc/tutorial/todolist.txt +20 -39
- data/examples/app/auth/layout/{auth.nag → auth.xhtml} +0 -0
- data/examples/app/auth/view/{index.nag → index.xhtml} +0 -0
- data/examples/app/auth/view/{login.nag → login.xhtml} +0 -0
- data/examples/app/auth/view/{secret.nag → secret.xhtml} +0 -0
- data/examples/app/blog/app.rb +1 -1
- data/examples/app/blog/controller/comment.rb +1 -1
- data/examples/app/blog/controller/entry.rb +12 -3
- data/examples/app/blog/model/init.rb +5 -0
- data/examples/app/blog/model/tag.rb +2 -2
- data/examples/app/blog/view/entry/index.nag +3 -3
- data/examples/app/blog/view/feed.atom.nag +1 -1
- data/examples/app/blog/view/feed.rss.nag +1 -1
- data/examples/app/blog/view/index.nag +1 -1
- data/examples/app/blog/view/tag/index.nag +1 -1
- data/examples/app/chat/layout/{default.nag → default.xhtml} +0 -0
- data/examples/app/chat/view/{chat.nag → chat.xhtml} +0 -0
- data/examples/app/chat/view/{index.nag → index.xhtml} +0 -0
- data/examples/app/localization/locale/de.yaml +5 -0
- data/examples/app/localization/locale/en.yaml +5 -0
- data/examples/app/localization/locale/ja.yaml +5 -0
- data/examples/app/localization/start.rb +33 -20
- data/examples/app/wikore/spec/wikore.rb +4 -6
- data/examples/app/wikore/src/controller.rb +9 -11
- data/examples/app/wikore/src/model.rb +7 -10
- data/examples/app/wikore/start.rb +1 -1
- data/examples/app/wikore/{template → view}/index.xhtml +0 -0
- data/examples/helpers/cache.rb +6 -4
- data/examples/misc/css.rb +6 -12
- data/examples/misc/rapp.rb +28 -17
- data/lib/proto/app.rb +14 -0
- data/lib/proto/config.ru +8 -5
- data/lib/proto/controller/init.rb +3 -3
- data/lib/proto/spec/main.rb +9 -11
- data/lib/proto/start.rb +6 -10
- data/lib/ramaze.rb +8 -9
- data/lib/ramaze/app.rb +4 -3
- data/lib/ramaze/cache/localmemcache.rb +2 -2
- data/lib/ramaze/cache/memcache.rb +26 -1
- data/lib/ramaze/cache/sequel.rb +24 -9
- data/lib/ramaze/contrib/addressable_route.rb +56 -0
- data/lib/ramaze/contrib/email.rb +2 -0
- data/lib/ramaze/contrib/facebook/facebook.rb +4 -4
- data/lib/ramaze/contrib/sequel/create_join.rb +1 -0
- data/lib/ramaze/contrib/sequel/form_field.rb +4 -4
- data/lib/ramaze/contrib/sequel/image.rb +9 -11
- data/lib/ramaze/contrib/sequel/relation.rb +17 -3
- data/lib/ramaze/controller.rb +26 -18
- data/lib/ramaze/gestalt.rb +4 -1
- data/lib/ramaze/helper.rb +1 -0
- data/lib/ramaze/helper/auth.rb +0 -5
- data/lib/ramaze/helper/cache.rb +65 -25
- data/lib/ramaze/helper/form.rb +14 -2
- data/lib/ramaze/helper/formatting.rb +3 -1
- data/lib/ramaze/helper/gestalt.rb +32 -0
- data/lib/ramaze/helper/identity.rb +3 -3
- data/lib/ramaze/helper/layout.rb +97 -0
- data/lib/ramaze/helper/link.rb +6 -25
- data/lib/ramaze/helper/localize.rb +13 -3
- data/lib/ramaze/helper/paginate.rb +4 -2
- data/lib/ramaze/helper/ultraviolet.rb +2 -0
- data/lib/ramaze/helper/user.rb +3 -3
- data/lib/ramaze/log/rotatinginformer.rb +10 -10
- data/lib/ramaze/request.rb +3 -5
- data/lib/ramaze/setup.rb +22 -9
- data/lib/ramaze/spec.rb +8 -12
- data/lib/ramaze/spec/bacon.rb +34 -0
- data/lib/ramaze/spec/helper/template_examples.rb +15 -22
- data/lib/ramaze/tool/bin.rb +340 -0
- data/lib/ramaze/tool/project_creator.rb +1 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view.rb +6 -11
- data/lib/ramaze/view/erubis.rb +2 -2
- data/lib/ramaze/view/ezamar.rb +2 -2
- data/lib/ramaze/view/gestalt.rb +14 -0
- data/lib/ramaze/view/haml.rb +2 -1
- data/lib/ramaze/view/liquid.rb +45 -11
- data/lib/ramaze/view/maruku.rb +2 -1
- data/lib/ramaze/view/nagoro/render_partial.rb +9 -9
- data/lib/ramaze/view/sass.rb +1 -1
- data/lib/ramaze/view/tenjin.rb +7 -4
- data/lib/vendor/etag.rb +4 -2
- data/lib/vendor/route_exceptions.rb +9 -15
- data/ramaze.gemspec +56 -9
- data/spec/contrib/addressable_route.rb +30 -0
- data/spec/contrib/rest.rb +2 -2
- data/spec/examples/caching.rb +5 -7
- data/spec/examples/css.rb +3 -3
- data/spec/examples/element.rb +4 -3
- data/spec/examples/hello.rb +3 -3
- data/spec/examples/helpers/httpdigest.rb +44 -69
- data/spec/examples/linking.rb +3 -3
- data/spec/examples/simple.rb +3 -3
- data/spec/examples/templates/template_erubis.rb +8 -4
- data/spec/examples/templates/template_ezamar.rb +9 -4
- data/spec/examples/templates/template_haml.rb +8 -4
- data/spec/examples/templates/template_liquid.rb +8 -4
- data/spec/examples/templates/template_markaby.rb +9 -5
- data/spec/examples/templates/template_nagoro.rb +9 -5
- data/spec/examples/templates/template_redcloth.rb +8 -4
- data/spec/examples/templates/template_remarkably.rb +8 -4
- data/spec/examples/templates/template_tenjin.rb +8 -4
- data/spec/helper.rb +1 -2
- data/spec/ramaze/action/render.rb +4 -1
- data/spec/ramaze/app.rb +5 -2
- data/spec/ramaze/bin/ramaze.rb +96 -0
- data/spec/ramaze/cache/localmemcache.rb +1 -1
- data/spec/ramaze/cache/memcache.rb +7 -1
- data/spec/ramaze/cache/sequel.rb +1 -1
- data/spec/ramaze/controller/actionless_templates.rb +2 -2
- data/spec/ramaze/controller/lonely_mapping.rb +18 -0
- data/spec/ramaze/controller/mapping.rb +4 -15
- data/spec/ramaze/controller/provide_inheritance.rb +5 -2
- data/spec/ramaze/controller/resolve.rb +2 -2
- data/spec/ramaze/controller/subclass.rb +2 -2
- data/spec/ramaze/controller/template_resolving.rb +2 -2
- data/spec/ramaze/dispatcher/directory.rb +5 -2
- data/spec/ramaze/dispatcher/file.rb +28 -26
- data/spec/ramaze/error.rb +3 -3
- data/spec/ramaze/files.rb +5 -2
- data/spec/ramaze/gestalt.rb +26 -17
- data/spec/ramaze/helper/auth.rb +30 -41
- data/spec/ramaze/helper/bench.rb +6 -2
- data/spec/ramaze/helper/cache.rb +45 -5
- data/spec/ramaze/helper/flash.rb +11 -15
- data/spec/ramaze/helper/form.rb +6 -3
- data/spec/ramaze/helper/formatting.rb +4 -1
- data/spec/ramaze/helper/gestalt.rb +4 -1
- data/spec/ramaze/helper/gravatar.rb +4 -1
- data/spec/ramaze/helper/httpdigest.rb +51 -66
- data/spec/ramaze/helper/layout.rb +79 -0
- data/spec/ramaze/helper/layout/default.xhtml +5 -0
- data/spec/ramaze/helper/link.rb +33 -12
- data/spec/ramaze/helper/localize.rb +9 -4
- data/spec/ramaze/helper/maruku.rb +5 -2
- data/spec/ramaze/helper/pager.rb +2 -2
- data/spec/ramaze/helper/paginate.rb +5 -2
- data/spec/ramaze/helper/request_accessor.rb +5 -2
- data/spec/ramaze/helper/sequel_form.rb +7 -2
- data/spec/ramaze/helper/simple_captcha.rb +10 -14
- data/spec/ramaze/helper/stack.rb +32 -40
- data/spec/ramaze/helper/user.rb +19 -14
- data/spec/ramaze/helper/xhtml.rb +4 -1
- data/spec/ramaze/log/informer.rb +1 -1
- data/spec/ramaze/log/logging.rb +4 -1
- data/spec/ramaze/log/syslog.rb +6 -6
- data/spec/ramaze/params.rb +5 -6
- data/spec/ramaze/request.rb +16 -1
- data/spec/ramaze/session/memcache.rb +66 -0
- data/spec/ramaze/struct.rb +4 -1
- data/spec/ramaze/view.rb +2 -2
- data/spec/ramaze/view/erubis.rb +2 -2
- data/spec/ramaze/view/ezamar.rb +2 -2
- data/spec/ramaze/view/gestalt.rb +94 -0
- data/spec/ramaze/view/gestalt/external.ges +8 -0
- data/spec/ramaze/view/haml.rb +2 -2
- data/spec/ramaze/view/liquid.rb +2 -2
- data/spec/ramaze/view/nagoro.rb +2 -2
- data/spec/ramaze/view/redcloth.rb +2 -2
- data/spec/ramaze/view/remarkably.rb +2 -2
- data/spec/ramaze/view/sass.rb +2 -2
- data/spec/ramaze/view/tagz.rb +2 -2
- data/spec/ramaze/view/tenjin.rb +2 -2
- data/spec/snippets/array/put_within.rb +30 -25
- data/spec/snippets/binding/locals.rb +4 -1
- data/spec/snippets/numeric/filesize_format.rb +4 -1
- data/spec/snippets/numeric/time.rb +5 -2
- data/spec/snippets/object/__dir__.rb +4 -1
- data/spec/snippets/ordered_set.rb +4 -1
- data/spec/snippets/ramaze/acquire.rb +4 -1
- data/spec/snippets/ramaze/dictionary.rb +4 -1
- data/spec/snippets/ramaze/struct.rb +4 -1
- data/spec/snippets/string/camel_case.rb +4 -1
- data/spec/snippets/string/color.rb +4 -1
- data/spec/snippets/string/snake_case.rb +4 -1
- data/spec/snippets/string/unindent.rb +4 -1
- data/spec/snippets/thread/into.rb +4 -1
- data/tasks/bacon.rake +5 -3
- data/tasks/changelog.rake +3 -1
- data/tasks/{gem_installer.rake → gem_setup.rake} +45 -22
- data/tasks/release.rake +12 -27
- data/tasks/setup.rake +6 -0
- data/tasks/todo.rake +2 -4
- metadata +205 -31
- data/CHANGELOG +0 -16546
- data/benchmark/suite/template_builder.rb +0 -12
- data/doc/tutorial/todolist.mkd +0 -787
- data/examples/helpers/provide.rb +0 -23
- data/lib/proto/view/page.xhtml +0 -27
- data/lib/ramaze/snippets/divide.rb +0 -22
- data/lib/ramaze/snippets/kernel/constant.rb +0 -41
- data/lib/ramaze/snippets/object/acquire.rb +0 -37
- data/lib/ramaze/snippets/string/each.rb +0 -19
- data/spec/ramaze/helper/partial.rb +0 -40
- data/spec/snippets/kernel/constant.rb +0 -23
- data/tasks/install_dependencies.rake +0 -6
@@ -0,0 +1,96 @@
|
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
|
+
require "ramaze/tool/bin"
|
6
|
+
|
7
|
+
require "pathname"
|
8
|
+
|
9
|
+
module Ramaze
|
10
|
+
BINPATH = Pathname(Ramaze::ROOT).join("../bin/ramaze").expand_path
|
11
|
+
end
|
12
|
+
|
13
|
+
USAGE = <<TXT
|
14
|
+
|
15
|
+
Usage:
|
16
|
+
ramaze <start [PIDFILE]|stop [PIDFILE]|restart [PIDFILE]|status [PIDFILE]|create PROJECT|console> [ruby/rack options]
|
17
|
+
|
18
|
+
Commands:
|
19
|
+
|
20
|
+
* All commands which take an optional PIDFILE (defaults to PROJECT.pid otherwise).
|
21
|
+
* All commands which start a ramaze instance will default to webrick on port 7000
|
22
|
+
unless you supply the rack options -p/--port PORT and/or * -s/--server SERVER.
|
23
|
+
|
24
|
+
start - Starts an instance of this application.
|
25
|
+
|
26
|
+
stop - Stops a running instance of this application.
|
27
|
+
|
28
|
+
restart - Stops running instance of this application, then starts it back up. Pidfile
|
29
|
+
(if supplied) is used for both stop and start.
|
30
|
+
|
31
|
+
status - Gives status of a running ramaze instance
|
32
|
+
|
33
|
+
create - Creates a new prototype Ramaze application in a directory named PROJECT in
|
34
|
+
the current directory. ramaze create foo would make ./foo containing an
|
35
|
+
application prototype. Rack options are ignored here.
|
36
|
+
|
37
|
+
console - Starts an irb console with app.rb (and irb completion) loaded. This command
|
38
|
+
ignores rack options, ARGV is passed on to IRB.
|
39
|
+
|
40
|
+
|
41
|
+
Ruby options:
|
42
|
+
-e, --eval LINE evaluate a LINE of code
|
43
|
+
-d, --debug set debugging flags (set $DEBUG to true)
|
44
|
+
-w, --warn turn warnings on for your script
|
45
|
+
-I, --include PATH specify $LOAD_PATH (may be used more than once)
|
46
|
+
-r, --require LIBRARY require the library, before executing your script
|
47
|
+
|
48
|
+
Rack options:
|
49
|
+
-s, --server SERVER serve using SERVER (webrick/mongrel)
|
50
|
+
-o, --host HOST listen on HOST (default: 0.0.0.0)
|
51
|
+
-p, --port PORT use PORT (default: 9292)
|
52
|
+
-E, --env ENVIRONMENT use ENVIRONMENT for defaults (default: development)
|
53
|
+
-D, --daemonize run daemonized in the background
|
54
|
+
-P, --pid FILE file to store PID (default: rack.pid)
|
55
|
+
|
56
|
+
Common options:
|
57
|
+
-h, --help Show this message
|
58
|
+
--version Show version
|
59
|
+
TXT
|
60
|
+
|
61
|
+
describe "bin/ramaze command" do
|
62
|
+
it "Can find the ramaze binary" do
|
63
|
+
Ramaze::BINPATH.file?.should == true
|
64
|
+
end
|
65
|
+
|
66
|
+
it "Shows command line help" do
|
67
|
+
output = `#{Ramaze::BINPATH} -h`
|
68
|
+
output.should == USAGE
|
69
|
+
end
|
70
|
+
|
71
|
+
it "Shows the correct version" do
|
72
|
+
output = %x{#{Ramaze::BINPATH} --version}
|
73
|
+
output.strip.should == Ramaze::VERSION
|
74
|
+
end
|
75
|
+
|
76
|
+
it "Can create a new tree from prototype" do
|
77
|
+
require "fileutils"
|
78
|
+
root = Pathname.new("/tmp/test_tree")
|
79
|
+
raise "#{root} already exists, please move it out of the way before running this test" if root.directory?
|
80
|
+
begin
|
81
|
+
output = %x{#{Ramaze::BINPATH} create #{root}}
|
82
|
+
root.directory?.should.be.true
|
83
|
+
root.join("config.ru").file?.should.be.true
|
84
|
+
root.join("start.rb").file?.should.be.true
|
85
|
+
root.join("controller").directory?.should.be.true
|
86
|
+
root.join("controller", "init.rb").file?.should.be.true
|
87
|
+
root.join("view").directory?.should.be.true
|
88
|
+
root.join("model").directory?.should.be.true
|
89
|
+
root.join("model", "init.rb").file?.should.be.true
|
90
|
+
ensure
|
91
|
+
FileUtils.rm_rf(root)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2009 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/helper'
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
5
|
spec_require 'localmemcache'
|
6
6
|
|
7
7
|
describe Ramaze::Cache::LocalMemCache do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2009 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/helper'
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
5
|
|
6
6
|
spec_precondition 'memcached is running' do
|
7
7
|
require 'memcache'
|
@@ -45,6 +45,12 @@ describe Ramaze::Cache::MemCache do
|
|
45
45
|
cache.fetch(:hello).should == nil
|
46
46
|
end
|
47
47
|
|
48
|
+
should 'amend the ttl if it is too high' do
|
49
|
+
ttl = Ramaze::Cache::MemCache::MAX_TTL + 1
|
50
|
+
cache.store(:hello, @hello, :ttl => ttl)
|
51
|
+
cache.fetch(:hello).should == @hello
|
52
|
+
end
|
53
|
+
|
48
54
|
should 'clear' do
|
49
55
|
cache.store(:hello, @hello)
|
50
56
|
cache.fetch(:hello).should == @hello
|
data/spec/ramaze/cache/sequel.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2009 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/helper'
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
5
|
spec_require 'sequel'
|
6
6
|
|
7
7
|
DB = Sequel.sqlite
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2009 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/helper'
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
5
|
|
6
6
|
Ramaze::App.options.merge!(:layouts => 'view')
|
7
7
|
|
@@ -23,7 +23,7 @@ class SpecActionlessTemplatesLayout < Ramaze::Controller
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "Testing Actionless Templates" do
|
26
|
-
behaves_like :
|
26
|
+
behaves_like :rack_test
|
27
27
|
|
28
28
|
it "should not find template file for non existant method" do
|
29
29
|
get('/list').status.should == 404
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
|
+
|
6
|
+
class SpecHello < Ramaze::Controller
|
7
|
+
def index
|
8
|
+
'automatically mapped'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'Lonely Controller automap' do
|
13
|
+
behaves_like :rack_test
|
14
|
+
|
15
|
+
it 'automatically creates an app and maps the controller into it' do
|
16
|
+
get('/').body.should == 'automatically mapped'
|
17
|
+
end
|
18
|
+
end
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
2
5
|
|
3
6
|
describe 'Controller::generate_mapping' do
|
4
7
|
def gen(klass)
|
@@ -41,17 +44,3 @@ describe 'Controller::generate_mapping' do
|
|
41
44
|
gen(Class.new.name).should == nil
|
42
45
|
end
|
43
46
|
end
|
44
|
-
|
45
|
-
class SpecControllerMapping < Ramaze::Controller
|
46
|
-
def index
|
47
|
-
'automatically mapped'
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'Controller automap' do
|
52
|
-
behaves_like :mock
|
53
|
-
|
54
|
-
it 'automatically creates an app and maps the controller into it' do
|
55
|
-
get('/spec_controller_mapping').body.should == 'automatically mapped'
|
56
|
-
end
|
57
|
-
end
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
2
5
|
|
3
6
|
class SpecControllerInheritedMain < Ramaze::Controller
|
4
7
|
Ramaze.node('/')
|
@@ -25,7 +28,7 @@ class SpecControllerInheritedYetAnother < SpecControllerInheritedAnother
|
|
25
28
|
end
|
26
29
|
|
27
30
|
describe 'Ramaze::Controller#self.inherited' do
|
28
|
-
behaves_like :
|
31
|
+
behaves_like :rack_test
|
29
32
|
|
30
33
|
should 'default renders nagoro' do
|
31
34
|
get('/').body.should == "<p>Main is nagoro</p>"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2009 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/helper'
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
5
|
|
6
6
|
class MainController < Ramaze::Controller
|
7
7
|
map '/'
|
@@ -13,7 +13,7 @@ class MainController < Ramaze::Controller
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe 'Controller resolving' do
|
16
|
-
behaves_like :
|
16
|
+
behaves_like :rack_test
|
17
17
|
|
18
18
|
it 'should work with .' do
|
19
19
|
get('/file.ext').body.should == 'file.ext'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2009 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/helper'
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
5
|
|
6
6
|
class BaseController < Ramaze::Controller
|
7
7
|
alias_view :foo, :bar
|
@@ -14,7 +14,7 @@ class MainController < BaseController
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe 'Controller' do
|
17
|
-
behaves_like :
|
17
|
+
behaves_like :rack_test
|
18
18
|
|
19
19
|
it 'allows sub-classing MainController' do
|
20
20
|
get('/test').body.should == 'test'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2009 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/helper'
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
5
|
|
6
6
|
class SpecViewAlias < Ramaze::Controller
|
7
7
|
map '/'
|
@@ -44,7 +44,7 @@ class SpecViewAlias2 < SpecViewAlias
|
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "Template aliasing" do
|
47
|
-
behaves_like :
|
47
|
+
behaves_like :rack_test
|
48
48
|
|
49
49
|
it 'serves normal template' do
|
50
50
|
get('/greet/asdf').body.should == '<html>asdf : Message</html>'
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
2
5
|
|
3
6
|
spec_require 'hpricot'
|
4
7
|
|
@@ -10,7 +13,7 @@ module Ramaze
|
|
10
13
|
end
|
11
14
|
|
12
15
|
describe 'Directory listing' do
|
13
|
-
behaves_like :
|
16
|
+
behaves_like :rack_test
|
14
17
|
|
15
18
|
@hierarchy = %w[
|
16
19
|
/test/deep/hierarchy/one.txt
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2009 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/helper'
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
5
|
|
6
6
|
# This spec more or less tries to ensure that we integrate with rack and
|
7
7
|
# rack-contrib in regards to static file serving.
|
@@ -9,61 +9,63 @@ require 'spec/helper'
|
|
9
9
|
module Ramaze
|
10
10
|
# minimal middleware, no exception handling
|
11
11
|
middleware!(:spec){|m|
|
12
|
-
m.apps
|
12
|
+
m.apps Rack::ConditionalGet, Rack::ETag
|
13
13
|
m.innate
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
17
17
|
describe 'Serving static files' do
|
18
|
-
behaves_like :
|
18
|
+
behaves_like :rack_test
|
19
19
|
|
20
|
-
Ramaze.map('/', lambda{|env| [200, {}, 'nothing']})
|
20
|
+
Ramaze.map('/', lambda{|env| [200, {}, ['nothing']]})
|
21
21
|
|
22
22
|
it 'serves from public root' do
|
23
23
|
css = File.read(__DIR__('public/test_download.css'))
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
get '/test_download.css'
|
25
|
+
last_response.body.should == css
|
26
|
+
last_response.status.should == 200
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'serves files with spaces' do
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
get '/file%20name.txt'
|
31
|
+
last_response.status.should == 200
|
32
|
+
last_response.body.should == 'hi'
|
33
33
|
end
|
34
34
|
|
35
|
-
it 'sends
|
36
|
-
|
37
|
-
|
35
|
+
it 'sends Etag for string bodies' do
|
36
|
+
get '/'
|
37
|
+
last_response['Etag'].size.should > 1
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'sends Last-Modified for file bodies' do
|
41
|
-
|
41
|
+
get '/test_download.css'
|
42
42
|
|
43
43
|
mtime = File.mtime(__DIR__('public/test_download.css'))
|
44
44
|
|
45
|
-
|
45
|
+
last_response['Last-Modified'].should == mtime.httpdate
|
46
46
|
end
|
47
47
|
|
48
|
-
it 'respects
|
49
|
-
|
48
|
+
it 'respects Etag with HTTP_IF_NONE_MATCH' do
|
49
|
+
get '/'
|
50
50
|
|
51
|
-
etag =
|
51
|
+
etag = last_response['Etag']
|
52
52
|
etag.should.not.be.nil
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
header 'HTTP_IF_NONE_MATCH', etag
|
55
|
+
get '/'
|
56
|
+
last_response.status.should == 304
|
57
|
+
last_response.body.should == ''
|
57
58
|
end
|
58
59
|
|
59
60
|
it 'respects Last-Modified with HTTP_IF_MODIFIED_SINCE' do
|
60
|
-
|
61
|
+
get '/test_download.css'
|
61
62
|
|
62
|
-
mtime =
|
63
|
+
mtime = last_response['Last-Modified']
|
63
64
|
mtime.should.not.be.nil
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
header 'HTTP_IF_MODIFIED_SINCE', mtime
|
67
|
+
get '/test_download.css'
|
68
|
+
last_response.status.should == 304
|
69
|
+
last_response.body.should == ''
|
68
70
|
end
|
69
71
|
end
|
data/spec/ramaze/error.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2009 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/helper'
|
4
|
+
require File.expand_path('../../../spec/helper', __FILE__)
|
5
5
|
require 'rexml/document'
|
6
6
|
require 'rexml/xpath'
|
7
7
|
|
@@ -35,7 +35,7 @@ class SpecErrorHandling < SpecError
|
|
35
35
|
end
|
36
36
|
|
37
37
|
describe 'Error handling' do
|
38
|
-
behaves_like :
|
38
|
+
behaves_like :rack_test
|
39
39
|
|
40
40
|
Ramaze.options.mode = :dev
|
41
41
|
|
@@ -66,7 +66,7 @@ describe 'Error handling' do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'uses Rack::RouteExceptions when a route is set' do
|
69
|
-
Rack::RouteExceptions
|
69
|
+
Rack::RouteExceptions.route(NameError, '/handle/name_error')
|
70
70
|
|
71
71
|
got = get('/raises')
|
72
72
|
[got.status, got['Content-Type']].should == [200, 'text/html']
|
data/spec/ramaze/files.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require File.expand_path('../../../spec/helper', __FILE__)
|
2
5
|
|
3
6
|
class SpecFilesCore < Ramaze::Controller
|
4
7
|
map '/', :core
|
@@ -17,7 +20,7 @@ Ramaze::App[:other].options.publics = 'files/public_2'
|
|
17
20
|
Ramaze.middleware!(:spec){|m| m.run(Ramaze::AppMap) }
|
18
21
|
|
19
22
|
describe Ramaze::Files do
|
20
|
-
behaves_like :
|
23
|
+
behaves_like :rack_test
|
21
24
|
|
22
25
|
it 'serves files for core app from public_1' do
|
23
26
|
get('/plain.txt').body.should == "Just some text in a file\n"
|
data/spec/ramaze/gestalt.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# * Encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
4
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
2
5
|
|
3
|
-
require 'spec/helper'
|
6
|
+
require File.expand_path('../../../spec/helper', __FILE__)
|
4
7
|
require 'ramaze/gestalt'
|
5
8
|
|
6
9
|
describe "Gestalt" do
|
@@ -26,38 +29,38 @@ describe "Gestalt" do
|
|
26
29
|
|
27
30
|
it "deep nested tags" do
|
28
31
|
gestalt{ p do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
+
div do
|
33
|
+
ol do
|
34
|
+
li
|
35
|
+
end
|
32
36
|
end
|
33
37
|
end
|
34
|
-
end
|
35
38
|
}.should == '<p><div><ol><li /></ol></div></p>'
|
36
39
|
end
|
37
40
|
|
38
41
|
it "deep nested tags with repetition" do
|
39
42
|
gestalt{ p do
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
div do
|
44
|
+
ol do
|
45
|
+
li
|
46
|
+
li
|
47
|
+
end
|
48
|
+
ol do
|
49
|
+
li
|
50
|
+
li
|
51
|
+
end
|
48
52
|
end
|
49
53
|
end
|
50
|
-
end
|
51
54
|
}.should == '<p><div><ol><li /><li /></ol><ol><li /><li /></ol></div></p>'
|
52
55
|
end
|
53
56
|
|
54
57
|
it "deep nested tags with strings" do
|
55
58
|
gestalt{
|
56
59
|
p do
|
57
|
-
|
58
|
-
|
60
|
+
div do
|
61
|
+
'Hello, World'
|
62
|
+
end
|
59
63
|
end
|
60
|
-
end
|
61
64
|
}.should == '<p><div>Hello, World</div></p>'
|
62
65
|
end
|
63
66
|
|
@@ -109,6 +112,12 @@ describe "Gestalt" do
|
|
109
112
|
}.should == '<a href="http://example.org/?a=one&b=two">Click here</a>'
|
110
113
|
end
|
111
114
|
|
115
|
+
it 'takes text and attributes' do
|
116
|
+
gestalt {
|
117
|
+
a('Click here', :href => "http://example.org/?a=one&b=two")
|
118
|
+
}.should == '<a href="http://example.org/?a=one&b=two">Click here</a>'
|
119
|
+
end
|
120
|
+
|
112
121
|
it 'should accept symbols as attributes' do
|
113
122
|
input = gestalt{ input(:type => :text, :value => :one) }
|
114
123
|
|