mango 0.5.4 → 0.6.0

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.
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
@@ -1,3 +1,2 @@
1
1
  .DS_Store
2
- .rvmrc
3
2
  .bundle
@@ -1,3 +1,3 @@
1
1
  # encoding: UTF-8
2
2
  source "http://rubygems.org"
3
- gem "mango", "~> 0.5.4"
3
+ gem "mango", "~> 0.6.0"
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: Congratulations!
3
+ ---
4
+ <h1><%= page.title %></h1>
5
+
6
+ <h2>You did it!</h2>
@@ -0,0 +1,6 @@
1
+ fire = ->
2
+ gap = Math.floor(Math.random() * 1201) + 600
3
+ setTimeout(fire, gap)
4
+ createFirework(30,125,7,5,null,null,null,null,false,true)
5
+
6
+ window.onload = fire
@@ -1,5 +1,3 @@
1
- @charset "UTF-8";
2
-
3
1
  /* v1.0 | 20080212 */
4
2
 
5
3
  html, body, div, span, applet, object, iframe,
@@ -1,5 +1,3 @@
1
- @charset "UTF-8"
2
-
3
1
  body
4
2
  background-color: #D05C12
5
3
  font-family: "Lobster", arial, serif
@@ -2,14 +2,14 @@
2
2
  %html
3
3
  %head
4
4
  %meta{ :charset => "utf-8" }
5
- %title= "Mango: #{@content_page.title}"
5
+ %title= "Mango: #{page.title}"
6
6
  %link{ :rel => "stylesheet", :type => "text/css", :media => "screen", :href => "http://fonts.googleapis.com/css?family=Lobster" }
7
- %link{ :rel => "stylesheet", :type => "text/css", :media => "screen", :href => "/styles/reset.css" }
8
- %link{ :rel => "stylesheet", :type => "text/css", :media => "screen", :href => "/styles/screen.css" }
9
- %link{ :rel => "stylesheet", :type => "text/css", :media => "screen", :href => "/styles/fireworks.css" }
7
+ %link{ :rel => "stylesheet", :type => "text/css", :media => "screen", :href => "/stylesheets/reset.css" }
8
+ %link{ :rel => "stylesheet", :type => "text/css", :media => "screen", :href => "/stylesheets/screen.css" }
9
+ %link{ :rel => "stylesheet", :type => "text/css", :media => "screen", :href => "/stylesheets/fireworks.css" }
10
10
  %script{ :type => "text/javascript", :src => "/javascripts/fireworks.js"}
11
11
  %script{ :type => "text/javascript", :src => "/javascripts/timer.js"}
12
- %body{ :onload => "fire();" }
12
+ %body
13
13
  %div#fireworks-template
14
14
  %div#fw.firework
15
15
  %div#fp.fireworkParticle
@@ -1,3 +1 @@
1
- %h1= @content_page.title
2
-
3
- = @content_page.to_html
1
+ = page.content
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mango
4
4
  # Current stable released version
5
- VERSION = "0.5.4"
5
+ VERSION = "0.6.0"
6
6
  end
@@ -15,18 +15,20 @@ Gem::Specification.new do |s|
15
15
  s.required_rubygems_version = ">= 1.3.7"
16
16
  s.rubyforge_project = "mango"
17
17
 
18
- s.add_runtime_dependency "bundler", "~> 1.0.7"
19
- s.add_runtime_dependency "rack", "~> 1.2.2"
20
- s.add_runtime_dependency "sinatra", "~> 1.1.4"
21
- s.add_runtime_dependency "haml", "~> 3.0.25"
22
- s.add_runtime_dependency "bluecloth", "~> 2.1.0"
23
- s.add_runtime_dependency "thor", "~> 0.14.6"
18
+ s.add_runtime_dependency "bundler", "~> 1.0.7"
19
+ s.add_runtime_dependency "rack", "~> 1.2.2"
20
+ s.add_runtime_dependency "sinatra", "~> 1.2.6"
21
+ s.add_runtime_dependency "haml", "~> 3.1.1"
22
+ s.add_runtime_dependency "sass", "~> 3.1.1"
23
+ s.add_runtime_dependency "liquid", "~> 2.2.2"
24
+ s.add_runtime_dependency "bluecloth", "~> 2.1.0"
25
+ s.add_runtime_dependency "coffee-script", "~> 2.2.0"
26
+ s.add_runtime_dependency "thor", "~> 0.14.6"
24
27
 
25
- s.add_development_dependency "rspec", "~> 2.5.0"
26
- s.add_development_dependency "rack-test", "~> 0.5.7"
27
- s.add_development_dependency "yard", "~> 0.6.8"
28
+ s.add_development_dependency "rspec", "~> 2.6.0"
29
+ s.add_development_dependency "rack-test", "~> 0.6.0"
30
+ s.add_development_dependency "yard", "~> 0.7.1"
28
31
  s.add_development_dependency "bluecloth", "~> 2.1.0"
29
- s.add_development_dependency "yard-sinatra", "~> 0.5.1"
30
32
 
31
33
  s.files = `git ls-files`.split("\n")
32
34
  s.test_files = `git ls-files -- spec/*`.split("\n")
@@ -0,0 +1,7 @@
1
+ ---
2
+ categories:
3
+ engines
4
+ erb
5
+ ---
6
+ <p><%= page.categories %></p>
7
+ <p><%= "/engines/erb.erb" %></p>
@@ -1,7 +1,7 @@
1
1
  ---
2
- title: Haml!
3
- category:
4
- - content
5
- - engine
2
+ categories:
3
+ engines
4
+ haml
6
5
  ---
6
+ %p= page.categories
7
7
  %p /engines/haml.haml
@@ -0,0 +1,7 @@
1
+ ---
2
+ categories:
3
+ engines
4
+ liquid
5
+ ---
6
+ <p>{{ page.categories }}</p>
7
+ <p>{{ "/engines/liquid.liquid" }}</p>
@@ -1,7 +1 @@
1
- ---
2
- title: Markdown!
3
- category:
4
- - content
5
- - engine
6
- ---
7
1
  ### /engines/markdown.markdown
@@ -1,7 +1 @@
1
- ---
2
- title: Markdown!
3
- category:
4
- - content
5
- - engine
6
- ---
7
1
  ### /engines/md.md
@@ -0,0 +1 @@
1
+ ### /engines/mkd.mkd
@@ -1,4 +1,4 @@
1
1
  ---
2
- view: missing_view_template
2
+ view: missing.haml
3
3
  ---
4
- %p /attributes.haml
4
+ %p /page_with_missing_view.haml
@@ -0,0 +1,4 @@
1
+ ---
2
+ view: unregistered.extension
3
+ ---
4
+ %p /page_with_unregistered_view.haml
@@ -0,0 +1,4 @@
1
+ ---
2
+ view: page.erb
3
+ ---
4
+ %p /view_engines/erb.haml
@@ -0,0 +1,4 @@
1
+ ---
2
+ view: page.liquid
3
+ ---
4
+ %p /view_engines/liquid.haml
@@ -0,0 +1 @@
1
+ singers = {Jagger: "Rock", Elvis: "Roll"}
@@ -0,0 +1,7 @@
1
+ kids =
2
+ brother:
3
+ name: "Max"
4
+ age: 11
5
+ sister:
6
+ name: "Ida"
7
+ age: 9
@@ -0,0 +1,5 @@
1
+ if happy and knowsIt
2
+ clapsHands()
3
+ chaChaCha()
4
+ else
5
+ showIt()
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8' />
5
+ <title>404 Page</title>
6
+ </head>
7
+ <body>
8
+ <h1>Page not found</h1>
9
+ <p id='template'>404.html</p>
10
+ </body>
11
+ </html>
@@ -0,0 +1,8 @@
1
+ if (this.studyingEconomics) {
2
+ while (supply > demand) {
3
+ buy();
4
+ }
5
+ while (!(supply > demand)) {
6
+ sell();
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ var number, opposite;
2
+ number = 42;
3
+ opposite = true;
4
+ if (opposite) {
5
+ number = -42;
6
+ }
@@ -0,0 +1 @@
1
+ var bitlist = [1, 0, 1, 0, 0, 1, 1, 1, 0];
@@ -0,0 +1,5 @@
1
+ var yearsOld = {
2
+ max: 10,
3
+ ida: 9,
4
+ tim: 11
5
+ };
@@ -0,0 +1 @@
1
+ This file should *not* be accessible to a browser.
@@ -1,7 +1,9 @@
1
- @charset "UTF-8"
2
-
3
1
  $blue: #3bbfce
4
2
  $margin: 16px
3
+ $template: "sass.sass"
4
+
5
+ .main
6
+ background-image: url($template)
5
7
 
6
8
  .content-navigation
7
9
  border-color: $blue
@@ -0,0 +1,19 @@
1
+ $blue: #3bbfce;
2
+ $margin: 16px;
3
+ $template: "scss.scss";
4
+
5
+ .main {
6
+ background-image: url($template);
7
+ }
8
+
9
+ .content-navigation {
10
+ border-color: $blue;
11
+ color:
12
+ darken($blue, 9%);
13
+ }
14
+
15
+ .border {
16
+ padding: $margin / 2;
17
+ margin: $margin / 2;
18
+ border-color: $blue;
19
+ }
@@ -1,5 +1,3 @@
1
- @charset "UTF-8"
2
-
3
1
  table.hl
4
2
  margin: 2em 0
5
3
  td.ln
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8' />
5
+ <title>404 Page</title>
6
+ </head>
7
+ <body>
8
+ <h1>Page not found</h1>
9
+ <p id='template'><%= "404.erb" %></p>
10
+ </body>
11
+ </html>
@@ -5,3 +5,4 @@
5
5
  %title 404 Page
6
6
  %body
7
7
  %h1 Page not found
8
+ %p#template 404.haml
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8' />
5
+ <title>404 Page</title>
6
+ </head>
7
+ <body>
8
+ <h1>Page not found</h1>
9
+ <p id='template'>{{ "404.liquid" }}</p>
10
+ </body>
11
+ </html>
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8' />
5
+ <title>layout.erb</title>
6
+ </head>
7
+ <body>
8
+ <%= yield %>
9
+ </body>
10
+ </html>
@@ -2,6 +2,6 @@
2
2
  %html
3
3
  %head
4
4
  %meta{ :charset => "utf-8" }
5
- %title App Root Page
5
+ %title layout.haml
6
6
  %body
7
7
  = yield
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8' />
5
+ <title>layout.liquid</title>
6
+ </head>
7
+ <body>
8
+ {{ yield }}
9
+ </body>
10
+ </html>
@@ -0,0 +1,7 @@
1
+ <h1>Welcome to Mango!</h1>
2
+
3
+ <p id="template">page.erb</p>
4
+
5
+ <div id="content">
6
+ <%= page.content %>
7
+ </div>
@@ -1,4 +1,6 @@
1
1
  %h1 Welcome to Mango!
2
2
 
3
+ %p#template page.haml
4
+
3
5
  %div#content
4
- = @content_page.to_html
6
+ = page.content
@@ -0,0 +1,7 @@
1
+ <h1>Welcome to Mango!</h1>
2
+
3
+ <p id="template">page.liquid</p>
4
+
5
+ <div id="content">
6
+ {{ page.content }}
7
+ </div>
@@ -12,7 +12,7 @@ describe Mango::Application do
12
12
  #################################################################################################
13
13
 
14
14
  describe "GET (empty String)" do
15
- before(:each) do
15
+ before(:all) do
16
16
  get ""
17
17
  end
18
18
 
@@ -30,10 +30,11 @@ describe Mango::Application do
30
30
  <html>
31
31
  <head>
32
32
  <meta charset='utf-8' />
33
- <title>App Root Page</title>
33
+ <title>layout.haml</title>
34
34
  </head>
35
35
  <body>
36
36
  <h1>Welcome to Mango!</h1>
37
+ <p id='template'>page.haml</p>
37
38
  <div id='content'>
38
39
  <p>/index.haml</p>
39
40
  </div>
@@ -46,7 +47,7 @@ describe Mango::Application do
46
47
  #################################################################################################
47
48
 
48
49
  describe "GET /" do
49
- before(:each) do
50
+ before(:all) do
50
51
  get "/"
51
52
  end
52
53
 
@@ -64,10 +65,11 @@ describe Mango::Application do
64
65
  <html>
65
66
  <head>
66
67
  <meta charset='utf-8' />
67
- <title>App Root Page</title>
68
+ <title>layout.haml</title>
68
69
  </head>
69
70
  <body>
70
71
  <h1>Welcome to Mango!</h1>
72
+ <p id='template'>page.haml</p>
71
73
  <div id='content'>
72
74
  <p>/index.haml</p>
73
75
  </div>
@@ -80,7 +82,7 @@ describe Mango::Application do
80
82
  #################################################################################################
81
83
 
82
84
  describe "GET /index" do
83
- before(:each) do
85
+ before(:all) do
84
86
  get "/index"
85
87
  end
86
88
 
@@ -98,10 +100,11 @@ describe Mango::Application do
98
100
  <html>
99
101
  <head>
100
102
  <meta charset='utf-8' />
101
- <title>App Root Page</title>
103
+ <title>layout.haml</title>
102
104
  </head>
103
105
  <body>
104
106
  <h1>Welcome to Mango!</h1>
107
+ <p id='template'>page.haml</p>
105
108
  <div id='content'>
106
109
  <p>/index.haml</p>
107
110
  </div>
@@ -114,7 +117,7 @@ describe Mango::Application do
114
117
  #################################################################################################
115
118
 
116
119
  describe "GET /index?foo=bar" do
117
- before(:each) do
120
+ before(:all) do
118
121
  get "/index?foo=bar"
119
122
  end
120
123
 
@@ -132,10 +135,11 @@ describe Mango::Application do
132
135
  <html>
133
136
  <head>
134
137
  <meta charset='utf-8' />
135
- <title>App Root Page</title>
138
+ <title>layout.haml</title>
136
139
  </head>
137
140
  <body>
138
141
  <h1>Welcome to Mango!</h1>
142
+ <p id='template'>page.haml</p>
139
143
  <div id='content'>
140
144
  <p>/index.haml</p>
141
145
  </div>
@@ -148,7 +152,7 @@ describe Mango::Application do
148
152
  #################################################################################################
149
153
 
150
154
  describe "GET /about/" do
151
- before(:each) do
155
+ before(:all) do
152
156
  get "/about/"
153
157
  end
154
158
 
@@ -166,10 +170,11 @@ describe Mango::Application do
166
170
  <html>
167
171
  <head>
168
172
  <meta charset='utf-8' />
169
- <title>App Root Page</title>
173
+ <title>layout.haml</title>
170
174
  </head>
171
175
  <body>
172
176
  <h1>Welcome to Mango!</h1>
177
+ <p id='template'>page.haml</p>
173
178
  <div id='content'>
174
179
  <p>/about/index.haml</p>
175
180
  </div>
@@ -182,7 +187,7 @@ describe Mango::Application do
182
187
  #################################################################################################
183
188
 
184
189
  describe "GET /about/index" do
185
- before(:each) do
190
+ before(:all) do
186
191
  get "/about/index"
187
192
  end
188
193
 
@@ -200,10 +205,11 @@ describe Mango::Application do
200
205
  <html>
201
206
  <head>
202
207
  <meta charset='utf-8' />
203
- <title>App Root Page</title>
208
+ <title>layout.haml</title>
204
209
  </head>
205
210
  <body>
206
211
  <h1>Welcome to Mango!</h1>
212
+ <p id='template'>page.haml</p>
207
213
  <div id='content'>
208
214
  <p>/about/index.haml</p>
209
215
  </div>
@@ -216,7 +222,7 @@ describe Mango::Application do
216
222
  #################################################################################################
217
223
 
218
224
  describe "GET /about/us" do
219
- before(:each) do
225
+ before(:all) do
220
226
  get "/about/us"
221
227
  end
222
228
 
@@ -234,10 +240,11 @@ describe Mango::Application do
234
240
  <html>
235
241
  <head>
236
242
  <meta charset='utf-8' />
237
- <title>App Root Page</title>
243
+ <title>layout.haml</title>
238
244
  </head>
239
245
  <body>
240
246
  <h1>Welcome to Mango!</h1>
247
+ <p id='template'>page.haml</p>
241
248
  <div id='content'>
242
249
  <p>/about/us.haml</p>
243
250
  </div>
@@ -250,7 +257,7 @@ describe Mango::Application do
250
257
  #################################################################################################
251
258
 
252
259
  describe "GET /turner%2Bhooch" do
253
- before(:each) do
260
+ before(:all) do
254
261
  get "/turner%2Bhooch"
255
262
  end
256
263
 
@@ -268,10 +275,11 @@ describe Mango::Application do
268
275
  <html>
269
276
  <head>
270
277
  <meta charset='utf-8' />
271
- <title>App Root Page</title>
278
+ <title>layout.haml</title>
272
279
  </head>
273
280
  <body>
274
281
  <h1>Welcome to Mango!</h1>
282
+ <p id='template'>page.haml</p>
275
283
  <div id='content'>
276
284
  <p>/turner+hooch.haml</p>
277
285
  </div>
@@ -283,8 +291,85 @@ describe Mango::Application do
283
291
 
284
292
  #################################################################################################
285
293
 
294
+ describe "GET /view_engines/erb" do
295
+ before(:all) do
296
+ get "/view_engines/erb"
297
+ end
298
+
299
+ it "returns 200 status code" do
300
+ last_response.should be_ok
301
+ end
302
+
303
+ it "sends the correct Content-Type header" do
304
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
305
+ end
306
+
307
+ it "sends the correct body content" do
308
+ last_response.body.should == <<-EXPECTED
309
+ <!DOCTYPE html>
310
+ <html>
311
+ <head>
312
+ <meta charset='utf-8' />
313
+ <title>layout.erb</title>
314
+ </head>
315
+ <body>
316
+ <h1>Welcome to Mango!</h1>
317
+
318
+ <p id="template">page.erb</p>
319
+
320
+ <div id="content">
321
+ <p>/view_engines/erb.haml</p>
322
+
323
+ </div>
324
+ </body>
325
+ </html>
326
+ EXPECTED
327
+ end
328
+ end
329
+
330
+ #################################################################################################
331
+
332
+ describe "GET /view_engines/liquid" do
333
+ before(:all) do
334
+ get "/view_engines/liquid"
335
+ end
336
+
337
+ it "returns 200 status code" do
338
+ last_response.should be_ok
339
+ end
340
+
341
+ it "sends the correct Content-Type header" do
342
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
343
+ end
344
+
345
+ it "sends the correct body content" do
346
+ last_response.body.should == <<-EXPECTED
347
+ <!DOCTYPE html>
348
+ <html>
349
+ <head>
350
+ <meta charset='utf-8' />
351
+ <title>layout.liquid</title>
352
+ </head>
353
+ <body>
354
+ <h1>Welcome to Mango!</h1>
355
+
356
+ <p id="template">page.liquid</p>
357
+
358
+ <div id="content">
359
+ <p>/view_engines/liquid.haml</p>
360
+
361
+ </div>
362
+
363
+ </body>
364
+ </html>
365
+ EXPECTED
366
+ end
367
+ end
368
+
369
+ #################################################################################################
370
+
286
371
  describe "GET /page_not_found" do
287
- before(:each) do
372
+ before(:all) do
288
373
  get "/page_not_found"
289
374
  end
290
375
 
@@ -306,6 +391,7 @@ describe Mango::Application do
306
391
  </head>
307
392
  <body>
308
393
  <h1>Page not found</h1>
394
+ <p id='template'>404.html</p>
309
395
  </body>
310
396
  </html>
311
397
  EXPECTED
@@ -314,19 +400,32 @@ describe Mango::Application do
314
400
 
315
401
  #################################################################################################
316
402
 
403
+ describe "GET /page_with_unregistered_view" do
404
+ it "raises an exception" do
405
+ path = FIXTURE_ROOT + "themes/default/views/unregistered.extension"
406
+ message = "Cannot find registered engine for view template file -- #{path}"
407
+ lambda {
408
+ get "/page_with_unregistered_view"
409
+ }.should raise_exception(Mango::Application::RegisteredEngineNotFound, message)
410
+ end
411
+ end
412
+
413
+ #################################################################################################
414
+
317
415
  describe "GET /page_with_missing_view" do
318
- it "raises RuntimeError" do
319
- path = FIXTURE_ROOT + "themes/default/views/missing_view_template.haml"
416
+ it "raises an exception" do
417
+ path = FIXTURE_ROOT + "themes/default/views/missing.haml"
418
+ message = "Cannot find view template file -- #{path}"
320
419
  lambda {
321
420
  get "/page_with_missing_view"
322
- }.should raise_exception(RuntimeError, "Unable to find a view template file -- #{path}")
421
+ }.should raise_exception(Mango::Application::ViewTemplateNotFound, message)
323
422
  end
324
423
  end
325
424
 
326
425
  #################################################################################################
327
426
 
328
427
  describe "GET /../security_hole" do
329
- before(:each) do
428
+ before(:all) do
330
429
  get "/../security_hole"
331
430
  end
332
431
 
@@ -348,10 +447,188 @@ describe Mango::Application do
348
447
  </head>
349
448
  <body>
350
449
  <h1>Page not found</h1>
450
+ <p id='template'>404.html</p>
451
+ </body>
452
+ </html>
453
+ EXPECTED
454
+ end
455
+ end
456
+
457
+ #################################################################################################
458
+
459
+ describe "GET /engines/haml" do
460
+ before(:all) do
461
+ get "/engines/haml"
462
+ end
463
+
464
+ it "returns 200 status code" do
465
+ last_response.should be_ok
466
+ end
467
+
468
+ it "sends the correct Content-Type header" do
469
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
470
+ end
471
+
472
+ it "sends the correct body content" do
473
+ last_response.body.should == <<-EXPECTED
474
+ <!DOCTYPE html>
475
+ <html>
476
+ <head>
477
+ <meta charset='utf-8' />
478
+ <title>layout.haml</title>
479
+ </head>
480
+ <body>
481
+ <h1>Welcome to Mango!</h1>
482
+ <p id='template'>page.haml</p>
483
+ <div id='content'>
484
+ <p>engines haml</p>
485
+ <p>/engines/haml.haml</p>
486
+ </div>
351
487
  </body>
352
488
  </html>
353
489
  EXPECTED
354
490
  end
355
491
  end
356
492
 
493
+ #################################################################################################
494
+
495
+ describe "GET /engines/md" do
496
+ before(:all) do
497
+ get "/engines/md"
498
+ end
499
+
500
+ it "returns 200 status code" do
501
+ last_response.should be_ok
502
+ end
503
+
504
+ it "sends the correct Content-Type header" do
505
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
506
+ end
507
+
508
+ it "sends the correct body content" do
509
+ last_response.body.should == <<-EXPECTED
510
+ <!DOCTYPE html>
511
+ <html>
512
+ <head>
513
+ <meta charset='utf-8' />
514
+ <title>layout.haml</title>
515
+ </head>
516
+ <body>
517
+ <h1>Welcome to Mango!</h1>
518
+ <p id='template'>page.haml</p>
519
+ <div id='content'>
520
+ <h3>/engines/md.md</h3>
521
+ </div>
522
+ </body>
523
+ </html>
524
+ EXPECTED
525
+ end
526
+ end
527
+
528
+ #################################################################################################
529
+
530
+ describe "GET /engines/mkd" do
531
+ before(:all) do
532
+ get "/engines/mkd"
533
+ end
534
+
535
+ it "returns 200 status code" do
536
+ last_response.should be_ok
537
+ end
538
+
539
+ it "sends the correct Content-Type header" do
540
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
541
+ end
542
+
543
+ it "sends the correct body content" do
544
+ last_response.body.should == <<-EXPECTED
545
+ <!DOCTYPE html>
546
+ <html>
547
+ <head>
548
+ <meta charset='utf-8' />
549
+ <title>layout.haml</title>
550
+ </head>
551
+ <body>
552
+ <h1>Welcome to Mango!</h1>
553
+ <p id='template'>page.haml</p>
554
+ <div id='content'>
555
+ <h3>/engines/mkd.mkd</h3>
556
+ </div>
557
+ </body>
558
+ </html>
559
+ EXPECTED
560
+ end
561
+ end
562
+
563
+ #################################################################################################
564
+
565
+ describe "GET /engines/erb" do
566
+ before(:all) do
567
+ get "/engines/erb"
568
+ end
569
+
570
+ it "returns 200 status code" do
571
+ last_response.should be_ok
572
+ end
573
+
574
+ it "sends the correct Content-Type header" do
575
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
576
+ end
577
+
578
+ it "sends the correct body content" do
579
+ last_response.body.should == <<-EXPECTED
580
+ <!DOCTYPE html>
581
+ <html>
582
+ <head>
583
+ <meta charset='utf-8' />
584
+ <title>layout.haml</title>
585
+ </head>
586
+ <body>
587
+ <h1>Welcome to Mango!</h1>
588
+ <p id='template'>page.haml</p>
589
+ <div id='content'>
590
+ <p>engines erb</p>
591
+ <p>/engines/erb.erb</p>
592
+ </div>
593
+ </body>
594
+ </html>
595
+ EXPECTED
596
+ end
597
+ end
598
+
599
+ #################################################################################################
600
+
601
+ describe "GET /engines/liquid" do
602
+ before(:all) do
603
+ get "/engines/liquid"
604
+ end
605
+
606
+ it "returns 200 status code" do
607
+ last_response.should be_ok
608
+ end
609
+
610
+ it "sends the correct Content-Type header" do
611
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
612
+ end
613
+
614
+ it "sends the correct body content" do
615
+ last_response.body.should == <<-EXPECTED
616
+ <!DOCTYPE html>
617
+ <html>
618
+ <head>
619
+ <meta charset='utf-8' />
620
+ <title>layout.haml</title>
621
+ </head>
622
+ <body>
623
+ <h1>Welcome to Mango!</h1>
624
+ <p id='template'>page.haml</p>
625
+ <div id='content'>
626
+ <p>engines liquid</p>
627
+ <p>/engines/liquid.liquid</p>
628
+ </div>
629
+ </body>
630
+ </html>
631
+ EXPECTED
632
+ end
633
+ end
357
634
  end