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 fileTake it
The walk stopped after 200 commits: lines older than 4d1bda0 point at it.
Removed Route#run(). Closes #188visionmediabefore adoption4d1bda0
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–32why, one step back28 end29 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 back33 this.render('list.html.haml', { locals: { items: ['foo', 'bar'] }})Merge branch 'partials'visionmediabefore adoption28f2ad0
lines 34–41why, one step back34 })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 back42 return this.partial('item.html.haml', {Merge branch 'partials'visionmediabefore adoption28f2ad0
lines 43–51why, one step back43 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 back52 return this.partial('video.html.haml', {Merge branch 'partials'visionmediabefore adoption28f2ad0
lines 53–59why, one step back53 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–62why, one step back60 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 back63 return this.partial('article.html.haml', {Merge branch 'partial-index-and-length'visionmediabefore adoptionb2093d6
lines 64–70why, one step back64 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–81why, one step back79 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 back82 this.render('hello.html.haml', {}, function(err, content){Added Request#render() callback function. Closes #258visionmediabefore adoption7b9f18b
lines 83–86why, one step back83 if (err) this.error(err)84 else this.halt(203, content)85 })86 })Merge branch 'better-haml'visionmediabefore adoptionbdf9f88
line 87why, one step back87 get('/').body.should.include '<html>\n<body>'Added Request#render() callback function. Closes #258visionmediabefore adoption7b9f18b
lines 88–91why, one step back88 get('/').status.should.eql 20389 end90 end91 Closes #52visionmediabefore adoption161c9f9
lines 92–95why, 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(){Merge branch 'flip-views'visionmediabefore adoption6b13fc9
line 96why, one step back96 this.render('hello.html.haml')Closes #52visionmediabefore adoption161c9f9
line 97why, one step back97 })Merge branch 'better-haml'visionmediabefore adoptionbdf9f88
line 98why, one step back98 get('/').body.should.include '<html>\n<body>'Closes #52visionmediabefore adoption161c9f9
lines 99–104why, one step back99 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 back105 this.render('page.html.haml', { layout: false })Closes #52visionmediabefore adoption161c9f9
lines 106–111why, one step back106 })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 back112 this.render('hello.html.haml')Closes #52visionmediabefore adoption161c9f9
lines 113–120why, one step back113 })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 back121 this.render('hello.html.haml', { layout: 'front' })Closes #52visionmediabefore adoption161c9f9
lines 122–130why, one step back122 })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 back131 this.render('hello.html.haml', { layout: 'page' })Closes #52visionmediabefore adoption161c9f9
lines 132–140why, one step back132 })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 back141 this.render('hello.html.haml', { layout: false })Closes #52visionmediabefore adoption161c9f9
lines 142–150why, one step back142 })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 back151 this.render('user.html.invalid')Closes #52visionmediabefore adoption161c9f9
lines 152–159why, one step back152 })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 back160 this.render('user.html.haml', {Closes #52visionmediabefore adoption161c9f9
lines 161–172why, one step back161 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 back173 this.render('user.html.haml', {Closes #52visionmediabefore adoption161c9f9
lines 174–189why, one step back174 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 back190 this.render('article.html.haml', {Closes #52visionmediabefore adoption161c9f9
lines 191–202why, one step back191 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 endRemoved Route#run(). Closes #188visionmediabefore adoption4d1bda0
lines 203–204why, one step back203 end204end