Fixed Request#flash() specs
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent a52dace · Browse files · 1 file·+29 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+29 added−15 removed
- tests:+29 added−15 removed
Provenance
- Commit
f2637c6- Tree
f86ba5e- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
a52dace
1 file changed+29 added−15 removed
modified:spec/spec.plugins.flash.js+29 added-15 removed
8 unmodified lines910111213141516171819202122232413141516171819202122232728292425262728293031323334353637383940414243444546478 unmodified lines end describe 'Flash' describe 'flash()' it 'should push a flash message' var headers = { headers: { cookie: 'sid=123' }} post('/', function(){ return this.flash('info', 'email sent') }) get('/', function(){ return this.flash('info', 'email received') }) get('/info', function(){ return this.flash('info').join(', ') }) get('/messages', function(){ return this.flash('info') || 'empty' }) post('/', headers).body.should.eql 'email sent' get('/', headers).body.should.eql 'email received' get('/info', headers).body.should.eql 'email sent, email received' get('/messages').body.should.eql 'empty' // TODO: seperate once segfault is fixed... describe 'given a type and msg' it 'should push a flash message' var headers = { headers: { cookie: 'sid=123' }} post('/', function(){ return this.flash('info', 'email sent') }) get('/', function(){ return this.flash('info').join(', ') }) post('/', headers) post('/', headers) get('/', headers).body.should.eql 'email sent, email sent' end end it 'should return the message pushed' get('/', function(){ return this.flash('info', 'email sent') }) get('/').body.should.eql 'email sent' describe 'given a type' describe 'when no messages have been pushed' it 'should return null' var headers = { headers: { cookie: 'sid=123' }} get('/', function(){ return this.flash('info') || 'empty' }) get('/', headers).body.should.eql 'empty' end end describe 'when messages have been pushed' it 'should persist only until flushed' var headers = { headers: { cookie: 'sid=123' }} post('/', function(){ return this.flash('info', 'email sent') }) get('/', function(){ return (this.flash('info') || ['nope!']).join(', ') }) post('/', headers) post('/', headers) get('/', headers).body.should.eql 'email sent, email sent' get('/', headers).body.should.eql 'nope!' end end end end endendNo newline at end of fileNo newline at end of file