arunoda/nodemock — Issue #18: Assert should throw error to be consistent with rest of methods
Author: oveddan
Created: 2012-03-08 02:50:56+00:00
State: open

All other methods besides assert throw errors when something happens that is not expected. Assert writes to console.log:

this.assert = function() {

var success = true;
for(var method in entries) {
var entriesForMethod = entries[method];
entriesForMethod.forEach(function(entry) {
if(!entry.shouldFail && entry.executed == false) {
success = false;
console.error(
"method call for: '" + method + "()' with params: " + getParamString(entry.args) + " was not executed!\n"
);
}
});
}

return success;
};

To be consistent, Assert should throw an Error