Permalink
Browse files

More view tests.

  • Loading branch information...
1 parent 492c321 commit 0bd340f8668d0624a44b136f9d7178abe64f68fe @mauricemach committed Aug 7, 2011
Showing with 167 additions and 5 deletions.
  1. +3 −1 package.json
  2. +155 −2 tests/views.coffee
  3. +1 −0 tests/views/index.eco
  4. +1 −1 tests/views/index.jade
  5. +7 −0 tests/views/layout.eco
  6. +0 −1 tests/views/layout.jade
View
4 package.json
@@ -13,7 +13,9 @@
"node-uuid": "1.2.0"
},
"devDependencies": {
- "expresso": "0.8.1"
+ "expresso": "0.8.1",
+ "eco": "1.1.0-rc-1",
+ "jade": "0.13.0"
},
"keywords": ["framework", "websockets", "coffeescript", "express", "socket.io", "sammy", "sinatra"],
"main": "./lib/zappa",
View
157 tests/views.coffee
@@ -6,6 +6,7 @@ module.exports =
get '/': ->
@foo = 'bar'
render 'index', layout: no
+
view index: -> h2 "CoffeeKup inline template: #{@foo}"
t.get '/', '<h2>CoffeeKup inline template: bar</h2>'
@@ -15,7 +16,9 @@ module.exports =
get '/': ->
@foo = 'bar'
render 'index'
+
view index: -> h2 "CoffeeKup inline template: #{@foo}"
+
view layout: ->
doctype 5
html ->
@@ -43,12 +46,162 @@ module.exports =
'Views (response.render)': ->
t = zappa ->
- get '/': -> response.render 'index', foo: 'bar', layout: no
+ get '/': ->
+ response.render 'index', foo: 'bar', layout: no
t.get '/', '<h2>CoffeeKup file template: bar</h2>'
'Views (response.render, layout)': ->
t = zappa ->
- get '/': -> response.render 'index', foo: 'bar'
+ get '/': ->
+ response.render 'index', foo: 'bar'
t.get '/', '<!DOCTYPE html><html><head><title>CoffeeKup file layout</title></head><body><h2>CoffeeKup file template: bar</h2></body></html>'
+
+ 'Views (eco, inline)': ->
+ t = zappa ->
+ set 'view engine': 'eco'
+
+ get '/': ->
+ @foo = 'bar'
+ render 'index', layout: no
+
+ view index: "<h2>Eco inline template: <%= @params.foo %></h2>"
+
+ t.get '/', '<h2>Eco inline template: bar</h2>'
+
+ 'Views (eco, inline, inline layout)': ->
+ t = zappa ->
+ set 'view engine': 'eco'
+
+ get '/': ->
+ @foo = 'bar'
+ render 'index'
+
+ view index: "<h2>Eco inline template: <%= @params.foo %></h2>"
+
+ view layout: '''
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <title>Eco inline layout</title>
+ </head>
+ <body><%- @body %></body>
+ </html>
+ '''
+
+ t.get '/', '<!DOCTYPE html>\n<html>\n <head>\n <title>Eco inline layout</title>\n </head>\n <body><h2>Eco inline template: bar</h2></body>\n</html>'
+
+
+ 'Views (eco, file)': ->
+ t = zappa ->
+ set 'view engine': 'eco'
+
+ get '/': ->
+ @foo = 'bar'
+ render 'index', layout: no
+
+ t.get '/', '<h2>Eco file template: bar</h2>'
+
+ 'Views (eco, file, file layout)': ->
+ t = zappa ->
+ set 'view engine': 'eco'
+
+ get '/': ->
+ @foo = 'bar'
+ render 'index'
+
+ t.get '/', '<!DOCTYPE html>\n<html>\n <head>\n <title>Eco file layout</title>\n </head>\n <body><h2>Eco file template: bar</h2></body>\n</html>'
+
+ 'Views (eco, zappa adapter, inline, inline layout)': ->
+ t = zappa ->
+ set 'view engine': 'eco'
+ app.register '.eco', require('../src/zappa').adapter('eco')
+
+ get '/': ->
+ @foo = 'bar'
+ render 'index'
+
+ view index: "<h2>Eco inline template: <%= @foo %></h2>"
+
+ view layout: '''
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <title>Eco inline layout</title>
+ </head>
+ <body><%- @body %></body>
+ </html>
+ '''
+
+ 'Views (jade, inline)': ->
+ t = zappa ->
+ set 'view engine': 'jade'
+
+ get '/': ->
+ @foo = 'bar'
+ render 'index', layout: no
+
+ view index: "h2= 'Jade inline template: ' + params.foo"
+
+ t.get '/', '<h2>Jade inline template: bar</h2>'
+
+ 'Views (jade, inline, inline layout)': ->
+ t = zappa ->
+ set 'view engine': 'jade'
+
+ get '/': ->
+ @foo = 'bar'
+ render 'index'
+
+ view index: "h2= 'Jade inline template: ' + params.foo"
+
+ view layout: '''
+ !!! 5
+ html
+ head
+ title Jade inline layout
+ body!= body
+ '''
+
+ t.get '/', '<!DOCTYPE html><html><head><title>Jade inline layout</title></head><body><h2>Jade inline template: bar</h2></body></html>'
+
+
+ 'Views (jade, file)': ->
+ t = zappa ->
+ set 'view engine': 'jade'
+
+ get '/': ->
+ @foo = 'bar'
+ render 'index', layout: no
+
+ t.get '/', '<h2>Jade file template: bar</h2>'
+
+ 'Views (jade, file, file layout)': ->
+ t = zappa ->
+ set 'view engine': 'jade'
+
+ get '/': ->
+ @foo = 'bar'
+ render 'index'
+
+ t.get '/', '<!DOCTYPE html><html><head><title>Jade file layout</title></head><body><h2>Jade file template: bar</h2></body></html>'
+
+ 'Views (jade, zappa adapter, inline, inline layout)': ->
+ t = zappa ->
+ set 'view engine': 'jade'
+ app.register '.jade', require('../src/zappa').adapter('jade')
+
+ get '/': ->
+ @foo = 'bar'
+ render 'index'
+
+ view index: "h2= 'Jade inline template: ' + foo"
+
+ view layout: '''
+ !!! 5
+ html
+ head
+ title Jade inline layout
+ body!= body
+ '''
View
1 tests/views/index.eco
@@ -0,0 +1 @@
+<h2>Eco file template: <%= @params.foo %></h2>
View
2 tests/views/index.jade
@@ -1 +1 @@
-h2 Jade file template
+h2= 'Jade file template: ' + params.foo
View
7 tests/views/layout.eco
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Eco file layout</title>
+ </head>
+ <body><%- @body %></body>
+</html>
View
1 tests/views/layout.jade
@@ -3,5 +3,4 @@ html
head
title Jade file layout
body
- h1 Jade file layout
!= body

0 comments on commit 0bd340f

Please sign in to comment.