title: Unit test express route calls controller method?
body: <p>I see some <a href="https://stackoverflow.com/questions/9517880/how-does-one-unit-test-routes-with-express">similar questions</a>, but my setup is slightly different and I can't figure out a good way to test this.  </p>
  
  <p>I'm trying to test that my express app routes are directed to the correct controller methods.  </p>
  
  <p>For example -  </p>
  
  <pre><code>//server.js, base application
  
  var express = require("express");
  var app = express();
  require("./routes.js")(app);
  ...
  
  //routes.js
  var menuController = require("./controllers/menu.js");
  
  module.exports = function(expressApp) {
      expressApp.get('/menu', menuController.getMenu);
  };
  ...
  
  //test file
  var express = require('express')
      , menuController = require("../../controllers/menu.js")
      , chai = require('chai')
      , should = chai.should()
      , sinon = require('sinon')
      , sinonChai = require("sinon-chai");
  chai.use(sinonChai);
  
  var app = express();
  require("../../routes/routes.js")(app);
  
  describe('routes.js', function(){
  
      it('/menu should call menuController.getMenu route', function(){
          var spy = sinon.spy(menuController, 'getMenu');
          app.get('/menu', spy);
  
          spy.should.have.been.called;  //fails, never called
      });
  
  });  
  </code></pre>
  
  <p>How can I check to see that when calling app.get('/menu', ..), the callback from menuController is invoked?  Or should I restructure the app somehow (I see a bunch of other ways to configure the routing)?</p>