diff options
| author | Andres Ornelas | 2010-07-27 17:04:37 -0700 |
|---|---|---|
| committer | Andres Ornelas | 2010-07-27 17:04:37 -0700 |
| commit | ef88eb9a71ee7666029c4fb5eb731ce2e986cecc (patch) | |
| tree | 1152efda8f109523808ba0baf2256465ca0ba6c7 | |
| parent | e8b477f5b1f6fcca99ea54731e7c4f09ef17b0f7 (diff) | |
| download | angular.js-ef88eb9a71ee7666029c4fb5eb731ce2e986cecc.tar.bz2 | |
refactoring done but Expect not working
| -rw-r--r-- | src/scenario/Matcher.js | 8 | ||||
| -rw-r--r-- | src/scenario/Runner.js | 3 | ||||
| -rw-r--r-- | test/scenario/DSLSpec.js | 9 | ||||
| -rw-r--r-- | test/scenario/RunnerSpec.js | 7 | ||||
| -rw-r--r-- | test/scenario/TestContext.js | 7 |
5 files changed, 18 insertions, 16 deletions
diff --git a/src/scenario/Matcher.js b/src/scenario/Matcher.js index a4a13285..b9787050 100644 --- a/src/scenario/Matcher.js +++ b/src/scenario/Matcher.js @@ -1,10 +1,10 @@ -function Matcher(future, logger) { - var self = this; +function Matcher(scope, future, logger) { + var self = scope.$scenario = this; this.logger = logger; this.future = future; } -Matcher.addMatcher = function(name, matcher){ +Matcher.addMatcher = function(name, matcher) { Matcher.prototype[name] = function(expected) { var future = this.future; $scenario.addFuture( @@ -18,4 +18,4 @@ Matcher.addMatcher = function(name, matcher){ }; }; -Matcher.addMatcher('toEqual', function(a,b){ return a == b; }); +Matcher.addMatcher('toEqual', function(a,b) { return a == b; }); diff --git a/src/scenario/Runner.js b/src/scenario/Runner.js index 4e5d0f01..13dfbe7d 100644 --- a/src/scenario/Runner.js +++ b/src/scenario/Runner.js @@ -8,6 +8,7 @@ angular.scenario.Runner = function(scope, jQuery){ this.scope.$testrun = {done: false, results: []}; var specs = this.specs = {}; + this.currentSpec = {name: '', futures: []}; var path = []; this.scope.describe = function(name, body){ path.push(name); @@ -23,7 +24,7 @@ angular.scenario.Runner = function(scope, jQuery){ afterEach = body; }; this.scope.expect = function(future) { - return new Matcher(future, self.logger); + return new Matcher(self, future, self.logger); }; this.scope.it = function(name, body) { var specName = path.join(' ') + ': it ' + name; diff --git a/test/scenario/DSLSpec.js b/test/scenario/DSLSpec.js index 4d8d1075..533d34ac 100644 --- a/test/scenario/DSLSpec.js +++ b/test/scenario/DSLSpec.js @@ -1,11 +1,9 @@ describe("DSL", function() { - var scenario, runner, $scenario, lastDocument, executeFuture; + var lastDocument, executeFuture, Expect; beforeEach(function() { - scenario = {}; - runner = new angular.scenario.Runner(scenario, _jQuery); - $scenario = scenario.$scenario; + setUpContext(); executeFuture = function(future, html, callback) { lastDocument =_jQuery('<div>' + html + '</div>'); _jQuery(document.body).append(lastDocument); @@ -15,6 +13,7 @@ describe("DSL", function() { }; future.behavior.call(specThis, callback || noop); }; + Expect = scenario.expect; }); describe("input", function() { @@ -48,7 +47,7 @@ describe("DSL", function() { expect(future.name).toEqual("repeater '.repeater-row' count"); executeFuture(future, "<div class='repeater-row'>a</div>" + "<div class='repeater-row'>b</div>"); -// Expect(future).toEqual(2); + Expect(future).toEqual(2); }); }); }); diff --git a/test/scenario/RunnerSpec.js b/test/scenario/RunnerSpec.js index f5c152a5..2eb13f7f 100644 --- a/test/scenario/RunnerSpec.js +++ b/test/scenario/RunnerSpec.js @@ -1,7 +1,14 @@ describe('Runner', function() { + var Describe, It, BeforeEach, AfterEach, body; + beforeEach(function() { setUpContext(); + Describe = scenario.describe; + It = scenario.it; + BeforeEach = scenario.beforeEach; + AfterEach = scenario.afterEach; + body = _jQuery('<div></div>'); }); describe('describe', function() { diff --git a/test/scenario/TestContext.js b/test/scenario/TestContext.js index 7a7b41e4..ebb40b95 100644 --- a/test/scenario/TestContext.js +++ b/test/scenario/TestContext.js @@ -1,4 +1,4 @@ -var scenario, runner, log, $scenario, Describe, It, body; +var scenario, runner, log, $scenario; function logger(text) { return function(done){ @@ -11,10 +11,5 @@ function setUpContext() { scenario = {}; runner = new angular.scenario.Runner(scenario, _jQuery); $scenario = scenario.$scenario; - Describe = scenario.describe; - BeforeEach = scenario.beforeEach; - AfterEach = scenario.afterEach; - It = scenario.it; log = ''; - body = _jQuery('<div></div>'); } |
