Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

48 lines (45 sloc) 1.58 kb
should = require 'should'
shell = require '..'
describe 'plugin error', ->
it 'should print a thrown error', (next) ->
stdout = new shell.NullStream
out = ''
stdout.on 'data', (data) ->
out += data
app = shell
command: 'test error'
stdin: new shell.NullStream
stdout: stdout
app.configure ->
app.use shell.router shell: app
app.use shell.error shell: app
app.cmd 'test error', (req, res) ->
should.not.exist true
app.on 'quit', ->
out.should.match /AssertionError/
next()
it 'should emit thrown error', (next) ->
app = shell
command: 'test error'
stdin: new shell.NullStream
stdout: new shell.NullStream
app.configure ->
app.use shell.router shell: app
app.use shell.error shell: app
app.cmd 'test error', (req, res) ->
should.not.exist true
app.on 'error', (err) ->
err.name.should.eql 'AssertionError'
next()
it 'router should graph error from previous route and emit it', (next) ->
app = shell
command: 'test error'
stdin: new shell.NullStream
stdout: new shell.NullStream
app.configure ->
app.use shell.router shell: app
app.cmd 'test error', (req, res, n) ->
n new Error 'My error'
app.on 'error', (err) ->
err.message.should.eql 'My error'
next()
Jump to Line
Something went wrong with that request. Please try again.