[api minor] Add `.loadSync()` to Memory store. Fixes #24

master
indexzero 2012-01-02 17:20:06 -05:00
parent d0a91219ec
commit 6242caafda
2 changed files with 14 additions and 4 deletions

View File

@ -199,4 +199,12 @@ Memory.prototype.reset = function () {
this.mtimes = {};
this.store = {};
return true;
};
//
// ### function loadSync
// Returns the store managed by this instance
//
Memory.prototype.loadSync = function () {
return this.store || {};
};

View File

@ -28,6 +28,7 @@ vows.describe('nconf').addBatch({
"the use() method": {
"should instaniate the correct store": function () {
nconf.use('memory');
nconf.load();
assert.instanceOf(nconf.stores['memory'], nconf.Memory);
}
},
@ -79,16 +80,17 @@ vows.describe('nconf').addBatch({
},
"the load() method": {
"without a callback": {
"should throw an exception": function () {
assert.throws(function () { nconf.load() });
"should respond with the merged store": function () {
assert.deepEqual(nconf.load(), { foo: { bar: {} } });
}
},
"with a callback": {
topic: function () {
nconf.load(this.callback.bind(null, null));
},
"should respond with an error": function (ign, err) {
assert.isNotNull(err);
"should respond with the merged store": function (ign, err, store) {
assert.isNull(err);
assert.deepEqual(store, { foo: { bar: {} } });
}
}
},