Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Commit

Permalink
Added array "unboxing" to property request matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
SQiShER committed Sep 4, 2013
1 parent eed20ab commit 3d7dcf9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions lib/RequestMatchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@ var _ = require('underscore');
var PropertyMatcher = function (config) {
this.callCount = 0;
this.matches = function (body) {
try {
var matches = true;
var matchesProperties = function (object, config) {
var matchesAllProperties = true;
_.forEach(config['properties'], function (value, key) {
matches &= body[key] === value;
matchesAllProperties = matchesAllProperties && object[key] === value;
});
return matches;
return matchesAllProperties;
};
if (_.isArray(body)) {
var matchesAnyItem = false;
_.forEach(body, function (item) {
if (matchesProperties(item, config) === true) {
matchesAnyItem = true;
}
});
return matchesAnyItem;
}
catch (e) {
return false;
else {
return matchesProperties(body, config);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-config-ngscenario-dsl",
"version": "1.1.0",
"version": "1.2.0",
"author": "Hypoport AG",
"description": "A simple angular-scenario DSL for configuring a node.js backend directly from your E2E tests",
"contributors": [
Expand Down

0 comments on commit 3d7dcf9

Please sign in to comment.