mango 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/.gitignore +1 -2
  2. data/.rvmrc +1 -0
  3. data/.yardopts +1 -3
  4. data/{CHANGES.mdown → CHANGES.md} +40 -0
  5. data/Gemfile.lock +35 -23
  6. data/LICENSE +1 -1
  7. data/{README.mdown → README.md} +38 -27
  8. data/Rakefile +0 -13
  9. data/lib/mango.rb +5 -0
  10. data/lib/mango/application.rb +361 -129
  11. data/lib/mango/content_page.rb +89 -115
  12. data/lib/mango/core_ext/string.rb +16 -0
  13. data/lib/mango/core_ext/uri.rb +14 -0
  14. data/lib/mango/dependencies.rb +5 -4
  15. data/lib/mango/flavored_markdown.rb +7 -0
  16. data/lib/mango/rack/debugger.rb +20 -0
  17. data/lib/mango/runner.rb +33 -50
  18. data/lib/mango/templates/.gitignore +0 -1
  19. data/lib/mango/templates/Gemfile +1 -1
  20. data/lib/mango/templates/content/index.erb +6 -0
  21. data/lib/mango/templates/themes/default/javascripts/timer.coffee +6 -0
  22. data/lib/mango/templates/themes/default/public/javascripts/fireworks.js +0 -0
  23. data/lib/mango/templates/themes/default/public/{styles → stylesheets}/fireworks.css +0 -0
  24. data/lib/mango/templates/themes/default/public/{styles → stylesheets}/reset.css +0 -2
  25. data/lib/mango/templates/themes/default/{styles → stylesheets}/screen.sass +0 -2
  26. data/lib/mango/templates/themes/default/views/layout.haml +5 -5
  27. data/lib/mango/templates/themes/default/views/page.haml +1 -3
  28. data/lib/mango/version.rb +1 -1
  29. data/mango.gemspec +12 -10
  30. data/spec/fixture/content/engines/erb.erb +7 -0
  31. data/spec/fixture/content/engines/haml.haml +4 -4
  32. data/spec/fixture/content/engines/liquid.liquid +7 -0
  33. data/spec/fixture/content/engines/markdown.markdown +0 -6
  34. data/spec/fixture/content/engines/md.md +0 -6
  35. data/spec/fixture/content/engines/mkd.mkd +1 -0
  36. data/spec/fixture/content/page_with_missing_view.haml +2 -2
  37. data/spec/fixture/content/page_with_unregistered_view.haml +4 -0
  38. data/spec/fixture/content/view_engines/erb.haml +4 -0
  39. data/spec/fixture/content/view_engines/liquid.haml +4 -0
  40. data/spec/fixture/themes/default/javascripts/override.coffee +1 -0
  41. data/spec/fixture/themes/default/javascripts/siblings.coffee +7 -0
  42. data/spec/fixture/themes/default/javascripts/songs/happy.coffee +5 -0
  43. data/spec/fixture/themes/default/public/404.html +11 -0
  44. data/spec/fixture/themes/default/public/javascripts/econ.js +8 -0
  45. data/spec/fixture/themes/default/public/javascripts/math/opposite.js +6 -0
  46. data/spec/fixture/themes/default/public/javascripts/override.js +1 -0
  47. data/spec/fixture/themes/default/public/root.js +5 -0
  48. data/spec/fixture/themes/default/public/{styles → stylesheets}/override.css +0 -0
  49. data/spec/fixture/themes/default/public/{styles → stylesheets}/reset.css +0 -0
  50. data/spec/fixture/themes/default/public/{styles → stylesheets}/subfolder/another.css +0 -0
  51. data/spec/fixture/themes/default/security_hole.js +1 -0
  52. data/spec/fixture/themes/default/{styles → stylesheets}/override.sass +0 -0
  53. data/spec/fixture/themes/default/{styles/screen.sass → stylesheets/sass.sass} +4 -2
  54. data/spec/fixture/themes/default/stylesheets/scss.scss +19 -0
  55. data/spec/fixture/themes/default/{styles → stylesheets}/subfolder/screen.sass +0 -2
  56. data/spec/fixture/themes/default/views/404.erb +11 -0
  57. data/spec/fixture/themes/default/views/404.haml +1 -0
  58. data/spec/fixture/themes/default/views/404.liquid +11 -0
  59. data/spec/fixture/themes/default/views/layout.erb +10 -0
  60. data/spec/fixture/themes/default/views/layout.haml +1 -1
  61. data/spec/fixture/themes/default/views/layout.liquid +10 -0
  62. data/spec/fixture/themes/default/views/page.erb +7 -0
  63. data/spec/fixture/themes/default/views/page.haml +3 -1
  64. data/spec/fixture/themes/default/views/page.liquid +7 -0
  65. data/spec/lib/application/routing_content_pages_spec.rb +298 -21
  66. data/spec/lib/application/routing_javascript_templates_spec.rb +278 -0
  67. data/spec/lib/application/routing_not_found_spec.rb +254 -0
  68. data/spec/lib/application/routing_public_files_spec.rb +9 -8
  69. data/spec/lib/application/{routing_style_sheets_spec.rb → routing_stylesheet_templates_spec.rb} +61 -24
  70. data/spec/lib/application_spec.rb +31 -2
  71. data/spec/lib/content_page/initializing_spec.rb +399 -126
  72. data/spec/lib/content_page_spec.rb +23 -19
  73. data/spec/lib/core_ext/string_spec.rb +12 -0
  74. data/spec/lib/core_ext/uri_spec.rb +42 -0
  75. data/spec/lib/dependencies_spec.rb +0 -1
  76. data/spec/lib/flavored_markdown_spec.rb +18 -3
  77. data/spec/lib/runner_spec.rb +40 -39
  78. data/spec/lib/version_spec.rb +4 -4
  79. metadata +145 -64
  80. data/lib/mango/templates/content/index.md +0 -5
  81. data/lib/mango/templates/themes/default/public/javascripts/timer.js +0 -5
  82. data/spec/fixture/content/engines/mdown.mdown +0 -7
  83. data/spec/lib/content_page/finding_spec.rb +0 -213
@@ -0,0 +1,278 @@
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 /javascripts/siblings.js" do
15
+ before(:all) do
16
+ get "/javascripts/siblings.js"
17
+ end
18
+
19
+ it "returns 200 status code" do
20
+ last_response.should be_ok
21
+ end
22
+
23
+ it "sends the correct Content-Type header" do
24
+ last_response["Content-Type"].should == "application/javascript;charset=utf-8"
25
+ end
26
+
27
+ it "sends the correct body content" do
28
+ last_response.body.should == <<-EXPECTED
29
+ (function() {
30
+ var kids;
31
+ kids = {
32
+ brother: {
33
+ name: "Max",
34
+ age: 11
35
+ },
36
+ sister: {
37
+ name: "Ida",
38
+ age: 9
39
+ }
40
+ };
41
+ }).call(this);
42
+ EXPECTED
43
+ end
44
+ end
45
+
46
+ #################################################################################################
47
+
48
+ describe "GET /javascripts/songs/happy.js" do
49
+ before(:all) do
50
+ get "/javascripts/songs/happy.js"
51
+ end
52
+
53
+ it "returns 200 status code" do
54
+ last_response.should be_ok
55
+ end
56
+
57
+ it "sends the correct Content-Type header" do
58
+ last_response["Content-Type"].should == "application/javascript;charset=utf-8"
59
+ end
60
+
61
+ it "sends the correct body content" do
62
+ last_response.body.should == <<-EXPECTED
63
+ (function() {
64
+ if (happy && knowsIt) {
65
+ clapsHands();
66
+ chaChaCha();
67
+ } else {
68
+ showIt();
69
+ }
70
+ }).call(this);
71
+ EXPECTED
72
+ end
73
+ end
74
+
75
+ #################################################################################################
76
+
77
+ describe "GET /javascripts/econ.js" do
78
+ before(:all) do
79
+ get "/javascripts/econ.js"
80
+ end
81
+
82
+ it "returns 200 status code" do
83
+ last_response.should be_ok
84
+ end
85
+
86
+ it "sends the correct Content-Type header" do
87
+ last_response["Content-Type"].should == "application/javascript;charset=utf-8"
88
+ end
89
+
90
+ it "sends the correct body content" do
91
+ expected = <<-EXPECTED
92
+ if (this.studyingEconomics) {
93
+ while (supply > demand) {
94
+ buy();
95
+ }
96
+ while (!(supply > demand)) {
97
+ sell();
98
+ }
99
+ }
100
+ EXPECTED
101
+
102
+ last_response.body.should == expected
103
+ end
104
+ end
105
+
106
+ #################################################################################################
107
+
108
+ describe "GET /javascripts/override.js" do
109
+ before(:all) do
110
+ get "/javascripts/override.js"
111
+ end
112
+
113
+ it "returns 200 status code" do
114
+ last_response.should be_ok
115
+ end
116
+
117
+ it "sends the correct Content-Type header" do
118
+ last_response["Content-Type"].should == "application/javascript;charset=utf-8"
119
+ end
120
+
121
+ it "sends the correct body content" do
122
+ last_response.body.should == "var bitlist = [1, 0, 1, 0, 0, 1, 1, 1, 0];\n"
123
+ end
124
+ end
125
+
126
+ #################################################################################################
127
+
128
+ describe "GET /root.js" do
129
+ before(:all) do
130
+ get "/root.js"
131
+ end
132
+
133
+ it "returns 200 status code" do
134
+ last_response.should be_ok
135
+ end
136
+
137
+ it "sends the correct Content-Type header" do
138
+ last_response["Content-Type"].should == "application/javascript;charset=utf-8"
139
+ end
140
+
141
+ it "sends the correct body content" do
142
+ expected = <<-EXPECTED
143
+ var yearsOld = {
144
+ max: 10,
145
+ ida: 9,
146
+ tim: 11
147
+ };
148
+ EXPECTED
149
+
150
+ last_response.body.should == expected
151
+ end
152
+ end
153
+
154
+ #################################################################################################
155
+
156
+ describe "GET /javascripts/math/opposite.js" do
157
+ before(:all) do
158
+ get "/javascripts/math/opposite.js"
159
+ end
160
+
161
+ it "returns 200 status code" do
162
+ last_response.should be_ok
163
+ end
164
+
165
+ it "sends the correct Content-Type header" do
166
+ last_response["Content-Type"].should == "application/javascript;charset=utf-8"
167
+ end
168
+
169
+ it "sends the correct body content" do
170
+ expected = <<-EXPECTED
171
+ var number, opposite;
172
+ number = 42;
173
+ opposite = true;
174
+ if (opposite) {
175
+ number = -42;
176
+ }
177
+ EXPECTED
178
+
179
+ last_response.body.should == expected
180
+ end
181
+ end
182
+
183
+ #################################################################################################
184
+
185
+ describe "GET /javascripts/not_found.js" do
186
+ before(:all) do
187
+ get "/javascripts/not_found.js"
188
+ end
189
+
190
+ it "returns 404 status code" do
191
+ last_response.should be_not_found
192
+ end
193
+
194
+ it "sends the correct Content-Type header" do
195
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
196
+ end
197
+
198
+ it "sends the correct body content" do
199
+ last_response.body.should == <<-EXPECTED
200
+ <!DOCTYPE html>
201
+ <html>
202
+ <head>
203
+ <meta charset='utf-8' />
204
+ <title>404 Page</title>
205
+ </head>
206
+ <body>
207
+ <h1>Page not found</h1>
208
+ <p id='template'>404.html</p>
209
+ </body>
210
+ </html>
211
+ EXPECTED
212
+ end
213
+ end
214
+
215
+ #################################################################################################
216
+
217
+ describe "GET /siblings.js" do
218
+ before(:all) do
219
+ get "/siblings.js"
220
+ end
221
+
222
+ it "returns 404 status code" do
223
+ last_response.should be_not_found
224
+ end
225
+
226
+ it "sends the correct Content-Type header" do
227
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
228
+ end
229
+
230
+ it "sends the correct body content" do
231
+ last_response.body.should == <<-EXPECTED
232
+ <!DOCTYPE html>
233
+ <html>
234
+ <head>
235
+ <meta charset='utf-8' />
236
+ <title>404 Page</title>
237
+ </head>
238
+ <body>
239
+ <h1>Page not found</h1>
240
+ <p id='template'>404.html</p>
241
+ </body>
242
+ </html>
243
+ EXPECTED
244
+ end
245
+ end
246
+
247
+ #################################################################################################
248
+
249
+ describe "GET /javascripts/../security_hole.js" do
250
+ before(:all) do
251
+ get "/javascripts/../security_hole.js"
252
+ end
253
+
254
+ it "returns 404 status code" do
255
+ last_response.should be_not_found
256
+ end
257
+
258
+ it "sends the correct Content-Type header" do
259
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
260
+ end
261
+
262
+ it "sends the correct body content" do
263
+ last_response.body.should == <<-EXPECTED
264
+ <!DOCTYPE html>
265
+ <html>
266
+ <head>
267
+ <meta charset='utf-8' />
268
+ <title>404 Page</title>
269
+ </head>
270
+ <body>
271
+ <h1>Page not found</h1>
272
+ <p id='template'>404.html</p>
273
+ </body>
274
+ </html>
275
+ EXPECTED
276
+ end
277
+ end
278
+ end
@@ -0,0 +1,254 @@
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 "not_found" do
15
+ describe "with an HTML file" do
16
+ before(:all) do
17
+ get "/not_found"
18
+ end
19
+
20
+ it "returns 404 status code" do
21
+ last_response.should be_not_found
22
+ end
23
+
24
+ it "sends the correct Content-Type header" do
25
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
26
+ end
27
+
28
+ it "sends the correct body content" do
29
+ last_response.body.should == <<-EXPECTED
30
+ <!DOCTYPE html>
31
+ <html>
32
+ <head>
33
+ <meta charset='utf-8' />
34
+ <title>404 Page</title>
35
+ </head>
36
+ <body>
37
+ <h1>Page not found</h1>
38
+ <p id='template'>404.html</p>
39
+ </body>
40
+ </html>
41
+ EXPECTED
42
+ end
43
+ end
44
+
45
+ ###############################################################################################
46
+
47
+ describe "with a Haml template" do
48
+ before(:all) do
49
+ %w(html).each do |extension|
50
+ visible = FIXTURE_ROOT + "themes/default/public/404.#{extension}"
51
+ hidden = FIXTURE_ROOT + "themes/default/public/404.#{extension}.hidden"
52
+ FileUtils.move(visible, hidden)
53
+ end
54
+
55
+ get "/not_found"
56
+ end
57
+
58
+ after(:all) do
59
+ %w(html).each do |extension|
60
+ visible = FIXTURE_ROOT + "themes/default/public/404.#{extension}"
61
+ hidden = FIXTURE_ROOT + "themes/default/public/404.#{extension}.hidden"
62
+ FileUtils.move(hidden, visible)
63
+ end
64
+ end
65
+
66
+ it "returns 404 status code" do
67
+ last_response.should be_not_found
68
+ end
69
+
70
+ it "sends the correct Content-Type header" do
71
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
72
+ end
73
+
74
+ it "sends the correct body content" do
75
+ last_response.body.should == <<-EXPECTED
76
+ <!DOCTYPE html>
77
+ <html>
78
+ <head>
79
+ <meta charset='utf-8' />
80
+ <title>404 Page</title>
81
+ </head>
82
+ <body>
83
+ <h1>Page not found</h1>
84
+ <p id='template'>404.haml</p>
85
+ </body>
86
+ </html>
87
+ EXPECTED
88
+ end
89
+ end
90
+
91
+ ###############################################################################################
92
+
93
+ describe "with an ERB template" do
94
+ before(:all) do
95
+ %w(html).each do |extension|
96
+ visible = FIXTURE_ROOT + "themes/default/public/404.#{extension}"
97
+ hidden = FIXTURE_ROOT + "themes/default/public/404.#{extension}.hidden"
98
+ FileUtils.move(visible, hidden)
99
+ end
100
+
101
+ %w(haml).each do |extension|
102
+ visible = FIXTURE_ROOT + "themes/default/views/404.#{extension}"
103
+ hidden = FIXTURE_ROOT + "themes/default/views/404.#{extension}.hidden"
104
+ FileUtils.move(visible, hidden)
105
+ end
106
+
107
+ get "/not_found"
108
+ end
109
+
110
+ after(:all) do
111
+ %w(haml).each do |extension|
112
+ visible = FIXTURE_ROOT + "themes/default/views/404.#{extension}"
113
+ hidden = FIXTURE_ROOT + "themes/default/views/404.#{extension}.hidden"
114
+ FileUtils.move(hidden, visible)
115
+ end
116
+
117
+ %w(html).each do |extension|
118
+ visible = FIXTURE_ROOT + "themes/default/public/404.#{extension}"
119
+ hidden = FIXTURE_ROOT + "themes/default/public/404.#{extension}.hidden"
120
+ FileUtils.move(hidden, visible)
121
+ end
122
+ end
123
+
124
+ it "returns 404 status code" do
125
+ last_response.should be_not_found
126
+ end
127
+
128
+ it "sends the correct Content-Type header" do
129
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
130
+ end
131
+
132
+ it "sends the correct body content" do
133
+ last_response.body.should == <<-EXPECTED
134
+ <!DOCTYPE html>
135
+ <html>
136
+ <head>
137
+ <meta charset='utf-8' />
138
+ <title>404 Page</title>
139
+ </head>
140
+ <body>
141
+ <h1>Page not found</h1>
142
+ <p id='template'>404.erb</p>
143
+ </body>
144
+ </html>
145
+ EXPECTED
146
+ end
147
+ end
148
+
149
+ ###############################################################################################
150
+
151
+ describe "with a Liquid template" do
152
+ before(:all) do
153
+ %w(html).each do |extension|
154
+ visible = FIXTURE_ROOT + "themes/default/public/404.#{extension}"
155
+ hidden = FIXTURE_ROOT + "themes/default/public/404.#{extension}.hidden"
156
+ FileUtils.move(visible, hidden)
157
+ end
158
+
159
+ %w(haml erb).each do |extension|
160
+ visible = FIXTURE_ROOT + "themes/default/views/404.#{extension}"
161
+ hidden = FIXTURE_ROOT + "themes/default/views/404.#{extension}.hidden"
162
+ FileUtils.move(visible, hidden)
163
+ end
164
+
165
+ get "/not_found"
166
+ end
167
+
168
+ after(:all) do
169
+ %w(haml erb).each do |extension|
170
+ visible = FIXTURE_ROOT + "themes/default/views/404.#{extension}"
171
+ hidden = FIXTURE_ROOT + "themes/default/views/404.#{extension}.hidden"
172
+ FileUtils.move(hidden, visible)
173
+ end
174
+
175
+ %w(html).each do |extension|
176
+ visible = FIXTURE_ROOT + "themes/default/public/404.#{extension}"
177
+ hidden = FIXTURE_ROOT + "themes/default/public/404.#{extension}.hidden"
178
+ FileUtils.move(hidden, visible)
179
+ end
180
+ end
181
+
182
+ it "returns 404 status code" do
183
+ last_response.should be_not_found
184
+ end
185
+
186
+ it "sends the correct Content-Type header" do
187
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
188
+ end
189
+
190
+ it "sends the correct body content" do
191
+ last_response.body.should == <<-EXPECTED
192
+ <!DOCTYPE html>
193
+ <html>
194
+ <head>
195
+ <meta charset='utf-8' />
196
+ <title>404 Page</title>
197
+ </head>
198
+ <body>
199
+ <h1>Page not found</h1>
200
+ <p id='template'>404.liquid</p>
201
+ </body>
202
+ </html>
203
+ EXPECTED
204
+ end
205
+ end
206
+
207
+ ###############################################################################################
208
+
209
+ describe "with no templates" do
210
+ before(:all) do
211
+ %w(html).each do |extension|
212
+ visible = FIXTURE_ROOT + "themes/default/public/404.#{extension}"
213
+ hidden = FIXTURE_ROOT + "themes/default/public/404.#{extension}.hidden"
214
+ FileUtils.move(visible, hidden)
215
+ end
216
+
217
+ %w(haml erb liquid).each do |extension|
218
+ visible = FIXTURE_ROOT + "themes/default/views/404.#{extension}"
219
+ hidden = FIXTURE_ROOT + "themes/default/views/404.#{extension}.hidden"
220
+ FileUtils.move(visible, hidden)
221
+ end
222
+
223
+ get "/not_found"
224
+ end
225
+
226
+ after(:all) do
227
+ %w(haml erb liquid).each do |extension|
228
+ visible = FIXTURE_ROOT + "themes/default/views/404.#{extension}"
229
+ hidden = FIXTURE_ROOT + "themes/default/views/404.#{extension}.hidden"
230
+ FileUtils.move(hidden, visible)
231
+ end
232
+
233
+ %w(html).each do |extension|
234
+ visible = FIXTURE_ROOT + "themes/default/public/404.#{extension}"
235
+ hidden = FIXTURE_ROOT + "themes/default/public/404.#{extension}.hidden"
236
+ FileUtils.move(hidden, visible)
237
+ end
238
+ end
239
+
240
+ it "returns 404 status code" do
241
+ last_response.should be_not_found
242
+ end
243
+
244
+ it "sends the correct Content-Type header" do
245
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
246
+ end
247
+
248
+ it "sends the correct body content" do
249
+ expected = "<!DOCTYPE html><title>404 Page Not Found</title><h1>404 Page Not Found</h1>"
250
+ last_response.body.should == expected
251
+ end
252
+ end
253
+ end
254
+ end