dwf/rva: results now propagated up.

This commit is contained in:
pivotal
2008-12-02 13:59:39 -08:00
parent 42eeab1cdb
commit 1df1de2bb7
3 changed files with 161 additions and 41 deletions

View File

@@ -23,6 +23,11 @@ var actionCollection = function () {
actions: [],
index: 0,
finished: false,
results: nestedResults(),
report: function (result) {
that.results.push(result);
},
execute: function () {
if (that.actions.length > 0) {
@@ -48,6 +53,7 @@ var actionCollection = function () {
var id = setInterval(function () {
if (action.finished) {
clearInterval(id);
that.report(action.results);
that.index++;
that.next();
}
@@ -68,7 +74,7 @@ var actionCollection = function () {
Matchers = function (actual, results) {
this.actual = actual;
this.passing_message = 'Passed.'
this.results = results || [];
this.results = results || nestedResults();
}
Matchers.method('report', function (result, failing_message) {
@@ -117,6 +123,33 @@ var queuedFunction = function(func, timeout, spec) {
return that;
}
var nestedResults = function() {
var that = {
totalCount: 0,
passedCount: 0,
failedCount: 0,
results: [],
push: function(result) {
if (result.results) {
that.totalCount += result.totalCount;
that.passedCount += result.passedCount;
that.failedCount += result.failedCount;
} else {
that.totalCount++;
if (result.passed) {
that.passedCount++;
} else {
that.failedCount++;
}
}
that.results.push(result);
}
}
return that;
}
var it = function (description, func) {
var that = {
@@ -124,9 +157,12 @@ var it = function (description, func) {
queue: [],
currentTimeout: 0,
finished: false,
suite: {next:function() {
}},
results: [],
// suite: {
// next: function() {
// }},
results: nestedResults(),
expects_that: function (actual) {
return new Matchers(actual, that.results);
@@ -208,6 +244,7 @@ var Jasmine = function () {
var that = actionCollection();
that.suites = that.actions;
currentRunner = that;
return that;
}
@@ -227,7 +264,7 @@ var currentSpec;
* - Suite supports after
* - Suite supports before_each
* - Suite supports after_each
* - Suite rolls up spec results
//* - Suite rolls up spec results
//* - Suite supports asynch
//* - Runner that runs suites in order
// * - Runner supports async