specs() refactor, added test coverage

This commit is contained in:
ragaskar 2009-09-02 07:30:31 -07:00
parent 50134eb1ac
commit 4533d6a7cd
20 changed files with 107 additions and 70 deletions

View File

@ -258,7 +258,7 @@ ul.inheritsList
</div>
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:38 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -300,7 +300,7 @@ ul.inheritsList
</div>
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:38 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -908,7 +908,7 @@ A convenience method that allows existing specs to be disabled temporarily durin
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -339,7 +339,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -384,7 +384,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -316,7 +316,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -316,7 +316,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -700,7 +700,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -316,7 +316,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -327,7 +327,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -339,7 +339,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -845,7 +845,7 @@ expect(foo.bar.callCount).toEqual(0);</pre>
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:38 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -345,7 +345,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:38 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -678,7 +678,7 @@ Jasmine environment.
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:37 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -316,7 +316,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:24:38 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -524,7 +524,7 @@
<span class='line'>517</span> </span><span class="WHIT"> </span><span class="STRN">"major"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>518</span> </span><span class="WHIT"> </span><span class="STRN">"minor"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">9</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>519</span> </span><span class="WHIT"> </span><span class="STRN">"build"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT"> </span><span class="STRN">"revision"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1251865107</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT"> </span><span class="STRN">"revision"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1251901364</span><span class="WHIT">
<span class='line'>521</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>522</span> </span><span class="COMM">/**
<span class='line'>523</span> * @namespace
@ -862,7 +862,7 @@
<span class='line'>855</span> </span><span class="WHIT"> </span><span class="NAME">children</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>856</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>857</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isSuite</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>858</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">specs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">suiteOrSpec.getSpecs</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>858</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">specs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">suiteOrSpec.specs</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>859</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">specs.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>860</span> </span><span class="WHIT"> </span><span class="NAME">summary.children.push</span><span class="PUNC">(</span><span class="NAME">this.summarize_</span><span class="PUNC">(</span><span class="NAME">specs</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>861</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
@ -1804,7 +1804,7 @@
<span class='line'>1797</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.specs.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1798</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1799</span>
<span class='line'>1800</span> </span><span class="NAME">jasmine.Suite.prototype.getSpecs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1800</span> </span><span class="NAME">jasmine.Suite.prototype.specs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1801</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.specs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1802</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1803</span>

View File

@ -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) {

View File

@ -12,7 +12,43 @@ describe('Suite', function() {
env.clearInterval = fakeTimer.clearInterval;
});
it('should keep a count of the number of specs that are run' , function() {
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');
});
describe('SpecCount', function () {
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 () {
@ -35,7 +71,7 @@ describe('Suite', function() {
expect(suite.specCount()).toEqual(3);
});
it('specCount should be correct even with runs/waits blocks' , 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 () {
@ -61,5 +97,6 @@ describe('Suite', function() {
var suite = env.currentRunner.suites[0];
expect(suite.specCount()).toEqual(3);
});
});
});
});

View File

@ -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]));
}

View File

@ -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) {