Move next spec/next suite ids into closure

No longer exposing these from the environment
This commit is contained in:
Sheel Choksi
2013-10-24 13:43:04 -07:00
parent d0aff9ed02
commit ab0b2b783c
2 changed files with 13 additions and 24 deletions

View File

@@ -5,14 +5,6 @@ describe("Env", function() {
env = new j$.Env(); env = new j$.Env();
}); });
describe('ids', function() {
it('nextSpecId should return consecutive integers, starting at 0', function() {
expect(env.nextSpecId()).toEqual('spec0');
expect(env.nextSpecId()).toEqual('spec1');
expect(env.nextSpecId()).toEqual('spec2');
});
});
describe("reporting", function() { describe("reporting", function() {
var fakeReporter; var fakeReporter;

View File

@@ -26,13 +26,10 @@ getJasmineRequireObj().Env = function(j$) {
"specDone" "specDone"
]); ]);
this.lastUpdate = 0;
this.specFilter = function() { this.specFilter = function() {
return true; return true;
}; };
this.nextSpecId_ = 0;
this.nextSuiteId_ = 0;
this.equalityTesters_ = []; this.equalityTesters_ = [];
var customEqualityTesters = []; var customEqualityTesters = [];
@@ -42,6 +39,16 @@ getJasmineRequireObj().Env = function(j$) {
j$.Expectation.addCoreMatchers(j$.matchers); j$.Expectation.addCoreMatchers(j$.matchers);
var nextSpecId = 0;
var getNextSpecId = function() {
return 'spec' + nextSpecId++;
};
var nextSuiteId = 0;
var getNextSuiteId = function() {
return 'suite' + nextSuiteId++;
};
var expectationFactory = function(actual, spec) { var expectationFactory = function(actual, spec) {
return j$.Expectation.Factory({ return j$.Expectation.Factory({
util: j$.matchersUtil, util: j$.matchersUtil,
@@ -133,7 +140,7 @@ getJasmineRequireObj().Env = function(j$) {
totalSpecsDefined++; totalSpecsDefined++;
var spec = new j$.Spec({ var spec = new j$.Spec({
id: self.nextSpecId(), id: getNextSpecId(),
beforeFns: beforeFns(suite), beforeFns: beforeFns(suite),
afterFns: afterFns(suite), afterFns: afterFns(suite),
expectationFactory: expectationFactory, expectationFactory: expectationFactory,
@@ -183,7 +190,7 @@ getJasmineRequireObj().Env = function(j$) {
this.topSuite = new j$.Suite({ this.topSuite = new j$.Suite({
env: this, env: this,
id: this.nextSuiteId(), id: getNextSuiteId(),
description: 'Jasmine__TopLevel__Suite', description: 'Jasmine__TopLevel__Suite',
queueRunner: queueRunnerFactory, queueRunner: queueRunnerFactory,
completeCallback: function() {}, // TODO - hook this up completeCallback: function() {}, // TODO - hook this up
@@ -195,7 +202,7 @@ getJasmineRequireObj().Env = function(j$) {
this.suiteFactory = function(description) { this.suiteFactory = function(description) {
var suite = new suiteConstructor({ var suite = new suiteConstructor({
env: self, env: self,
id: self.nextSuiteId(), id: getNextSuiteId(),
description: description, description: description,
parentSuite: self.currentSuite, parentSuite: self.currentSuite,
queueRunner: queueRunnerFactory, queueRunner: queueRunnerFactory,
@@ -273,16 +280,6 @@ getJasmineRequireObj().Env = function(j$) {
return j$.version; return j$.version;
}; };
// TODO: move this to closure
Env.prototype.nextSpecId = function() {
return 'spec' + this.nextSpecId_++;
};
// TODO: move this to closure
Env.prototype.nextSuiteId = function() {
return 'suite' + this.nextSuiteId_++;
};
// TODO: move this to closure // TODO: move this to closure
Env.prototype.addReporter = function(reporter) { Env.prototype.addReporter = function(reporter) {
this.reporter.addReporter(reporter); this.reporter.addReporter(reporter);