Skip to content
Myr

spec.plugins.view.js

This file

Path

spec/spec.plugins.view.js

90 lines · 2.6 KiB · JavaScript

Last changed by

Added spec for invalid view enginevisionmediabefore adoption8fc0620

History of this file

Take it

View is now a plugin [#87]visionmediabefore adoption8e408e3

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

Started view specsvisionmediabefore adoption00a8c64

lines 14–21why, one step back
14
15 describe '#render()'16 before_each17 set('views', 'spec/fixtures')18 end19 20 describe 'given a valid view name'21 describe 'and layout of the same type exists'

Spec for custom layoutvisionmediabefore adoptionda7ea96

line 22why, one step back
22 it 'should render the layout and view'

Started view specsvisionmediabefore adoption00a8c64

lines 23–36why, one step back
23 get('/', function(){
24 this.render('hello.haml.html')25 })26 get('/').body.should.include '<html><body>'27 get('/').body.should.include '<h2>Hello'28 end29 end30 31 describe 'and layout of the same type does not exist'32 it 'should throw an error'33 get('/', function(){34 this.render('hello.haml.html', { layout: 'front' })35 })36 -{ get('/') }.should.throw_error 'No such file or directory'

Spec for custom layoutvisionmediabefore adoptionda7ea96

lines 37–46why, one step back
37 end
38 end39 40 describe 'given a custom layout name'41 it 'should render the layout and view'42 get('/', function(){43 this.render('hello.haml.html', { layout: 'page' })44 })45 get('/').body.should.include '<title>Express'46 get('/').body.should.include '<h2>Hello'

Started view specsvisionmediabefore adoption00a8c64

lines 47–48why, one step back
47 end
48 end

Spec for layout: falsevisionmediabefore adoptiona4cbbe5

lines 49–59why, one step back
49
50 describe 'when layout: false'51 it 'should render the view only'52 get('/', function(){53 this.render('hello.haml.html', { layout: false })54 })55 get('/').body.should.not.include '<body>'56 get('/').body.should.include '<h2>Hello'57 end58 end59

Added view caching specsvisionmediabefore adoption9fd92e3

lines 60–76why, one step back
60 describe 'when "cache view contents" is enabled'
61 it 'should read the views into memory only once'62 enable('cache view contents')63 get('/', function(){64 this.render('hello.haml.html')65 })66 get('/cached', function(){67 return this.cache.get('spec/fixtures/hello.haml.html') ? 'yes' : 'no'68 })69 get('/cached').body.should.eql 'no'70 get('/')71 get('/cached').body.should.eql 'yes'72 get('/')73 get('/cached').body.should.eql 'yes'74 end75 end76

Added spec for invalid view enginevisionmediabefore adoption8fc0620

lines 77–85why, one step back
77 describe 'when engine cannot be found'
78 it 'should throw an error'79 get('/', function(){80 this.render('user.invalid.html')81 })82 -{ get('/') }.should.throw_error "Cannot find module 'invalid'"83 end84 end85

Started view specsvisionmediabefore adoption00a8c64

lines 86–88why, one step back
86 end
87 88 end

View is now a plugin [#87]visionmediabefore adoption8e408e3

lines 89–90why, one step back
89 end
90end