ramaze 0.1.0 → 0.1.1
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/Rakefile +4 -12
- data/bin/ramaze +95 -171
- data/doc/CHANGELOG +387 -4
- data/doc/README +81 -13
- data/doc/meta/announcement.txt +51 -8
- data/doc/meta/configuration.txt +17 -34
- data/doc/meta/internals.txt +34 -4
- data/doc/migrate/1110_to_1111.txt +131 -0
- data/doc/readme_chunks/features.txt +81 -12
- data/doc/readme_chunks/installing.txt +0 -1
- data/doc/tutorial/todolist.html +293 -65
- data/doc/tutorial/{todolist.txt → todolist.mkd} +251 -51
- data/examples/blog/main.rb +1 -1
- data/examples/blog/src/model.rb +0 -1
- data/examples/hello.rb +2 -5
- data/examples/templates/template/external.haml +5 -5
- data/examples/templates/template/external.liquid +1 -1
- data/examples/templates/template/external.mab +8 -8
- data/examples/templates/template/external.rem +30 -0
- data/examples/templates/template/external.rhtml +6 -7
- data/examples/templates/template/external.zmr +13 -9
- data/examples/templates/template_amrita2.rb +8 -8
- data/examples/templates/template_erubis.rb +11 -11
- data/examples/templates/template_ezamar.rb +9 -11
- data/examples/templates/template_haml.rb +13 -13
- data/examples/templates/template_liquid.rb +10 -10
- data/examples/templates/template_markaby.rb +13 -10
- data/examples/templates/template_remarkably.rb +59 -0
- data/examples/todolist/main.rb +1 -7
- data/examples/todolist/src/controller/main.rb +26 -13
- data/examples/todolist/src/element/page.rb +5 -0
- data/examples/whywiki/main.rb +1 -1
- data/lib/proto/main.rb +0 -8
- data/lib/proto/public/css/ramaze_error.css +12 -4
- data/lib/proto/public/error.zmr +6 -25
- data/lib/ramaze.rb +35 -245
- data/lib/ramaze/action.rb +21 -0
- data/lib/ramaze/adapter.rb +94 -29
- data/lib/ramaze/adapter/base.rb +57 -0
- data/lib/ramaze/adapter/mongrel.rb +12 -19
- data/lib/ramaze/adapter/webrick.rb +21 -20
- data/lib/ramaze/cache.rb +47 -3
- data/lib/ramaze/cache/memcached.rb +22 -0
- data/lib/ramaze/cache/yaml_store.rb +19 -0
- data/lib/ramaze/controller.rb +47 -271
- data/lib/ramaze/controller/error.rb +43 -0
- data/lib/ramaze/controller/render.rb +90 -0
- data/lib/ramaze/controller/resolve.rb +147 -0
- data/lib/ramaze/dispatcher.rb +41 -9
- data/lib/ramaze/dispatcher/file.rb +1 -1
- data/lib/ramaze/global.rb +73 -158
- data/lib/ramaze/global/dsl.rb +29 -0
- data/lib/ramaze/global/globalstruct.rb +90 -0
- data/lib/ramaze/helper.rb +1 -1
- data/lib/ramaze/helper/aspect.rb +39 -179
- data/lib/ramaze/helper/cache.rb +8 -9
- data/lib/ramaze/helper/cgi.rb +23 -0
- data/lib/ramaze/helper/file.rb +3 -0
- data/lib/ramaze/helper/inform.rb +3 -0
- data/lib/ramaze/helper/link.rb +56 -63
- data/lib/ramaze/helper/nitroform.rb +4 -0
- data/lib/ramaze/helper/redirect.rb +1 -1
- data/lib/ramaze/inform.rb +6 -2
- data/lib/ramaze/inform/analogger.rb +5 -1
- data/lib/ramaze/inform/hub.rb +1 -1
- data/lib/ramaze/inform/informing.rb +7 -0
- data/lib/ramaze/snippets/kernel/aquire.rb +2 -0
- data/lib/ramaze/snippets/kernel/constant.rb +2 -0
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +2 -0
- data/lib/ramaze/snippets/object/traits.rb +4 -0
- data/lib/ramaze/snippets/openstruct/temp.rb +3 -0
- data/lib/ramaze/snippets/string/DIVIDE.rb +2 -0
- data/lib/ramaze/snippets/string/camel_case.rb +2 -0
- data/lib/ramaze/snippets/string/color.rb +2 -0
- data/lib/ramaze/snippets/string/each.rb +2 -0
- data/lib/ramaze/snippets/string/snake_case.rb +3 -0
- data/lib/ramaze/snippets/struct/fill.rb +8 -2
- data/lib/ramaze/snippets/struct/values_at.rb +16 -0
- data/lib/ramaze/snippets/symbol/to_proc.rb +3 -0
- data/lib/ramaze/sourcereload.rb +89 -0
- data/lib/ramaze/template.rb +21 -12
- data/lib/ramaze/template/amrita2.rb +6 -6
- data/lib/ramaze/template/erubis.rb +4 -9
- data/lib/ramaze/template/ezamar.rb +13 -57
- data/lib/ramaze/template/ezamar/element.rb +10 -12
- data/lib/ramaze/template/ezamar/engine.rb +40 -101
- data/lib/ramaze/template/ezamar/morpher.rb +3 -3
- data/lib/ramaze/template/haml.rb +3 -6
- data/lib/ramaze/template/liquid.rb +4 -9
- data/lib/ramaze/template/markaby.rb +16 -22
- data/lib/ramaze/template/remarkably.rb +28 -0
- data/lib/ramaze/tool/mime.rb +2 -0
- data/lib/ramaze/tool/record.rb +6 -0
- data/lib/ramaze/trinity/request.rb +44 -54
- data/lib/ramaze/trinity/response.rb +1 -1
- data/lib/ramaze/trinity/session.rb +15 -37
- data/lib/ramaze/version.rb +1 -1
- data/rake_tasks/gem.rake +2 -2
- data/rake_tasks/maintaince.rake +42 -1
- data/rake_tasks/spec.rake +45 -0
- data/spec/examples/caching.rb +1 -1
- data/spec/examples/simple.rb +1 -1
- data/spec/examples/templates/template_amrita2.rb +1 -0
- data/spec/examples/templates/template_erubis.rb +2 -1
- data/spec/examples/templates/template_ezamar.rb +1 -1
- data/spec/examples/templates/template_haml.rb +2 -1
- data/spec/examples/templates/template_liquid.rb +2 -1
- data/spec/examples/templates/template_markaby.rb +2 -1
- data/spec/examples/templates/template_remarkably.rb +22 -0
- data/spec/examples/todolist.rb +125 -0
- data/spec/helper.rb +2 -23
- data/spec/helper/minimal.rb +20 -0
- data/spec/helper/mock_http.rb +24 -30
- data/spec/helper/simple_http.rb +2 -2
- data/spec/helper/wrap.rb +6 -9
- data/spec/ramaze/adapter.rb +1 -1
- data/spec/ramaze/adapter/record.rb +31 -0
- data/spec/ramaze/cache.rb +41 -54
- data/spec/ramaze/controller.rb +121 -137
- data/spec/ramaze/controller/template/list.xhtml +1 -0
- data/spec/ramaze/controller/template/other/greet/other.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +27 -3
- data/spec/ramaze/element.rb +11 -7
- data/spec/ramaze/error.rb +1 -1
- data/spec/ramaze/gestalt.rb +2 -0
- data/spec/ramaze/helper/aspect.rb +30 -21
- data/spec/ramaze/helper/auth.rb +1 -1
- data/spec/ramaze/helper/cache.rb +2 -1
- data/spec/ramaze/helper/form.rb +14 -11
- data/spec/ramaze/helper/link.rb +18 -41
- data/spec/ramaze/localize.rb +29 -2
- data/spec/ramaze/morpher.rb +23 -12
- data/spec/ramaze/params.rb +46 -24
- data/spec/ramaze/request.rb +6 -2
- data/spec/ramaze/store/yaml.rb +5 -0
- data/spec/ramaze/template.rb +22 -27
- data/spec/ramaze/template/amrita2.rb +1 -2
- data/spec/ramaze/template/erubis.rb +1 -1
- data/spec/ramaze/template/ezamar.rb +1 -2
- data/spec/ramaze/template/haml.rb +2 -2
- data/spec/ramaze/template/haml/with_vars.haml +1 -1
- data/spec/ramaze/template/liquid.rb +1 -1
- data/spec/ramaze/template/markaby.rb +1 -1
- data/spec/ramaze/template/remarkably.rb +56 -0
- data/spec/ramaze/template/remarkably/external.rem +8 -0
- data/spec/ramaze/template/remarkably/sum.rem +1 -0
- metadata +38 -63
- data/doc/README.html +0 -637
- data/doc/allison/LICENSE +0 -184
- data/doc/allison/README +0 -37
- data/doc/allison/allison.css +0 -299
- data/doc/allison/allison.gif +0 -0
- data/doc/allison/allison.js +0 -307
- data/doc/allison/allison.rb +0 -287
- data/doc/allison/cache/BODY +0 -588
- data/doc/allison/cache/CLASS_INDEX +0 -4
- data/doc/allison/cache/CLASS_PAGE +0 -1
- data/doc/allison/cache/FILE_INDEX +0 -4
- data/doc/allison/cache/FILE_PAGE +0 -1
- data/doc/allison/cache/FONTS +0 -1
- data/doc/allison/cache/FR_INDEX_BODY +0 -1
- data/doc/allison/cache/IMGPATH +0 -1
- data/doc/allison/cache/INDEX +0 -1
- data/doc/allison/cache/JAVASCRIPT +0 -307
- data/doc/allison/cache/METHOD_INDEX +0 -4
- data/doc/allison/cache/METHOD_LIST +0 -1
- data/doc/allison/cache/SRC_PAGE +0 -1
- data/doc/allison/cache/STYLE +0 -321
- data/doc/allison/cache/URL +0 -1
- data/doc/changes.txt +0 -3375
- data/doc/changes.xml +0 -3378
- data/examples/todolist/conf/benchmark.yaml +0 -35
- data/examples/todolist/conf/debug.yaml +0 -34
- data/examples/todolist/conf/live.yaml +0 -33
- data/examples/todolist/conf/silent.yaml +0 -31
- data/examples/todolist/conf/stage.yaml +0 -33
- data/examples/todolist/public/css/coderay.css +0 -105
- data/examples/todolist/public/css/ramaze_error.css +0 -42
- data/lib/proto/conf/benchmark.yaml +0 -21
- data/lib/proto/conf/debug.yaml +0 -21
- data/lib/proto/conf/live.yaml +0 -21
- data/lib/proto/conf/silent.yaml +0 -21
- data/lib/proto/conf/stage.yaml +0 -21
- data/lib/proto/public/css/coderay.css +0 -105
- data/lib/ramaze/http_status.rb +0 -66
- data/lib/ramaze/snippets/hash/keys_to_sym.rb +0 -19
- data/lib/ramaze/snippets/kernel/method.rb +0 -26
- data/lib/ramaze/snippets/method/name.rb +0 -22
- data/lib/ramaze/snippets/ramaze/autoreload.rb +0 -135
- data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +0 -65
- data/spec/all.rb +0 -32
- data/spec/ramaze/conf/locale_de.yaml +0 -6
- data/spec/ramaze/conf/locale_en.yaml +0 -6
- data/spec/ramaze/dependencies.rb +0 -16
- data/spec/ramaze/global.rb +0 -44
data/spec/examples/caching.rb
CHANGED
data/spec/examples/simple.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'spec/helper'
|
|
2
2
|
|
|
3
|
+
testcase_requires 'erubis'
|
|
3
4
|
require 'examples/templates/template_erubis'
|
|
4
5
|
|
|
5
6
|
describe 'Template Erubis' do
|
|
@@ -7,7 +8,7 @@ describe 'Template Erubis' do
|
|
|
7
8
|
|
|
8
9
|
it '/' do
|
|
9
10
|
get('/').body.strip.should ==
|
|
10
|
-
"<a href=\"/\">
|
|
11
|
+
"<a href=\"/\">Home</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
%w[/internal /external].each do |url|
|
|
@@ -7,7 +7,7 @@ describe 'Template Ezamar' do
|
|
|
7
7
|
|
|
8
8
|
it '/' do
|
|
9
9
|
get('/').body.should ==
|
|
10
|
-
"<a href=\"/\">
|
|
10
|
+
"<a href=\"/\">Home</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
%w[/internal /external].each do |url|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'spec/helper'
|
|
2
2
|
|
|
3
|
+
testcase_requires 'haml'
|
|
3
4
|
require 'examples/templates/template_haml'
|
|
4
5
|
|
|
5
6
|
describe 'Template Haml' do
|
|
@@ -7,7 +8,7 @@ describe 'Template Haml' do
|
|
|
7
8
|
|
|
8
9
|
it '/' do
|
|
9
10
|
get('/').body.strip.should ==
|
|
10
|
-
"<a href=\"/\">
|
|
11
|
+
"<a href=\"/\">Home</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
%w[/internal /external].each do |url|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'spec/helper'
|
|
2
2
|
|
|
3
|
+
testcase_requires 'liquid'
|
|
3
4
|
require 'examples/templates/template_liquid'
|
|
4
5
|
|
|
5
6
|
describe 'Template Liquid' do
|
|
@@ -7,7 +8,7 @@ describe 'Template Liquid' do
|
|
|
7
8
|
|
|
8
9
|
it '/' do
|
|
9
10
|
get('/').body.strip.should ==
|
|
10
|
-
"<a href=\"/\">
|
|
11
|
+
"<a href=\"/\">Home</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
%w[/internal /external].each do |url|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'spec/helper'
|
|
2
2
|
|
|
3
|
+
testcase_requires 'markaby'
|
|
3
4
|
require 'examples/templates/template_markaby'
|
|
4
5
|
|
|
5
6
|
describe 'Template Markaby' do
|
|
@@ -7,7 +8,7 @@ describe 'Template Markaby' do
|
|
|
7
8
|
|
|
8
9
|
it '/' do
|
|
9
10
|
get('/').body.strip.should ==
|
|
10
|
-
"<a href=\"/\">
|
|
11
|
+
"<a href=\"/\">Home</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
%w[/internal /external].each do |url|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
testcase_requires 'remarkably/engines/html'
|
|
4
|
+
require 'examples/templates/template_remarkably'
|
|
5
|
+
|
|
6
|
+
describe 'Template Remarkably' do
|
|
7
|
+
ramaze
|
|
8
|
+
|
|
9
|
+
it '/' do
|
|
10
|
+
get('/').body.strip.should ==
|
|
11
|
+
"<a href=\"/\">Home</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
%w[/internal /external].each do |url|
|
|
15
|
+
it url do
|
|
16
|
+
html = get(url).body
|
|
17
|
+
html.should_not == nil
|
|
18
|
+
html.should =~ %r{<title>Template::Remarkably (internal|external)</title>}
|
|
19
|
+
html.should =~ %r{<h1>The (internal|external) Template for Remarkably</h1>}
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
testcase_requires 'hpricot'
|
|
4
|
+
|
|
5
|
+
$:.unshift 'examples/todolist'
|
|
6
|
+
require 'main'
|
|
7
|
+
|
|
8
|
+
# fix the paths to template and public for the spec
|
|
9
|
+
class MainController
|
|
10
|
+
template_root 'examples/todolist/template'
|
|
11
|
+
public_root 'examples/todolist/public'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe 'todolist' do
|
|
15
|
+
def h_get(*args)
|
|
16
|
+
Hpricot(get(*args).body)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def task_titles
|
|
20
|
+
doc = h_get('/')
|
|
21
|
+
doc.search("td[@class='title']").
|
|
22
|
+
map{|t| t.inner_html.strip}.sort
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def tasks
|
|
26
|
+
(h_get('/')/:tr)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def spectask
|
|
30
|
+
tasks.find do |task|
|
|
31
|
+
(task/:td).find do |td|
|
|
32
|
+
td['class'] == 'title' and
|
|
33
|
+
td.inner_html.strip == 'spectask'
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def spectask_status
|
|
39
|
+
spectask.search("td[@class='status']").inner_html.strip
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def error_on_page(url, response)
|
|
43
|
+
doc = h_get(url, :cookie => response.headers['Set-Cookie'])
|
|
44
|
+
|
|
45
|
+
error = doc.search("div[@class='error']")
|
|
46
|
+
error.inner_html.strip
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should start' do
|
|
50
|
+
ramaze :port => 7080
|
|
51
|
+
get('/').status.should == 200
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'should have no empty mainpage' do
|
|
55
|
+
get('/').body.should_not be_nil
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'should have two preset tasks' do
|
|
59
|
+
task_titles.should == %w[Laundry Wash\ dishes]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'should have a link to new tasks' do
|
|
63
|
+
doc = h_get('/')
|
|
64
|
+
link = (doc/:a).find{|a| a.inner_html == 'New Task'}
|
|
65
|
+
link['href'].should == '/new'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'should have a page to create new tasks' do
|
|
69
|
+
get('/new').body.should_not be_nil
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'should have a form to create a tasks on the /new page' do
|
|
73
|
+
doc = h_get('/new')
|
|
74
|
+
form = doc.at :form
|
|
75
|
+
form.should_not be_nil
|
|
76
|
+
input = form.at(:input)
|
|
77
|
+
input['type'].should == 'text'
|
|
78
|
+
input['name'].should == 'title'
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'should POST new task and redirect to /' do
|
|
82
|
+
result = post('/create', 'title' => 'spectask')
|
|
83
|
+
result.status.should == 303
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'should show have the new task' do
|
|
87
|
+
task_titles.should include('spectask')
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'should toggle the spectask' do
|
|
91
|
+
get('/close/spectask').status.should == 303
|
|
92
|
+
spectask.should_not be_nil
|
|
93
|
+
spectask_status.should == 'done'
|
|
94
|
+
get('/open/spectask').status.should == 303
|
|
95
|
+
spectask.should_not be_nil
|
|
96
|
+
spectask_status.should == 'not done'
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'should raise on modifying a not existing task' do
|
|
100
|
+
%w[open close].each do |action|
|
|
101
|
+
response = get("/#{action}/nothere", :referrer => "/")
|
|
102
|
+
response.status.should == 303
|
|
103
|
+
response.original_headers['Location'].should == '/'
|
|
104
|
+
error_on_page('/', response).should == "No such Task: `nothere'"
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it 'should delete the new task' do
|
|
109
|
+
get('/delete/spectask').status.should == 303
|
|
110
|
+
task_titles.should_not include('spectask')
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'should not create empty tasks but show a subtle error message' do
|
|
114
|
+
response = post('/create', 'title' => '', :referrer => "/new")
|
|
115
|
+
|
|
116
|
+
response.status.should == 303
|
|
117
|
+
response.original_headers['Location'].should == '/new'
|
|
118
|
+
|
|
119
|
+
error_on_page('/new', response).should == 'Please enter a title'
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
after :all do
|
|
123
|
+
FileUtils.rm('todolist.db') rescue nil
|
|
124
|
+
end
|
|
125
|
+
end
|
data/spec/helper.rb
CHANGED
|
@@ -1,27 +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 '
|
|
5
|
-
|
|
6
|
-
$:.unshift File.join(File.dirname(File.expand_path(__FILE__)), '..', 'lib')
|
|
7
|
-
$:.unshift '/home/manveru/prog/projects/rack/lib'
|
|
8
|
-
|
|
9
|
-
# $VERBOSE = 1
|
|
10
|
-
$context_runner = false
|
|
11
|
-
|
|
12
|
-
require 'ramaze'
|
|
13
|
-
|
|
14
|
-
begin
|
|
15
|
-
require 'rubygems'
|
|
16
|
-
rescue LoadError => ex
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
require 'spec'
|
|
20
|
-
if Spec::VERSION::FULL_VERSION < "0.9.1 (r1880)"
|
|
21
|
-
puts "please update rspec >= 0.9.1"
|
|
22
|
-
exit 1
|
|
23
|
-
end
|
|
24
|
-
|
|
4
|
+
require 'spec/helper/minimal'
|
|
25
5
|
require 'spec/helper/mock_http'
|
|
26
6
|
require 'spec/helper/simple_http'
|
|
27
7
|
require 'spec/helper/requester'
|
|
@@ -43,14 +23,13 @@ end
|
|
|
43
23
|
|
|
44
24
|
def ramaze_start hash = {}
|
|
45
25
|
options = {
|
|
46
|
-
:mode => :debug,
|
|
47
26
|
:adapter => false,
|
|
48
27
|
:run_loose => true,
|
|
49
28
|
:error_page => false,
|
|
50
29
|
:port => 7007,
|
|
51
30
|
:host => '127.0.0.1',
|
|
52
31
|
:force => true,
|
|
53
|
-
:
|
|
32
|
+
:origin => :spec,
|
|
54
33
|
}.merge(hash)
|
|
55
34
|
|
|
56
35
|
Ramaze.start(options)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'timeout'
|
|
2
|
+
|
|
3
|
+
base = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
|
4
|
+
$:.unshift base.gsub(/^#{Dir.pwd}/, '.')
|
|
5
|
+
|
|
6
|
+
# $VERBOSE = 1
|
|
7
|
+
$context_runner = false
|
|
8
|
+
|
|
9
|
+
require 'ramaze'
|
|
10
|
+
|
|
11
|
+
begin
|
|
12
|
+
require 'rubygems'
|
|
13
|
+
rescue LoadError => ex
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
require 'spec'
|
|
17
|
+
if Spec::VERSION::FULL_VERSION < "0.9.1 (r1880)"
|
|
18
|
+
puts "please update rspec >= 0.9.1"
|
|
19
|
+
exit 1
|
|
20
|
+
end
|
data/spec/helper/mock_http.rb
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
require 'ramaze'
|
|
2
2
|
require 'rack/mock'
|
|
3
3
|
|
|
4
|
-
module Ramaze
|
|
5
|
-
|
|
4
|
+
module Ramaze
|
|
5
|
+
module Adapter
|
|
6
|
+
class Fake < Base
|
|
7
|
+
end
|
|
6
8
|
end
|
|
7
9
|
end
|
|
8
10
|
|
|
@@ -16,34 +18,30 @@ module MockHTTP
|
|
|
16
18
|
:port => 80
|
|
17
19
|
)
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
FISHING = {
|
|
22
|
+
:input => :input,
|
|
23
|
+
:referrer => 'HTTP_REFERER',
|
|
24
|
+
:referer => 'HTTP_REFERER',
|
|
25
|
+
:cookie => 'HTTP_COOKIE',
|
|
26
|
+
}
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
input = query.delete(:input)
|
|
26
|
-
uri = create_url(path, query)
|
|
27
|
-
if input
|
|
28
|
-
mock_request.post(uri, DEFAULTS.merge(:input => input))
|
|
29
|
-
else
|
|
30
|
-
mock_request.post(uri, DEFAULTS)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
28
|
+
MOCK_REQUEST = ::Rack::MockRequest.new(Ramaze::Adapter::Fake)
|
|
33
29
|
|
|
34
|
-
def
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
def get(*args) mock_request(:get, *args) end
|
|
31
|
+
def put(*args) mock_request(:put, *args) end
|
|
32
|
+
def post(*args) mock_request(:post, *args) end
|
|
33
|
+
def delete(*args) mock_request(:delete, *args) end
|
|
34
|
+
|
|
35
|
+
def mock_request(meth, path, query = {})
|
|
36
|
+
uri, options = process_request(path, query)
|
|
37
|
+
MOCK_REQUEST.send(meth, uri, DEFAULTS.merge(options))
|
|
42
38
|
end
|
|
43
39
|
|
|
44
|
-
def
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
def process_request(path, query)
|
|
41
|
+
options = {}
|
|
42
|
+
FISHING.each{|key, value|
|
|
43
|
+
options[value] = query.delete(key)}
|
|
44
|
+
[create_url(path, query), options]
|
|
47
45
|
end
|
|
48
46
|
|
|
49
47
|
def create_url(path, query)
|
|
@@ -59,8 +57,4 @@ module MockHTTP
|
|
|
59
57
|
s + [CGI::escape(key) + "=" + CGI::escape(value)]
|
|
60
58
|
end.join('&')
|
|
61
59
|
end
|
|
62
|
-
|
|
63
|
-
def mock_request
|
|
64
|
-
::Rack::MockRequest.new(Ramaze::Adapter::Fake)
|
|
65
|
-
end
|
|
66
60
|
end
|
data/spec/helper/simple_http.rb
CHANGED
|
@@ -342,10 +342,10 @@ class SimpleHttp
|
|
|
342
342
|
# add custom request headers.
|
|
343
343
|
|
|
344
344
|
@request_headers.each {|key,value|
|
|
345
|
-
request[key]=value
|
|
345
|
+
request[key]=value
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
-
handle_response(request, http.request(request))
|
|
348
|
+
handle_response(request, http.request(request))
|
|
349
349
|
end
|
|
350
350
|
|
|
351
351
|
# internal
|
data/spec/helper/wrap.rb
CHANGED
|
@@ -134,26 +134,23 @@ class SpecFile
|
|
|
134
134
|
total = f[@passed + @failed] rescue nil
|
|
135
135
|
failed, passed = f[@failed], f[@passed]
|
|
136
136
|
color = :red
|
|
137
|
+
width = 22
|
|
137
138
|
|
|
138
139
|
if total_failure?
|
|
139
|
-
text = 'total failure'
|
|
140
|
+
text = 'total failure'.center(width)
|
|
140
141
|
elsif failed?
|
|
141
|
-
text = "#{total} specs - #{failed} failed"
|
|
142
|
+
text = "#{total} specs - #{failed} failed".rjust(width)
|
|
142
143
|
if @stdout =~ /Usually you should not worry about this failure, just install the/
|
|
143
144
|
lib = @stdout.scan(/^no such file to load -- (.*?)$/).flatten.first
|
|
144
|
-
text = "needs #{lib}"
|
|
145
|
+
text = "needs #{lib}".center(width)
|
|
145
146
|
@mark_passed = true
|
|
146
147
|
end
|
|
147
148
|
elsif (not @mark_passed) and succeeded?
|
|
148
149
|
color = :green
|
|
149
|
-
text = "#{total} specs - all passed"
|
|
150
|
+
text = "#{total} specs - all passed".rjust(width)
|
|
150
151
|
end
|
|
151
152
|
|
|
152
|
-
text.
|
|
153
|
-
text = (' ' + text + ' ').center(24)
|
|
154
|
-
text = "[#{text}]"
|
|
155
|
-
|
|
156
|
-
puts(text.send(color))
|
|
153
|
+
puts "[ #{text.send(color)} ]"
|
|
157
154
|
end
|
|
158
155
|
|
|
159
156
|
def long_summary
|
data/spec/ramaze/adapter.rb
CHANGED
|
@@ -10,7 +10,7 @@ class TCAdapterController < Ramaze::Controller
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
describe "Adapter" do
|
|
13
|
-
ramaze ramaze_options.merge( :port =>
|
|
13
|
+
ramaze ramaze_options.merge( :port => 7007, :spawn => 10, :mapping => {'/' => TCAdapterController} )
|
|
14
14
|
|
|
15
15
|
describe "multiple" do
|
|
16
16
|
it "simple request" do
|