Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // app.js
- var express = require('express');
- app = express(),
- mongo = require('mongoskin'),
- db = mongo.db('localhost:27017/test?auto_reconnect');
- app.get('/posts/:slug', function(req, res){
- db.collection('posts').findOne({slug: req.params.slug}, function (err, post) {
- res.send(JSON.stringify(post), 200);
- });
- });
- app.listen(3000);
- // test.js
- r = require('requestah')(3000);
- describe("Does some testing", function() {
- it("Fetches a blogpost by slug", function(done) {
- r.get("/posts/aslug", function(res) {
- expect(res.statusCode).to.equal(200);
- expect(JSON.parse(res.body)["title"]).to.not.equal(null);
- return done();
- });
- });
- ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement