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); +