Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(scenario): include "not " in error messages if test is inverted
Browse files Browse the repository at this point in the history
Closes #3840
  • Loading branch information
hsablonniere authored and petebacondarwin committed Sep 18, 2013
1 parent be0b485 commit 3589f17
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/ngScenario/Scenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,16 @@ angular.scenario.dsl = angular.scenario.dsl || function(name, fn) {
*/
angular.scenario.matcher = angular.scenario.matcher || function(name, fn) {
angular.scenario.matcher[name] = function(expected) {
var prefix = 'expect ' + this.future.name + ' ';
if (this.inverse) {
prefix += 'not ';
}
var prefix = 'expect ' + this.future.name + ' ',
not = this.inverse && 'not ';
var self = this;
this.addFuture(prefix + name + ' ' + angular.toJson(expected),
this.addFuture(prefix + not + name + ' ' + angular.toJson(expected),
function(done) {
var error;
self.actual = self.future.value;
if ((self.inverse && fn.call(self, expected)) ||
(!self.inverse && !fn.call(self, expected))) {
error = 'expected ' + angular.toJson(expected) +
error = 'expected ' + not + name + ' ' + angular.toJson(expected) +
' but was ' + angular.toJson(self.actual);
}
done(error);
Expand Down

0 comments on commit 3589f17

Please sign in to comment.