diff --git a/lib/test.js b/lib/test.js index b610e212..2550a246 100644 --- a/lib/test.js +++ b/lib/test.js @@ -36,10 +36,8 @@ var getTestArgs = function (name_, opts_, cb_) { }; function Test (name_, opts_, cb_) { - var self = this; - var args = getTestArgs(name_, opts_, cb_); - + this.readable = true; this.name = args.name || '(anonymous)'; this.assertCount = 0; @@ -49,9 +47,18 @@ function Test (name_, opts_, cb_) { this._cb = args.cb; this._progeny = []; this._ok = true; - this.end = function () { - return Test.prototype.end.apply(self, arguments); - }; + + for (prop in this) { + this[prop] = (function bind(self, val) { + if (typeof val === 'function') { + return function bound() { + return val.apply(self, arguments); + }; + } else { + return val; + } + })(this, this[prop]); + } } Test.prototype.run = function () {