Skip to content
Myr

spec.plugins.view.js

This file

Path

spec/spec.plugins.view.js

204 lines · 6.4 KiB · JavaScript

Last changed by

Merge branch 'better-haml'visionmediabefore adoptionbdf9f88

History of this file

Take it

The walk stopped after 200 commits: lines older than 3863a76 point at it.

Merge branch 'flash'visionmediabefore adoption3863a76

lines 1–13why, one step back
1
2describe 'Express'3 before_each4 reset()5 end6 7 describe 'View'8 describe 'set("views")'9 it 'should default to <root>/views'10 set('root', 'spec')11 set('views').should.eql 'spec/views'12 end13 end

Closes #52visionmediabefore adoption161c9f9

line 14why, one step back
14

Merge branch 'integration'visionmediabefore adoption7d100da

lines 15–23why, one step back
15 describe 'set("partials")'
16 it 'should default to <views>/partials'17 set('root', 'spec')18 set('partials').should.eql 'spec/views/partials'19 set('views', 'magicland')20 set('partials').should.eql 'magicland/partials'21 end22 end23

Merge branch 'partials'visionmediabefore adoption28f2ad0

lines 24–26why, one step back
24 describe '#partial()'
25 before_each26 set('views', 'spec/fixtures')

Merge branch 'integration'visionmediabefore adoption7d100da

line 27why, one step back
27 set('partials', 'spec/fixtures/partials')

Merge branch 'partials'visionmediabefore adoption28f2ad0

lines 28–32why, one step back
28 end
29 30 describe 'given a valid view name'31 it 'should render a partial'32 get('/', function(){

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 33why, one step back
33 this.render('list.html.haml', { locals: { items: ['foo', 'bar'] }})

Merge branch 'partials'visionmediabefore adoption28f2ad0

lines 34–41why, one step back
34 })
35 get('/').body.should.include '<ul>'36 get('/').body.should.include '<li>foo'37 get('/').body.should.include '<li>bar'38 end39 40 it 'should render collections'41 get('/', function(){

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 42why, one step back
42 return this.partial('item.html.haml', {

Merge branch 'partials'visionmediabefore adoption28f2ad0

lines 43–51why, one step back
43 collection: ['foo', 'bar']
44 })45 })46 get('/').body.should.include '<li>foo'47 get('/').body.should.include '<li>bar'48 end49 50 it 'should render collections with a given object name'51 get('/', function(){

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 52why, one step back
52 return this.partial('video.html.haml', {

Merge branch 'partials'visionmediabefore adoption28f2ad0

lines 53–59why, one step back
53 collection: ['im a movie', 'im another movie'],
54 as: 'vid'55 })56 })57 get('/').body.should.include '<li>im a movie'58 get('/').body.should.include '<li>im another movie'59 end

Merge branch 'partial-index-and-length'visionmediabefore adoptionb2093d6

lines 60–62why, one step back
60
61 it 'should pass __isFirst__, __isLast__, and __index__ to partials as locals'62 get('/', function(){

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 63why, one step back
63 return this.partial('article.html.haml', {

Merge branch 'partial-index-and-length'visionmediabefore adoptionb2093d6

lines 64–70why, one step back
64 collection: ['a', 'b', 'c']
65 })66 })67 get('/').body.should.include '<li class="first">a'68 get('/').body.should.include '<li class="1">b'69 get('/').body.should.include '<li class="last">c'70 end

Merge branch 'partials'visionmediabefore adoption28f2ad0

lines 71–73why, one step back
71 end
72 end73

Closes #52visionmediabefore adoption161c9f9

lines 74–78why, one step back
74 describe '#render()'
75 before_each76 set('views', 'spec/fixtures')77 end78

Added Request#render() callback function. Closes #258visionmediabefore adoption7b9f18b

lines 79–81why, one step back
79 describe 'given a callback'
80 it 'should be passed the rendered content'81 get('/', function(){

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 82why, one step back
82 this.render('hello.html.haml', {}, function(err, content){

Added Request#render() callback function. Closes #258visionmediabefore adoption7b9f18b

lines 83–86why, one step back
83 if (err) this.error(err)
84 else this.halt(203, content)85 })86 })

Merge branch 'better-haml'visionmediabefore adoptionbdf9f88

line 87why, one step back
87 get('/').body.should.include '<html>\n<body>'

Added Request#render() callback function. Closes #258visionmediabefore adoption7b9f18b

lines 88–91why, one step back
88 get('/').status.should.eql 203
89 end90 end91

Closes #52visionmediabefore adoption161c9f9

lines 92–95why, one step back
92 describe 'given a valid view name'
93 describe 'and layout of the same type exists'94 it 'should render the layout and view'95 get('/', function(){

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 96why, one step back
96 this.render('hello.html.haml')

Closes #52visionmediabefore adoption161c9f9

line 97why, one step back
97 })

Merge branch 'better-haml'visionmediabefore adoptionbdf9f88

line 98why, one step back
98 get('/').body.should.include '<html>\n<body>'

Closes #52visionmediabefore adoption161c9f9

lines 99–104why, one step back
99 get('/').body.should.include '<h2>Hello'
100 end101 102 it 'should default context to the current request'103 get('/', function(){104 this.title = 'Welcome'

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 105why, one step back
105 this.render('page.html.haml', { layout: false })

Closes #52visionmediabefore adoption161c9f9

lines 106–111why, one step back
106 })
107 get('/').body.should.include '<title>Welcome'108 end109 110 it 'should set the content type based on the last path segment'111 get('/', function(){

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 112why, one step back
112 this.render('hello.html.haml')

Closes #52visionmediabefore adoption161c9f9

lines 113–120why, one step back
113 })
114 get('/').headers['content-type'].should.eql 'text/html'115 end116 end117 118 describe 'and layout of the same type does not exist'119 it 'should throw an error'120 get('/', function(){

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 121why, one step back
121 this.render('hello.html.haml', { layout: 'front' })

Closes #52visionmediabefore adoption161c9f9

lines 122–130why, one step back
122 })
123 -{ get('/') }.should.throw_error 'No such file or directory'124 end125 end126 127 describe 'given a custom layout name'128 it 'should render the layout and view'129 get('/', function(){130 this.title = 'Express'

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 131why, one step back
131 this.render('hello.html.haml', { layout: 'page' })

Closes #52visionmediabefore adoption161c9f9

lines 132–140why, one step back
132 })
133 get('/').body.should.include '<title>Express'134 get('/').body.should.include '<h2>Hello'135 end136 end137 138 describe 'when layout: false'139 it 'should render the view only'140 get('/', function(){

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 141why, one step back
141 this.render('hello.html.haml', { layout: false })

Closes #52visionmediabefore adoption161c9f9

lines 142–150why, one step back
142 })
143 get('/').body.should.not.include '<body>'144 get('/').body.should.include '<h2>Hello'145 end146 end147 148 describe 'when engine cannot be found'149 it 'should throw an error'150 get('/', function(){

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 151why, one step back
151 this.render('user.html.invalid')

Closes #52visionmediabefore adoption161c9f9

lines 152–159why, one step back
152 })
153 -{ get('/') }.should.throw_error "Cannot find module 'invalid'"154 end155 end156 157 describe 'when locals are passed'158 it 'should have direct access to locals'159 get('/user', function(){

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 160why, one step back
160 this.render('user.html.haml', {

Closes #52visionmediabefore adoption161c9f9

lines 161–172why, one step back
161 locals: {
162 name: 'tj',163 email: 'tj@vision-media.ca'164 }165 })166 })167 get('/user').body.should.include '<h1>tj'168 get('/user').body.should.include '<p>tj@vision-media.ca'169 end170 171 it 'should have direct access to locals within the layout'172 get('/user', function(){

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 173why, one step back
173 this.render('user.html.haml', {

Closes #52visionmediabefore adoption161c9f9

lines 174–189why, one step back
174 layout: 'layout.user',
175 locals: {176 name: 'tj',177 email: 'tj@vision-media.ca'178 }179 })180 })181 get('/user').body.should.include '<title>Viewing tj'182 get('/user').body.should.include '<h1>tj'183 get('/user').body.should.include '<p>tj@vision-media.ca'184 end185 end186 187 describe 'when context is passed'188 it 'should evaluate in context to that object'189 get('/article', function(){

Merge branch 'flip-views'visionmediabefore adoption6b13fc9

line 190why, one step back
190 this.render('article.html.haml', {

Closes #52visionmediabefore adoption161c9f9

lines 191–202why, one step back
191 context: {
192 name: 'Writing a Node.js Web Application'193 }194 })195 })196 get('/article').body.should.include '<h2>Writing a Node.js Web Application'197 end198 end199 200 end201 202 end

Merge branch 'flash'visionmediabefore adoption3863a76

lines 203–204why, one step back
203 end
204end