Advertisement
Guest User

Untitled

a guest
May 25th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. // app.js
  2. var express = require('express');
  3. app = express(),
  4. mongo = require('mongoskin'),
  5. db = mongo.db('localhost:27017/test?auto_reconnect');
  6.  
  7. app.get('/posts/:slug', function(req, res){
  8. db.collection('posts').findOne({slug: req.params.slug}, function (err, post) {
  9. res.send(JSON.stringify(post), 200);
  10. });
  11. });
  12.  
  13. app.listen(3000);
  14.  
  15. // test.js
  16. r = require('requestah')(3000);
  17. describe("Does some testing", function() {
  18.  
  19. it("Fetches a blogpost by slug", function(done) {
  20. r.get("/posts/aslug", function(res) {
  21. expect(res.statusCode).to.equal(200);
  22. expect(JSON.parse(res.body)["title"]).to.not.equal(null);
  23. return done();
  24. });
  25.  
  26. });
  27. ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement