ramaze 0.0.7 → 0.0.8
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 +52 -19
- data/bin/ramaze +19 -6
- data/doc/CHANGELOG +33 -0
- data/doc/COPYING +1 -1
- data/doc/FAQ +92 -0
- data/doc/GPL +340 -0
- data/doc/INSTALL +34 -0
- data/doc/ProjectInfo +53 -0
- data/doc/README +187 -110
- data/doc/readme_chunks/appendix.txt +13 -0
- data/doc/readme_chunks/examples.txt +38 -0
- data/doc/readme_chunks/features.txt +82 -0
- data/doc/readme_chunks/getting_help.txt +5 -0
- data/doc/readme_chunks/getting_started.txt +18 -0
- data/doc/readme_chunks/installing.txt +41 -0
- data/doc/readme_chunks/introduction.txt +18 -0
- data/doc/readme_chunks/principles.txt +41 -0
- data/doc/readme_chunks/thanks.txt +59 -0
- data/doc/tutorial/todolist.txt +546 -0
- data/examples/blog/main.rb +1 -1
- data/examples/blog/src/controller.rb +13 -11
- data/examples/blog/src/element.rb +11 -6
- data/examples/blog/src/model.rb +8 -23
- data/examples/blog/template/edit.xhtml +3 -1
- data/examples/blog/template/index.xhtml +4 -4
- data/examples/caching.rb +4 -4
- data/examples/element.rb +10 -7
- data/examples/hello.rb +3 -4
- data/examples/simple.rb +5 -3
- data/examples/templates/template/external.amrita +19 -0
- data/examples/templates/template/{external.rmze → external.zmr} +2 -2
- data/examples/templates/template_amrita2.rb +48 -0
- data/examples/templates/template_erubis.rb +5 -2
- data/examples/templates/{template_ramaze.rb → template_ezamar.rb} +13 -7
- data/examples/templates/template_haml.rb +4 -1
- data/examples/templates/template_liquid.rb +2 -1
- data/examples/templates/template_markaby.rb +2 -1
- data/examples/todolist/conf/benchmark.yaml +35 -0
- data/examples/todolist/conf/debug.yaml +34 -0
- data/examples/todolist/conf/live.yaml +33 -0
- data/examples/todolist/conf/silent.yaml +31 -0
- data/examples/todolist/conf/stage.yaml +33 -0
- data/examples/todolist/main.rb +18 -0
- data/examples/todolist/public/404.jpg +0 -0
- data/examples/todolist/public/css/coderay.css +105 -0
- data/examples/todolist/public/css/ramaze_error.css +42 -0
- data/{lib/proto → examples/todolist}/public/error.xhtml +0 -0
- data/examples/todolist/public/favicon.ico +0 -0
- data/examples/todolist/public/js/jquery.js +1923 -0
- data/examples/todolist/public/ramaze.png +0 -0
- data/examples/todolist/src/controller/main.rb +56 -0
- data/examples/todolist/src/element/page.rb +26 -0
- data/examples/todolist/src/model.rb +14 -0
- data/examples/todolist/template/index.xhtml +17 -0
- data/examples/todolist/template/new.xhtml +7 -0
- data/examples/todolist/todolist.db +9 -0
- data/examples/whywiki/main.rb +3 -8
- data/examples/whywiki/template/show.xhtml +4 -0
- data/lib/proto/public/error.zmr +77 -0
- data/lib/proto/src/controller/main.rb +2 -1
- data/lib/proto/src/element/page.rb +2 -1
- data/lib/proto/src/model.rb +3 -2
- data/lib/ramaze.rb +7 -9
- data/lib/ramaze/adapter.rb +51 -0
- data/lib/ramaze/adapter/cgi.rb +23 -0
- data/lib/ramaze/adapter/fcgi.rb +22 -0
- data/lib/ramaze/adapter/mongrel.rb +7 -86
- data/lib/ramaze/adapter/webrick.rb +14 -133
- data/lib/ramaze/cache/memcached.rb +6 -0
- data/lib/ramaze/cache/yaml_store.rb +3 -1
- data/lib/ramaze/controller.rb +292 -2
- data/lib/ramaze/dispatcher.rb +85 -213
- data/lib/ramaze/error.rb +10 -0
- data/lib/ramaze/global.rb +8 -0
- data/lib/ramaze/helper/aspect.rb +30 -7
- data/lib/ramaze/helper/auth.rb +16 -9
- data/lib/ramaze/helper/cache.rb +40 -35
- data/lib/ramaze/helper/feed.rb +1 -1
- data/lib/ramaze/helper/flash.rb +34 -0
- data/lib/ramaze/helper/link.rb +8 -2
- data/lib/ramaze/helper/openid.rb +63 -0
- data/lib/ramaze/helper/redirect.rb +12 -11
- data/lib/ramaze/helper/stack.rb +5 -7
- data/lib/ramaze/inform.rb +12 -1
- data/lib/ramaze/snippets/kernel/aquire.rb +1 -1
- data/lib/ramaze/snippets/kernel/{self_method.rb → method.rb} +3 -18
- data/lib/ramaze/snippets/kernel/{rescue_require.rb → pretty_inspect.rb} +7 -6
- data/lib/ramaze/snippets/method/name.rb +22 -0
- data/lib/ramaze/snippets/{kernel → ramaze}/autoreload.rb +0 -0
- data/lib/ramaze/snippets/ramaze/caller_info.rb +14 -0
- data/lib/ramaze/snippets/{kernel → ramaze}/caller_lines.rb +3 -10
- data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +49 -23
- data/lib/ramaze/snippets/string/DIVIDE.rb +0 -1
- data/lib/ramaze/store/default.rb +58 -2
- data/lib/ramaze/store/yaml.rb +161 -0
- data/lib/ramaze/template.rb +27 -86
- data/lib/ramaze/template/amrita2.rb +14 -19
- data/lib/ramaze/template/erubis.rb +15 -38
- data/lib/ramaze/template/ezamar.rb +100 -0
- data/lib/ramaze/template/ezamar/element.rb +166 -0
- data/lib/ramaze/template/ezamar/engine.rb +124 -0
- data/lib/ramaze/template/ezamar/morpher.rb +155 -0
- data/lib/ramaze/template/haml.rb +16 -43
- data/lib/ramaze/template/liquid.rb +11 -51
- data/lib/ramaze/template/markaby.rb +44 -42
- data/lib/ramaze/tool/mime.rb +18 -0
- data/lib/ramaze/tool/mime_types.yaml +615 -0
- data/lib/ramaze/trinity/request.rb +20 -196
- data/lib/ramaze/trinity/response.rb +4 -33
- data/lib/ramaze/trinity/session.rb +150 -72
- data/lib/ramaze/version.rb +1 -1
- data/spec/adapter_spec.rb +20 -0
- data/spec/public/favicon.ico +0 -0
- data/spec/public/ramaze.png +0 -0
- data/spec/public/test_download.css +141 -0
- data/spec/{tc_request.rb → request_tc_helper.rb} +45 -21
- data/spec/spec_all.rb +77 -34
- data/spec/spec_helper.rb +8 -157
- data/spec/spec_helper_context.rb +72 -0
- data/spec/spec_helper_requester.rb +52 -0
- data/spec/spec_helper_simple_http.rb +433 -0
- data/spec/tc_adapter_mongrel.rb +3 -15
- data/spec/tc_adapter_webrick.rb +4 -14
- data/spec/tc_cache.rb +3 -5
- data/spec/tc_controller.rb +22 -12
- data/spec/tc_dependencies.rb +13 -0
- data/spec/tc_element.rb +8 -7
- data/spec/tc_error.rb +13 -7
- data/spec/tc_global.rb +16 -18
- data/spec/tc_helper_aspect.rb +2 -4
- data/spec/tc_helper_auth.rb +15 -14
- data/spec/tc_helper_cache.rb +5 -7
- data/spec/tc_helper_feed.rb +0 -2
- data/spec/tc_helper_flash.rb +103 -0
- data/spec/tc_helper_form.rb +4 -6
- data/spec/tc_helper_link.rb +1 -3
- data/spec/tc_helper_redirect.rb +23 -8
- data/spec/tc_helper_stack.rb +31 -15
- data/spec/tc_morpher.rb +1 -3
- data/spec/tc_params.rb +48 -7
- data/spec/tc_request_mongrel.rb +9 -0
- data/spec/tc_request_webrick.rb +5 -0
- data/spec/tc_session.rb +41 -25
- data/spec/tc_store.rb +55 -6
- data/spec/tc_store_yaml.rb +71 -0
- data/spec/tc_template_amrita2.rb +3 -3
- data/spec/tc_template_erubis.rb +2 -3
- data/spec/{tc_template_ramaze.rb → tc_template_ezamar.rb} +15 -5
- data/spec/tc_template_haml.rb +4 -3
- data/spec/tc_template_liquid.rb +3 -4
- data/spec/tc_template_markaby.rb +4 -6
- data/spec/tc_tidy.rb +1 -3
- data/spec/template/amrita2/{data.html → data.amrita} +0 -0
- data/spec/template/amrita2/{index.html → index.amrita} +0 -0
- data/spec/template/amrita2/{sum.html → sum.amrita} +0 -0
- data/spec/template/ezamar/another/long/action.zmr +1 -0
- data/spec/template/ezamar/combined.zmr +1 -0
- data/spec/template/{ramaze/file_only.rmze → ezamar/file_only.zmr} +0 -0
- data/spec/template/{ramaze/index.rmze → ezamar/index.zmr} +0 -0
- data/spec/template/{ramaze/nested.rmze → ezamar/nested.zmr} +0 -0
- data/spec/template/ezamar/some__long__action.zmr +1 -0
- data/spec/template/{ramaze/sum.rmze → ezamar/sum.zmr} +0 -0
- metadata +181 -123
- data/doc/allison/LICENSE +0 -184
- data/doc/allison/README +0 -37
- data/doc/allison/allison.css +0 -300
- 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 -322
- data/doc/allison/cache/URL +0 -1
- data/doc/changes.txt +0 -2021
- data/doc/changes.xml +0 -2024
- data/lib/ramaze/snippets/kernel/silently.rb +0 -13
- data/lib/ramaze/snippets/thread/deadQUESTIONMARK.rb +0 -11
- data/lib/ramaze/template/haml/actionview_stub.rb +0 -20
- data/lib/ramaze/template/ramaze.rb +0 -177
- data/lib/ramaze/template/ramaze/element.rb +0 -166
- data/lib/ramaze/template/ramaze/morpher.rb +0 -156
- data/spec/tc_test.rb +0 -17
data/lib/ramaze/version.rb
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
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 TCAdapterController < Ramaze::Controller
|
|
7
|
+
def index
|
|
8
|
+
"The index"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context "Adapter" do
|
|
13
|
+
ramaze ramaze_options.merge( :port => '7007..7010', :mapping => {'/' => TCAdapterController} )
|
|
14
|
+
|
|
15
|
+
context "multiple" do
|
|
16
|
+
specify "simple request" do
|
|
17
|
+
get('/').should == "The index"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/*#############################################################
|
|
2
|
+
* Name: Light
|
|
3
|
+
* Date: 2006-08-20
|
|
4
|
+
* Description: Bright and smooth.
|
|
5
|
+
* Author: Viktor Persson
|
|
6
|
+
* URL: http://templates.arcsin.se
|
|
7
|
+
*
|
|
8
|
+
* Feel free to use and modify but please provide credits.
|
|
9
|
+
* #############################################################*/
|
|
10
|
+
|
|
11
|
+
/* standard elements */
|
|
12
|
+
{
|
|
13
|
+
margin: 0;
|
|
14
|
+
padding: 0;
|
|
15
|
+
}
|
|
16
|
+
a {
|
|
17
|
+
color: #567;
|
|
18
|
+
}
|
|
19
|
+
a:hover {
|
|
20
|
+
color: #28E;
|
|
21
|
+
}
|
|
22
|
+
body {
|
|
23
|
+
background: #F2F2F2 url(/media/bg.gif) repeat-y center top;
|
|
24
|
+
color: #555A60;
|
|
25
|
+
font: normal 62.5% "Lucida Sans Unicode",sans-serif;
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
p,cite,code,ul {
|
|
29
|
+
font-size: 1.0em;
|
|
30
|
+
padding-bottom: 1.2em;
|
|
31
|
+
}
|
|
32
|
+
h1 {
|
|
33
|
+
font-size: 1.4em;
|
|
34
|
+
margin-bottom: 4px;
|
|
35
|
+
}
|
|
36
|
+
li {
|
|
37
|
+
list-style: url(/media/li.gif);
|
|
38
|
+
margin-left: 18px;
|
|
39
|
+
}
|
|
40
|
+
code {
|
|
41
|
+
background: url(/media/bgcode.gif);
|
|
42
|
+
border: 1px solid #F6F6F6;
|
|
43
|
+
color: #666;
|
|
44
|
+
display: block;
|
|
45
|
+
font: normal 1.1em "Lucida Sans Unicode",serif;
|
|
46
|
+
margin-bottom: 12px;
|
|
47
|
+
padding: 8px 10px;
|
|
48
|
+
white-space: pre;
|
|
49
|
+
}
|
|
50
|
+
cite {
|
|
51
|
+
background: url(/media/quote.gif) no-repeat;
|
|
52
|
+
color: #456;
|
|
53
|
+
display: block;
|
|
54
|
+
font: normal 1.4em "Lucida Sans Unicode",serif;
|
|
55
|
+
padding-left: 28px;
|
|
56
|
+
}
|
|
57
|
+
h1,h2,h3 {
|
|
58
|
+
color: #579;
|
|
59
|
+
padding-top: 6px;
|
|
60
|
+
}
|
|
61
|
+
*
|
|
62
|
+
/* misc */
|
|
63
|
+
.clearer {
|
|
64
|
+
clear: both;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* structure */
|
|
68
|
+
.container {
|
|
69
|
+
margin: 0 auto;
|
|
70
|
+
width: 730px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* title */
|
|
74
|
+
.title {
|
|
75
|
+
float: left;
|
|
76
|
+
margin-top: 22px;
|
|
77
|
+
text-align: center;
|
|
78
|
+
width: 220px;
|
|
79
|
+
}
|
|
80
|
+
.title h1 {
|
|
81
|
+
font: normal 2em Verdana,sans-serif;
|
|
82
|
+
}
|
|
83
|
+
.title h2 {
|
|
84
|
+
color: #999;
|
|
85
|
+
font: normal 1.1em Verdana,sans-serif;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* navigation */
|
|
89
|
+
.navigation {
|
|
90
|
+
background: url(/media/holder.jpg) no-repeat;
|
|
91
|
+
height: 100px;
|
|
92
|
+
padding: 0 16px;
|
|
93
|
+
}
|
|
94
|
+
.navigation a {
|
|
95
|
+
border-left: 1px solid #DDD;
|
|
96
|
+
border-right: 1px solid #FFF;
|
|
97
|
+
color: #89A;
|
|
98
|
+
float: right;
|
|
99
|
+
font: bold 1.2em "Trebuchet MS",sans-serif;
|
|
100
|
+
margin-top: 9px;
|
|
101
|
+
padding: 58px 18px 8px;
|
|
102
|
+
text-align: center;
|
|
103
|
+
text-decoration: none;
|
|
104
|
+
}
|
|
105
|
+
.navigation a:hover {
|
|
106
|
+
background: #FFF url(/media/navhover.gif) repeat-x;
|
|
107
|
+
color: #28E;
|
|
108
|
+
padding: 56px 18px 10px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* holders */
|
|
112
|
+
.holder {
|
|
113
|
+
background: url(/media/bgholder.jpg) repeat-y;
|
|
114
|
+
padding: 0 32px;
|
|
115
|
+
}
|
|
116
|
+
.holder_top,.footer {
|
|
117
|
+
clear: both;
|
|
118
|
+
background: url(/media/holder.jpg) no-repeat;
|
|
119
|
+
height: 40px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* footer */
|
|
123
|
+
.footer {
|
|
124
|
+
background-position: left bottom;
|
|
125
|
+
color: #666;
|
|
126
|
+
font-size: 1.1em;
|
|
127
|
+
text-align: center;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
form {
|
|
131
|
+
text-align: right;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
form input {
|
|
135
|
+
width: 95%;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
form textarea {
|
|
139
|
+
width: 95%;
|
|
140
|
+
height: 30em;
|
|
141
|
+
}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
require 'spec/spec_helper'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
class TCRequestController < Ramaze::Controller
|
|
7
|
+
trait :public => 'spec/public'
|
|
7
8
|
|
|
8
|
-
class TCRequestController < Template::Ramaze
|
|
9
9
|
def is_post() request.post?.to_s end
|
|
10
10
|
def is_get() request.get?.to_s end
|
|
11
11
|
def is_put() request.put?.to_s end
|
|
@@ -31,11 +31,6 @@ class TCRequestController < Template::Ramaze
|
|
|
31
31
|
request['foo']
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def test_get_set(arg)
|
|
35
|
-
request['foo'] = arg
|
|
36
|
-
request['foo']
|
|
37
|
-
end
|
|
38
|
-
|
|
39
34
|
def test_headers
|
|
40
35
|
end
|
|
41
36
|
|
|
@@ -45,9 +40,10 @@ class TCRequestController < Template::Ramaze
|
|
|
45
40
|
end
|
|
46
41
|
|
|
47
42
|
context "Request" do
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
options = ramaze_options rescue {:adapter => :webrick}
|
|
44
|
+
ramaze options.merge( :mapping => {'/' => TCRequestController})
|
|
50
45
|
|
|
46
|
+
context "POST" do
|
|
51
47
|
specify "give me the result of request.post?" do
|
|
52
48
|
post("is_post").should == 'true'
|
|
53
49
|
end
|
|
@@ -64,9 +60,11 @@ context "Request" do
|
|
|
64
60
|
|
|
65
61
|
context "PUT" do
|
|
66
62
|
specify "put a ressource" do
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
image = 'favicon.ico'
|
|
64
|
+
image_path = File.join('spec', 'public', image)
|
|
65
|
+
address = "http://localhost:7007/put_inspect/#{image}"
|
|
66
|
+
response = `curl -S -s -T #{image_path} #{address}`
|
|
67
|
+
file = File.read(image_path)
|
|
70
68
|
|
|
71
69
|
response[1..-2].should == file
|
|
72
70
|
end
|
|
@@ -88,7 +86,8 @@ context "Request" do
|
|
|
88
86
|
end
|
|
89
87
|
|
|
90
88
|
specify "give me back what i gave" do
|
|
91
|
-
|
|
89
|
+
params = {'one' => 'two', 'three' => 'four'}
|
|
90
|
+
get("/get_inspect", params).should == params.inspect
|
|
92
91
|
end
|
|
93
92
|
|
|
94
93
|
specify "my ip" do
|
|
@@ -96,16 +95,41 @@ context "Request" do
|
|
|
96
95
|
end
|
|
97
96
|
|
|
98
97
|
specify "request[key]" do
|
|
99
|
-
get('test_get
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
specify "request[key] = value" do
|
|
103
|
-
get('test_get_set/bar').should == 'bar'
|
|
98
|
+
get('/test_get', 'foo' => 'bar').should == 'bar'
|
|
104
99
|
end
|
|
100
|
+
end
|
|
105
101
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
context "send files" do
|
|
103
|
+
specify "threaded concurrently" do
|
|
104
|
+
css_path = 'test_download.css'
|
|
105
|
+
image_path = 'favicon.ico'
|
|
106
|
+
static_css = File.read("spec/public/#{css_path}").strip
|
|
107
|
+
static_image = File.read("spec/public/#{image_path}").strip
|
|
108
|
+
|
|
109
|
+
images = []
|
|
110
|
+
csses = []
|
|
111
|
+
threads = []
|
|
112
|
+
|
|
113
|
+
times = 100
|
|
114
|
+
|
|
115
|
+
times.times do
|
|
116
|
+
threads << Thread.new do
|
|
117
|
+
csses << get(css_path)
|
|
118
|
+
images << get(image_path)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
threads.each do |t|
|
|
123
|
+
t.join
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
images.each do |image|
|
|
127
|
+
image.should == static_image
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
csses.each do |css|
|
|
131
|
+
css.should == static_css
|
|
132
|
+
end
|
|
109
133
|
end
|
|
110
134
|
end
|
|
111
135
|
end
|
data/spec/spec_all.rb
CHANGED
|
@@ -2,12 +2,29 @@
|
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
3
|
|
|
4
4
|
require 'pp'
|
|
5
|
+
|
|
6
|
+
begin
|
|
7
|
+
require 'systemu'
|
|
8
|
+
rescue LoadError
|
|
9
|
+
puts "Please install systemu for better-looking results"
|
|
10
|
+
|
|
11
|
+
# small drop-in replacement for systemu... far from perfect though, so please
|
|
12
|
+
# install the library
|
|
13
|
+
|
|
14
|
+
def systemu command
|
|
15
|
+
stdout = `#{command} 2>&1`
|
|
16
|
+
status, stdout, stderr = $?, stdout, ''
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
5
20
|
begin
|
|
6
21
|
require 'term/ansicolor'
|
|
7
22
|
class String
|
|
8
23
|
include Term::ANSIColor
|
|
9
24
|
end
|
|
10
25
|
rescue LoadError
|
|
26
|
+
puts "Please install term-ansicolor for better-looking results"
|
|
27
|
+
|
|
11
28
|
class String
|
|
12
29
|
|
|
13
30
|
# this will be set in case term/ansicolor cannot be
|
|
@@ -24,50 +41,76 @@ end
|
|
|
24
41
|
|
|
25
42
|
$stdout.sync = true
|
|
26
43
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
total_specs = 0
|
|
45
|
+
total_fails = 0
|
|
46
|
+
failed = {}
|
|
47
|
+
specs = Dir[File.join('spec', 'tc_*.rb')].sort
|
|
48
|
+
width = specs.sort_by{|s| s.size }.last.size
|
|
49
|
+
|
|
50
|
+
result_format = lambda do |str|
|
|
51
|
+
str = " #{ str } ".center(22, '=')
|
|
52
|
+
"[ #{str} ]"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
specs.each do |spec|
|
|
56
|
+
print "Running #{spec}... ".ljust(width + 20)
|
|
57
|
+
status, stdout, stderr = systemu("ruby #{spec}")
|
|
58
|
+
hash = {:status => status, :stdout => stdout, :stderr => stderr}
|
|
59
|
+
|
|
60
|
+
if stdout =~ /Usually you should not worry about this failure, just install the/
|
|
61
|
+
|
|
62
|
+
lib = stdout.scan(/^no such file to load -- (.*?)$/).flatten.first
|
|
63
|
+
print result_format["needs #{lib}"].red
|
|
64
|
+
|
|
65
|
+
elsif status.exitstatus.nonzero? or stdout.empty? or not stderr.empty?
|
|
66
|
+
|
|
67
|
+
failed[spec] = hash
|
|
68
|
+
print result_format['failed'].red
|
|
69
|
+
|
|
70
|
+
else
|
|
71
|
+
stdout.each do |line|
|
|
72
|
+
if line =~ /(\d+) specifications?, (\d+) failures?/
|
|
73
|
+
s, f = $1.to_i, $2.to_i
|
|
74
|
+
ss, sf = s.to_s.rjust(3), f.to_s.rjust(3)
|
|
75
|
+
|
|
76
|
+
total_specs += s
|
|
77
|
+
total_fails += f
|
|
78
|
+
|
|
79
|
+
message = "[ #{ss} specs - "
|
|
80
|
+
|
|
81
|
+
if f.nonzero?
|
|
82
|
+
failed[spec] = hash
|
|
83
|
+
print((message << "#{f} failed ]").red)
|
|
84
|
+
else
|
|
85
|
+
print((message << "all passed ]").green)
|
|
86
|
+
end
|
|
50
87
|
end
|
|
51
88
|
end
|
|
52
89
|
end
|
|
90
|
+
puts
|
|
53
91
|
end
|
|
54
92
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
puts "
|
|
93
|
+
failed.each do |name, hash|
|
|
94
|
+
status, stdout, stderr = hash.values_at(:status, :stdout, :stderr)
|
|
95
|
+
|
|
96
|
+
puts "[ #{name} ]".center(80, '-')
|
|
97
|
+
puts "ExitStatus:".yellow
|
|
98
|
+
pp status
|
|
99
|
+
puts
|
|
100
|
+
puts "StdOut:".yellow
|
|
101
|
+
puts stdout
|
|
59
102
|
puts
|
|
60
|
-
puts
|
|
61
|
-
puts
|
|
103
|
+
puts "StdErr:".yellow
|
|
104
|
+
puts stderr
|
|
62
105
|
end
|
|
63
106
|
|
|
64
107
|
puts
|
|
65
|
-
puts "#{
|
|
108
|
+
puts "#{total_specs} specifications, #{total_fails} failures"
|
|
66
109
|
puts
|
|
67
110
|
|
|
68
|
-
|
|
69
|
-
puts "These failed: #{problems}"
|
|
70
|
-
else
|
|
111
|
+
if failed.empty?
|
|
71
112
|
puts "No failing specifications, let's add some tests!"
|
|
113
|
+
puts
|
|
114
|
+
else
|
|
115
|
+
puts "These failed: #{failed.keys.join(', ')}"
|
|
72
116
|
end
|
|
73
|
-
puts
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
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 'timeout'
|
|
5
|
+
|
|
4
6
|
$:.unshift File.join(File.dirname(File.expand_path(__FILE__)), '..', 'lib')
|
|
5
7
|
|
|
6
8
|
require 'ramaze'
|
|
@@ -12,162 +14,11 @@ end
|
|
|
12
14
|
|
|
13
15
|
require 'spec'
|
|
14
16
|
|
|
15
|
-
require '
|
|
16
|
-
require '
|
|
17
|
-
require '
|
|
18
|
-
|
|
19
|
-
# provides get/post methods for use inside your
|
|
20
|
-
# Spec::Runner
|
|
21
|
-
|
|
22
|
-
module StatelessContext
|
|
23
|
-
def raw_get url = ''
|
|
24
|
-
url = "http://localhost:#{Ramaze::Global.port}" + "/#{url}".squeeze('/')
|
|
25
|
-
Timeout.timeout(1) do
|
|
26
|
-
open(url)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# just GET an [url]
|
|
31
|
-
|
|
32
|
-
def get url = ''
|
|
33
|
-
raw_get(url).read.strip
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# POST to an url the given params
|
|
37
|
-
|
|
38
|
-
def post url = '', params = {}
|
|
39
|
-
url = "http://localhost:#{Ramaze::Global.port}" + "/#{url}".squeeze('/')
|
|
40
|
-
uri = URI.parse(url)
|
|
41
|
-
Timeout.timeout(1) do
|
|
42
|
-
res = Net::HTTP.post_form(uri, params)
|
|
43
|
-
result = res.body.to_s.strip
|
|
44
|
-
#p res => result
|
|
45
|
-
result
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
include StatelessContext
|
|
51
|
-
|
|
52
|
-
# provides a convinient Context for your requests
|
|
53
|
-
# so you can simulate sessions and consecutive requests
|
|
54
|
-
|
|
55
|
-
class Context
|
|
56
|
-
attr_accessor :cookie
|
|
57
|
-
|
|
58
|
-
# initialize the context with an url to obtain your cookie
|
|
59
|
-
|
|
60
|
-
def initialize(url = '/', base = nil)
|
|
61
|
-
@base = base
|
|
62
|
-
@cookie_url = with_base(url)
|
|
63
|
-
@history = []
|
|
64
|
-
reset
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# combines the url given with the @base given, sanitizes
|
|
68
|
-
# the result a bit.
|
|
69
|
-
|
|
70
|
-
def with_base(url = '/')
|
|
71
|
-
url = url.to_s.squeeze('/')
|
|
72
|
-
if @base
|
|
73
|
-
unless url[0...@base.size] == @base
|
|
74
|
-
url = [@base, url].join('/')
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
url.strip.squeeze('/')
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
# reset your session
|
|
81
|
-
|
|
82
|
-
def reset(url = @cookie_url)
|
|
83
|
-
@cookie = obtain_cookie( with_base(url) )
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# just get a cookie, doesn't reset your session
|
|
87
|
-
|
|
88
|
-
def obtain_cookie(url = @cookie_url)
|
|
89
|
-
open(url).meta['set-cookie']
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# our custom little open, take into account parameters and
|
|
93
|
-
# the port the server is running on
|
|
94
|
-
# the parameters are used for the session but could use
|
|
95
|
-
# any headers you wanna use for the request
|
|
96
|
-
|
|
97
|
-
def open url, hash = {}
|
|
98
|
-
unless @history.empty?
|
|
99
|
-
hash = {'HTTP_REFERER' => @history.last}.merge(hash)
|
|
100
|
-
end
|
|
101
|
-
url = with_base(url)
|
|
102
|
-
uri = "http://localhost:#{Global.port}#{url}"
|
|
103
|
-
puts "GET: #{uri}"
|
|
104
|
-
result = Kernel.open(uri, hash)
|
|
105
|
-
@history << url
|
|
106
|
-
result
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# use Context#open with our cookie
|
|
110
|
-
# you can pass any header you want with an hash
|
|
111
|
-
|
|
112
|
-
def get url = '', headers = {}
|
|
113
|
-
open(url, {'Set-Cookie' => @cookie}.merge(headers)).read
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
# Net::HTTP.post_form with the cookie
|
|
117
|
-
# params are for the POST-parameters
|
|
118
|
-
|
|
119
|
-
def post url_param = '', params = {}, limit = 10
|
|
120
|
-
raise "Too many redirections" if limit <= 0
|
|
121
|
-
|
|
122
|
-
params['Set-Cookie'] = @cookie
|
|
123
|
-
url = "http://localhost:#{Ramaze::Global.port}"
|
|
124
|
-
new = with_base("/#{url_param.gsub(url, '')}")
|
|
125
|
-
url << new
|
|
126
|
-
|
|
127
|
-
uri = URI.parse(url)
|
|
128
|
-
puts "POST: #{uri}"
|
|
129
|
-
res = Net::HTTP.post_form(uri, params)
|
|
130
|
-
@history << uri.path
|
|
131
|
-
|
|
132
|
-
case res
|
|
133
|
-
when Net::HTTPSuccess
|
|
134
|
-
result = res.body.to_s.strip
|
|
135
|
-
result
|
|
136
|
-
when Net::HTTPRedirection
|
|
137
|
-
post(res['location'], params, limit - 1)
|
|
138
|
-
else
|
|
139
|
-
res.error!
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
# like post, but seval the returned string
|
|
144
|
-
# very comfortable if you just do {'foo' => 'bar'}.inspect in your template
|
|
145
|
-
# and in your specs you can
|
|
146
|
-
# epost('/foo').should == {'foo' => 'bar'}
|
|
147
|
-
|
|
148
|
-
def epost opt = '', params = {}
|
|
149
|
-
seval(post(opt, params))
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
# like get, but seval the returned string
|
|
153
|
-
# very comfortable if you just do {'foo' => 'bar'}.inspect in your template
|
|
154
|
-
# and in your specs you can
|
|
155
|
-
# eget('/foo').should == {'foo' => 'bar'}
|
|
17
|
+
require 'spec/spec_helper_simple_http'
|
|
18
|
+
require 'spec/spec_helper_requester'
|
|
19
|
+
require 'spec/spec_helper_context'
|
|
156
20
|
|
|
157
|
-
|
|
158
|
-
seval(get(opt))
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
# a very simple wrapper for eval that returns the
|
|
162
|
-
# error-message instead of the result of the eval
|
|
163
|
-
# in case there are errors.
|
|
164
|
-
|
|
165
|
-
def seval(string)
|
|
166
|
-
eval(string)
|
|
167
|
-
rescue Object => ex
|
|
168
|
-
ex.message
|
|
169
|
-
end
|
|
170
|
-
end
|
|
21
|
+
include Requester
|
|
171
22
|
|
|
172
23
|
module Spec::Runner::ContextEval::ModuleMethods
|
|
173
24
|
|
|
@@ -177,7 +28,7 @@ module Spec::Runner::ContextEval::ModuleMethods
|
|
|
177
28
|
def ramaze_start hash = {}
|
|
178
29
|
options = {
|
|
179
30
|
:mode => :debug,
|
|
180
|
-
:adapter => :
|
|
31
|
+
:adapter => :mongrel,
|
|
181
32
|
:run_loose => true,
|
|
182
33
|
:error_page => false,
|
|
183
34
|
:port => 7007,
|
|
@@ -210,6 +61,6 @@ rescue LoadError => ex
|
|
|
210
61
|
puts ex
|
|
211
62
|
puts "Can't run #{$0}: #{ex}"
|
|
212
63
|
puts "Usually you should not worry about this failure, just install the"
|
|
213
|
-
puts "library and try again (if you want to use that
|
|
64
|
+
puts "library and try again (if you want to use that feature later on)"
|
|
214
65
|
exit
|
|
215
66
|
end
|