BUGFIX Passing through ignoreMethodDoesntExist parameter in jasmine.js, so we can use it in jasmine-ajax and avoid "xhr has already been spied upon" errors when executing tests through JSTestDriver (submitted patch to both projects)

This commit is contained in:
Ingo Schommer 2011-03-10 11:26:01 +13:00
parent 7bda1ecab6
commit 99099e8838
2 changed files with 4 additions and 4 deletions

View File

@ -1,7 +1,7 @@
beforeEach(function() { beforeEach(function() {
if (typeof jQuery != 'undefined') { if (typeof jQuery != 'undefined') {
spyOn(jQuery.ajaxSettings, 'xhr').andCallFake(function() { spyOn(jQuery.ajaxSettings, 'xhr', true).andCallFake(function() {
var newXhr = new FakeXMLHttpRequest(); var newXhr = new FakeXMLHttpRequest();
ajaxRequests.push(newXhr); ajaxRequests.push(newXhr);
return newXhr; return newXhr;
@ -9,7 +9,7 @@ beforeEach(function() {
} }
if (typeof Prototype != 'undefined') { if (typeof Prototype != 'undefined') {
spyOn(Ajax, "getTransport").andCallFake(function() { spyOn(Ajax, "getTransport", true).andCallFake(function() {
return new FakeXMLHttpRequest(); return new FakeXMLHttpRequest();
}); });
} }

View File

@ -440,8 +440,8 @@ jasmine.log = function() {
* @param methodName * @param methodName
* @returns a Jasmine spy that can be chained with all spy methods * @returns a Jasmine spy that can be chained with all spy methods
*/ */
var spyOn = function(obj, methodName) { var spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
return jasmine.getEnv().currentSpec.spyOn(obj, methodName); return jasmine.getEnv().currentSpec.spyOn(obj, methodName, ignoreMethodDoesntExist);
}; };
/** /**