Permalink
Browse files

Adding negative message when use matcher not.toThrow with an expected…

… error
  • Loading branch information...
1 parent 41f4960 commit 52bba61ee84ebf0a345f34e6a7c1effe5d3433fa Andre Mendonça committed Oct 20, 2011
Showing with 6 additions and 4 deletions.
  1. +2 −2 lib/jasmine-core/jasmine.js
  2. +2 −0 spec/core/MatchersSpec.js
  3. +1 −1 src/core/Matchers.js
  4. +1 −1 src/version.js
@@ -1442,7 +1442,7 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
} else {
- return "Expected function to throw an exception.";
+ return "Expected function " + not + "to throw an exception.";
}
};
@@ -2472,5 +2472,5 @@ jasmine.version_= {
"major": 1,
"minor": 1,
"build": 0,
- "revision": 1315677058
+ "revision": 1319128960
};
@@ -542,11 +542,13 @@ describe("jasmine.Matchers", function() {
it("should match exceptions specified by message", function() {
expect(match(throwingFn).not.toThrow("Fake Error")).toFail();
// expect(lastResult().message).toMatch(/Expected function not to throw Fake Error./);
+ expect(lastResult().message).toMatch(/Expected function not to throw an exception/);
expect(match(throwingFn).not.toThrow("Other Error")).toPass();
});
it("should match exceptions specified by Error", function() {
expect(match(throwingFn).not.toThrow(new Error("Fake Error"))).toFail();
+ expect(lastResult().message).toMatch(/Expected function not to throw an exception/);
// expect(lastResult().message).toMatch("Other Error");
expect(match(throwingFn).not.toThrow(new Error("Other Error"))).toPass();
});
@@ -334,7 +334,7 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
} else {
- return "Expected function to throw an exception.";
+ return "Expected function " + not + "to throw an exception.";
}
};
View
@@ -2,5 +2,5 @@ jasmine.version_= {
"major": 1,
"minor": 1,
"build": 0,
- "revision": 1315677058
+ "revision": 1319128960
};

0 comments on commit 52bba61

Please sign in to comment.