dwf/rva: Suites now have beforeEach and AfterEach

This commit is contained in:
pivotal
2008-12-02 15:27:07 -08:00
parent a9a6d7cbda
commit f0de62906c
3 changed files with 129 additions and 33 deletions

View File

@@ -40,13 +40,19 @@ var actionCollection = function () {
},
next: function() {
if (that.index < that.actions.length) {
var currentAction = that.getCurrentAction();
currentAction.execute();
that.waitForDone(currentAction);
} else {
if (that.index >= that.actions.length) {
that.finished = true;
return;
}
var currentAction = that.getCurrentAction();
if (that.beforeEach) {
that.beforeEach.apply(currentAction);
}
currentAction.execute();
that.waitForDone(currentAction);
},
waitForDone: function(action) {
@@ -54,6 +60,11 @@ var actionCollection = function () {
if (action.finished) {
clearInterval(id);
that.report(action.results);
if (that.afterEach) {
that.afterEach.apply(action);
}
that.index++;
that.next();
}
@@ -217,11 +228,19 @@ var runs = function (func) {
currentSpec.runs(func);
}
var then = runs;
var waits = function (timeout) {
currentSpec.waits(timeout);
}
var then = runs;
var beforeEach = function (beforeEach) {
currentSuite.beforeEach = beforeEach;
}
var afterEach = function (afterEach) {
currentSuite.afterEach = afterEach;
}
var describe = function (description, spec_definitions) {
var that = actionCollection();