aboutsummaryrefslogtreecommitdiffstats
path: root/src/scenario/Matcher.js
blob: 326bb948cd0ed695ab9acf1b98ba168258d58d75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function Matcher(scope, future, logger) {
  var self = scope.$scenario = this;
  this.logger = logger;
  this.future = future;
}

Matcher.addMatcher = function(name, matcher) {
  Matcher.prototype[name] = function(expected) {
    var future = this.future;
    $scenario.addFuture(
      'expect ' + future.name + ' ' + name + ' ' + expected,
      function(done){
        if (!matcher(future.value, expected))
          throw "Expected " + expected + ' but was ' + future.value;
        done();
      }
    );
    dump('future added');
  };
};

Matcher.addMatcher('toEqual', function(a,b) { return a == b; });