Remove #proxyTestStubs in favor of inline solution
This commit is contained in:
parent
b312f6bb6b
commit
55f9445149
|
@ -324,6 +324,14 @@ Robot.prototype.initAdaptor = function(adaptorName, connection, opts) {
|
|||
extraParams: opts
|
||||
});
|
||||
return Utils.proxyTestStubs(adaptor.commands, testAdaptor);
|
||||
|
||||
for (var prop in adaptor) {
|
||||
if (typeof adaptor[prop] === 'function' && !testAdaptor[prop]) {
|
||||
testAdaptor[prop] = function() { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
return testAdaptor;
|
||||
} else {
|
||||
return adaptor;
|
||||
}
|
||||
|
|
21
lib/utils.js
21
lib/utils.js
|
@ -137,27 +137,6 @@ var Utils = module.exports = {
|
|||
return base;
|
||||
},
|
||||
|
||||
// Public: Proxies a list of methods for test stubbing.
|
||||
//
|
||||
// methods - array of functions to proxy
|
||||
// base - (optional) object that proxied functions will be declared on. Defaults
|
||||
// to this
|
||||
//
|
||||
// Returns base
|
||||
proxyTestStubs: function proxyTestStubs(methods, base) {
|
||||
base = base || this;
|
||||
|
||||
methods.forEach(function(method) {
|
||||
base[method] = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
base.commands.push(method);
|
||||
});
|
||||
|
||||
return base;
|
||||
},
|
||||
|
||||
// Public: Analogue to Ruby's Hash#fetch method for looking up object
|
||||
// properties.
|
||||
//
|
||||
|
|
|
@ -186,23 +186,6 @@ describe("Utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("#proxyTestStubs", function() {
|
||||
it("proxies methods to an object's commands", function() {
|
||||
var methods = ["hello", "goodbye"],
|
||||
base = { commands: [] };
|
||||
|
||||
utils.proxyTestStubs(methods, base);
|
||||
expect(base.commands).to.be.eql(methods);
|
||||
});
|
||||
|
||||
it("returns the object methods have been proxied to", function() {
|
||||
var methods = ["hello", "goodbye"],
|
||||
base = { commands: [] };
|
||||
|
||||
expect(utils.proxyTestStubs(methods, base)).to.be.eql(base);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#fetch", function() {
|
||||
var fetch = utils.fetch,
|
||||
obj = { property: 'hello world', 'false': false, 'null': null };
|
||||
|
|
Loading…
Reference in New Issue