Factor out some common logic between fdesc and desc
This commit is contained in:
@@ -265,26 +265,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
|
|
||||||
this.describe = function(description, specDefinitions) {
|
this.describe = function(description, specDefinitions) {
|
||||||
var suite = suiteFactory(description);
|
var suite = suiteFactory(description);
|
||||||
|
addSpecsToSuite(suite, specDefinitions);
|
||||||
var parentSuite = currentDeclarationSuite;
|
|
||||||
parentSuite.addChild(suite);
|
|
||||||
currentDeclarationSuite = suite;
|
|
||||||
|
|
||||||
var declarationError = null;
|
|
||||||
try {
|
|
||||||
specDefinitions.call(suite);
|
|
||||||
} catch (e) {
|
|
||||||
declarationError = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (declarationError) {
|
|
||||||
this.it('encountered a declaration exception', function() {
|
|
||||||
throw declarationError;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
currentDeclarationSuite = parentSuite;
|
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -297,7 +278,15 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
this.fdescribe = function(description, specDefinitions) {
|
this.fdescribe = function(description, specDefinitions) {
|
||||||
var suite = suiteFactory(description);
|
var suite = suiteFactory(description);
|
||||||
suite.isFocused = true;
|
suite.isFocused = true;
|
||||||
|
addSpecsToSuite(suite, specDefinitions);
|
||||||
|
|
||||||
|
if (!hasFocusedAncestor(suite.parentSuite)) {
|
||||||
|
focusedRunnables.push(suite.id);
|
||||||
|
}
|
||||||
|
return suite;
|
||||||
|
};
|
||||||
|
|
||||||
|
function addSpecsToSuite(suite, specDefinitions) {
|
||||||
var parentSuite = currentDeclarationSuite;
|
var parentSuite = currentDeclarationSuite;
|
||||||
parentSuite.addChild(suite);
|
parentSuite.addChild(suite);
|
||||||
currentDeclarationSuite = suite;
|
currentDeclarationSuite = suite;
|
||||||
@@ -310,17 +299,13 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (declarationError) {
|
if (declarationError) {
|
||||||
this.it('encountered a declaration exception', function() {
|
self.it('encountered a declaration exception', function() {
|
||||||
throw declarationError;
|
throw declarationError;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDeclarationSuite = parentSuite;
|
currentDeclarationSuite = parentSuite;
|
||||||
if (!hasFocusedAncestor(parentSuite)) {
|
}
|
||||||
focusedRunnables.push(suite.id);
|
|
||||||
}
|
|
||||||
return suite;
|
|
||||||
};
|
|
||||||
|
|
||||||
function hasFocusedAncestor(suite) {
|
function hasFocusedAncestor(suite) {
|
||||||
while (suite) {
|
while (suite) {
|
||||||
|
|||||||
Reference in New Issue
Block a user