From 99eb7debcee0bc0fecb936dadfc718f2d18fbbe0 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Tue, 11 May 2010 14:05:19 -0400 Subject: [PATCH] improved emitter code in describe() --- lib/vows.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/vows.js b/lib/vows.js index 9f31009..11d27a1 100644 --- a/lib/vows.js +++ b/lib/vows.js @@ -370,17 +370,18 @@ vows.describe = function (subject) { broken = 0, errored = 0; buffer = [], suites = 0; - var promise = new(events.EventEmitter); - process.nextTick(function () { if (!vows.options.brief) { puts('\n' + stylize(subject, 'underline') + '\n'); } - promise.emit("end"); }); - start = new(Date); - - return promise; + return new(events.EventEmitter)().addListener('newListener', function (e, listener) { + if (e === 'end') { + this.removeListener(e, listener); + start = new(Date); + listener.call(this); + } + }); }; vows.tell = vows.describe;