From 11082b44a90d8d075e0721714f4b602d90868284 Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Tue, 2 Sep 2014 20:26:26 -0700 Subject: [PATCH] Remove extraneous Connection#halt method --- lib/connection.js | 11 ----------- lib/robot.js | 2 +- test/specs/connection.spec.js | 23 ----------------------- test/specs/robot.spec.js | 6 +++--- 4 files changed, 4 insertions(+), 38 deletions(-) diff --git a/lib/connection.js b/lib/connection.js index 1b520b5..2c5744a 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -89,17 +89,6 @@ Connection.prototype.initAdaptor = function(opts) { return this.robot.initAdaptor(opts.adaptor, this, opts); }; -// Public: Halt the adaptor's connection -// -// callback - function to be triggered when the connection has halted -// -// Returns nothing -Connection.prototype.halt = function(callback) { - var msg = this._logstring("Halting adaptor"); - Logger.info(msg); - return this.disconnect(callback); -}; - Connection.prototype._logstring = function _logstring(action) { var msg = action + " '" + this.name + "'"; diff --git a/lib/robot.js b/lib/robot.js index 84a4cca..b4d2004 100644 --- a/lib/robot.js +++ b/lib/robot.js @@ -294,7 +294,7 @@ Robot.prototype.halt = function(callback) { for (var c in this.connections) { var connection = this.connections[c]; - fns.push(connection.halt.bind(connection)); + fns.push(connection.disconnect.bind(connection)); } Async.parallel(fns, callback); diff --git a/test/specs/connection.spec.js b/test/specs/connection.spec.js index 9775d5a..c2e8991 100644 --- a/test/specs/connection.spec.js +++ b/test/specs/connection.spec.js @@ -93,27 +93,4 @@ describe("Connection", function() { expect(connection.adaptor.disconnect).to.be.called; }); }); - - describe("#halt", function() { - beforeEach(function() { - stub(Logger, 'info').returns(true); - stub(connection, 'disconnect').returns(true); - - connection.halt(); - }); - - afterEach(function() { - connection.disconnect.restore(); - Logger.info.restore(); - }); - - it("logs that it's halting the adaptor", function() { - var message = "Halting adaptor 'loopback' on port /dev/null."; - expect(Logger.info).to.be.calledWith(message); - }); - - it("tells the connection to disconnect", function() { - expect(connection.disconnect).to.be.called; - }); - }); }); diff --git a/test/specs/robot.spec.js b/test/specs/robot.spec.js index fe7a7e7..67ff756 100644 --- a/test/specs/robot.spec.js +++ b/test/specs/robot.spec.js @@ -349,19 +349,19 @@ describe("Robot", function() { connection = bot.connections.loopback; stub(device, 'halt').returns(true); - stub(connection, 'halt').returns(true); + stub(connection, 'disconnect').returns(true); }); afterEach(function() { device.halt.restore(); - connection.halt.restore(); + connection.disconnect.restore(); }); it("calls #halt on all devices and connections", function() { bot.halt(); expect(device.halt).to.be.called; - expect(connection.halt).to.be.called; + expect(connection.disconnect).to.be.called; }); });