From 21ba481df89d6bfe2b22a5d73fac19252ab65761 Mon Sep 17 00:00:00 2001 From: James Carr Date: Mon, 16 Jan 2012 11:34:35 -0600 Subject: [PATCH] fixed broken tests --- package.json | 1 + routes/index.coffee | 1 + test/routes-test.coffee | 12 +++++++----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 789951b..0fce8f7 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ , "dependencies": { "express": "2.5.4" , "jade": ">= 0.0.1" + , "mongoose": "2.4.1" } , "devDependencies": { "mocha": "0.10.0" diff --git a/routes/index.coffee b/routes/index.coffee index c8ea0b5..3036fc0 100644 --- a/routes/index.coffee +++ b/routes/index.coffee @@ -14,6 +14,7 @@ module.exports = post.id = posts.length posts.push post res.redirect "/" + viewPost: (req, res) -> post = posts[req.params.id] res.render 'post', post: post, title: post.title diff --git a/test/routes-test.coffee b/test/routes-test.coffee index 9c76c22..21c9870 100644 --- a/test/routes-test.coffee +++ b/test/routes-test.coffee @@ -4,6 +4,7 @@ require "should" describe "routes", -> req = params: {} + body: {} res = redirect: (route) -> # do nothing @@ -29,11 +30,12 @@ describe "routes", -> req.body.post = title: "My Post!" body: "My wonderful post." - res.render = (view, vars) -> + + routes.addPost req, redirect: (route) -> + route.should.eql "/" + routes.index req, render: (view, vars) -> view.should.equal "index" - vars.posts.should.eql [{title: 'My Post!', body: "My wonderful post."}] + vars.posts.should.eql [{id: 0, title: 'My Post!', body: "My wonderful post."}] done() - - routes.addPost req, res - routes.index req, res +