Squashed spy refactor and new spy syntax

Jasmine spies now have a 'and' property which allows the user to
change the spy's execution strategy-- such as '.and.callReturn(4)'
and a 'calls' property which allows inspection of the calls a spy
has received.

* This is a breaking change *

There is a CallTracker that keeps track of all calls and arguments
and a SpyStrategy which determines what the spy should do when it
is called.
This commit is contained in:
Davis W. Frank & Sheel Choksi
2013-07-17 23:11:55 -07:00
committed by Colin O'Byrne and JR Boyens
parent 18c30566bd
commit 3847557bbc
32 changed files with 692 additions and 413 deletions

View File

@@ -13,11 +13,11 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
}
result.pass = actual.wasCalled;
result.pass = actual.calls.any();
result.message = result.pass ?
"Expected spy " + actual.identity + " not to have been called." :
"Expected spy " + actual.identity + " to have been called.";
"Expected spy " + actual.and.identity() + " not to have been called." :
"Expected spy " + actual.and.identity() + " to have been called.";
return result;
}

View File

@@ -12,13 +12,13 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
}
return {
pass: util.contains(actual.argsForCall, expectedArgs)
pass: util.contains(actual.calls.allArgs(), expectedArgs)
};
},
message: function(actual) {
return {
affirmative: "Expected spy " + actual.identity + " to have been called.",
negative: "Expected spy " + actual.identity + " not to have been called."
affirmative: "Expected spy " + actual.and.identity() + " to have been called.",
negative: "Expected spy " + actual.and.identity() + " not to have been called."
};
}
};