diff --git a/test/cli-test.js b/test/cli-test.js index 9f3aab72..5bba63f9 100644 --- a/test/cli-test.js +++ b/test/cli-test.js @@ -10,7 +10,7 @@ var fs = require('fs'), path = require('path'), assert = require('assert'), vows = require('vows'), - helpers = require('./helpers'), + macros = require('./helpers/macros'), rimraf = require('utile').rimraf, forever = require('../lib/forever'); @@ -23,16 +23,16 @@ vows.describe('forever/cli').addBatch({ topic: function () { rimraf(path.join(process.env.HOME, '.forever', 'sock'), this.callback); }, - 'and starting script using `forever start`': helpers.spawn(['start', script], { - '`forever.list` result': helpers.list({ + 'and starting script using `forever start`': macros.spawn(['start', script], { + '`forever.list` result': macros.list({ 'should contain spawned process': function (list) { - helpers.assertList(list); + macros.assertList(list); assert.equal(list[0].command, 'node'); assert.equal(fs.realpathSync(list[0].file), fs.realpathSync(script)); - helpers.assertStartsWith(list[0].logFile, forever.config.get('root')); + macros.assertStartsWith(list[0].logFile, forever.config.get('root')); }, - 'and stopping it using `forever stop`': helpers.spawn(['stop', script], { - '`forever.list` result': helpers.list({ + 'and stopping it using `forever stop`': macros.spawn(['stop', script], { + '`forever.list` result': macros.list({ 'should not contain previous process': function (list) { assert.isNull(list); } @@ -44,10 +44,10 @@ vows.describe('forever/cli').addBatch({ } }).addBatch({ 'When using forever CLI': { - 'and starting script using `forever start` with arguments': helpers.spawn(['start', script].concat(options), { - '`forever.list` result': helpers.list({ + 'and starting script using `forever start` with arguments': macros.spawn(['start', script].concat(options), { + '`forever.list` result': macros.list({ 'should contain spawned process with proper options': function (list) { - helpers.assertList(list); + macros.assertList(list); assert.notEqual(list[0].uid, 'itShouldNotGoToUIDField'); assert.deepEqual(list[0].options, options); } diff --git a/test/env-spawn-test.js b/test/env-spawn-test.js index c8ba258f..4c5d5beb 100644 --- a/test/env-spawn-test.js +++ b/test/env-spawn-test.js @@ -9,8 +9,7 @@ var assert = require('assert'), path = require('path'), vows = require('vows'), - forever = require('../lib/forever'), - helpers = require('./helpers'); + forever = require('../lib/forever'); vows.describe('forever/spawn-options').addBatch({ "When using forever": { diff --git a/test/forever-test.js b/test/forever-test.js index 586db3ba..381a9aff 100644 --- a/test/forever-test.js +++ b/test/forever-test.js @@ -10,7 +10,7 @@ var assert = require('assert'), path = require('path'), vows = require('vows'), forever = require('../lib/forever'), - helpers = require('./helpers'); + macros = require('./helpers/macros'); vows.describe('forever').addBatch({ "When using forever": { @@ -43,7 +43,7 @@ vows.describe('forever').addBatch({ } } }, - "running error-on-timer sample three times": helpers.assertTimes( + "running error-on-timer sample three times": macros.assertTimes( path.join(__dirname, '..', 'examples', 'error-on-timer.js'), 3, { @@ -54,7 +54,7 @@ vows.describe('forever').addBatch({ options: [] } ), - "running error-on-timer sample once": helpers.assertTimes( + "running error-on-timer sample once": macros.assertTimes( path.join(__dirname, '..', 'examples', 'error-on-timer.js'), 1, { diff --git a/test/helpers.js b/test/helpers/macros.js similarity index 80% rename from test/helpers.js rename to test/helpers/macros.js index 07fbe8c0..616e8e9d 100644 --- a/test/helpers.js +++ b/test/helpers/macros.js @@ -1,5 +1,5 @@ /* - * helpers.js: Test helpers for the forever module + * macros.js: Test macros for the forever module * * (C) 2010 Nodejitsu Inc. * MIT LICENCE @@ -9,11 +9,11 @@ var assert = require('assert'), path = require('path'), spawn = require('child_process').spawn, - forever = require('../lib/forever'); + forever = require('../../lib/forever'); -var helpers = exports; +var macros = exports; -helpers.assertTimes = function (script, times, options) { +macros.assertTimes = function (script, times, options) { options.max = times; return { @@ -28,7 +28,7 @@ helpers.assertTimes = function (script, times, options) { } }; -helpers.spawn = function (args, options) { +macros.spawn = function (args, options) { options.topic = function () { var self = this; @@ -57,18 +57,19 @@ helpers.spawn = function (args, options) { return options; }; -helpers.list = function (options) { +macros.list = function (options) { options.topic = function () { forever.list(false, this.callback) }; return options; }; -helpers.assertStartsWith = function (string, substring) { +macros.assertStartsWith = function (string, substring) { assert.equal(string.slice(0, substring.length), substring); }; -helpers.assertList = function (list) { +macros.assertList = function (list) { assert.isNotNull(list); assert.lengthOf(list, 1); -}; \ No newline at end of file +}; + diff --git a/test/tail-test.js b/test/tail-test.js index 26755d05..948bf9ae 100644 --- a/test/tail-test.js +++ b/test/tail-test.js @@ -10,8 +10,7 @@ var assert = require('assert'), path = require('path'), spawn = require('child_process').spawn, vows = require('vows'), - forever = require('../lib/forever'), - helpers = require('./helpers'); + forever = require('../lib/forever'); vows.describe('forever/tail').addBatch({ "When using forever": {