diff --git a/lib/jasmine-core/jasmine-html.js b/lib/jasmine-core/jasmine-html.js index 154fa678..5b090aab 100644 --- a/lib/jasmine-core/jasmine-html.js +++ b/lib/jasmine-core/jasmine-html.js @@ -22,11 +22,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ jasmineRequire.html = function(j$) { j$.ResultsNode = jasmineRequire.ResultsNode(); - j$.HtmlReporter = jasmineRequire.HtmlReporter(); + j$.HtmlReporter = jasmineRequire.HtmlReporter(j$); j$.QueryString = jasmineRequire.QueryString(); j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(); }; -jasmineRequire.HtmlReporter = function() { +jasmineRequire.HtmlReporter = function(j$) { var noopTimer = { start: function(){}, diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 510c9223..ec432119 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -576,7 +576,7 @@ getJasmineRequireObj().Env = function(j$) { // TODO: move this to closure Env.prototype.describe = function(description, specDefinitions) { - var suite = this.suiteFactory(description, specDefinitions); + var suite = this.suiteFactory(description); var parentSuite = this.currentSuite; parentSuite.addSuite(suite); @@ -1156,7 +1156,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) { mismatchKeys.push("expected has key '" + property + "', but missing from actual."); } else if (!j$.matchersUtil.equals(this.sample[property], other[property], mismatchKeys, mismatchValues)) { - mismatchValues.push("'" + property + "' was '" + (other[property] ? j$.util.htmlEscape(other[property].toString()) : other[property]) + "' in expected, but was '" + (this.sample[property] ? j$.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in actual."); + mismatchValues.push("'" + property + "' was '" + (other[property] ? j$.util.htmlEscape(other[property].toString()) : other[property]) + "' in actual, but was '" + (this.sample[property] ? j$.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in expected."); } } @@ -2110,7 +2110,9 @@ getJasmineRequireObj().toThrowError = function(j$) { thrown, errorType, message, - regexp; + regexp, + name, + constructorName; if (typeof actual != "function") { throw new Error("Actual is not a Function"); @@ -2134,32 +2136,37 @@ getJasmineRequireObj().toThrowError = function(j$) { } if (arguments.length == 1) { - return pass("Expected function not to throw an Error, but it threw " + thrown + "."); + return pass("Expected function not to throw an Error, but it threw " + fnNameFor(thrown) + "."); + } + + if (errorType) { + name = fnNameFor(errorType); + constructorName = fnNameFor(thrown.constructor); } if (errorType && message) { if (thrown.constructor == errorType && util.equals(thrown.message, message)) { - return pass("Expected function not to throw " + errorType.name + " with message \"" + message + "\"."); + return pass("Expected function not to throw " + name + " with message \"" + message + "\"."); } else { - return fail("Expected function to throw " + errorType.name + " with message \"" + message + - "\", but it threw " + thrown.constructor.name + " with message \"" + thrown.message + "\"."); + return fail("Expected function to throw " + name + " with message \"" + message + + "\", but it threw " + constructorName + " with message \"" + thrown.message + "\"."); } } if (errorType && regexp) { if (thrown.constructor == errorType && regexp.test(thrown.message)) { - return pass("Expected function not to throw " + errorType.name + " with message matching " + regexp + "."); + return pass("Expected function not to throw " + name + " with message matching " + regexp + "."); } else { - return fail("Expected function to throw " + errorType.name + " with message matching " + regexp + - ", but it threw " + thrown.constructor.name + " with message \"" + thrown.message + "\"."); + return fail("Expected function to throw " + name + " with message matching " + regexp + + ", but it threw " + constructorName + " with message \"" + thrown.message + "\"."); } } if (errorType) { if (thrown.constructor == errorType) { - return pass("Expected function not to throw " + errorType.name + "."); + return pass("Expected function not to throw " + name + "."); } else { - return fail("Expected function to throw " + errorType.name + ", but it threw " + thrown.constructor.name + "."); + return fail("Expected function to throw " + name + ", but it threw " + constructorName + "."); } } @@ -2181,6 +2188,10 @@ getJasmineRequireObj().toThrowError = function(j$) { } } + function fnNameFor(func) { + return func.name || func.toString().match(/^\s*function\s*(\w*)\s*\(/)[1]; + } + function pass(notMessage) { return { pass: true, @@ -2246,6 +2257,7 @@ getJasmineRequireObj().toThrowError = function(j$) { return toThrowError; }; + getJasmineRequireObj().version = function() { return "2.0.0-alpha"; }; \ No newline at end of file