Skip to content
This repository
Browse code

More view tests.

  • Loading branch information...
commit 0bd340f8668d0624a44b136f9d7178abe64f68fe 1 parent 492c321
Maurice Machado authored August 07, 2011
4  package.json
@@ -13,7 +13,9 @@
13 13
     "node-uuid": "1.2.0"
14 14
   },
15 15
   "devDependencies": {
16  
-    "expresso": "0.8.1"
  16
+    "expresso": "0.8.1",
  17
+    "eco": "1.1.0-rc-1",
  18
+    "jade": "0.13.0"
17 19
   },
18 20
   "keywords": ["framework", "websockets", "coffeescript", "express", "socket.io", "sammy", "sinatra"],
19 21
   "main": "./lib/zappa",
157  tests/views.coffee
@@ -6,6 +6,7 @@ module.exports =
6 6
       get '/': ->
7 7
         @foo = 'bar'
8 8
         render 'index', layout: no
  9
+
9 10
       view index: -> h2 "CoffeeKup inline template: #{@foo}"
10 11
     
11 12
     t.get '/', '<h2>CoffeeKup inline template: bar</h2>'
@@ -15,7 +16,9 @@ module.exports =
15 16
       get '/': ->
16 17
         @foo = 'bar'
17 18
         render 'index'
  19
+
18 20
       view index: -> h2 "CoffeeKup inline template: #{@foo}"
  21
+
19 22
       view layout: ->
20 23
         doctype 5
21 24
         html ->
@@ -43,12 +46,162 @@ module.exports =
43 46
 
44 47
   'Views (response.render)': ->
45 48
     t = zappa ->
46  
-      get '/': -> response.render 'index', foo: 'bar', layout: no
  49
+      get '/': ->
  50
+        response.render 'index', foo: 'bar', layout: no
47 51
     
48 52
     t.get '/', '<h2>CoffeeKup file template: bar</h2>'
49 53
 
50 54
   'Views (response.render, layout)': ->
51 55
     t = zappa ->
52  
-      get '/': -> response.render 'index', foo: 'bar'
  56
+      get '/': ->
  57
+        response.render 'index', foo: 'bar'
53 58
     
54 59
     t.get '/', '<!DOCTYPE html><html><head><title>CoffeeKup file layout</title></head><body><h2>CoffeeKup file template: bar</h2></body></html>'
  60
+
  61
+  'Views (eco, inline)': ->
  62
+    t = zappa ->
  63
+      set 'view engine': 'eco'
  64
+      
  65
+      get '/': ->
  66
+        @foo = 'bar'
  67
+        render 'index', layout: no
  68
+
  69
+      view index: "<h2>Eco inline template: <%= @params.foo %></h2>"
  70
+    
  71
+    t.get '/', '<h2>Eco inline template: bar</h2>'
  72
+
  73
+  'Views (eco, inline, inline layout)': ->
  74
+    t = zappa ->
  75
+      set 'view engine': 'eco'
  76
+      
  77
+      get '/': ->
  78
+        @foo = 'bar'
  79
+        render 'index'
  80
+
  81
+      view index: "<h2>Eco inline template: <%= @params.foo %></h2>"
  82
+
  83
+      view layout: '''
  84
+        <!DOCTYPE html>
  85
+        <html>
  86
+          <head>
  87
+            <title>Eco inline layout</title>
  88
+          </head>
  89
+          <body><%- @body %></body>
  90
+        </html>
  91
+      '''
  92
+
  93
+    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>'
  94
+
  95
+
  96
+  'Views (eco, file)': ->
  97
+    t = zappa ->
  98
+      set 'view engine': 'eco'
  99
+      
  100
+      get '/': ->
  101
+        @foo = 'bar'
  102
+        render 'index', layout: no
  103
+    
  104
+    t.get '/', '<h2>Eco file template: bar</h2>'
  105
+
  106
+  'Views (eco, file, file layout)': ->
  107
+    t = zappa ->
  108
+      set 'view engine': 'eco'
  109
+      
  110
+      get '/': ->
  111
+        @foo = 'bar'
  112
+        render 'index'
  113
+    
  114
+    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>'
  115
+
  116
+  'Views (eco, zappa adapter, inline, inline layout)': ->
  117
+    t = zappa ->
  118
+      set 'view engine': 'eco'
  119
+      app.register '.eco', require('../src/zappa').adapter('eco')
  120
+      
  121
+      get '/': ->
  122
+        @foo = 'bar'
  123
+        render 'index'
  124
+
  125
+      view index: "<h2>Eco inline template: <%= @foo %></h2>"
  126
+
  127
+      view layout: '''
  128
+        <!DOCTYPE html>
  129
+        <html>
  130
+          <head>
  131
+            <title>Eco inline layout</title>
  132
+          </head>
  133
+          <body><%- @body %></body>
  134
+        </html>
  135
+      '''
  136
+
  137
+  'Views (jade, inline)': ->
  138
+    t = zappa ->
  139
+      set 'view engine': 'jade'
  140
+      
  141
+      get '/': ->
  142
+        @foo = 'bar'
  143
+        render 'index', layout: no
  144
+
  145
+      view index: "h2= 'Jade inline template: ' + params.foo"
  146
+    
  147
+    t.get '/', '<h2>Jade inline template: bar</h2>'
  148
+
  149
+  'Views (jade, inline, inline layout)': ->
  150
+    t = zappa ->
  151
+      set 'view engine': 'jade'
  152
+      
  153
+      get '/': ->
  154
+        @foo = 'bar'
  155
+        render 'index'
  156
+
  157
+      view index: "h2= 'Jade inline template: ' + params.foo"
  158
+
  159
+      view layout: '''
  160
+        !!! 5
  161
+        html
  162
+          head
  163
+            title Jade inline layout
  164
+          body!= body
  165
+      '''
  166
+
  167
+    t.get '/', '<!DOCTYPE html><html><head><title>Jade inline layout</title></head><body><h2>Jade inline template: bar</h2></body></html>'
  168
+
  169
+
  170
+  'Views (jade, file)': ->
  171
+    t = zappa ->
  172
+      set 'view engine': 'jade'
  173
+      
  174
+      get '/': ->
  175
+        @foo = 'bar'
  176
+        render 'index', layout: no
  177
+    
  178
+    t.get '/', '<h2>Jade file template: bar</h2>'
  179
+
  180
+  'Views (jade, file, file layout)': ->
  181
+    t = zappa ->
  182
+      set 'view engine': 'jade'
  183
+      
  184
+      get '/': ->
  185
+        @foo = 'bar'
  186
+        render 'index'
  187
+    
  188
+    t.get '/', '<!DOCTYPE html><html><head><title>Jade file layout</title></head><body><h2>Jade file template: bar</h2></body></html>'
  189
+
  190
+  'Views (jade, zappa adapter, inline, inline layout)': ->
  191
+    t = zappa ->
  192
+      set 'view engine': 'jade'
  193
+      app.register '.jade', require('../src/zappa').adapter('jade')
  194
+      
  195
+      get '/': ->
  196
+        @foo = 'bar'
  197
+        render 'index'
  198
+
  199
+      view index: "h2= 'Jade inline template: ' + foo"
  200
+
  201
+      view layout: '''
  202
+        !!! 5
  203
+        html
  204
+          head
  205
+            title Jade inline layout
  206
+          body!= body
  207
+      '''
1  tests/views/index.eco
... ...
@@ -0,0 +1 @@
  1
+<h2>Eco file template: <%= @params.foo %></h2>
2  tests/views/index.jade
... ...
@@ -1 +1 @@
1  
-h2 Jade file template
  1
+h2= 'Jade file template: ' + params.foo
7  tests/views/layout.eco
... ...
@@ -0,0 +1,7 @@
  1
+<!DOCTYPE html>
  2
+<html>
  3
+  <head>
  4
+    <title>Eco file layout</title>
  5
+  </head>
  6
+  <body><%- @body %></body>
  7
+</html>
1  tests/views/layout.jade
@@ -3,5 +3,4 @@ html
3 3
   head
4 4
     title Jade file layout
5 5
   body
6  
-    h1 Jade file layout
7 6
     != body

0 notes on commit 0bd340f

Please sign in to comment.
Something went wrong with that request. Please try again.