dirname('/path/to/images/foo.bar.png').should.eql '/path/to/images'
end
end
describe 'halt()'
describe 'when given no arguments'
it 'should respond with 404 Not Found'
get('/user', function(){ halt() })
get('/user').body.should include('Not Found')
get('/user').status.should.eql 404
end
end
describe 'when given a status code'
it 'should respond with that status and its associated default body'
get('/user', function(){ halt(400) })
get('/user').body.should include('Bad Request')
get('/user').status.should.eql 400
end
end
describe 'when given a status code and body'
it 'should respond with the status and its body'
get('/user', function(){ halt(400, 'Oh noes!') })
get('/user').body.should include('Oh noes!')
get('/user').status.should.eql 400
end
end
describe 'when given an invalid status code'
it 'should throw an InvalidStatusCode exception'
get('/user', function(){ halt(123123) })
-{ get('/user') }.should.throw_error(/InvalidStatusCode: 123123/)
end
end
end
describe 'param()'
it 'should return a route placeholder value'
get('/user/:id', function(){
return 'user ' + param('id')