Browse files

added checking for dupliate specs

  • Loading branch information...
1 parent 8e1f308 commit 29bcc742e58e7b7f55eeaf50bb2dc623ea34d22b @refractalize committed Mar 8, 2011
Showing with 7 additions and 1 deletion.
  1. +7 −1 cupoftea.js
View
8 cupoftea.js
@@ -12,6 +12,7 @@ var d = function (msg) {
var SpecDefinition = function (desc, parentSpec, index) {
var childSpecs = [];
var specsRun = 0;
+ var firstRun = true;
var findChildSpecByDescription = function (desc) {
debug('childSpecs:');
@@ -27,6 +28,9 @@ var SpecDefinition = function (desc, parentSpec, index) {
addSpec: function (desc, definition) {
var existingSpec = findChildSpecByDescription(desc);
if (existingSpec) {
+ if (firstRun) {
+ throw new Error('this spec seems to be a duplicate: ' + desc);
+ }
debug('found spec: ' + existingSpec.description());
debug('specs run: ' + specsRun);
debug('spec index: ' + existingSpec.index());
@@ -70,6 +74,7 @@ var SpecDefinition = function (desc, parentSpec, index) {
return finished && specsRun === childSpecs.length;
},
end: function () {
+ firstRun = false;
if (childSpecs.length > specsRun && childSpecs[specsRun].isFinished()) {
specsRun++;
}
@@ -257,7 +262,6 @@ shouldCall = function (f) {
};
process.addListener('exit', function () {
- //console.log('exiting');
_(runStacks).each(function (runStack) {
runStack.assertAllCallbacks();
});
@@ -266,5 +270,7 @@ process.addListener('exit', function () {
process.on('uncaughtException', function(err) {
if (!_(expectedExceptions).contains(err)) {
throw err;
+ } else {
+ console.log('caught exception');
}
});

0 comments on commit 29bcc74

Please sign in to comment.