Merge pull request #269 from daniellmb/master

The register method should return existing modules
This commit is contained in:
Andrew Stewart 2015-02-20 11:55:31 -08:00
commit 31bdfe31f8
2 changed files with 18 additions and 1 deletions

View File

@ -35,7 +35,7 @@ var Registry = module.exports = {
register: function(module) {
if (this.data[module]) {
return;
return this.data[module].module;
}
var pkg;

View File

@ -34,5 +34,22 @@ describe("Registry", function() {
}
});
});
context("when the module already exists", function() {
it("returns the module", function() {
expect(Registry.data).to.be.eql({});
var result = Registry.register(path);
// should register the module and return it
expect(result).to.be.eql(mod);
result = Registry.register(path);
// should just return the existing module
expect(result).to.be.eql(mod);
});
});
});
});