Skip to content

Commit

Permalink
Mock function expectations fail with correct error message when withA…
Browse files Browse the repository at this point in the history
…rgs is used but the function was not called, instead of saying the fn was called with null
  • Loading branch information
nathansobo committed Dec 29, 2010
1 parent 44d8138 commit f135d05
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion client/lib/screw/matchers.js
Expand Up @@ -188,6 +188,7 @@ Monarch.module("Screw.Matchers", {

matchWithExpectation: function(expectation, mockFunction) {
if (expectation._withArgs_) {
if (mockFunction.callCount == 0 ) return false;
return Screw.Matchers.equal.match(expectation.arguments, mockFunction.mostRecentArgs);
} else if (expectation._onObject_) {
return Screw.Matchers.equal.match(expectation.object, mockFunction.mostRecentThisValue);
Expand Down Expand Up @@ -218,7 +219,11 @@ Monarch.module("Screw.Matchers", {

errorMessageActualFragment: function(expected, actual, not) {
if (expected && expected._withArgs_) {
return "with arguments " + Screw.$.print(actual.mostRecentArgs);
if (actual.callCount === 0) {
return "0 times";
} else {
return "with arguments " + Screw.$.print(actual.mostRecentArgs);
}
} else if (expected && expected._onObject_) {
return "on object " + Screw.$.print(actual.mostRecentThisValue);
} else {
Expand Down

0 comments on commit f135d05

Please sign in to comment.