Created
August 24, 2011 16:20
Testing made easy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var routes = require('./routes'); | |
var configure = exports.configure = function(app, callback) { | |
app.use(express.bodyParser()); | |
app.use(app.router); | |
app.use(function(err, req, res, next) { | |
res.json({error: err.message}, 500); | |
}); | |
routes.configure(app); | |
return app; | |
}; | |
if (!module.parent) { | |
var options = { | |
key: fs.readFileSync(__dirname + '/certs/server.key'), | |
cert: fs.readFileSync(__dirname + '/certs/server.crt'), | |
ca: [fs.readFileSync(__dirname + '/certs/ca.crt')], | |
requestCert: true, | |
rejectUnauthorized: true | |
}; | |
var app = configure(express.createServer(options), function() { | |
app.listen(3000); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.configure = function(app) { | |
['user', 'post'].forEach(function(name) { | |
require('./' + name).configure(app); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var api = require('../app.js'); | |
var walks; | |
buster.testCase('Walk', { | |
setUp: function(done) { | |
process.env.NODE_ENV = 'test'; | |
app = api.configure(express.createServer(), function() { | |
walks = app.db.bind('walks'); | |
app.listen(0, function() { | |
done(); | |
}); | |
}); | |
}, | |
tearDown: function(done) { | |
walks.drop(function(err) { | |
app.on('close', function() { | |
app.db.close(done); | |
}); | |
app.close(); | |
}); | |
}, | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment