diff options
| author | Andres Ornelas | 2010-06-09 14:12:54 -0700 |
|---|---|---|
| committer | Andres Ornelas | 2010-06-09 14:12:54 -0700 |
| commit | 85fac4d78c131771d7fdd46d6ccd44bae92419cd (patch) | |
| tree | f15243a5a71b5c363acba11781f9bd83e2435b2f /src/scenario/Runner.js | |
| parent | f6a405c283ba1f2e0037e0bedb52e5cee618d4ff (diff) | |
| download | angular.js-85fac4d78c131771d7fdd46d6ccd44bae92419cd.tar.bz2 | |
add beforeEach and afterEach to scenario DSL
Diffstat (limited to 'src/scenario/Runner.js')
| -rw-r--r-- | src/scenario/Runner.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/scenario/Runner.js b/src/scenario/Runner.js index da6e2c39..8e0cc909 100644 --- a/src/scenario/Runner.js +++ b/src/scenario/Runner.js @@ -8,23 +8,34 @@ angular.scenario.Runner = function(scope, jQuery){ var specs = this.specs = {}; var path = []; - this.scope.describe = function describe(name, body){ + this.scope.describe = function(name, body){ path.push(name); body(); path.pop(); }; - this.scope.it = function it(name, body) { + var beforeEach = noop; + var afterEach = noop; + this.scope.beforeEach = function(body) { + beforeEach = body; + }; + this.scope.afterEach = function(body) { + afterEach = body; + }; + this.scope.it = function(name, body) { var specName = path.join(' ') + ': it ' + name; self.currentSpec = specs[specName] = { name: specName, steps:[] }; try { + beforeEach(); body(); } catch(err) { self.addStep(err.message || 'ERROR', function(){ throw err; }); + } finally { + afterEach(); } self.currentSpec = null; }; |
