From af04a10c90120c7fa9348bf17d07e20c11fcf5d8 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Fri, 4 Jun 2010 02:00:02 -0400 Subject: [PATCH] exported Suites also run automatically when file is run directly --- lib/vows/suite.js | 8 ++++++-- test/other-test.js | 2 +- test/vows-test.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/vows/suite.js b/lib/vows/suite.js index cc2cfd3..403894f 100644 --- a/lib/vows/suite.js +++ b/lib/vows/suite.js @@ -210,7 +210,11 @@ this.Suite.prototype = new(function () { this.runParallel = function () {}; - this.export = function (exports) { - return exports.vows = this; + this.export = function (module) { + if (require.main === module) { + return this.run(); + } else { + return module.exports.vows = this; + } }; }); diff --git a/test/other-test.js b/test/other-test.js index a4d0d94..013a50c 100644 --- a/test/other-test.js +++ b/test/other-test.js @@ -12,4 +12,4 @@ vows.describe("Vows/other").addVows({ assert.ok (topic); } } -}).export(this); +}).export(module); diff --git a/test/vows-test.js b/test/vows-test.js index 01fde4d..99a6215 100644 --- a/test/vows-test.js +++ b/test/vows-test.js @@ -272,4 +272,4 @@ vows.describe("Vows").addVows({ "A 3rd test suite": { "should run last": function () {} } -}).export(this); +}).export(module);