sinon-rails 1.9.0 → 1.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sinon/rails/version.rb +1 -1
- data/vendor/assets/javascripts/sinon.js +367 -88
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82cccc9a5461b8e375a3e1db66455b757cb93e9c
|
4
|
+
data.tar.gz: 659d9a9863351e7e2a1e4b3d8ffe45b323d67b36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a37b15d31f7a7dac38ea977c7fdddd29c303249b1e3367dc6c50b9a66fcd8ce3f6c6ae9c61f10d8af784714075edc3572cb03f76c938244ece17e7f32e0444da
|
7
|
+
data.tar.gz: be824a55f2b4d34dc3b7899c74407dec77d39d506d3bcedd7095e30703a915e3516c3be2a186d00db931f7cc3e59d4ed64db1c57c801a5718b901674581c41ff
|
data/lib/sinon/rails/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Sinon.JS 1.
|
2
|
+
* Sinon.JS 1.10.3, 2014/07/11
|
3
3
|
*
|
4
4
|
* @author Christian Johansen (christian@cjohansen.no)
|
5
5
|
* @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS
|
@@ -35,8 +35,8 @@
|
|
35
35
|
|
36
36
|
this.sinon = (function () {
|
37
37
|
var samsam, formatio;
|
38
|
-
function define(mod, deps, fn) { if (mod == "samsam") { samsam = deps(); } else { formatio = fn(samsam); } }
|
39
|
-
define.amd =
|
38
|
+
function define(mod, deps, fn) { if (mod == "samsam") { samsam = deps(); } else if (typeof fn === "function") { formatio = fn(samsam); } }
|
39
|
+
define.amd = {};
|
40
40
|
((typeof define === "function" && define.amd && function (m) { define("samsam", m); }) ||
|
41
41
|
(typeof module === "object" &&
|
42
42
|
function (m) { module.exports = m(); }) || // Node
|
@@ -655,6 +655,10 @@ var sinon = (function (formatio) {
|
|
655
655
|
return typeof obj === "function" || !!(obj && obj.constructor && obj.call && obj.apply);
|
656
656
|
}
|
657
657
|
|
658
|
+
function isReallyNaN(val) {
|
659
|
+
return typeof val === 'number' && isNaN(val);
|
660
|
+
}
|
661
|
+
|
658
662
|
function mirrorProperties(target, source) {
|
659
663
|
for (var prop in source) {
|
660
664
|
if (!hasOwn.call(target, prop)) {
|
@@ -683,19 +687,15 @@ var sinon = (function (formatio) {
|
|
683
687
|
if (!isFunction(wrappedMethod)) {
|
684
688
|
error = new TypeError("Attempted to wrap " + (typeof wrappedMethod) + " property " +
|
685
689
|
property + " as function");
|
686
|
-
}
|
687
|
-
|
688
|
-
if (wrappedMethod.restore && wrappedMethod.restore.sinon) {
|
690
|
+
} else if (wrappedMethod.restore && wrappedMethod.restore.sinon) {
|
689
691
|
error = new TypeError("Attempted to wrap " + property + " which is already wrapped");
|
690
|
-
}
|
691
|
-
|
692
|
-
if (wrappedMethod.calledBefore) {
|
692
|
+
} else if (wrappedMethod.calledBefore) {
|
693
693
|
var verb = !!wrappedMethod.returns ? "stubbed" : "spied on";
|
694
694
|
error = new TypeError("Attempted to wrap " + property + " which is already " + verb);
|
695
695
|
}
|
696
696
|
|
697
697
|
if (error) {
|
698
|
-
if (wrappedMethod._stack) {
|
698
|
+
if (wrappedMethod && wrappedMethod._stack) {
|
699
699
|
error.stack += '\n--------------\n' + wrappedMethod._stack;
|
700
700
|
}
|
701
701
|
throw error;
|
@@ -756,8 +756,13 @@ var sinon = (function (formatio) {
|
|
756
756
|
if (sinon.match && sinon.match.isMatcher(a)) {
|
757
757
|
return a.test(b);
|
758
758
|
}
|
759
|
-
|
760
|
-
|
759
|
+
|
760
|
+
if (typeof a != 'object' || typeof b != 'object') {
|
761
|
+
if (isReallyNaN(a) && isReallyNaN(b)) {
|
762
|
+
return true;
|
763
|
+
} else {
|
764
|
+
return a === b;
|
765
|
+
}
|
761
766
|
}
|
762
767
|
|
763
768
|
if (isElement(a) || isElement(b)) {
|
@@ -773,7 +778,7 @@ var sinon = (function (formatio) {
|
|
773
778
|
}
|
774
779
|
|
775
780
|
if (a instanceof RegExp && b instanceof RegExp) {
|
776
|
-
return (a.source === b.source) && (a.global === b.global) &&
|
781
|
+
return (a.source === b.source) && (a.global === b.global) &&
|
777
782
|
(a.ignoreCase === b.ignoreCase) && (a.multiline === b.multiline);
|
778
783
|
}
|
779
784
|
|
@@ -795,6 +800,10 @@ var sinon = (function (formatio) {
|
|
795
800
|
for (prop in a) {
|
796
801
|
aLength += 1;
|
797
802
|
|
803
|
+
if (!(prop in b)) {
|
804
|
+
return false;
|
805
|
+
}
|
806
|
+
|
798
807
|
if (!deepEqual(a[prop], b[prop])) {
|
799
808
|
return false;
|
800
809
|
}
|
@@ -940,30 +949,31 @@ var sinon = (function (formatio) {
|
|
940
949
|
}
|
941
950
|
};
|
942
951
|
|
943
|
-
var isNode = typeof module !== "undefined" && module.exports;
|
952
|
+
var isNode = typeof module !== "undefined" && module.exports && typeof require == "function";
|
944
953
|
var isAMD = typeof define === 'function' && typeof define.amd === 'object' && define.amd;
|
945
954
|
|
955
|
+
function makePublicAPI(require, exports, module) {
|
956
|
+
module.exports = sinon;
|
957
|
+
sinon.spy = require("./sinon/spy");
|
958
|
+
sinon.spyCall = require("./sinon/call");
|
959
|
+
sinon.behavior = require("./sinon/behavior");
|
960
|
+
sinon.stub = require("./sinon/stub");
|
961
|
+
sinon.mock = require("./sinon/mock");
|
962
|
+
sinon.collection = require("./sinon/collection");
|
963
|
+
sinon.assert = require("./sinon/assert");
|
964
|
+
sinon.sandbox = require("./sinon/sandbox");
|
965
|
+
sinon.test = require("./sinon/test");
|
966
|
+
sinon.testCase = require("./sinon/test_case");
|
967
|
+
sinon.match = require("./sinon/match");
|
968
|
+
}
|
969
|
+
|
946
970
|
if (isAMD) {
|
947
|
-
define(
|
948
|
-
return sinon;
|
949
|
-
});
|
971
|
+
define(makePublicAPI);
|
950
972
|
} else if (isNode) {
|
951
973
|
try {
|
952
974
|
formatio = require("formatio");
|
953
975
|
} catch (e) {}
|
954
|
-
|
955
|
-
module.exports.spy = require("./sinon/spy");
|
956
|
-
module.exports.spyCall = require("./sinon/call");
|
957
|
-
module.exports.behavior = require("./sinon/behavior");
|
958
|
-
module.exports.stub = require("./sinon/stub");
|
959
|
-
module.exports.mock = require("./sinon/mock");
|
960
|
-
module.exports.collection = require("./sinon/collection");
|
961
|
-
module.exports.assert = require("./sinon/assert");
|
962
|
-
module.exports.sandbox = require("./sinon/sandbox");
|
963
|
-
module.exports.test = require("./sinon/test");
|
964
|
-
module.exports.testCase = require("./sinon/test_case");
|
965
|
-
module.exports.assert = require("./sinon/assert");
|
966
|
-
module.exports.match = require("./sinon/match");
|
976
|
+
makePublicAPI(require, exports, module);
|
967
977
|
}
|
968
978
|
|
969
979
|
if (formatio) {
|
@@ -999,7 +1009,7 @@ var sinon = (function (formatio) {
|
|
999
1009
|
*/
|
1000
1010
|
|
1001
1011
|
(function (sinon) {
|
1002
|
-
var commonJSModule = typeof module !==
|
1012
|
+
var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function";
|
1003
1013
|
|
1004
1014
|
if (!sinon && commonJSModule) {
|
1005
1015
|
sinon = require("../sinon");
|
@@ -1222,10 +1232,12 @@ var sinon = (function (formatio) {
|
|
1222
1232
|
match.regexp = match.typeOf("regexp");
|
1223
1233
|
match.date = match.typeOf("date");
|
1224
1234
|
|
1225
|
-
|
1235
|
+
sinon.match = match;
|
1236
|
+
|
1237
|
+
if (typeof define === "function" && define.amd) {
|
1238
|
+
define(["module"], function(module) { module.exports = match; });
|
1239
|
+
} else if (commonJSModule) {
|
1226
1240
|
module.exports = match;
|
1227
|
-
} else {
|
1228
|
-
sinon.match = match;
|
1229
1241
|
}
|
1230
1242
|
}(typeof sinon == "object" && sinon || null));
|
1231
1243
|
|
@@ -1247,7 +1259,7 @@ var sinon = (function (formatio) {
|
|
1247
1259
|
*/
|
1248
1260
|
|
1249
1261
|
(function (sinon) {
|
1250
|
-
var commonJSModule = typeof module !==
|
1262
|
+
var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function";
|
1251
1263
|
if (!sinon && commonJSModule) {
|
1252
1264
|
sinon = require("../sinon");
|
1253
1265
|
}
|
@@ -1424,10 +1436,12 @@ var sinon = (function (formatio) {
|
|
1424
1436
|
}
|
1425
1437
|
createSpyCall.toString = callProto.toString; // used by mocks
|
1426
1438
|
|
1427
|
-
|
1439
|
+
sinon.spyCall = createSpyCall;
|
1440
|
+
|
1441
|
+
if (typeof define === "function" && define.amd) {
|
1442
|
+
define(["module"], function(module) { module.exports = createSpyCall; });
|
1443
|
+
} else if (commonJSModule) {
|
1428
1444
|
module.exports = createSpyCall;
|
1429
|
-
} else {
|
1430
|
-
sinon.spyCall = createSpyCall;
|
1431
1445
|
}
|
1432
1446
|
}(typeof sinon == "object" && sinon || null));
|
1433
1447
|
|
@@ -1448,7 +1462,7 @@ var sinon = (function (formatio) {
|
|
1448
1462
|
*/
|
1449
1463
|
|
1450
1464
|
(function (sinon) {
|
1451
|
-
var commonJSModule = typeof module !==
|
1465
|
+
var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function";
|
1452
1466
|
var push = Array.prototype.push;
|
1453
1467
|
var slice = Array.prototype.slice;
|
1454
1468
|
var callId = 0;
|
@@ -1579,6 +1593,9 @@ var sinon = (function (formatio) {
|
|
1579
1593
|
push.call(this.args, args);
|
1580
1594
|
push.call(this.callIds, callId++);
|
1581
1595
|
|
1596
|
+
// Make call properties available from within the spied function:
|
1597
|
+
createCallProperties.call(this);
|
1598
|
+
|
1582
1599
|
try {
|
1583
1600
|
if (matching) {
|
1584
1601
|
returnValue = matching.invoke(func, thisValue, args);
|
@@ -1597,6 +1614,7 @@ var sinon = (function (formatio) {
|
|
1597
1614
|
push.call(this.exceptions, exception);
|
1598
1615
|
push.call(this.returnValues, returnValue);
|
1599
1616
|
|
1617
|
+
// Make return value and exception available in the calls:
|
1600
1618
|
createCallProperties.call(this);
|
1601
1619
|
|
1602
1620
|
if (exception !== undefined) {
|
@@ -1606,6 +1624,11 @@ var sinon = (function (formatio) {
|
|
1606
1624
|
return returnValue;
|
1607
1625
|
},
|
1608
1626
|
|
1627
|
+
named: function named(name) {
|
1628
|
+
this.displayName = name;
|
1629
|
+
return this;
|
1630
|
+
},
|
1631
|
+
|
1609
1632
|
getCall: function getCall(i) {
|
1610
1633
|
if (i < 0 || i >= this.callCount) {
|
1611
1634
|
return null;
|
@@ -1831,11 +1854,12 @@ var sinon = (function (formatio) {
|
|
1831
1854
|
sinon.extend(spy, spyApi);
|
1832
1855
|
|
1833
1856
|
spy.spyCall = sinon.spyCall;
|
1857
|
+
sinon.spy = spy;
|
1834
1858
|
|
1835
|
-
if (
|
1859
|
+
if (typeof define === "function" && define.amd) {
|
1860
|
+
define(["module"], function(module) { module.exports = spy; });
|
1861
|
+
} else if (commonJSModule) {
|
1836
1862
|
module.exports = spy;
|
1837
|
-
} else {
|
1838
|
-
sinon.spy = spy;
|
1839
1863
|
}
|
1840
1864
|
}(typeof sinon == "object" && sinon || null));
|
1841
1865
|
|
@@ -1855,7 +1879,7 @@ var sinon = (function (formatio) {
|
|
1855
1879
|
*/
|
1856
1880
|
|
1857
1881
|
(function (sinon) {
|
1858
|
-
var commonJSModule = typeof module !==
|
1882
|
+
var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function";
|
1859
1883
|
|
1860
1884
|
if (!sinon && commonJSModule) {
|
1861
1885
|
sinon = require("../sinon");
|
@@ -2164,12 +2188,15 @@ var sinon = (function (formatio) {
|
|
2164
2188
|
}
|
2165
2189
|
}
|
2166
2190
|
|
2167
|
-
|
2191
|
+
sinon.behavior = proto;
|
2192
|
+
|
2193
|
+
if (typeof define === "function" && define.amd) {
|
2194
|
+
define(["module"], function(module) { module.exports = proto; });
|
2195
|
+
} else if (commonJSModule) {
|
2168
2196
|
module.exports = proto;
|
2169
|
-
} else {
|
2170
|
-
sinon.behavior = proto;
|
2171
2197
|
}
|
2172
2198
|
}(typeof sinon == "object" && sinon || null));
|
2199
|
+
|
2173
2200
|
/**
|
2174
2201
|
* @depend ../sinon.js
|
2175
2202
|
* @depend spy.js
|
@@ -2187,7 +2214,7 @@ var sinon = (function (formatio) {
|
|
2187
2214
|
*/
|
2188
2215
|
|
2189
2216
|
(function (sinon) {
|
2190
|
-
var commonJSModule = typeof module !==
|
2217
|
+
var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function";
|
2191
2218
|
|
2192
2219
|
if (!sinon && commonJSModule) {
|
2193
2220
|
sinon = require("../sinon");
|
@@ -2322,10 +2349,12 @@ var sinon = (function (formatio) {
|
|
2322
2349
|
return proto;
|
2323
2350
|
}()));
|
2324
2351
|
|
2325
|
-
|
2352
|
+
sinon.stub = stub;
|
2353
|
+
|
2354
|
+
if (typeof define === "function" && define.amd) {
|
2355
|
+
define(["module"], function(module) { module.exports = stub; });
|
2356
|
+
} else if (commonJSModule) {
|
2326
2357
|
module.exports = stub;
|
2327
|
-
} else {
|
2328
|
-
sinon.stub = stub;
|
2329
2358
|
}
|
2330
2359
|
}(typeof sinon == "object" && sinon || null));
|
2331
2360
|
|
@@ -2345,7 +2374,7 @@ var sinon = (function (formatio) {
|
|
2345
2374
|
*/
|
2346
2375
|
|
2347
2376
|
(function (sinon) {
|
2348
|
-
var commonJSModule = typeof module !==
|
2377
|
+
var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function";
|
2349
2378
|
var push = [].push;
|
2350
2379
|
var match;
|
2351
2380
|
|
@@ -2771,10 +2800,12 @@ var sinon = (function (formatio) {
|
|
2771
2800
|
};
|
2772
2801
|
}());
|
2773
2802
|
|
2774
|
-
|
2803
|
+
sinon.mock = mock;
|
2804
|
+
|
2805
|
+
if (typeof define === "function" && define.amd) {
|
2806
|
+
define(["module"], function(module) { module.exports = mock; });
|
2807
|
+
} else if (commonJSModule) {
|
2775
2808
|
module.exports = mock;
|
2776
|
-
} else {
|
2777
|
-
sinon.mock = mock;
|
2778
2809
|
}
|
2779
2810
|
}(typeof sinon == "object" && sinon || null));
|
2780
2811
|
|
@@ -2795,7 +2826,7 @@ var sinon = (function (formatio) {
|
|
2795
2826
|
*/
|
2796
2827
|
|
2797
2828
|
(function (sinon) {
|
2798
|
-
var commonJSModule = typeof module !==
|
2829
|
+
var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function";
|
2799
2830
|
var push = [].push;
|
2800
2831
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
2801
2832
|
|
@@ -2924,10 +2955,12 @@ var sinon = (function (formatio) {
|
|
2924
2955
|
}
|
2925
2956
|
};
|
2926
2957
|
|
2927
|
-
|
2958
|
+
sinon.collection = collection;
|
2959
|
+
|
2960
|
+
if (typeof define === "function" && define.amd) {
|
2961
|
+
define(["module"], function(module) { module.exports = collection; });
|
2962
|
+
} else if (commonJSModule) {
|
2928
2963
|
module.exports = collection;
|
2929
|
-
} else {
|
2930
|
-
sinon.collection = collection;
|
2931
2964
|
}
|
2932
2965
|
}(typeof sinon == "object" && sinon || null));
|
2933
2966
|
|
@@ -2956,6 +2989,13 @@ if (typeof sinon == "undefined") {
|
|
2956
2989
|
}
|
2957
2990
|
|
2958
2991
|
(function (global) {
|
2992
|
+
// node expects setTimeout/setInterval to return a fn object w/ .ref()/.unref()
|
2993
|
+
// browsers, a number.
|
2994
|
+
// see https://github.com/cjohansen/Sinon.JS/pull/436
|
2995
|
+
var timeoutResult = setTimeout(function() {}, 0);
|
2996
|
+
var addTimerReturnsObject = typeof timeoutResult === 'object';
|
2997
|
+
clearTimeout(timeoutResult);
|
2998
|
+
|
2959
2999
|
var id = 1;
|
2960
3000
|
|
2961
3001
|
function addTimer(args, recurring) {
|
@@ -2985,7 +3025,16 @@ if (typeof sinon == "undefined") {
|
|
2985
3025
|
this.timeouts[toId].interval = delay;
|
2986
3026
|
}
|
2987
3027
|
|
2988
|
-
|
3028
|
+
if (addTimerReturnsObject) {
|
3029
|
+
return {
|
3030
|
+
id: toId,
|
3031
|
+
ref: function() {},
|
3032
|
+
unref: function() {}
|
3033
|
+
};
|
3034
|
+
}
|
3035
|
+
else {
|
3036
|
+
return toId;
|
3037
|
+
}
|
2989
3038
|
}
|
2990
3039
|
|
2991
3040
|
function parseTime(str) {
|
@@ -3051,10 +3100,18 @@ if (typeof sinon == "undefined") {
|
|
3051
3100
|
},
|
3052
3101
|
|
3053
3102
|
clearTimeout: function clearTimeout(timerId) {
|
3103
|
+
if (!timerId) {
|
3104
|
+
// null appears to be allowed in most browsers, and appears to be relied upon by some libraries, like Bootstrap carousel
|
3105
|
+
return;
|
3106
|
+
}
|
3054
3107
|
if (!this.timeouts) {
|
3055
3108
|
this.timeouts = [];
|
3056
3109
|
}
|
3057
|
-
|
3110
|
+
// in Node, timerId is an object with .ref()/.unref(), and
|
3111
|
+
// its .id field is the actual timer id.
|
3112
|
+
if (typeof timerId === 'object') {
|
3113
|
+
timerId = timerId.id
|
3114
|
+
}
|
3058
3115
|
if (timerId in this.timeouts) {
|
3059
3116
|
delete this.timeouts[timerId];
|
3060
3117
|
}
|
@@ -3441,7 +3498,7 @@ if (typeof sinon == "undefined") {
|
|
3441
3498
|
xhr.supportsXHR = typeof xhr.GlobalXMLHttpRequest != "undefined";
|
3442
3499
|
xhr.workingXHR = xhr.supportsXHR ? xhr.GlobalXMLHttpRequest : xhr.supportsActiveX
|
3443
3500
|
? function() { return new xhr.GlobalActiveXObject("MSXML2.XMLHTTP.3.0") } : false;
|
3444
|
-
xhr.supportsCORS = 'withCredentials' in (new sinon.xhr.GlobalXMLHttpRequest());
|
3501
|
+
xhr.supportsCORS = xhr.supportsXHR && 'withCredentials' in (new sinon.xhr.GlobalXMLHttpRequest());
|
3445
3502
|
|
3446
3503
|
/*jsl:ignore*/
|
3447
3504
|
var unsafeHeaders = {
|
@@ -3979,7 +4036,7 @@ if (typeof sinon == "undefined") {
|
|
3979
4036
|
|
3980
4037
|
sinon.FakeXMLHttpRequest = FakeXMLHttpRequest;
|
3981
4038
|
|
3982
|
-
})(typeof global === "object" ? global : this);
|
4039
|
+
})((function(){ return typeof global === "object" ? global : this; })());
|
3983
4040
|
|
3984
4041
|
if (typeof module !== 'undefined' && module.exports) {
|
3985
4042
|
module.exports = sinon;
|
@@ -4062,15 +4119,6 @@ sinon.fakeServer = (function () {
|
|
4062
4119
|
return false;
|
4063
4120
|
}
|
4064
4121
|
|
4065
|
-
function log(response, request) {
|
4066
|
-
var str;
|
4067
|
-
|
4068
|
-
str = "Request:\n" + sinon.format(request) + "\n\n";
|
4069
|
-
str += "Response:\n" + sinon.format(response) + "\n\n";
|
4070
|
-
|
4071
|
-
sinon.log(str);
|
4072
|
-
}
|
4073
|
-
|
4074
4122
|
return {
|
4075
4123
|
create: function () {
|
4076
4124
|
var server = create(this);
|
@@ -4123,6 +4171,15 @@ sinon.fakeServer = (function () {
|
|
4123
4171
|
}
|
4124
4172
|
},
|
4125
4173
|
|
4174
|
+
log: function(response, request) {
|
4175
|
+
var str;
|
4176
|
+
|
4177
|
+
str = "Request:\n" + sinon.format(request) + "\n\n";
|
4178
|
+
str += "Response:\n" + sinon.format(response) + "\n\n";
|
4179
|
+
|
4180
|
+
sinon.log(str);
|
4181
|
+
},
|
4182
|
+
|
4126
4183
|
respondWith: function respondWith(method, url, body) {
|
4127
4184
|
if (arguments.length == 1 && typeof method != "function") {
|
4128
4185
|
this.response = responseArray(method);
|
@@ -4152,7 +4209,7 @@ sinon.fakeServer = (function () {
|
|
4152
4209
|
respond: function respond() {
|
4153
4210
|
if (arguments.length > 0) this.respondWith.apply(this, arguments);
|
4154
4211
|
var queue = this.queue || [];
|
4155
|
-
var requests = queue.splice(0);
|
4212
|
+
var requests = queue.splice(0, queue.length);
|
4156
4213
|
var request;
|
4157
4214
|
|
4158
4215
|
while(request = requests.shift()) {
|
@@ -4178,7 +4235,7 @@ sinon.fakeServer = (function () {
|
|
4178
4235
|
}
|
4179
4236
|
|
4180
4237
|
if (request.readyState != 4) {
|
4181
|
-
log(response, request);
|
4238
|
+
sinon.fakeServer.log(response, request);
|
4182
4239
|
|
4183
4240
|
request.respond(response[0], response[1], response[2]);
|
4184
4241
|
}
|
@@ -4298,7 +4355,7 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
4298
4355
|
* Copyright (c) 2010-2013 Christian Johansen
|
4299
4356
|
*/
|
4300
4357
|
|
4301
|
-
if (typeof module !==
|
4358
|
+
if (typeof module !== "undefined" && module.exports && typeof require == "function") {
|
4302
4359
|
var sinon = require("../sinon");
|
4303
4360
|
sinon.extend(sinon, require("./util/fake_timers"));
|
4304
4361
|
}
|
@@ -4417,7 +4474,9 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
4417
4474
|
|
4418
4475
|
sinon.sandbox.useFakeXMLHttpRequest = sinon.sandbox.useFakeServer;
|
4419
4476
|
|
4420
|
-
if (typeof
|
4477
|
+
if (typeof define === "function" && define.amd) {
|
4478
|
+
define(["module"], function(module) { module.exports = sinon.sandbox; });
|
4479
|
+
} else if (typeof module !== 'undefined' && module.exports) {
|
4421
4480
|
module.exports = sinon.sandbox;
|
4422
4481
|
}
|
4423
4482
|
}());
|
@@ -4440,7 +4499,7 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
4440
4499
|
*/
|
4441
4500
|
|
4442
4501
|
(function (sinon) {
|
4443
|
-
var commonJSModule = typeof module !==
|
4502
|
+
var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function";
|
4444
4503
|
|
4445
4504
|
if (!sinon && commonJSModule) {
|
4446
4505
|
sinon = require("../sinon");
|
@@ -4457,7 +4516,7 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
4457
4516
|
throw new TypeError("sinon.test needs to wrap a test function, got " + type);
|
4458
4517
|
}
|
4459
4518
|
|
4460
|
-
|
4519
|
+
function sinonSandboxedTest() {
|
4461
4520
|
var config = sinon.getConfig(sinon.config);
|
4462
4521
|
config.injectInto = config.injectIntoThis && this || config.injectInto;
|
4463
4522
|
var sandbox = sinon.sandbox.create(config);
|
@@ -4480,6 +4539,14 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
4480
4539
|
|
4481
4540
|
return result;
|
4482
4541
|
};
|
4542
|
+
|
4543
|
+
if (callback.length) {
|
4544
|
+
return function sinonAsyncSandboxedTest(callback) {
|
4545
|
+
return sinonSandboxedTest.apply(this, arguments);
|
4546
|
+
};
|
4547
|
+
}
|
4548
|
+
|
4549
|
+
return sinonSandboxedTest;
|
4483
4550
|
}
|
4484
4551
|
|
4485
4552
|
test.config = {
|
@@ -4490,10 +4557,12 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
4490
4557
|
useFakeServer: true
|
4491
4558
|
};
|
4492
4559
|
|
4493
|
-
|
4560
|
+
sinon.test = test;
|
4561
|
+
|
4562
|
+
if (typeof define === "function" && define.amd) {
|
4563
|
+
define(["module"], function(module) { module.exports = test; });
|
4564
|
+
} else if (commonJSModule) {
|
4494
4565
|
module.exports = test;
|
4495
|
-
} else {
|
4496
|
-
sinon.test = test;
|
4497
4566
|
}
|
4498
4567
|
}(typeof sinon == "object" && sinon || null));
|
4499
4568
|
|
@@ -4513,7 +4582,7 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
4513
4582
|
*/
|
4514
4583
|
|
4515
4584
|
(function (sinon) {
|
4516
|
-
var commonJSModule = typeof module !==
|
4585
|
+
var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function";
|
4517
4586
|
|
4518
4587
|
if (!sinon && commonJSModule) {
|
4519
4588
|
sinon = require("../sinon");
|
@@ -4587,10 +4656,12 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
4587
4656
|
return methods;
|
4588
4657
|
}
|
4589
4658
|
|
4590
|
-
|
4659
|
+
sinon.testCase = testCase;
|
4660
|
+
|
4661
|
+
if (typeof define === "function" && define.amd) {
|
4662
|
+
define(["module"], function(module) { module.exports = testCase; });
|
4663
|
+
} else if (commonJSModule) {
|
4591
4664
|
module.exports = testCase;
|
4592
|
-
} else {
|
4593
|
-
sinon.testCase = testCase;
|
4594
4665
|
}
|
4595
4666
|
}(typeof sinon == "object" && sinon || null));
|
4596
4667
|
|
@@ -4610,7 +4681,7 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
4610
4681
|
*/
|
4611
4682
|
|
4612
4683
|
(function (sinon, global) {
|
4613
|
-
var commonJSModule = typeof module !== "undefined" && module.exports;
|
4684
|
+
var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function";
|
4614
4685
|
var slice = Array.prototype.slice;
|
4615
4686
|
var assert;
|
4616
4687
|
|
@@ -4784,11 +4855,219 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
4784
4855
|
mirrorPropAsAssertion("threw", "%n did not throw exception%C");
|
4785
4856
|
mirrorPropAsAssertion("alwaysThrew", "%n did not always throw exception%C");
|
4786
4857
|
|
4787
|
-
|
4858
|
+
sinon.assert = assert;
|
4859
|
+
|
4860
|
+
if (typeof define === "function" && define.amd) {
|
4861
|
+
define(["module"], function(module) { module.exports = assert; });
|
4862
|
+
} else if (commonJSModule) {
|
4788
4863
|
module.exports = assert;
|
4789
|
-
} else {
|
4790
|
-
sinon.assert = assert;
|
4791
4864
|
}
|
4792
4865
|
}(typeof sinon == "object" && sinon || null, typeof window != "undefined" ? window : (typeof self != "undefined") ? self : global));
|
4793
4866
|
|
4867
|
+
/**
|
4868
|
+
* @depend ../../sinon.js
|
4869
|
+
* @depend event.js
|
4870
|
+
*/
|
4871
|
+
/*jslint eqeqeq: false, onevar: false*/
|
4872
|
+
/*global sinon, module, require, XDomainRequest*/
|
4873
|
+
/**
|
4874
|
+
* Fake XDomainRequest object
|
4875
|
+
*/
|
4876
|
+
|
4877
|
+
if (typeof sinon == "undefined") {
|
4878
|
+
this.sinon = {};
|
4879
|
+
}
|
4880
|
+
sinon.xdr = { XDomainRequest: this.XDomainRequest };
|
4881
|
+
|
4882
|
+
// wrapper for global
|
4883
|
+
(function (global) {
|
4884
|
+
var xdr = sinon.xdr;
|
4885
|
+
xdr.GlobalXDomainRequest = global.XDomainRequest;
|
4886
|
+
xdr.supportsXDR = typeof xdr.GlobalXDomainRequest != "undefined";
|
4887
|
+
xdr.workingXDR = xdr.supportsXDR ? xdr.GlobalXDomainRequest : false;
|
4888
|
+
|
4889
|
+
function FakeXDomainRequest() {
|
4890
|
+
this.readyState = FakeXDomainRequest.UNSENT;
|
4891
|
+
this.requestBody = null;
|
4892
|
+
this.requestHeaders = {};
|
4893
|
+
this.status = 0;
|
4894
|
+
this.timeout = null;
|
4895
|
+
|
4896
|
+
if (typeof FakeXDomainRequest.onCreate == "function") {
|
4897
|
+
FakeXDomainRequest.onCreate(this);
|
4898
|
+
}
|
4899
|
+
}
|
4900
|
+
|
4901
|
+
function verifyState(xdr) {
|
4902
|
+
if (xdr.readyState !== FakeXDomainRequest.OPENED) {
|
4903
|
+
throw new Error("INVALID_STATE_ERR");
|
4904
|
+
}
|
4905
|
+
|
4906
|
+
if (xdr.sendFlag) {
|
4907
|
+
throw new Error("INVALID_STATE_ERR");
|
4908
|
+
}
|
4909
|
+
}
|
4910
|
+
|
4911
|
+
function verifyRequestSent(xdr) {
|
4912
|
+
if (xdr.readyState == FakeXDomainRequest.UNSENT) {
|
4913
|
+
throw new Error("Request not sent");
|
4914
|
+
}
|
4915
|
+
if (xdr.readyState == FakeXDomainRequest.DONE) {
|
4916
|
+
throw new Error("Request done");
|
4917
|
+
}
|
4918
|
+
}
|
4919
|
+
|
4920
|
+
function verifyResponseBodyType(body) {
|
4921
|
+
if (typeof body != "string") {
|
4922
|
+
var error = new Error("Attempted to respond to fake XDomainRequest with " +
|
4923
|
+
body + ", which is not a string.");
|
4924
|
+
error.name = "InvalidBodyException";
|
4925
|
+
throw error;
|
4926
|
+
}
|
4927
|
+
}
|
4928
|
+
|
4929
|
+
sinon.extend(FakeXDomainRequest.prototype, sinon.EventTarget, {
|
4930
|
+
open: function open(method, url) {
|
4931
|
+
this.method = method;
|
4932
|
+
this.url = url;
|
4933
|
+
|
4934
|
+
this.responseText = null;
|
4935
|
+
this.sendFlag = false;
|
4936
|
+
|
4937
|
+
this.readyStateChange(FakeXDomainRequest.OPENED);
|
4938
|
+
},
|
4939
|
+
|
4940
|
+
readyStateChange: function readyStateChange(state) {
|
4941
|
+
this.readyState = state;
|
4942
|
+
var eventName = '';
|
4943
|
+
switch (this.readyState) {
|
4944
|
+
case FakeXDomainRequest.UNSENT:
|
4945
|
+
break;
|
4946
|
+
case FakeXDomainRequest.OPENED:
|
4947
|
+
break;
|
4948
|
+
case FakeXDomainRequest.LOADING:
|
4949
|
+
if (this.sendFlag){
|
4950
|
+
//raise the progress event
|
4951
|
+
eventName = 'onprogress';
|
4952
|
+
}
|
4953
|
+
break;
|
4954
|
+
case FakeXDomainRequest.DONE:
|
4955
|
+
if (this.isTimeout){
|
4956
|
+
eventName = 'ontimeout'
|
4957
|
+
}
|
4958
|
+
else if (this.errorFlag || (this.status < 200 || this.status > 299)) {
|
4959
|
+
eventName = 'onerror';
|
4960
|
+
}
|
4961
|
+
else {
|
4962
|
+
eventName = 'onload'
|
4963
|
+
}
|
4964
|
+
break;
|
4965
|
+
}
|
4966
|
+
|
4967
|
+
// raising event (if defined)
|
4968
|
+
if (eventName) {
|
4969
|
+
if (typeof this[eventName] == "function") {
|
4970
|
+
try {
|
4971
|
+
this[eventName]();
|
4972
|
+
} catch (e) {
|
4973
|
+
sinon.logError("Fake XHR " + eventName + " handler", e);
|
4974
|
+
}
|
4975
|
+
}
|
4976
|
+
}
|
4977
|
+
},
|
4978
|
+
|
4979
|
+
send: function send(data) {
|
4980
|
+
verifyState(this);
|
4981
|
+
|
4982
|
+
if (!/^(get|head)$/i.test(this.method)) {
|
4983
|
+
this.requestBody = data;
|
4984
|
+
}
|
4985
|
+
this.requestHeaders["Content-Type"] = "text/plain;charset=utf-8";
|
4986
|
+
|
4987
|
+
this.errorFlag = false;
|
4988
|
+
this.sendFlag = true;
|
4989
|
+
this.readyStateChange(FakeXDomainRequest.OPENED);
|
4990
|
+
|
4991
|
+
if (typeof this.onSend == "function") {
|
4992
|
+
this.onSend(this);
|
4993
|
+
}
|
4994
|
+
},
|
4995
|
+
|
4996
|
+
abort: function abort() {
|
4997
|
+
this.aborted = true;
|
4998
|
+
this.responseText = null;
|
4999
|
+
this.errorFlag = true;
|
5000
|
+
|
5001
|
+
if (this.readyState > sinon.FakeXDomainRequest.UNSENT && this.sendFlag) {
|
5002
|
+
this.readyStateChange(sinon.FakeXDomainRequest.DONE);
|
5003
|
+
this.sendFlag = false;
|
5004
|
+
}
|
5005
|
+
},
|
5006
|
+
|
5007
|
+
setResponseBody: function setResponseBody(body) {
|
5008
|
+
verifyRequestSent(this);
|
5009
|
+
verifyResponseBodyType(body);
|
5010
|
+
|
5011
|
+
var chunkSize = this.chunkSize || 10;
|
5012
|
+
var index = 0;
|
5013
|
+
this.responseText = "";
|
5014
|
+
|
5015
|
+
do {
|
5016
|
+
this.readyStateChange(FakeXDomainRequest.LOADING);
|
5017
|
+
this.responseText += body.substring(index, index + chunkSize);
|
5018
|
+
index += chunkSize;
|
5019
|
+
} while (index < body.length);
|
5020
|
+
|
5021
|
+
this.readyStateChange(FakeXDomainRequest.DONE);
|
5022
|
+
},
|
5023
|
+
|
5024
|
+
respond: function respond(status, contentType, body) {
|
5025
|
+
// content-type ignored, since XDomainRequest does not carry this
|
5026
|
+
// we keep the same syntax for respond(...) as for FakeXMLHttpRequest to ease
|
5027
|
+
// test integration across browsers
|
5028
|
+
this.status = typeof status == "number" ? status : 200;
|
5029
|
+
this.setResponseBody(body || "");
|
5030
|
+
},
|
5031
|
+
|
5032
|
+
simulatetimeout: function(){
|
5033
|
+
this.status = 0;
|
5034
|
+
this.isTimeout = true;
|
5035
|
+
// Access to this should actually throw an error
|
5036
|
+
this.responseText = undefined;
|
5037
|
+
this.readyStateChange(FakeXDomainRequest.DONE);
|
5038
|
+
}
|
5039
|
+
});
|
5040
|
+
|
5041
|
+
sinon.extend(FakeXDomainRequest, {
|
5042
|
+
UNSENT: 0,
|
5043
|
+
OPENED: 1,
|
5044
|
+
LOADING: 3,
|
5045
|
+
DONE: 4
|
5046
|
+
});
|
5047
|
+
|
5048
|
+
sinon.useFakeXDomainRequest = function () {
|
5049
|
+
sinon.FakeXDomainRequest.restore = function restore(keepOnCreate) {
|
5050
|
+
if (xdr.supportsXDR) {
|
5051
|
+
global.XDomainRequest = xdr.GlobalXDomainRequest;
|
5052
|
+
}
|
5053
|
+
|
5054
|
+
delete sinon.FakeXDomainRequest.restore;
|
5055
|
+
|
5056
|
+
if (keepOnCreate !== true) {
|
5057
|
+
delete sinon.FakeXDomainRequest.onCreate;
|
5058
|
+
}
|
5059
|
+
};
|
5060
|
+
if (xdr.supportsXDR) {
|
5061
|
+
global.XDomainRequest = sinon.FakeXDomainRequest;
|
5062
|
+
}
|
5063
|
+
return sinon.FakeXDomainRequest;
|
5064
|
+
};
|
5065
|
+
|
5066
|
+
sinon.FakeXDomainRequest = FakeXDomainRequest;
|
5067
|
+
})(this);
|
5068
|
+
|
5069
|
+
if (typeof module == "object" && typeof require == "function") {
|
5070
|
+
module.exports = sinon;
|
5071
|
+
}
|
5072
|
+
|
4794
5073
|
return sinon;}.call(typeof window != 'undefined' && window || {}));
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinon-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Jeffery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.1'
|
27
27
|
description:
|
@@ -31,7 +31,7 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
- .gitignore
|
34
|
+
- ".gitignore"
|
35
35
|
- Gemfile
|
36
36
|
- LICENSE
|
37
37
|
- README.md
|
@@ -50,17 +50,17 @@ require_paths:
|
|
50
50
|
- lib
|
51
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
requirements: []
|
62
62
|
rubyforge_project:
|
63
|
-
rubygems_version: 2.
|
63
|
+
rubygems_version: 2.2.2
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: sinon.js via asset pipeline
|