Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for ddescribe and iit for Jasmine2.0 branch. #342

Open
wants to merge 3 commits into
base: Jasmine2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/jasmine-node/jasmine-loader.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 63 additions & 25 deletions lib/jasmine-node/jasmine/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
junitReporter = require('../junit-reporter');

boot = function(jasmineRequire, clockCallback) {
var clockInstaller, clockUninstaller, env, extend, jasmine, jasmineInterface;
var clockInstaller, clockUninstaller, env, extend, focuseSpec, focuseSuite, focusedSpecs, focusedSuites, insideFocusedSuite, jasmine, jasmineInterface, wrapSpecFunc;
jasmine = jasmineRequire.core(jasmineRequire);

/*
Expand All @@ -30,6 +30,52 @@
jasmine.TerminalReporter = nodeReporters.TerminalReporter;
jasmine.JUnitReporter = junitReporter.JUnitReporter;
jasmine.GrowlReporter = growlReporter;
focusedSuites = [];
focusedSpecs = [];
insideFocusedSuite = false;
focuseSpec = function(env, description, body) {
var spec;
spec = env.it(description, body);
focusedSpecs.push(spec.id);
return spec;
};
focuseSuite = function(env, description, body) {
var suite;
if (insideFocusedSuite) {
return env.describe(description, body);
}
insideFocusedSuite = true;
suite = env.describe(description, body);
insideFocusedSuite = false;
focusedSuites.push(suite.id);
return suite;
};
wrapSpecFunc = function(func) {
var spec, wrappedDone, wrappedFunc;
spec = {
done: false,
doneFunc: function() {},
returned: false
};
wrappedFunc = func;
wrappedDone = function() {
spec.done = true;
if (spec.returned) {
return spec.doneFunc();
}
};
if (func != null ? func.length : void 0) {
wrappedFunc = function(done) {
spec.doneFunc = done;
func.call(this, wrappedDone);
spec.returned = true;
if (spec.done) {
return spec.doneFunc();
}
};
}
return wrappedFunc;
};

/*
*# The Global Interface
Expand All @@ -40,34 +86,17 @@
describe: function(description, specDefinitions) {
return env.describe(description, specDefinitions);
},
ddescribe: function(description, specDefinitions) {
return focuseSuite(env, description, specDefinitions);
},
xdescribe: function(description, specDefinitions) {
return env.xdescribe(description, specDefinitions);
},
it: function(desc, func) {
var spec, wrappedDone, wrappedFunc;
spec = {
done: false,
doneFunc: function() {},
returned: false
};
wrappedFunc = func;
wrappedDone = function() {
spec.done = true;
if (spec.returned) {
return spec.doneFunc();
}
};
if (func.length > 0) {
wrappedFunc = function(done) {
spec.doneFunc = done;
func.call(this, wrappedDone);
spec.returned = true;
if (spec.done) {
return spec.doneFunc();
}
};
}
return env.it(desc, wrappedFunc);
return env.it(desc, wrapSpecFunc(func));
},
iit: function(desc, func) {
return focuseSpec(env, desc, wrapSpecFunc(func));
},
xit: function(desc, func) {
return env.xit(desc, func);
Expand All @@ -94,6 +123,15 @@
*/
extend(global, jasmineInterface);
global.jasmine = jasmine;
env.executeFiltered = function() {
if (focusedSpecs.length) {
return env.execute(focusedSpecs);
} else if (focusedSuites.length) {
return env.execute(focusedSuites);
} else {
return env.execute();
}
};
clockInstaller = jasmine.currentEnv_.clock.install;
clockUninstaller = jasmine.currentEnv_.clock.uninstall;
jasmine.currentEnv_.clock.install = function() {
Expand Down
Loading