var should = require('should');

describe('Application config package', function () {
    var Config = require('../index.js');

    describe('#constructor', function () {
        it('should return object', function () {
            var config = new Config();
            should.exist(config);
        });

        it('should pass default options', function () {
            var config = new Config();
            config.startupPath.should.be.equal(process.cwd());
        });

        it('should throw on wrong options', function () {
            should.throws(function () {
                var config = new Config({
                    startupPath: './'
                });
            });

            should.throws(function () {
                var config = new Config({
                    configName: 'konfig.js'
                });
            });
        });

        it('should return correct config', function () {
            var config = new Config({
                localConfigName: 'noop.js'
            });

            config.startupPath.should.be.equal(process.cwd());
            should.exist(config.db);
            should.exist(config.very.nested.config);

            config.db.user.should.equal('test');
            config.db.pass.should.equal('testPass');

            config.very.nested.config.variable.should.equal(true);
        });

        it('should merge config correctly with localconfig', function () {
            var config = new Config();

            should.exist(config.db);
            should.exist(config.very.nested.config);

            config.db.user.should.equal('test');
            config.db.pass.should.equal('mergePass');

            config.very.nested.config.variable.should.equal(true);
            config.very.nested.config.variableTwo.should.equal(true);
        });

        describe('environmental variables', function () {
            before(function () {
                process.env.app_config_db_user = 'envUser';
            });

            after(function () {
                delete process.env.app_config_db_user;
            });

            it('should merge config correctly with environment variables', function () {
                var config = new Config();

                should.exist(config.db);
                should.exist(config.very.nested.config);

                config.db.user.should.equal('envUser');
                config.db.pass.should.equal('mergePass');

                config.very.nested.config.variable.should.equal(true);
                config.very.nested.config.variableTwo.should.equal(true);
            });
        })
    });

    describe('#reload', function () {
        after(function () {
            delete process.env.app_config_db_user;
        });

        it('should reload and merge config correctly', function () {
            var config = new Config();

            config.db.user.should.equal('test');

            process.env.app_config_db_user = 'envUser';

            config.reload();

            config.db.user.should.equal('envUser');
        });
    });
});
@@ -87,16 +87,19 @@
     var 
+app
 Config =
@@ -119,24 +119,24 @@
 index.js');%0A
-
 %0A    describ
@@ -233,36 +233,35 @@
    var config = 
-new 
+app
 Config();%0A      
@@ -374,36 +374,35 @@
    var config = 
-new 
+app
 Config();%0A      
@@ -590,36 +590,35 @@
    var config = 
-new 
+app
 Config(%7B%0A       
@@ -746,36 +746,35 @@
    var config = 
-new 
+app
 Config(%7B%0A       
@@ -937,28 +937,27 @@
 ar config = 
-new 
+app
 Config(%7B%0A   
@@ -1442,36 +1442,35 @@
    var config = 
-new 
+app
 Config();%0A%0A     
@@ -1801,32 +1801,1199 @@
 );%0A        %7D);%0A%0A
+        it('should disable isStage and isDebug', function () %7B%0A            var config = appConfig(%7B%0A                enableStateVariables: false%0A            %7D);%0A%0A            should.not.exist(config.isDebug);%0A            should.not.exist(config.isStage);%0A        %7D);%0A%0A        it('should configure isDebug correctly', function () %7B%0A            var config = appConfig();%0A%0A            config.isDebug.should.equal(true);%0A            config.isStage.should.equal(false);%0A        %7D);%0A%0A        it('should configure isStage correctly', function () %7B%0A            var old = process.env.NODE_ENV;%0A            process.env.NODE_ENV = 'staging';%0A%0A            var config = appConfig();%0A%0A            config.isDebug.should.equal(false);%0A            config.isStage.should.equal(true);%0A%0A            process.env.NODE_ENV = old;%0A        %7D);%0A%0A        it('should configure production correctly', function () %7B%0A            var old = process.env.NODE_ENV;%0A            process.env.NODE_ENV = 'production';%0A%0A            var config = appConfig();%0A%0A            config.isDebug.should.equal(false);%0A            config.isStage.should.equal(false);%0A%0A            process.env.NODE_ENV = old;%0A        %7D);%0A%0A
         describe
@@ -3358,36 +3358,35 @@
    var config = 
-new 
+app
 Config();%0A%0A     
@@ -4003,12 +4003,11 @@
 g = 
-new 
+app
 Conf

add more tests