From 00509bdd7b51cee7aad2596e2a8f3732cfb723d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Fri, 14 Oct 2011 03:53:18 +0200 Subject: [PATCH] [test] Test `--supress-stdout` flag --- test/supress-stdout-test.js | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 test/supress-stdout-test.js diff --git a/test/supress-stdout-test.js b/test/supress-stdout-test.js new file mode 100644 index 0000000..7ad8a4d --- /dev/null +++ b/test/supress-stdout-test.js @@ -0,0 +1,43 @@ +var assert = require('assert'), + path = require('path'), + vows = require('../lib/vows'), + exec = require('child_process').exec; + +function generateTopic(supress) { + return function () { + var cmd = './bin/vows ' + (supress ? '--supress-stdout ' : '') + + './test/fixtures/supress-stdout/output.js', + options = {cwd: path.resolve(__dirname + '/../')}, + callback = this.callback; + + exec(cmd, options, function (err, stdout, _) { + callback(null, {err: err, stdout: stdout}); + }); + }; +} + +vows.describe('vows/supress-stdout').addBatch({ + 'Running vows for test/fixtures/supress-stdout/output.js': { + 'with --supress-stdout flag': { + topic: generateTopic(true), + 'should be ok': function (result) { + assert.isNull(result.err); + }, + 'should not contain output from stdout': function (result) { + assert.equal(result.stdout.toString().indexOf('goo'), -1); + // console.log output? + // nope, just Chuck Testa! + } + }, + 'without --supress-stdout flag': { + topic: generateTopic(), + 'should be ok': function (result) { + assert.isNull(result.err); + }, + 'should contain output from stdout': function (result) { + assert.notEqual(result.stdout.toString().indexOf('goo'), -1); + } + } + } +}).export(module); +