-CanvasAssertions.matchAttributes = function(expected, actual) {
- for (var attr in expected) {
- if (expected.hasOwnProperty(attr) && expected[attr] != actual[attr]) {
- return false;
+/**
+ * For matching a proxy call against defined conditions.
+ * predicate can either by a hash of items compared against call.properties,
+ * or it can be a function that accepts the call, and returns true or false.
+ */
+CanvasAssertions.match = function(predicate, call) {
+ if (typeof(predicate) === "function") {
+ return predicate(call);
+ } else {
+ for (var attr in predicate) {
+ if (predicate.hasOwnProperty(attr) && predicate[attr] != call.properties[attr]) {
+ return false;
+ }