Major refactoring of Spec. Moved QueuedFunction to Block, WaitsBlock and WaitsForBlock. Waits and WaitsFor blocks now sequentially stackable
This commit is contained in:
31
src/Block.js
Normal file
31
src/Block.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Blocks are functions with executable code that make up a spec.
|
||||
*
|
||||
* @constructor
|
||||
* @param {jasmine.Env} env
|
||||
* @param {Function} func
|
||||
* @param {jasmine.Spec} spec
|
||||
*/
|
||||
jasmine.Block = function(env, func, spec) {
|
||||
this.env = env;
|
||||
this.func = func;
|
||||
this.spec = spec;
|
||||
};
|
||||
|
||||
jasmine.Block.prototype.next = function() {
|
||||
this.spec.finish(); // default value is to be done after one function
|
||||
};
|
||||
|
||||
jasmine.Block.prototype.execute = function() {
|
||||
this.env.reporter.log('>> Jasmine Running ' + this.spec.suite.description + ' ' + this.spec.description + '...');
|
||||
try {
|
||||
this.func.apply(this.spec);
|
||||
} catch (e) {
|
||||
this.fail(e);
|
||||
}
|
||||
this.next();
|
||||
};
|
||||
|
||||
jasmine.Block.prototype.fail = function(e) {
|
||||
this.spec.results.addResult(new jasmine.ExpectationResult(false, jasmine.util.formatException(e), null));
|
||||
};
|
||||
Reference in New Issue
Block a user