dwf/rva: more async refactoring; results now stored on a per-spec basis;

This commit is contained in:
pivotal
2008-12-01 15:59:41 -08:00
parent 0ccb6dfc90
commit 29a0e1f519
3 changed files with 75 additions and 91 deletions

View File

@@ -25,14 +25,15 @@ if (typeof Function.method !== 'function') {
/*
* Matchers methods; add your own with Matchers.method()
*/
Matchers = function (actual) {
Matchers = function (actual, results) {
this.actual = actual;
this.passing_message = 'Passed.'
this.results = results || [];
}
Matchers.method('report', function (result, failing_message) {
Jasmine.results.push({
this.results.push({
passed: result,
message: result ? this.passing_message : failing_message
});
@@ -51,27 +52,9 @@ Matchers.method('should_not_equal', function (expected) {
'Expected ' + expected + ' to not equal ' + this.actual + ', but it does.');
});
/*
* expects_hat helper method that allows for chaining Matcher
*/
var expects_that = function (actual) {
return new Matchers(actual);
}
/*
* Jasmine spec constructor
*/
//var it = function (description, func) {
// var that = {
// description: description,
// func: func,
// done: false,
// execute: function() {
// that.func.apply(that);
// }
// }
// return that;
//}
var queuedFunction = function(func, timeout, spec) {
var that = {
@@ -82,11 +65,11 @@ var queuedFunction = function(func, timeout, spec) {
execute: function () {
if (timeout > 0) {
setTimeout(function () {
that.func();
that.func.apply(spec);
that.next();
}, timeout);
} else {
that.func();
that.func.apply(spec);
that.next();
}
}
@@ -94,12 +77,18 @@ var queuedFunction = function(func, timeout, spec) {
return that;
}
var it = function (description) {
var that = {
description: description,
queue: [],
currentTimeout: 0,
done: false,
results: [],
expects_that: function (actual) {
return new Matchers(actual, that.results);
},
waits: function (timeout) {
that.currentTimeout = timeout;