Start of before/after refactor. Yank defineGetter on nestedResults. rake build task now sorts sources to minimize jasmine.js changes post-build
This commit is contained in:
3
Rakefile
3
Rakefile
@@ -4,11 +4,10 @@ task :build do
|
|||||||
# these files must be loaded first
|
# these files must be loaded first
|
||||||
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/ActionCollection.js", "src/Reporter.js", "src/Block.js"]
|
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/ActionCollection.js", "src/Reporter.js", "src/Block.js"]
|
||||||
|
|
||||||
sources += Dir.glob('src/*.js').reject{|f| sources.include?(f)}
|
sources += Dir.glob('src/*.js').reject{|f| sources.include?(f)}.sort
|
||||||
|
|
||||||
jasmine = File.new('lib/jasmine.js', 'w')
|
jasmine = File.new('lib/jasmine.js', 'w')
|
||||||
sources.each do |source_filename|
|
sources.each do |source_filename|
|
||||||
jasmine.puts(File.read(source_filename))
|
jasmine.puts(File.read(source_filename))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
1224
lib/jasmine.js
1224
lib/jasmine.js
File diff suppressed because it is too large
Load Diff
@@ -587,7 +587,6 @@ describe("jasmine spec running", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
xit("#beforeEach should be able to eval runs and waits blocks", function () {
|
xit("#beforeEach should be able to eval runs and waits blocks", function () {
|
||||||
|
|
||||||
var foo = 0;
|
var foo = 0;
|
||||||
var bar = 0;
|
var bar = 0;
|
||||||
var suiteWithBefore = env.describe('one suite with a before', function () {
|
var suiteWithBefore = env.describe('one suite with a before', function () {
|
||||||
@@ -609,17 +608,20 @@ describe("jasmine spec running", function () {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//expect(foo).toEqual(0);
|
expect(foo).toEqual(0);
|
||||||
expect(bar).toEqual(0);
|
expect(bar).toEqual(0);
|
||||||
suiteWithBefore.execute();
|
suiteWithBefore.execute();
|
||||||
|
|
||||||
|
|
||||||
expect(bar).toEqual(0);
|
expect(bar).toEqual(0);
|
||||||
//expect(foo).toEqual(1);
|
expect(foo).toEqual(1);
|
||||||
fakeTimer.tick(500);
|
fakeTimer.tick(500);
|
||||||
|
|
||||||
expect(bar).toEqual(0);
|
expect(bar).toEqual(0);
|
||||||
//expect(foo).toEqual(2);
|
expect(foo).toEqual(2);
|
||||||
fakeTimer.tick(500);
|
fakeTimer.tick(500);
|
||||||
expect(bar).toEqual(1);
|
expect(bar).toEqual(1);
|
||||||
//expect(foo).toEqual(3);
|
expect(foo).toEqual(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("testBeforeExecutesSafely", function() {
|
it("testBeforeExecutesSafely", function() {
|
||||||
@@ -773,7 +775,9 @@ describe("jasmine spec running", function () {
|
|||||||
"inner 2 afterEach",
|
"inner 2 afterEach",
|
||||||
"outer afterEach"
|
"outer afterEach"
|
||||||
];
|
];
|
||||||
expect(env.equals_(actions, expected)).toEqual(true); // "nested describes order failed: <blockquote>" + jasmine.pp(actions) + "</blockquote> wanted <blockquote>" + jasmine.pp(expected) + "</blockquote");
|
console.log(actions);
|
||||||
|
console.log(expected);
|
||||||
|
expect(env.equals_(actions, expected)).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("builds up nested names", function() {
|
it("builds up nested names", function() {
|
||||||
|
|||||||
14
src/Spec.js
14
src/Spec.js
@@ -145,7 +145,10 @@ jasmine.Spec.prototype.execute = function() {
|
|||||||
jasmine.Spec.prototype.safeExecuteBefores = function() {
|
jasmine.Spec.prototype.safeExecuteBefores = function() {
|
||||||
var befores = [];
|
var befores = [];
|
||||||
for (var suite = this.suite; suite; suite = suite.parentSuite) {
|
for (var suite = this.suite; suite; suite = suite.parentSuite) {
|
||||||
if (suite.beforeEachFunction) befores.push(suite.beforeEachFunction);
|
if (suite.beforeQueue) {
|
||||||
|
for (var i = 0; i < suite.beforeQueue.length; i++)
|
||||||
|
befores.push(suite.beforeQueue[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (befores.length) {
|
while (befores.length) {
|
||||||
@@ -154,8 +157,15 @@ jasmine.Spec.prototype.safeExecuteBefores = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Spec.prototype.safeExecuteAfters = function() {
|
jasmine.Spec.prototype.safeExecuteAfters = function() {
|
||||||
|
var afters = [];
|
||||||
for (var suite = this.suite; suite; suite = suite.parentSuite) {
|
for (var suite = this.suite; suite; suite = suite.parentSuite) {
|
||||||
if (suite.afterEachFunction) this.safeExecuteBeforeOrAfter(suite.afterEachFunction);
|
if (suite.afterQueue) {
|
||||||
|
for (var i = 0; i < suite.afterQueue.length; i++)
|
||||||
|
afters.unshift(suite.afterQueue[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (afters.length) {
|
||||||
|
this.safeExecuteBeforeOrAfter(afters.pop());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
|
|||||||
this.specs = this.actions;
|
this.specs = this.actions;
|
||||||
this.parentSuite = parentSuite;
|
this.parentSuite = parentSuite;
|
||||||
|
|
||||||
this.beforeEachFunction = null;
|
this.beforeQueue = [];
|
||||||
this.afterEachFunction = null;
|
this.afterQueue = [];
|
||||||
};
|
};
|
||||||
jasmine.util.inherit(jasmine.Suite, jasmine.ActionCollection);
|
jasmine.util.inherit(jasmine.Suite, jasmine.ActionCollection);
|
||||||
|
|
||||||
@@ -34,12 +34,12 @@ jasmine.Suite.prototype.finishCallback = function() {
|
|||||||
|
|
||||||
jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
|
jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
|
||||||
beforeEachFunction.typeName = 'beforeEach';
|
beforeEachFunction.typeName = 'beforeEach';
|
||||||
this.beforeEachFunction = beforeEachFunction;
|
this.beforeQueue.push(beforeEachFunction);
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
|
jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
|
||||||
afterEachFunction.typeName = 'afterEach';
|
afterEachFunction.typeName = 'afterEach';
|
||||||
this.afterEachFunction = afterEachFunction;
|
this.afterQueue.push(afterEachFunction);
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Suite.prototype.getResults = function() {
|
jasmine.Suite.prototype.getResults = function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user