2 var app = require('../../examples/route-separation')
3 var request = require('supertest')
5 describe('route-separation', function () {
6 describe('GET /', function () {
7 it('should respond with index', function (done) {
10 .expect(200, /Route Separation Example/, done)
14 describe('GET /users', function () {
15 it('should list users', function (done) {
24 describe('GET /user/:id', function () {
25 it('should get a user', function (done) {
28 .expect(200, /Viewing user TJ/, done)
31 it('should 404 on missing user', function (done) {
38 describe('GET /user/:id/view', function () {
39 it('should get a user', function (done) {
42 .expect(200, /Viewing user TJ/, done)
45 it('should 404 on missing user', function (done) {
52 describe('GET /user/:id/edit', function () {
53 it('should get a user to edit', function (done) {
56 .expect(200, /Editing user TJ/, done)
60 describe('PUT /user/:id/edit', function () {
61 it('should edit a user', function (done) {
64 .set('Content-Type', 'application/x-www-form-urlencoded')
65 .send({ user: { name: 'TJ', email: 'tj-invalid@vision-media.ca' } })
66 .expect(302, function (err) {
67 if (err) return done(err)
70 .expect(200, /tj-invalid@vision-media\.ca/, done)
75 describe('POST /user/:id/edit?_method=PUT', function () {
76 it('should edit a user', function (done) {
78 .post('/user/1/edit?_method=PUT')
79 .set('Content-Type', 'application/x-www-form-urlencoded')
80 .send({ user: { name: 'Tobi', email: 'tobi-invalid@vision-media.ca' } })
81 .expect(302, function (err) {
82 if (err) return done(err)
85 .expect(200, /tobi-invalid@vision-media\.ca/, done)
90 describe('GET /posts', function () {
91 it('should get a list of posts', function (done) {
94 .expect(200, /Posts/, done)