From f6be3b1ae30767c583cbb45fd4f8925a776ffc8f Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sun, 27 Mar 2016 18:28:14 -0700 Subject: [PATCH] Adds back robot-scoped connections by name, and the tests to prove it. Signed-off-by: deadprogram --- lib/robot.js | 1 + spec/lib/robot.spec.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/robot.js b/lib/robot.js index ab7c825..18356c3 100644 --- a/lib/robot.js +++ b/lib/robot.js @@ -316,6 +316,7 @@ Robot.prototype.startConnection = function(connection, callback) { } this.log(str + "."); + this[connection.name] = connection; connection.connect.call(connection, callback); connection.connected = true; return true; diff --git a/spec/lib/robot.spec.js b/spec/lib/robot.spec.js index c71f517..4a16980 100644 --- a/spec/lib/robot.spec.js +++ b/spec/lib/robot.spec.js @@ -415,6 +415,13 @@ describe("Robot", function() { expect(bot.connections.alpha.connect).to.be.called; expect(bot.connections.bravo.connect).to.be.called; }); + + it("defines a named connection on robot for each connection", function() { + bot.startConnections(); + + expect(bot["alpha"]).to.be.an.instanceOf(Adaptor); + expect(bot["bravo"]).to.be.an.instanceOf(Adaptor); + }); }); describe("#startDevices", function() { @@ -461,6 +468,13 @@ describe("Robot", function() { expect(bot.devices.bravo.start).to.be.called.once; expect(bot.devices.charlie.start).to.be.called.once; }); + + it("defines a named device on robot for each device", function() { + bot.startDevices(); + + expect(bot["alpha"]).to.be.an.instanceOf(Driver); + expect(bot["bravo"]).to.be.an.instanceOf(Driver); + }); }); describe("#halt", function() {