Skip to content

Commit

Permalink
Fix asserts err return
Browse files Browse the repository at this point in the history
  • Loading branch information
mklabs committed Apr 26, 2016
1 parent 0e3d98e commit 115f129
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test.js
Expand Up @@ -12,14 +12,13 @@ var constants = require('constants');
module.exports = Runnable;

// Public: Initialize a new `Runnable` with the given `options` Hash object.
function Runnable(cmds, options) {
function Runnable(options) {
this.options = options || {};
this._body = null;
this._status = 0;
this._command = '';
this._prompts = [];
this._expects = [];
this.use(cmds);
}

// inherits from EventEmitter
Expand Down Expand Up @@ -142,7 +141,7 @@ Runnable.prototype.end = function end(done) {
}.bind(this));
}.bind(this));

promise.catch(done || function(err) {
promise.catch(function(err) {
debug('Error: %s', err.stack || err.message);
});

Expand Down Expand Up @@ -251,13 +250,13 @@ Runnable.prototype.assert = function assert(res, fn) {
});

if(!errors.length) return fn(null, res);
err = new Error(msg);
err.code = status || 1;

var msg = 'Expected ' + util.inspect(res.text) + '\n to match:\n';
msg += errors.map(function(expected) {
return ' - ' + expected;
}).join('\n');
err = new Error(msg);
err.code = status || 1;

fn(err, res);
};

0 comments on commit 115f129

Please sign in to comment.