mango 0.1.1 → 0.5.0.beta1
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/.gitignore +6 -0
- data/.yardopts +6 -0
- data/README.mdown +62 -29
- data/Rakefile +62 -0
- data/VERSION +1 -0
- data/bin/mango +5 -0
- data/doc/HISTORY.mdown +71 -0
- data/doc/ROAD-MAP.mdown +10 -0
- data/lib/mango.rb +7 -0
- data/lib/mango/application.rb +334 -0
- data/lib/mango/content_page.rb +193 -0
- data/lib/mango/dependencies.rb +125 -0
- data/lib/mango/flavored_markdown.rb +82 -0
- data/lib/mango/rack/debugger.rb +22 -0
- data/lib/mango/runner.rb +95 -0
- data/lib/mango/templates/Gemfile +4 -0
- data/lib/mango/templates/README.md +1 -0
- data/lib/mango/templates/config.ru +4 -0
- data/lib/mango/templates/content/index.md +5 -0
- data/lib/mango/templates/themes/default/public/images/particles.gif +0 -0
- data/lib/mango/templates/themes/default/public/javascripts/fireworks.js +546 -0
- data/lib/mango/templates/themes/default/public/javascripts/timer.js +5 -0
- data/lib/mango/templates/themes/default/public/robots.txt +5 -0
- data/lib/mango/templates/themes/default/public/styles/fireworks.css +55 -0
- data/lib/mango/templates/themes/default/public/styles/reset.css +54 -0
- data/lib/mango/templates/themes/default/styles/screen.sass +17 -0
- data/lib/mango/templates/themes/default/views/404.haml +21 -0
- data/lib/mango/templates/themes/default/views/layout.haml +20 -0
- data/lib/mango/templates/themes/default/views/page.haml +3 -0
- data/lib/mango/version.rb +6 -0
- data/mango.gemspec +35 -0
- data/spec/app_root/content/about/index.haml +1 -0
- data/spec/app_root/content/about/us.haml +1 -0
- data/spec/app_root/content/engines/haml.haml +7 -0
- data/spec/app_root/content/engines/markdown.markdown +7 -0
- data/spec/app_root/content/engines/md.md +7 -0
- data/spec/app_root/content/engines/mdown.mdown +7 -0
- data/spec/app_root/content/index.haml +1 -0
- data/spec/app_root/content/override.haml +1 -0
- data/spec/app_root/content/page_with_missing_view.haml +4 -0
- data/spec/app_root/content/turner+hooch.haml +1 -0
- data/spec/app_root/security_hole.haml +1 -0
- data/spec/app_root/themes/default/public/default.css +3 -0
- data/spec/app_root/themes/default/public/images/index.html +10 -0
- data/spec/app_root/themes/default/public/images/ripe-mango.jpg +0 -0
- data/spec/app_root/themes/default/public/override +10 -0
- data/spec/app_root/themes/default/public/robots.txt +2 -0
- data/spec/app_root/themes/default/public/styles/override.css +3 -0
- data/spec/app_root/themes/default/public/styles/reset.css +27 -0
- data/spec/app_root/themes/default/public/styles/subfolder/another.css +3 -0
- data/spec/app_root/themes/default/security_hole.sass +1 -0
- data/spec/app_root/themes/default/security_hole.txt +1 -0
- data/spec/app_root/themes/default/styles/override.sass +2 -0
- data/spec/app_root/themes/default/styles/screen.sass +13 -0
- data/spec/app_root/themes/default/styles/subfolder/screen.sass +12 -0
- data/spec/app_root/themes/default/views/404.haml +7 -0
- data/spec/app_root/themes/default/views/layout.haml +7 -0
- data/spec/app_root/themes/default/views/page.haml +4 -0
- data/spec/mango/application/routing_content_pages_spec.rb +357 -0
- data/spec/mango/application/routing_public_files_spec.rb +181 -0
- data/spec/mango/application/routing_style_sheets_spec.rb +286 -0
- data/spec/mango/application_spec.rb +34 -0
- data/spec/mango/content_page/finding_spec.rb +213 -0
- data/spec/mango/content_page/initializing_spec.rb +298 -0
- data/spec/mango/content_page_spec.rb +44 -0
- data/spec/mango/dependencies_spec.rb +189 -0
- data/spec/mango/flavored_markdown_spec.rb +52 -0
- data/spec/mango/rack/debugger_spec.rb +114 -0
- data/spec/mango/version_spec.rb +18 -0
- data/spec/quality_spec.rb +32 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/matchers/malformed_whitespace_matchers.rb +60 -0
- metadata +304 -17
@@ -0,0 +1,357 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require "spec_helper"
|
3
|
+
require "rack/test"
|
4
|
+
|
5
|
+
describe Mango::Application do
|
6
|
+
include Rack::Test::Methods
|
7
|
+
|
8
|
+
def app
|
9
|
+
Mango::Application
|
10
|
+
end
|
11
|
+
|
12
|
+
#################################################################################################
|
13
|
+
|
14
|
+
describe "GET (empty String)" do
|
15
|
+
before(:each) do
|
16
|
+
get ""
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return 200 status code" do
|
20
|
+
last_response.should be_ok
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should send the correct Content-Type header" do
|
24
|
+
last_response["Content-Type"] == "text/html"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should send the correct body content" do
|
28
|
+
last_response.body.should == <<-EXPECTED
|
29
|
+
<!DOCTYPE html>
|
30
|
+
<html>
|
31
|
+
<head>
|
32
|
+
<meta charset='utf-8' />
|
33
|
+
<title>App Root Page</title>
|
34
|
+
</head>
|
35
|
+
<body>
|
36
|
+
<h1>Welcome to Mango!</h1>
|
37
|
+
<div id='content'>
|
38
|
+
<p>/index.haml</p>
|
39
|
+
</div>
|
40
|
+
</body>
|
41
|
+
</html>
|
42
|
+
EXPECTED
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
#################################################################################################
|
47
|
+
|
48
|
+
describe "GET /" do
|
49
|
+
before(:each) do
|
50
|
+
get "/"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should return 200 status code" do
|
54
|
+
last_response.should be_ok
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should send the correct Content-Type header" do
|
58
|
+
last_response["Content-Type"] == "text/html"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should send the correct body content" do
|
62
|
+
last_response.body.should == <<-EXPECTED
|
63
|
+
<!DOCTYPE html>
|
64
|
+
<html>
|
65
|
+
<head>
|
66
|
+
<meta charset='utf-8' />
|
67
|
+
<title>App Root Page</title>
|
68
|
+
</head>
|
69
|
+
<body>
|
70
|
+
<h1>Welcome to Mango!</h1>
|
71
|
+
<div id='content'>
|
72
|
+
<p>/index.haml</p>
|
73
|
+
</div>
|
74
|
+
</body>
|
75
|
+
</html>
|
76
|
+
EXPECTED
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
#################################################################################################
|
81
|
+
|
82
|
+
describe "GET /index" do
|
83
|
+
before(:each) do
|
84
|
+
get "/index"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should return 200 status code" do
|
88
|
+
last_response.should be_ok
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should send the correct Content-Type header" do
|
92
|
+
last_response["Content-Type"] == "text/html"
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should send the correct body content" do
|
96
|
+
last_response.body.should == <<-EXPECTED
|
97
|
+
<!DOCTYPE html>
|
98
|
+
<html>
|
99
|
+
<head>
|
100
|
+
<meta charset='utf-8' />
|
101
|
+
<title>App Root Page</title>
|
102
|
+
</head>
|
103
|
+
<body>
|
104
|
+
<h1>Welcome to Mango!</h1>
|
105
|
+
<div id='content'>
|
106
|
+
<p>/index.haml</p>
|
107
|
+
</div>
|
108
|
+
</body>
|
109
|
+
</html>
|
110
|
+
EXPECTED
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
#################################################################################################
|
115
|
+
|
116
|
+
describe "GET /index?foo=bar" do
|
117
|
+
before(:each) do
|
118
|
+
get "/index?foo=bar"
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should return 200 status code" do
|
122
|
+
last_response.should be_ok
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should send the correct Content-Type header" do
|
126
|
+
last_response["Content-Type"] == "text/html"
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should send the correct body content" do
|
130
|
+
last_response.body.should == <<-EXPECTED
|
131
|
+
<!DOCTYPE html>
|
132
|
+
<html>
|
133
|
+
<head>
|
134
|
+
<meta charset='utf-8' />
|
135
|
+
<title>App Root Page</title>
|
136
|
+
</head>
|
137
|
+
<body>
|
138
|
+
<h1>Welcome to Mango!</h1>
|
139
|
+
<div id='content'>
|
140
|
+
<p>/index.haml</p>
|
141
|
+
</div>
|
142
|
+
</body>
|
143
|
+
</html>
|
144
|
+
EXPECTED
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
#################################################################################################
|
149
|
+
|
150
|
+
describe "GET /about/" do
|
151
|
+
before(:each) do
|
152
|
+
get "/about/"
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should return 200 status code" do
|
156
|
+
last_response.should be_ok
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should send the correct Content-Type header" do
|
160
|
+
last_response["Content-Type"] == "text/html"
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should send the correct body content" do
|
164
|
+
last_response.body.should == <<-EXPECTED
|
165
|
+
<!DOCTYPE html>
|
166
|
+
<html>
|
167
|
+
<head>
|
168
|
+
<meta charset='utf-8' />
|
169
|
+
<title>App Root Page</title>
|
170
|
+
</head>
|
171
|
+
<body>
|
172
|
+
<h1>Welcome to Mango!</h1>
|
173
|
+
<div id='content'>
|
174
|
+
<p>/about/index.haml</p>
|
175
|
+
</div>
|
176
|
+
</body>
|
177
|
+
</html>
|
178
|
+
EXPECTED
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
#################################################################################################
|
183
|
+
|
184
|
+
describe "GET /about/index" do
|
185
|
+
before(:each) do
|
186
|
+
get "/about/index"
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should return 200 status code" do
|
190
|
+
last_response.should be_ok
|
191
|
+
end
|
192
|
+
|
193
|
+
it "should send the correct Content-Type header" do
|
194
|
+
last_response["Content-Type"] == "text/html"
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should send the correct body content" do
|
198
|
+
last_response.body.should == <<-EXPECTED
|
199
|
+
<!DOCTYPE html>
|
200
|
+
<html>
|
201
|
+
<head>
|
202
|
+
<meta charset='utf-8' />
|
203
|
+
<title>App Root Page</title>
|
204
|
+
</head>
|
205
|
+
<body>
|
206
|
+
<h1>Welcome to Mango!</h1>
|
207
|
+
<div id='content'>
|
208
|
+
<p>/about/index.haml</p>
|
209
|
+
</div>
|
210
|
+
</body>
|
211
|
+
</html>
|
212
|
+
EXPECTED
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
#################################################################################################
|
217
|
+
|
218
|
+
describe "GET /about/us" do
|
219
|
+
before(:each) do
|
220
|
+
get "/about/us"
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should return 200 status code" do
|
224
|
+
last_response.should be_ok
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should send the correct Content-Type header" do
|
228
|
+
last_response["Content-Type"] == "text/html"
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should send the correct body content" do
|
232
|
+
last_response.body.should == <<-EXPECTED
|
233
|
+
<!DOCTYPE html>
|
234
|
+
<html>
|
235
|
+
<head>
|
236
|
+
<meta charset='utf-8' />
|
237
|
+
<title>App Root Page</title>
|
238
|
+
</head>
|
239
|
+
<body>
|
240
|
+
<h1>Welcome to Mango!</h1>
|
241
|
+
<div id='content'>
|
242
|
+
<p>/about/us.haml</p>
|
243
|
+
</div>
|
244
|
+
</body>
|
245
|
+
</html>
|
246
|
+
EXPECTED
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
#################################################################################################
|
251
|
+
|
252
|
+
describe "GET /turner%2Bhooch" do
|
253
|
+
before(:each) do
|
254
|
+
get "/turner%2Bhooch"
|
255
|
+
end
|
256
|
+
|
257
|
+
it "should return 200 status code" do
|
258
|
+
last_response.should be_ok
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should send the correct Content-Type header" do
|
262
|
+
last_response["Content-Type"] == "text/html"
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should send the correct body content" do
|
266
|
+
last_response.body.should == <<-EXPECTED
|
267
|
+
<!DOCTYPE html>
|
268
|
+
<html>
|
269
|
+
<head>
|
270
|
+
<meta charset='utf-8' />
|
271
|
+
<title>App Root Page</title>
|
272
|
+
</head>
|
273
|
+
<body>
|
274
|
+
<h1>Welcome to Mango!</h1>
|
275
|
+
<div id='content'>
|
276
|
+
<p>/turner+hooch.haml</p>
|
277
|
+
</div>
|
278
|
+
</body>
|
279
|
+
</html>
|
280
|
+
EXPECTED
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
#################################################################################################
|
285
|
+
|
286
|
+
describe "GET /page_not_found" do
|
287
|
+
before(:each) do
|
288
|
+
get "/page_not_found"
|
289
|
+
end
|
290
|
+
|
291
|
+
it "should return 404 status code" do
|
292
|
+
last_response.should be_not_found
|
293
|
+
end
|
294
|
+
|
295
|
+
it "should send the correct Content-Type header" do
|
296
|
+
last_response["Content-Type"] == "text/html"
|
297
|
+
end
|
298
|
+
|
299
|
+
it "should send the correct body content" do
|
300
|
+
last_response.body.should == <<-EXPECTED
|
301
|
+
<!DOCTYPE html>
|
302
|
+
<html>
|
303
|
+
<head>
|
304
|
+
<meta charset='utf-8' />
|
305
|
+
<title>404 Page</title>
|
306
|
+
</head>
|
307
|
+
<body>
|
308
|
+
<h1>Page not found</h1>
|
309
|
+
</body>
|
310
|
+
</html>
|
311
|
+
EXPECTED
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
#################################################################################################
|
316
|
+
|
317
|
+
describe "GET /page_with_missing_view" do
|
318
|
+
it "should raise RuntimeError" do
|
319
|
+
path = File.join(SPEC_APP_ROOT, "themes", "default", "views", "missing_view_template.haml")
|
320
|
+
lambda {
|
321
|
+
get "/page_with_missing_view"
|
322
|
+
}.should raise_exception(RuntimeError, "Unable to find a view template file -- #{path}")
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
#################################################################################################
|
327
|
+
|
328
|
+
describe "GET /../security_hole" do
|
329
|
+
before(:each) do
|
330
|
+
get "/../security_hole"
|
331
|
+
end
|
332
|
+
|
333
|
+
it "should return 404 status code" do
|
334
|
+
last_response.should be_not_found
|
335
|
+
end
|
336
|
+
|
337
|
+
it "should send the correct Content-Type header" do
|
338
|
+
last_response["Content-Type"] == "text/html"
|
339
|
+
end
|
340
|
+
|
341
|
+
it "should send the correct body content" do
|
342
|
+
last_response.body.should == <<-EXPECTED
|
343
|
+
<!DOCTYPE html>
|
344
|
+
<html>
|
345
|
+
<head>
|
346
|
+
<meta charset='utf-8' />
|
347
|
+
<title>404 Page</title>
|
348
|
+
</head>
|
349
|
+
<body>
|
350
|
+
<h1>Page not found</h1>
|
351
|
+
</body>
|
352
|
+
</html>
|
353
|
+
EXPECTED
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require "spec_helper"
|
3
|
+
require "rack/test"
|
4
|
+
|
5
|
+
describe Mango::Application do
|
6
|
+
include Rack::Test::Methods
|
7
|
+
|
8
|
+
def app
|
9
|
+
Mango::Application
|
10
|
+
end
|
11
|
+
|
12
|
+
#################################################################################################
|
13
|
+
|
14
|
+
describe "GET /robots.txt" do
|
15
|
+
before(:each) do
|
16
|
+
get "/robots.txt"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return 200 status code" do
|
20
|
+
last_response.should be_ok
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should send the correct Content-Type header" do
|
24
|
+
last_response["Content-Type"] == "text/plain"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should send the correct body content" do
|
28
|
+
last_response.body.should == <<-EXPECTED
|
29
|
+
User-agent: *
|
30
|
+
Disallow: /cgi-bin/
|
31
|
+
EXPECTED
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
#################################################################################################
|
36
|
+
|
37
|
+
describe "GET /images/index.html" do
|
38
|
+
before(:each) do
|
39
|
+
get "/images/index.html"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return 200 status code" do
|
43
|
+
last_response.should be_ok
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should send the correct Content-Type header" do
|
47
|
+
last_response["Content-Type"] == "text/html"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should send the correct body content" do
|
51
|
+
last_response.body.should == <<-EXPECTED
|
52
|
+
<!DOCTYPE html>
|
53
|
+
<html>
|
54
|
+
<head>
|
55
|
+
<meta charset='utf-8' />
|
56
|
+
<title>/themes/default/public/images/index.html</title>
|
57
|
+
</head>
|
58
|
+
<body>
|
59
|
+
<p>/themes/default/public/images/index.html</p>
|
60
|
+
</body>
|
61
|
+
</html>
|
62
|
+
EXPECTED
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
#################################################################################################
|
67
|
+
|
68
|
+
describe "GET /images/ripe-mango.jpg" do
|
69
|
+
before(:each) do
|
70
|
+
get "/images/ripe-mango.jpg"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should return 200 status code" do
|
74
|
+
last_response.should be_ok
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should send the correct Content-Type header" do
|
78
|
+
last_response["Content-Type"] == "image/jpeg"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should send the correct body content" do
|
82
|
+
content_path = File.join(Mango::Application.public, "images", "ripe-mango.jpg")
|
83
|
+
last_response.body.should == File.open(content_path, "rb").read
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
#################################################################################################
|
88
|
+
|
89
|
+
describe "GET /override" do
|
90
|
+
before(:each) do
|
91
|
+
get "/override"
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should return 200 status code" do
|
95
|
+
last_response.should be_ok
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should send the correct Content-Type header" do
|
99
|
+
last_response["Content-Type"] == "text/html"
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should send the correct body content" do
|
103
|
+
last_response.body.should == <<-EXPECTED
|
104
|
+
<!DOCTYPE html>
|
105
|
+
<html>
|
106
|
+
<head>
|
107
|
+
<meta charset='utf-8' />
|
108
|
+
<title>/themes/default/public/override</title>
|
109
|
+
</head>
|
110
|
+
<body>
|
111
|
+
<p>/themes/default/public/override</p>
|
112
|
+
</body>
|
113
|
+
</html>
|
114
|
+
EXPECTED
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
#################################################################################################
|
119
|
+
|
120
|
+
# see http://bit.ly/9kLBDx
|
121
|
+
describe "GET /images/" do
|
122
|
+
before(:each) do
|
123
|
+
get "/images/"
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should return 200 status code" do
|
127
|
+
last_response.should be_ok
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should send the correct Content-Type header" do
|
131
|
+
last_response["Content-Type"] == "text/html"
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should send the correct body content" do
|
135
|
+
last_response.body.should == <<-EXPECTED
|
136
|
+
<!DOCTYPE html>
|
137
|
+
<html>
|
138
|
+
<head>
|
139
|
+
<meta charset='utf-8' />
|
140
|
+
<title>/themes/default/public/images/index.html</title>
|
141
|
+
</head>
|
142
|
+
<body>
|
143
|
+
<p>/themes/default/public/images/index.html</p>
|
144
|
+
</body>
|
145
|
+
</html>
|
146
|
+
EXPECTED
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
#################################################################################################
|
151
|
+
|
152
|
+
describe "GET /../security_hole.txt" do
|
153
|
+
before(:each) do
|
154
|
+
get "/../security_hole.txt"
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should return 404 status code" do
|
158
|
+
last_response.should be_not_found
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should send the correct Content-Type header" do
|
162
|
+
last_response["Content-Type"] == "text/html"
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should send the correct body content" do
|
166
|
+
last_response.body.should == <<-EXPECTED
|
167
|
+
<!DOCTYPE html>
|
168
|
+
<html>
|
169
|
+
<head>
|
170
|
+
<meta charset='utf-8' />
|
171
|
+
<title>404 Page</title>
|
172
|
+
</head>
|
173
|
+
<body>
|
174
|
+
<h1>Page not found</h1>
|
175
|
+
</body>
|
176
|
+
</html>
|
177
|
+
EXPECTED
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|