Don't clobber previous custom plans with later plans
[finishes #37288941]
This commit is contained in:
@@ -20,20 +20,24 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
||||
var k, cs = options.customStrategies || {};
|
||||
for (k in cs) {
|
||||
if (j$.util.has(cs, k) && !this[k]) {
|
||||
this[k] = function() {
|
||||
var plan = cs[k].apply(null, arguments);
|
||||
|
||||
if (!j$.isFunction_(plan)) {
|
||||
throw new Error('Spy strategy must return a function');
|
||||
}
|
||||
|
||||
this.plan = plan;
|
||||
return this.getSpy();
|
||||
};
|
||||
this[k] = createCustomPlan(cs[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createCustomPlan(factory) {
|
||||
return function() {
|
||||
var plan = factory.apply(null, arguments);
|
||||
|
||||
if (!j$.isFunction_(plan)) {
|
||||
throw new Error('Spy strategy must return a function');
|
||||
}
|
||||
|
||||
this.plan = plan;
|
||||
return this.getSpy();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the current spy strategy.
|
||||
* @name SpyStrategy#exec
|
||||
|
||||
Reference in New Issue
Block a user