spec.plugins.view.js
This file
Path
spec/spec.plugins.view.js
204 lines · 6.4 KiB · JavaScript
Last changed by
Merge branch 'partial-index-and-length'visionmediabefore adoptionb2093d6
History of this fileTake it
The walk stopped after 200 commits: lines older than 0186659 point at it.
Fixed upload app submit button stylingvisionmediabefore adoption0186659
lines 1–13why, one step back12describe '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 endCloses #52visionmediabefore adoption161c9f9
line 14why, one step back14 Merge branch 'integration'visionmediabefore adoption7d100da
lines 15–23why, one step back15 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 back24 describe '#partial()'25 before_each26 set('views', 'spec/fixtures')Merge branch 'integration'visionmediabefore adoption7d100da
line 27why, one step back27 set('partials', 'spec/fixtures/partials')Merge branch 'partials'visionmediabefore adoption28f2ad0
lines 28–59why, one step back28 end29 30 describe 'given a valid view name'31 it 'should render a partial'32 get('/', function(){33 this.render('list.haml.html', { locals: { items: ['foo', 'bar'] }})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(){42 return this.partial('item.haml.html', {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(){52 return this.partial('video.haml.html', {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 endMerge branch 'partial-index-and-length'visionmediabefore adoptionb2093d6
lines 60–70why, one step back60 61 it 'should pass __isFirst__, __isLast__, and __index__ to partials as locals'62 get('/', function(){63 return this.partial('article.haml.html', {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 endMerge branch 'partials'visionmediabefore adoption28f2ad0
lines 71–73why, one step back71 end72 end73 Closes #52visionmediabefore adoption161c9f9
lines 74–78why, one step back74 describe '#render()'75 before_each76 set('views', 'spec/fixtures')77 end78 Added Request#render() callback function. Closes #258visionmediabefore adoption7b9f18b
lines 79–91why, one step back79 describe 'given a callback'80 it 'should be passed the rendered content'81 get('/', function(){82 this.render('hello.haml.html', {}, function(err, content){83 if (err) this.error(err)84 else this.halt(203, content)85 })86 })87 get('/').body.should.include '<html><body>'88 get('/').status.should.eql 20389 end90 end91 Closes #52visionmediabefore adoption161c9f9
lines 92–202why, one step back92 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(){96 this.render('hello.haml.html')97 })98 get('/').body.should.include '<html><body>'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'105 this.render('page.haml.html', { layout: false })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(){112 this.render('hello.haml.html')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(){121 this.render('hello.haml.html', { layout: 'front' })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'131 this.render('hello.haml.html', { layout: 'page' })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(){141 this.render('hello.haml.html', { layout: false })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(){151 this.render('user.invalid.html')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(){160 this.render('user.haml.html', {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(){173 this.render('user.haml.html', {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(){190 this.render('article.haml.html', {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 endFixed upload app submit button stylingvisionmediabefore adoption0186659
lines 203–204why, one step back203 end204end