added MatcherSpec

This commit is contained in:
Andres Ornelas 2010-08-04 12:36:53 -07:00
parent 26ed747588
commit 6d0eeda1e2
2 changed files with 30 additions and 1 deletions

View file

@ -15,7 +15,6 @@ Matcher.addMatcher = function(name, matcher) {
done();
}
);
dump('future added');
};
};

View file

@ -0,0 +1,30 @@
describe('Matcher', function () {
function executeFutures() {
for(var i in $scenario.currentSpec.futures) {
var future = $scenario.currentSpec.futures[i];
future.behavior.call({}, function(value) { future.fulfill(value); });
}
}
var matcher;
beforeEach(function() {
setUpContext();
var future = $scenario.addFuture('Calculate first future', function(done) {
done(123);
});
matcher = new Matcher(this, future);
});
it('should correctly match toEqual', function() {
matcher.toEqual(123);
executeFutures();
});
it('should throw an error when incorrect match toEqual', function() {
matcher.toEqual(456);
try {
executeFutures();
fail();
} catch (e) {
expect(e).toEqual('Expected 456 but was 123');
}
});
});