Skip to content

Commit

Permalink
A little cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Dec 21, 2015
1 parent d095064 commit f2ba4dc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/Unexpected.js
Expand Up @@ -902,15 +902,17 @@ Unexpected.prototype.lookupAssertionRule = function (subject, testDescriptionStr
if (!handlers) {
// if lookupAssertionRule(subject, assertionString, args) fails:
var tokens = testDescriptionString.split(' ');
for (var n = tokens.length - 1; n > 0 ; n -= 1) {
for (var n = tokens.length - 1; n > 1 ; n -= 1) {
var prefix = tokens.slice(0, n).join(' ');
var argsWithAssertionPrepended = [ tokens.slice(n).join(' ') ].concat(args);
var assertionRule;
try {
assertionRule = this.assertions[tokens.slice(0, n).join(' ')] && this.lookupAssertionRule(subject, tokens.slice(0, n).join(' '), [ (tokens.slice(n).join(' ')) ].concat(args), true);
assertionRule = this.assertions[prefix] && this.lookupAssertionRule(subject, prefix, argsWithAssertionPrepended, true);
} catch (e) {}
if (assertionRule) {
// Great, found the longest prefix of the string that yielded a suitable assertion
// for the given subject and args
return [tokens.slice(0, n).join(' '), [ (tokens.slice(n).join(' ')) ].concat(args), assertionRule];
return [ prefix, argsWithAssertionPrepended, assertionRule ];
}
}
this.throwAssertionNotFoundError(subject, testDescriptionString, args);
Expand Down

0 comments on commit f2ba4dc

Please sign in to comment.