Consistent 'this' between befores/it/afters

Change the 'this' user functions are called with to be an empty object
instead of the QueueRunner so that if the user puts properties on it,
        they won't conflict.

Also, changes async specs to be called with a proper 'this', as pointed
out by @Eric-Wright in #419 and #420.

[finishes #56030080]
This commit is contained in:
Sheel Choksi
2013-09-07 18:28:03 -07:00
parent 4bff199c2a
commit f463e1f7aa
5 changed files with 89 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ getJasmineRequireObj().QueueRunner = function() {
this.clearStack = attrs.clearStack || function(fn) {fn();};
this.onException = attrs.onException || function() {};
this.catchException = attrs.catchException || function() { return true; };
this.userContext = {};
}
QueueRunner.prototype.execute = function() {
@@ -34,7 +35,7 @@ getJasmineRequireObj().QueueRunner = function() {
function attemptSync(fn) {
try {
fn.call(self);
fn.call(self.userContext);
} catch (e) {
handleException(e);
}
@@ -44,7 +45,7 @@ getJasmineRequireObj().QueueRunner = function() {
var next = function () { self.run(fns, iterativeIndex + 1); };
try {
fn.call(self, next);
fn.call(self.userContext, next);
} catch (e) {
handleException(e);
next();