diff --git a/lib/metadata.js b/lib/metadata.js index 2bc1c52..b6734ce 100644 --- a/lib/metadata.js +++ b/lib/metadata.js @@ -56,13 +56,9 @@ class Metadata { } getVar(name) { - if (!this.values.hasOwnProperty(name)) { + if (!this.values.hasOwnProperty(name) && this.defs[name]) { this.hasValues = true; - if (this.defs[name] instanceof VariableMetadata) { - this.values[name] = this.defs[name].evaluate(); - } else { - this.values[name] = undefined; - } + this.values[name] = this.defs[name].evaluate(); } return this.values[name]; diff --git a/spec/interface_examples.js b/spec/interface_examples.js index 04baf38..75fe1cc 100644 --- a/spec/interface_examples.js +++ b/spec/interface_examples.js @@ -28,8 +28,8 @@ sharedExamplesFor('Lazy Vars Interface', function(getVar) { expect(getVar('staticVar')).to.equal(value); }); - it('returns undefined where there is no definition', () => { - expect(getVar('notDefined')).to.equal(undefined); + it('returns `undefined` where there is no definition', () => { + expect(getVar('notDefined')).to.be.undefined; }); it('defines "get.variable" and its alias "get.definitionOf" getter builder', function() {