From 2475d06cb2e483c206ce11dd1322a06fbf74bf84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Sat, 19 Nov 2011 02:02:22 +0100 Subject: [PATCH] [test] Test command line arguments reparsing --- test/fixtures/scripts/nconf-change-argv.js | 18 ++++++++++++++++++ test/provider-test.js | 7 ++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/scripts/nconf-change-argv.js diff --git a/test/fixtures/scripts/nconf-change-argv.js b/test/fixtures/scripts/nconf-change-argv.js new file mode 100644 index 0000000..8dd4fd3 --- /dev/null +++ b/test/fixtures/scripts/nconf-change-argv.js @@ -0,0 +1,18 @@ +/* + * nconf-change-argv.js: Test fixture for changing argv on the fly + * + * (C) 2011, Charlie Robbins + * + */ + +var nconf = require('../../../lib/nconf'); + +nconf.argv = true; + +// +// Remove 'badValue', 'evenWorse' and 'OHNOEZ' +// +process.argv.splice(3, 3); +nconf.system.loadArgv(); +process.stdout.write(nconf.get('something')); + diff --git a/test/provider-test.js b/test/provider-test.js index 1ac9b11..f6e899e 100644 --- a/test/provider-test.js +++ b/test/provider-test.js @@ -51,6 +51,10 @@ vows.describe('nconf/provider').addBatch({ "when 'env' is set to true": helpers.assertSystemConf({ script: path.join(fixturesDir, 'scripts', 'nconf-env.js'), env: { SOMETHING: 'foobar' } + }), + "when 'argv' is set to true and process.argv is modified": helpers.assertSystemConf({ + script: path.join(fixturesDir, 'scripts', 'nconf-change-argv.js'), + argv: ['--something', 'badValue', 'evenWorse', 'OHNOEZ', 'foobar'] }) } } @@ -84,4 +88,5 @@ vows.describe('nconf/provider').addBatch({ } } } -}).export(module); \ No newline at end of file +}).export(module); +