From 4533d6a7cdfaaf7ead48b7a21d5326dc8fa6c994 Mon Sep 17 00:00:00 2001 From: ragaskar Date: Wed, 2 Sep 2009 07:30:31 -0700 Subject: [PATCH] specs() refactor, added test coverage --- doc/files.html | 2 +- doc/index.html | 2 +- doc/symbols/_global_.html | 2 +- doc/symbols/jasmine.Block.html | 2 +- doc/symbols/jasmine.Env.html | 2 +- doc/symbols/jasmine.JsApiReporter.html | 2 +- doc/symbols/jasmine.MultiReporter.html | 2 +- doc/symbols/jasmine.NestedResults.html | 2 +- doc/symbols/jasmine.Reporter.html | 2 +- doc/symbols/jasmine.Runner.html | 2 +- doc/symbols/jasmine.Spec.html | 2 +- doc/symbols/jasmine.Spy.html | 2 +- doc/symbols/jasmine.Suite.html | 2 +- doc/symbols/jasmine.html | 2 +- doc/symbols/jasmine.util.html | 2 +- doc/symbols/src/lib_jasmine-0.9.0.js.html | 6 +- lib/jasmine-0.9.0.js | 14 +-- spec/suites/SuiteSpec.js | 115 ++++++++++++++-------- src/JsApiReporter.js | 2 +- src/Suite.js | 10 +- 20 files changed, 107 insertions(+), 70 deletions(-) diff --git a/doc/files.html b/doc/files.html index ad54a31..3728f1a 100644 --- a/doc/files.html +++ b/doc/files.html @@ -258,7 +258,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:38 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/index.html b/doc/index.html index 573ae9f..c6e5b21 100644 --- a/doc/index.html +++ b/doc/index.html @@ -300,7 +300,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:38 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/symbols/_global_.html b/doc/symbols/_global_.html index 3de8e73..453a388 100644 --- a/doc/symbols/_global_.html +++ b/doc/symbols/_global_.html @@ -908,7 +908,7 @@ A convenience method that allows existing specs to be disabled temporarily durin
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Block.html b/doc/symbols/jasmine.Block.html index 007e260..037b998 100644 --- a/doc/symbols/jasmine.Block.html +++ b/doc/symbols/jasmine.Block.html @@ -339,7 +339,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Env.html b/doc/symbols/jasmine.Env.html index 5d10810..800315f 100644 --- a/doc/symbols/jasmine.Env.html +++ b/doc/symbols/jasmine.Env.html @@ -384,7 +384,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.JsApiReporter.html b/doc/symbols/jasmine.JsApiReporter.html index 05e9646..c94cbbd 100644 --- a/doc/symbols/jasmine.JsApiReporter.html +++ b/doc/symbols/jasmine.JsApiReporter.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.MultiReporter.html b/doc/symbols/jasmine.MultiReporter.html index 9cf8c9f..efd4719 100644 --- a/doc/symbols/jasmine.MultiReporter.html +++ b/doc/symbols/jasmine.MultiReporter.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.NestedResults.html b/doc/symbols/jasmine.NestedResults.html index 5277921..23eb3d2 100644 --- a/doc/symbols/jasmine.NestedResults.html +++ b/doc/symbols/jasmine.NestedResults.html @@ -700,7 +700,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Reporter.html b/doc/symbols/jasmine.Reporter.html index 48c85b5..cb52873 100644 --- a/doc/symbols/jasmine.Reporter.html +++ b/doc/symbols/jasmine.Reporter.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Runner.html b/doc/symbols/jasmine.Runner.html index 2ba2a60..1df5807 100644 --- a/doc/symbols/jasmine.Runner.html +++ b/doc/symbols/jasmine.Runner.html @@ -327,7 +327,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Spec.html b/doc/symbols/jasmine.Spec.html index 9ddc595..3bfc98e 100644 --- a/doc/symbols/jasmine.Spec.html +++ b/doc/symbols/jasmine.Spec.html @@ -339,7 +339,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Spy.html b/doc/symbols/jasmine.Spy.html index 7f6b4a2..54ceff6 100644 --- a/doc/symbols/jasmine.Spy.html +++ b/doc/symbols/jasmine.Spy.html @@ -845,7 +845,7 @@ expect(foo.bar.callCount).toEqual(0);
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:38 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Suite.html b/doc/symbols/jasmine.Suite.html index 8c3f04e..f68c85a 100644 --- a/doc/symbols/jasmine.Suite.html +++ b/doc/symbols/jasmine.Suite.html @@ -345,7 +345,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:38 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.html b/doc/symbols/jasmine.html index 223627e..b7561b9 100644 --- a/doc/symbols/jasmine.html +++ b/doc/symbols/jasmine.html @@ -678,7 +678,7 @@ Jasmine environment.
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.util.html b/doc/symbols/jasmine.util.html index 3c6c13e..dd8eb69 100644 --- a/doc/symbols/jasmine.util.html +++ b/doc/symbols/jasmine.util.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:24:38 GMT-0700 (PDT)
diff --git a/doc/symbols/src/lib_jasmine-0.9.0.js.html b/doc/symbols/src/lib_jasmine-0.9.0.js.html index 885ecb7..5efc6d8 100644 --- a/doc/symbols/src/lib_jasmine-0.9.0.js.html +++ b/doc/symbols/src/lib_jasmine-0.9.0.js.html @@ -524,7 +524,7 @@ 517 "major": 0, 518 "minor": 9, 519 "build": 0, -520 "revision": 1251865107 +520 "revision": 1251901364 521 }; 522 /** 523 * @namespace @@ -862,7 +862,7 @@ 855 children: [] 856 }; 857 if (isSuite) { -858 var specs = suiteOrSpec.getSpecs(); +858 var specs = suiteOrSpec.specs(); 859 for (var i = 0; i < specs.length; i++) { 860 summary.children.push(this.summarize_(specs[i])); 861 } @@ -1804,7 +1804,7 @@ 1797 return this.specs.length; 1798 }; 1799 -1800 jasmine.Suite.prototype.getSpecs = function() { +1800 jasmine.Suite.prototype.specs = function() { 1801 return this.specs; 1802 }; 1803 diff --git a/lib/jasmine-0.9.0.js b/lib/jasmine-0.9.0.js index de0f1f9..07f1a79 100644 --- a/lib/jasmine-0.9.0.js +++ b/lib/jasmine-0.9.0.js @@ -517,7 +517,7 @@ jasmine.version_= { "major": 0, "minor": 9, "build": 0, - "revision": 1251865169 + "revision": 1251901478 }; /** * @namespace @@ -855,7 +855,7 @@ jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) { children: [] }; if (isSuite) { - var specs = suiteOrSpec.getSpecs(); + var specs = suiteOrSpec.specs(); for (var i = 0; i < specs.length; i++) { summary.children.push(this.summarize_(specs[i])); } @@ -1751,7 +1751,7 @@ jasmine.Suite = function(env, description, specDefinitions, parentSuite) { self.env = env; self.beforeQueue = []; self.afterQueue = []; - self.specs = []; + self.specs_ = []; }; jasmine.Suite.prototype.getFullName = function() { @@ -1788,17 +1788,17 @@ jasmine.Suite.prototype.add = function(block) { if (block instanceof jasmine.Suite) { this.env.currentRunner.addSuite(block); } else { - this.specs.push(block); + this.specs_.push(block); } this.queue.add(block); }; jasmine.Suite.prototype.specCount = function() { - return this.specs.length; + return this.specs_.length; }; -jasmine.Suite.prototype.getSpecs = function() { - return this.specs; +jasmine.Suite.prototype.specs = function() { + return this.specs_; }; jasmine.Suite.prototype.execute = function(onComplete) { diff --git a/spec/suites/SuiteSpec.js b/spec/suites/SuiteSpec.js index 7d3256c..1769869 100644 --- a/spec/suites/SuiteSpec.js +++ b/spec/suites/SuiteSpec.js @@ -12,54 +12,91 @@ describe('Suite', function() { env.clearInterval = fakeTimer.clearInterval; }); - it('should keep a count of the number of specs that are run' , function() { - env.describe('one suite description', function () { - env.it('should be a test', function() { - this.runs(function () { - this.expect(true).toEqual(true); - }); - }); - env.it('should be another test', function() { - this.runs(function () { - this.expect(true).toEqual(true); - }); - }); - env.it('should be a third test', function() { - this.runs(function () { - this.expect(true).toEqual(true); + describe('Specs', function () { + it('#specs should return all immediate children that are specs.', function () { + var suite =env.describe('Suite 1', function () { + env.it('Spec 1', function() { + this.runs(function () { + this.expect(true).toEqual(true); + }); + }); + env.it('Spec 2', function() { + this.runs(function () { + this.expect(true).toEqual(true); + }); + }); + env.describe('Suite 2', function () { + env.it('Spec 3', function() { + this.runs(function () { + this.expect(true).toEqual(true); + }); + }); + }); + env.it('Spec 4', function() { + this.runs(function () { + this.expect(true).toEqual(true); + }); }); }); + + var suiteSpecs = suite.specs(); + expect(suiteSpecs.length).toEqual(3); + expect(suiteSpecs[0].description).toEqual('Spec 1'); + expect(suiteSpecs[1].description).toEqual('Spec 2'); + expect(suiteSpecs[2].description).toEqual('Spec 4'); }); - var suite = env.currentRunner.suites[0]; - expect(suite.specCount()).toEqual(3); - }); + describe('SpecCount', function () { - it('specCount should be correct even with runs/waits blocks' , function() { - env.describe('one suite description', function () { - env.it('should be a test', function() { - this.runs(function () { - this.expect(true).toEqual(true); + it('should keep a count of the number of specs that are run', function() { + env.describe('one suite description', function () { + env.it('should be a test', function() { + this.runs(function () { + this.expect(true).toEqual(true); + }); + }); + env.it('should be another test', function() { + this.runs(function () { + this.expect(true).toEqual(true); + }); + }); + env.it('should be a third test', function() { + this.runs(function () { + this.expect(true).toEqual(true); + }); + }); }); + + var suite = env.currentRunner.suites[0]; + expect(suite.specCount()).toEqual(3); }); - env.it('should be another test', function() { - this.runs(function () { - this.expect(true).toEqual(true); - }); - this.waits(10); - this.runs(function () { - this.expect(true).toEqual(true); - }); - }); - env.it('should be a third test', function() { - this.runs(function () { - this.expect(true).toEqual(true); + + it('specCount should be correct even with runs/waits blocks', function() { + env.describe('one suite description', function () { + env.it('should be a test', function() { + this.runs(function () { + this.expect(true).toEqual(true); + }); + }); + env.it('should be another test', function() { + this.runs(function () { + this.expect(true).toEqual(true); + }); + this.waits(10); + this.runs(function () { + this.expect(true).toEqual(true); + }); + }); + env.it('should be a third test', function() { + this.runs(function () { + this.expect(true).toEqual(true); + }); + }); }); + + var suite = env.currentRunner.suites[0]; + expect(suite.specCount()).toEqual(3); }); }); - - var suite = env.currentRunner.suites[0]; - expect(suite.specCount()).toEqual(3); }); - }); \ No newline at end of file diff --git a/src/JsApiReporter.js b/src/JsApiReporter.js index a5da634..081bec5 100644 --- a/src/JsApiReporter.js +++ b/src/JsApiReporter.js @@ -27,7 +27,7 @@ jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) { children: [] }; if (isSuite) { - var specs = suiteOrSpec.getSpecs(); + var specs = suiteOrSpec.specs(); for (var i = 0; i < specs.length; i++) { summary.children.push(this.summarize_(specs[i])); } diff --git a/src/Suite.js b/src/Suite.js index b4d9f4b..57f5658 100644 --- a/src/Suite.js +++ b/src/Suite.js @@ -16,7 +16,7 @@ jasmine.Suite = function(env, description, specDefinitions, parentSuite) { self.env = env; self.beforeQueue = []; self.afterQueue = []; - self.specs = []; + self.specs_ = []; }; jasmine.Suite.prototype.getFullName = function() { @@ -53,17 +53,17 @@ jasmine.Suite.prototype.add = function(block) { if (block instanceof jasmine.Suite) { this.env.currentRunner.addSuite(block); } else { - this.specs.push(block); + this.specs_.push(block); } this.queue.add(block); }; jasmine.Suite.prototype.specCount = function() { - return this.specs.length; + return this.specs_.length; }; -jasmine.Suite.prototype.getSpecs = function() { - return this.specs; +jasmine.Suite.prototype.specs = function() { + return this.specs_; }; jasmine.Suite.prototype.execute = function(onComplete) {