/*
 * before-test.js: Tests for running before methods on HTTP server(s).
 *
 * (C) 2011, Nodejitsu Inc.
 * MIT LICENSE
 *
 */

var assert = require('assert'),
    http = require('http'),
    vows = require('vows'),
    request = require('request'),
    director = require('../../../lib/director'),
    helpers = require('../helpers'),
    handlers = helpers.handlers,
    macros = helpers.macros;

function assertBark(uri) {
  return macros.assertGet(
    9090,
    uri,
    'hello from (bark)'
  );
}

vows.describe('director/http').addBatch({
  "An instance of director.http.Router": {
    "instantiated with a Routing table": {
      topic: function () {
        var router = new director.http.Router();
        
        console.dir(router.before);
        router.before('/hello', function () {
          console.log('hello');
        });
        
        router.get('/hello', handlers.respondWithId);
        
        console.dir(router);
        return router;
      },
      "should have the correct routes defined": function (router) {
        assert.isObject(router.routes.hello);
        assert.isFunction(router.routes.hello.before);
        assert.isFunction(router.routes.hello.get);
      }
    }
  }
}).export(module);
@@ -396,113 +396,8 @@
 s;%0A%0A
-function assertBark(uri) %7B%0A  return macros.assertGet(%0A    9090,%0A    uri,%0A    'hello from (bark)'%0A  );%0A%7D%0A%0A
 vows
@@ -420,16 +420,23 @@
 tor/http
+/before
 ').addBa
@@ -493,41 +493,46 @@
    %22
-instantiated with a Routing table
+with ad-hoc routes including .before()
 %22: %7B
@@ -621,44 +621,8 @@
    %0A
-        console.dir(router.before);%0A
     
@@ -654,32 +654,36 @@
 ', function () %7B
+ %7D);
 %0A          conso
@@ -679,52 +679,48 @@
     
-  console.log
+router.after
 ('
+/
 hello'
-);%0A        %7D);%0A        
+, function () %7B %7D);
 %0A   
@@ -774,45 +774,8 @@
 d);%0A
-        %0A        console.dir(router);
 %0A   
@@ -972,16 +972,70 @@
 efore);%0A
+        assert.isFunction(router.routes.hello.after);%0A
         

Clean up failing test for #169