spec/dummy/tmp/cache/assets/C7D/8F0/sprockets%2Ff13d01b85f2449a4f0638ff260425906 in teabag-0.7.1 vs spec/dummy/tmp/cache/assets/C7D/8F0/sprockets%2Ff13d01b85f2449a4f0638ff260425906 in teabag-0.7.2
- old
+ new
@@ -1,16 +1,16 @@
-o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1361042083.9818711:@value"ÙÍ{I"
-class:EFI"BundledAsset; FI"logical_path; FI"support/sinon.js; FI"
pathname; FI"P/Users/jejacks0n/Projects/teabag/vendor/assets/javascripts/support/sinon.js; FI"content_type; FI"application/javascript; FI"
-mtime; FI"2013-01-21T15:52:04-07:00; FI"length; FiÌI"digest; F"%d3f31baf1f593c2742c0570b0e949b22I"source; FI"Ì/**
- * Sinon.JS 1.5.2, 2012/11/27
+o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1367990556.846839:@value"tÝ{I"
+class:EFI"ProcessedAsset; FI"logical_path; FI"support/sinon.js; FI"
pathname; FI"P/Users/jejacks0n/Projects/teabag/vendor/assets/javascripts/support/sinon.js; FI"content_type; FI"application/javascript; FI"
+mtime; FI"2013-05-07T23:15:45-06:00; FI"length; FihÚI"digest; F"%ce8eee416c38d4e2bc984fd10e814327I"source; FI"hÚ/**
+ * Sinon.JS 1.7.1, 2013/05/07
*
* @author Christian Johansen (christian@cjohansen.no)
* @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS
*
* (The BSD License)
*
- * Copyright (c) 2010-2012, Christian Johansen, christian@cjohansen.no
+ * Copyright (c) 2010-2013, Christian Johansen, christian@cjohansen.no
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
@@ -34,13 +34,11 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-var sinon = (function () {
- "use strict";
-
+this.sinon = (function () {
var buster = (function (setTimeout, B) {
var isNode = typeof require == "function" && typeof module == "object";
var div = typeof document != "undefined" && document.createElement("div");
var F = function () {};
@@ -464,11 +462,11 @@
* Sinon core utilities. For internal use only.
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
- * Copyright (c) 2010-2011 Christian Johansen
+ * Copyright (c) 2010-2013 Christian Johansen
*/
var sinon = (function (buster) {
var div = typeof document != "undefined" && document.createElement("div");
var hasOwn = Object.prototype.hasOwnProperty;
@@ -506,10 +504,14 @@
target[prop] = source[prop];
}
}
}
+ function isRestorable (obj) {
+ return typeof obj === "function" && typeof obj.restore === "function" && obj.restore.sinon;
+ }
+
var sinon = {
wrapMethod: function wrapMethod(object, property, method) {
if (!object) {
throw new TypeError("Should wrap property of object");
}
@@ -632,15 +634,11 @@
for (prop in b) {
bLength += 1;
}
- if (aLength != bLength) {
- return false;
- }
-
- return true;
+ return aLength == bLength;
},
functionName: function functionName(func) {
var name = func.displayName || func.name;
@@ -707,11 +705,11 @@
(count || 0) + " times";
},
calledInOrder: function (spies) {
for (var i = 1, l = spies.length; i < l; i++) {
- if (!spies[i - 1].calledBefore(spies[i])) {
+ if (!spies[i - 1].calledBefore(spies[i]) || !spies[i].called) {
return false;
}
}
return true;
@@ -749,10 +747,30 @@
else if (value === undefined) {
return "undefined";
}
var string = Object.prototype.toString.call(value);
return string.substring(8, string.length - 1).toLowerCase();
+ },
+
+ createStubInstance: function (constructor) {
+ if (typeof constructor !== "function") {
+ throw new TypeError("The constructor should be a function.");
+ }
+ return sinon.stub(sinon.create(constructor.prototype));
+ },
+
+ restore: function (object) {
+ if (object !== null && typeof object === "object") {
+ for (var prop in object) {
+ if (isRestorable(object[prop])) {
+ object[prop].restore();
+ }
+ }
+ }
+ else if (isRestorable(object)) {
+ object.restore();
+ }
}
};
var isNode = typeof module == "object" && typeof require == "function";
@@ -760,10 +778,11 @@
try {
buster = { format: require("buster-format") };
} catch (e) {}
module.exports = sinon;
module.exports.spy = require("./sinon/spy");
+ module.exports.spyCall = require("./sinon/call");
module.exports.stub = require("./sinon/stub");
module.exports.mock = require("./sinon/mock");
module.exports.collection = require("./sinon/collection");
module.exports.assert = require("./sinon/assert");
module.exports.sandbox = require("./sinon/sandbox");
@@ -1038,533 +1057,590 @@
* @depend match.js
*/
/*jslint eqeqeq: false, onevar: false, plusplus: false*/
/*global module, require, sinon*/
/**
- * Spy functions
+ * Spy calls
*
* @author Christian Johansen (christian@cjohansen.no)
+ * @author Maximilian Antoni (mail@maxantoni.de)
* @license BSD
*
- * Copyright (c) 2010-2011 Christian Johansen
+ * Copyright (c) 2010-2013 Christian Johansen
+ * Copyright (c) 2013 Maximilian Antoni
*/
(function (sinon) {
var commonJSModule = typeof module == "object" && typeof require == "function";
- var spyCall;
- var callId = 0;
- var push = [].push;
- var slice = Array.prototype.slice;
-
if (!sinon && commonJSModule) {
sinon = require("../sinon");
}
if (!sinon) {
return;
}
- function spy(object, property) {
- if (!property && typeof object == "function") {
- return spy.create(object);
+ function throwYieldError(proxy, text, args) {
+ var msg = sinon.functionName(proxy) + text;
+ if (args.length) {
+ msg += " Received [" + slice.call(args).join(", ") + "]";
}
-
- if (!object && !property) {
- return spy.create(function () {});
- }
-
- var method = object[property];
- return sinon.wrapMethod(object, property, spy.create(method));
+ throw new Error(msg);
}
- sinon.extend(spy, (function () {
+ var slice = Array.prototype.slice;
- function delegateToCalls(api, method, matchAny, actual, notCalled) {
- api[method] = function () {
- if (!this.called) {
- if (notCalled) {
- return notCalled.apply(this, arguments);
- }
+ var callProto = {
+ calledOn: function calledOn(thisValue) {
+ if (sinon.match && sinon.match.isMatcher(thisValue)) {
+ return thisValue.test(this.thisValue);
+ }
+ return this.thisValue === thisValue;
+ },
+
+ calledWith: function calledWith() {
+ for (var i = 0, l = arguments.length; i < l; i += 1) {
+ if (!sinon.deepEqual(arguments[i], this.args[i])) {
return false;
}
+ }
- var currentCall;
- var matches = 0;
+ return true;
+ },
- for (var i = 0, l = this.callCount; i < l; i += 1) {
- currentCall = this.getCall(i);
+ calledWithMatch: function calledWithMatch() {
+ for (var i = 0, l = arguments.length; i < l; i += 1) {
+ var actual = this.args[i];
+ var expectation = arguments[i];
+ if (!sinon.match || !sinon.match(expectation).test(actual)) {
+ return false;
+ }
+ }
+ return true;
+ },
- if (currentCall[actual || method].apply(currentCall, arguments)) {
- matches += 1;
+ calledWithExactly: function calledWithExactly() {
+ return arguments.length == this.args.length &&
+ this.calledWith.apply(this, arguments);
+ },
- if (matchAny) {
- return true;
- }
- }
- }
+ notCalledWith: function notCalledWith() {
+ return !this.calledWith.apply(this, arguments);
+ },
- return matches === this.callCount;
- };
- }
+ notCalledWithMatch: function notCalledWithMatch() {
+ return !this.calledWithMatch.apply(this, arguments);
+ },
- function matchingFake(fakes, args, strict) {
- if (!fakes) {
- return;
+ returned: function returned(value) {
+ return sinon.deepEqual(value, this.returnValue);
+ },
+
+ threw: function threw(error) {
+ if (typeof error === "undefined" || !this.exception) {
+ return !!this.exception;
}
- var alen = args.length;
+ return this.exception === error || this.exception.name === error;
+ },
- for (var i = 0, l = fakes.length; i < l; i++) {
- if (fakes[i].matches(args, strict)) {
- return fakes[i];
- }
- }
- }
+ calledWithNew: function calledWithNew(thisValue) {
+ return this.thisValue instanceof this.proxy;
+ },
- function incrementCallCount() {
- this.called = true;
- this.callCount += 1;
- this.notCalled = false;
- this.calledOnce = this.callCount == 1;
- this.calledTwice = this.callCount == 2;
- this.calledThrice = this.callCount == 3;
- }
+ calledBefore: function (other) {
+ return this.callId < other.callId;
+ },
- function createCallProperties() {
- this.firstCall = this.getCall(0);
- this.secondCall = this.getCall(1);
- this.thirdCall = this.getCall(2);
- this.lastCall = this.getCall(this.callCount - 1);
- }
+ calledAfter: function (other) {
+ return this.callId > other.callId;
+ },
- var vars = "a,b,c,d,e,f,g,h,i,j,k,l";
- function createProxy(func) {
- // Retain the function length:
- var p;
- if (func.length) {
- eval("p = (function proxy(" + vars.substring(0, func.length * 2 - 1) +
- ") { return p.invoke(func, this, slice.call(arguments)); });");
- }
- else {
- p = function proxy() {
- return p.invoke(func, this, slice.call(arguments));
- };
- }
- return p;
- }
+ callArg: function (pos) {
+ this.args[pos]();
+ },
- var uuid = 0;
+ callArgOn: function (pos, thisValue) {
+ this.args[pos].apply(thisValue);
+ },
- // Public API
- var spyApi = {
- reset: function () {
- this.called = false;
- this.notCalled = true;
- this.calledOnce = false;
- this.calledTwice = false;
- this.calledThrice = false;
- this.callCount = 0;
- this.firstCall = null;
- this.secondCall = null;
- this.thirdCall = null;
- this.lastCall = null;
- this.args = [];
- this.returnValues = [];
- this.thisValues = [];
- this.exceptions = [];
- this.callIds = [];
- if (this.fakes) {
- for (var i = 0; i < this.fakes.length; i++) {
- this.fakes[i].reset();
- }
- }
- },
+ callArgWith: function (pos) {
+ this.callArgOnWith.apply(this, [pos, null].concat(slice.call(arguments, 1)));
+ },
- create: function create(func) {
- var name;
+ callArgOnWith: function (pos, thisValue) {
+ var args = slice.call(arguments, 2);
+ this.args[pos].apply(thisValue, args);
+ },
- if (typeof func != "function") {
- func = function () {};
- } else {
- name = sinon.functionName(func);
+ "yield": function () {
+ this.yieldOn.apply(this, [null].concat(slice.call(arguments, 0)));
+ },
+
+ yieldOn: function (thisValue) {
+ var args = this.args;
+ for (var i = 0, l = args.length; i < l; ++i) {
+ if (typeof args[i] === "function") {
+ args[i].apply(thisValue, slice.call(arguments, 1));
+ return;
}
+ }
+ throwYieldError(this.proxy, " cannot yield since no callback was passed.", args);
+ },
- var proxy = createProxy(func);
+ yieldTo: function (prop) {
+ this.yieldToOn.apply(this, [prop, null].concat(slice.call(arguments, 1)));
+ },
- sinon.extend(proxy, spy);
- delete proxy.create;
- sinon.extend(proxy, func);
+ yieldToOn: function (prop, thisValue) {
+ var args = this.args;
+ for (var i = 0, l = args.length; i < l; ++i) {
+ if (args[i] && typeof args[i][prop] === "function") {
+ args[i][prop].apply(thisValue, slice.call(arguments, 2));
+ return;
+ }
+ }
+ throwYieldError(this.proxy, " cannot yield to '" + prop +
+ "' since no callback was passed.", args);
+ },
- proxy.reset();
- proxy.prototype = func.prototype;
- proxy.displayName = name || "spy";
- proxy.toString = sinon.functionToString;
- proxy._create = sinon.spy.create;
- proxy.id = "spy#" + uuid++;
+ toString: function () {
+ var callStr = this.proxy.toString() + "(";
+ var args = [];
- return proxy;
- },
+ for (var i = 0, l = this.args.length; i < l; ++i) {
+ args.push(sinon.format(this.args[i]));
+ }
- invoke: function invoke(func, thisValue, args) {
- var matching = matchingFake(this.fakes, args);
- var exception, returnValue;
+ callStr = callStr + args.join(", ") + ")";
- incrementCallCount.call(this);
- push.call(this.thisValues, thisValue);
- push.call(this.args, args);
- push.call(this.callIds, callId++);
+ if (typeof this.returnValue != "undefined") {
+ callStr += " => " + sinon.format(this.returnValue);
+ }
- try {
- if (matching) {
- returnValue = matching.invoke(func, thisValue, args);
- } else {
- returnValue = (this.func || func).apply(thisValue, args);
- }
- } catch (e) {
- push.call(this.returnValues, undefined);
- exception = e;
- throw e;
- } finally {
- push.call(this.exceptions, exception);
+ if (this.exception) {
+ callStr += " !" + this.exception.name;
+
+ if (this.exception.message) {
+ callStr += "(" + this.exception.message + ")";
}
+ }
- push.call(this.returnValues, returnValue);
+ return callStr;
+ }
+ };
- createCallProperties.call(this);
+ callProto.invokeCallback = callProto.yield;
- return returnValue;
- },
+ function createSpyCall(spy, thisValue, args, returnValue, exception, id) {
+ if (typeof id !== "number") {
+ throw new TypeError("Call id is not a number");
+ }
+ var proxyCall = sinon.create(callProto);
+ proxyCall.proxy = spy;
+ proxyCall.thisValue = thisValue;
+ proxyCall.args = args;
+ proxyCall.returnValue = returnValue;
+ proxyCall.exception = exception;
+ proxyCall.callId = id;
- getCall: function getCall(i) {
- if (i < 0 || i >= this.callCount) {
- return null;
- }
+ return proxyCall;
+ };
+ createSpyCall.toString = callProto.toString; // used by mocks
- return spyCall.create(this, this.thisValues[i], this.args[i],
- this.returnValues[i], this.exceptions[i],
- this.callIds[i]);
- },
+ if (commonJSModule) {
+ module.exports = createSpyCall;
+ } else {
+ sinon.spyCall = createSpyCall;
+ }
+ }(typeof sinon == "object" && sinon || null));
- calledBefore: function calledBefore(spyFn) {
- if (!this.called) {
- return false;
- }
- if (!spyFn.called) {
- return true;
- }
+ /**
+ * @depend ../sinon.js
+ * @depend call.js
+ */
+ /*jslint eqeqeq: false, onevar: false, plusplus: false*/
+ /*global module, require, sinon*/
+ /**
+ * Spy functions
+ *
+ * @author Christian Johansen (christian@cjohansen.no)
+ * @license BSD
+ *
+ * Copyright (c) 2010-2013 Christian Johansen
+ */
- return this.callIds[0] < spyFn.callIds[spyFn.callIds.length - 1];
- },
+ (function (sinon) {
+ var commonJSModule = typeof module == "object" && typeof require == "function";
+ var push = Array.prototype.push;
+ var slice = Array.prototype.slice;
+ var callId = 0;
- calledAfter: function calledAfter(spyFn) {
- if (!this.called || !spyFn.called) {
- return false;
- }
+ if (!sinon && commonJSModule) {
+ sinon = require("../sinon");
+ }
- return this.callIds[this.callCount - 1] > spyFn.callIds[spyFn.callCount - 1];
- },
+ if (!sinon) {
+ return;
+ }
- withArgs: function () {
- var args = slice.call(arguments);
+ function spy(object, property) {
+ if (!property && typeof object == "function") {
+ return spy.create(object);
+ }
- if (this.fakes) {
- var match = matchingFake(this.fakes, args, true);
+ if (!object && !property) {
+ return spy.create(function () { });
+ }
- if (match) {
- return match;
- }
- } else {
- this.fakes = [];
- }
+ var method = object[property];
+ return sinon.wrapMethod(object, property, spy.create(method));
+ }
- var original = this;
- var fake = this._create();
- fake.matchingAguments = args;
- push.call(this.fakes, fake);
+ function matchingFake(fakes, args, strict) {
+ if (!fakes) {
+ return;
+ }
- fake.withArgs = function () {
- return original.withArgs.apply(original, arguments);
- };
+ var alen = args.length;
- for (var i = 0; i < this.args.length; i++) {
- if (fake.matches(this.args[i])) {
- incrementCallCount.call(fake);
- push.call(fake.thisValues, this.thisValues[i]);
- push.call(fake.args, this.args[i]);
- push.call(fake.returnValues, this.returnValues[i]);
- push.call(fake.exceptions, this.exceptions[i]);
- push.call(fake.callIds, this.callIds[i]);
- }
- }
- createCallProperties.call(fake);
+ for (var i = 0, l = fakes.length; i < l; i++) {
+ if (fakes[i].matches(args, strict)) {
+ return fakes[i];
+ }
+ }
+ }
- return fake;
- },
+ function incrementCallCount() {
+ this.called = true;
+ this.callCount += 1;
+ this.notCalled = false;
+ this.calledOnce = this.callCount == 1;
+ this.calledTwice = this.callCount == 2;
+ this.calledThrice = this.callCount == 3;
+ }
- matches: function (args, strict) {
- var margs = this.matchingAguments;
+ function createCallProperties() {
+ this.firstCall = this.getCall(0);
+ this.secondCall = this.getCall(1);
+ this.thirdCall = this.getCall(2);
+ this.lastCall = this.getCall(this.callCount - 1);
+ }
- if (margs.length <= args.length &&
- sinon.deepEqual(margs, args.slice(0, margs.length))) {
- return !strict || margs.length == args.length;
- }
- },
+ var vars = "a,b,c,d,e,f,g,h,i,j,k,l";
+ function createProxy(func) {
+ // Retain the function length:
+ var p;
+ if (func.length) {
+ eval("p = (function proxy(" + vars.substring(0, func.length * 2 - 1) +
+ ") { return p.invoke(func, this, slice.call(arguments)); });");
+ }
+ else {
+ p = function proxy() {
+ return p.invoke(func, this, slice.call(arguments));
+ };
+ }
+ return p;
+ }
- printf: function (format) {
- var spy = this;
- var args = slice.call(arguments, 1);
- var formatter;
+ var uuid = 0;
- return (format || "").replace(/%(.)/g, function (match, specifyer) {
- formatter = spyApi.formatters[specifyer];
+ // Public API
+ var spyApi = {
+ reset: function () {
+ this.called = false;
+ this.notCalled = true;
+ this.calledOnce = false;
+ this.calledTwice = false;
+ this.calledThrice = false;
+ this.callCount = 0;
+ this.firstCall = null;
+ this.secondCall = null;
+ this.thirdCall = null;
+ this.lastCall = null;
+ this.args = [];
+ this.returnValues = [];
+ this.thisValues = [];
+ this.exceptions = [];
+ this.callIds = [];
+ if (this.fakes) {
+ for (var i = 0; i < this.fakes.length; i++) {
+ this.fakes[i].reset();
+ }
+ }
+ },
- if (typeof formatter == "function") {
- return formatter.call(null, spy, args);
- } else if (!isNaN(parseInt(specifyer), 10)) {
- return sinon.format(args[specifyer - 1]);
- }
+ create: function create(func) {
+ var name;
- return "%" + specifyer;
- });
+ if (typeof func != "function") {
+ func = function () { };
+ } else {
+ name = sinon.functionName(func);
}
- };
- delegateToCalls(spyApi, "calledOn", true);
- delegateToCalls(spyApi, "alwaysCalledOn", false, "calledOn");
- delegateToCalls(spyApi, "calledWith", true);
- delegateToCalls(spyApi, "calledWithMatch", true);
- delegateToCalls(spyApi, "alwaysCalledWith", false, "calledWith");
- delegateToCalls(spyApi, "alwaysCalledWithMatch", false, "calledWithMatch");
- delegateToCalls(spyApi, "calledWithExactly", true);
- delegateToCalls(spyApi, "alwaysCalledWithExactly", false, "calledWithExactly");
- delegateToCalls(spyApi, "neverCalledWith", false, "notCalledWith",
- function () { return true; });
- delegateToCalls(spyApi, "neverCalledWithMatch", false, "notCalledWithMatch",
- function () { return true; });
- delegateToCalls(spyApi, "threw", true);
- delegateToCalls(spyApi, "alwaysThrew", false, "threw");
- delegateToCalls(spyApi, "returned", true);
- delegateToCalls(spyApi, "alwaysReturned", false, "returned");
- delegateToCalls(spyApi, "calledWithNew", true);
- delegateToCalls(spyApi, "alwaysCalledWithNew", false, "calledWithNew");
- delegateToCalls(spyApi, "callArg", false, "callArgWith", function () {
- throw new Error(this.toString() + " cannot call arg since it was not yet invoked.");
- });
- spyApi.callArgWith = spyApi.callArg;
- delegateToCalls(spyApi, "yield", false, "yield", function () {
- throw new Error(this.toString() + " cannot yield since it was not yet invoked.");
- });
- // "invokeCallback" is an alias for "yield" since "yield" is invalid in strict mode.
- spyApi.invokeCallback = spyApi.yield;
- delegateToCalls(spyApi, "yieldTo", false, "yieldTo", function (property) {
- throw new Error(this.toString() + " cannot yield to '" + property +
- "' since it was not yet invoked.");
- });
+ var proxy = createProxy(func);
- spyApi.formatters = {
- "c": function (spy) {
- return sinon.timesInWords(spy.callCount);
- },
+ sinon.extend(proxy, spy);
+ delete proxy.create;
+ sinon.extend(proxy, func);
- "n": function (spy) {
- return spy.toString();
- },
+ proxy.reset();
+ proxy.prototype = func.prototype;
+ proxy.displayName = name || "spy";
+ proxy.toString = sinon.functionToString;
+ proxy._create = sinon.spy.create;
+ proxy.id = "spy#" + uuid++;
- "C": function (spy) {
- var calls = [];
+ return proxy;
+ },
- for (var i = 0, l = spy.callCount; i < l; ++i) {
- push.call(calls, " " + spy.getCall(i).toString());
- }
+ invoke: function invoke(func, thisValue, args) {
+ var matching = matchingFake(this.fakes, args);
+ var exception, returnValue;
- return calls.length > 0 ? "\n" + calls.join("\n") : "";
- },
+ incrementCallCount.call(this);
+ push.call(this.thisValues, thisValue);
+ push.call(this.args, args);
+ push.call(this.callIds, callId++);
- "t": function (spy) {
- var objects = [];
-
- for (var i = 0, l = spy.callCount; i < l; ++i) {
- push.call(objects, sinon.format(spy.thisValues[i]));
+ try {
+ if (matching) {
+ returnValue = matching.invoke(func, thisValue, args);
+ } else {
+ returnValue = (this.func || func).apply(thisValue, args);
}
+ } catch (e) {
+ push.call(this.returnValues, undefined);
+ exception = e;
+ throw e;
+ } finally {
+ push.call(this.exceptions, exception);
+ }
- return objects.join(", ");
- },
+ push.call(this.returnValues, returnValue);
- "*": function (spy, args) {
- var formatted = [];
+ createCallProperties.call(this);
- for (var i = 0, l = args.length; i < l; ++i) {
- push.call(formatted, sinon.format(args[i]));
- }
+ return returnValue;
+ },
- return formatted.join(", ");
+ getCall: function getCall(i) {
+ if (i < 0 || i >= this.callCount) {
+ return null;
}
- };
- return spyApi;
- }()));
+ return sinon.spyCall(this, this.thisValues[i], this.args[i],
+ this.returnValues[i], this.exceptions[i],
+ this.callIds[i]);
+ },
- spyCall = (function () {
+ calledBefore: function calledBefore(spyFn) {
+ if (!this.called) {
+ return false;
+ }
- function throwYieldError(proxy, text, args) {
- var msg = sinon.functionName(proxy) + text;
- if (args.length) {
- msg += " Received [" + slice.call(args).join(", ") + "]";
+ if (!spyFn.called) {
+ return true;
}
- throw new Error(msg);
- }
- var callApi = {
- create: function create(spy, thisValue, args, returnValue, exception, id) {
- var proxyCall = sinon.create(spyCall);
- delete proxyCall.create;
- proxyCall.proxy = spy;
- proxyCall.thisValue = thisValue;
- proxyCall.args = args;
- proxyCall.returnValue = returnValue;
- proxyCall.exception = exception;
- proxyCall.callId = typeof id == "number" && id || callId++;
+ return this.callIds[0] < spyFn.callIds[spyFn.callIds.length - 1];
+ },
- return proxyCall;
- },
+ calledAfter: function calledAfter(spyFn) {
+ if (!this.called || !spyFn.called) {
+ return false;
+ }
- calledOn: function calledOn(thisValue) {
- if (sinon.match && sinon.match.isMatcher(thisValue)) {
- return thisValue.test(this.thisValue);
- }
- return this.thisValue === thisValue;
- },
+ return this.callIds[this.callCount - 1] > spyFn.callIds[spyFn.callCount - 1];
+ },
- calledWith: function calledWith() {
- for (var i = 0, l = arguments.length; i < l; i += 1) {
- if (!sinon.deepEqual(arguments[i], this.args[i])) {
- return false;
- }
+ withArgs: function () {
+ var args = slice.call(arguments);
+
+ if (this.fakes) {
+ var match = matchingFake(this.fakes, args, true);
+
+ if (match) {
+ return match;
}
+ } else {
+ this.fakes = [];
+ }
- return true;
- },
+ var original = this;
+ var fake = this._create();
+ fake.matchingAguments = args;
+ push.call(this.fakes, fake);
- calledWithMatch: function calledWithMatch() {
- for (var i = 0, l = arguments.length; i < l; i += 1) {
- var actual = this.args[i];
- var expectation = arguments[i];
- if (!sinon.match || !sinon.match(expectation).test(actual)) {
- return false;
- }
+ fake.withArgs = function () {
+ return original.withArgs.apply(original, arguments);
+ };
+
+ for (var i = 0; i < this.args.length; i++) {
+ if (fake.matches(this.args[i])) {
+ incrementCallCount.call(fake);
+ push.call(fake.thisValues, this.thisValues[i]);
+ push.call(fake.args, this.args[i]);
+ push.call(fake.returnValues, this.returnValues[i]);
+ push.call(fake.exceptions, this.exceptions[i]);
+ push.call(fake.callIds, this.callIds[i]);
}
- return true;
- },
+ }
+ createCallProperties.call(fake);
- calledWithExactly: function calledWithExactly() {
- return arguments.length == this.args.length &&
- this.calledWith.apply(this, arguments);
- },
+ return fake;
+ },
- notCalledWith: function notCalledWith() {
- return !this.calledWith.apply(this, arguments);
- },
+ matches: function (args, strict) {
+ var margs = this.matchingAguments;
- notCalledWithMatch: function notCalledWithMatch() {
- return !this.calledWithMatch.apply(this, arguments);
- },
+ if (margs.length <= args.length &&
+ sinon.deepEqual(margs, args.slice(0, margs.length))) {
+ return !strict || margs.length == args.length;
+ }
+ },
- returned: function returned(value) {
- return sinon.deepEqual(value, this.returnValue);
- },
+ printf: function (format) {
+ var spy = this;
+ var args = slice.call(arguments, 1);
+ var formatter;
- threw: function threw(error) {
- if (typeof error == "undefined" || !this.exception) {
- return !!this.exception;
- }
+ return (format || "").replace(/%(.)/g, function (match, specifyer) {
+ formatter = spyApi.formatters[specifyer];
- if (typeof error == "string") {
- return this.exception.name == error;
+ if (typeof formatter == "function") {
+ return formatter.call(null, spy, args);
+ } else if (!isNaN(parseInt(specifyer), 10)) {
+ return sinon.format(args[specifyer - 1]);
}
- return this.exception === error;
- },
+ return "%" + specifyer;
+ });
+ }
+ };
- calledWithNew: function calledWithNew(thisValue) {
- return this.thisValue instanceof this.proxy;
- },
+ function delegateToCalls(method, matchAny, actual, notCalled) {
+ spyApi[method] = function () {
+ if (!this.called) {
+ if (notCalled) {
+ return notCalled.apply(this, arguments);
+ }
+ return false;
+ }
- calledBefore: function (other) {
- return this.callId < other.callId;
- },
+ var currentCall;
+ var matches = 0;
- calledAfter: function (other) {
- return this.callId > other.callId;
- },
+ for (var i = 0, l = this.callCount; i < l; i += 1) {
+ currentCall = this.getCall(i);
- callArg: function (pos) {
- this.args[pos]();
- },
+ if (currentCall[actual || method].apply(currentCall, arguments)) {
+ matches += 1;
- callArgWith: function (pos) {
- var args = slice.call(arguments, 1);
- this.args[pos].apply(null, args);
- },
-
- "yield": function () {
- var args = this.args;
- for (var i = 0, l = args.length; i < l; ++i) {
- if (typeof args[i] === "function") {
- args[i].apply(null, slice.call(arguments));
- return;
+ if (matchAny) {
+ return true;
}
}
- throwYieldError(this.proxy, " cannot yield since no callback was passed.", args);
- },
+ }
- yieldTo: function (prop) {
- var args = this.args;
- for (var i = 0, l = args.length; i < l; ++i) {
- if (args[i] && typeof args[i][prop] === "function") {
- args[i][prop].apply(null, slice.call(arguments, 1));
- return;
- }
- }
- throwYieldError(this.proxy, " cannot yield to '" + prop +
- "' since no callback was passed.", args);
- },
+ return matches === this.callCount;
+ };
+ }
- toString: function () {
- var callStr = this.proxy.toString() + "(";
- var args = [];
+ delegateToCalls("calledOn", true);
+ delegateToCalls("alwaysCalledOn", false, "calledOn");
+ delegateToCalls("calledWith", true);
+ delegateToCalls("calledWithMatch", true);
+ delegateToCalls("alwaysCalledWith", false, "calledWith");
+ delegateToCalls("alwaysCalledWithMatch", false, "calledWithMatch");
+ delegateToCalls("calledWithExactly", true);
+ delegateToCalls("alwaysCalledWithExactly", false, "calledWithExactly");
+ delegateToCalls("neverCalledWith", false, "notCalledWith",
+ function () { return true; });
+ delegateToCalls("neverCalledWithMatch", false, "notCalledWithMatch",
+ function () { return true; });
+ delegateToCalls("threw", true);
+ delegateToCalls("alwaysThrew", false, "threw");
+ delegateToCalls("returned", true);
+ delegateToCalls("alwaysReturned", false, "returned");
+ delegateToCalls("calledWithNew", true);
+ delegateToCalls("alwaysCalledWithNew", false, "calledWithNew");
+ delegateToCalls("callArg", false, "callArgWith", function () {
+ throw new Error(this.toString() + " cannot call arg since it was not yet invoked.");
+ });
+ spyApi.callArgWith = spyApi.callArg;
+ delegateToCalls("callArgOn", false, "callArgOnWith", function () {
+ throw new Error(this.toString() + " cannot call arg since it was not yet invoked.");
+ });
+ spyApi.callArgOnWith = spyApi.callArgOn;
+ delegateToCalls("yield", false, "yield", function () {
+ throw new Error(this.toString() + " cannot yield since it was not yet invoked.");
+ });
+ // "invokeCallback" is an alias for "yield" since "yield" is invalid in strict mode.
+ spyApi.invokeCallback = spyApi.yield;
+ delegateToCalls("yieldOn", false, "yieldOn", function () {
+ throw new Error(this.toString() + " cannot yield since it was not yet invoked.");
+ });
+ delegateToCalls("yieldTo", false, "yieldTo", function (property) {
+ throw new Error(this.toString() + " cannot yield to '" + property +
+ "' since it was not yet invoked.");
+ });
+ delegateToCalls("yieldToOn", false, "yieldToOn", function (property) {
+ throw new Error(this.toString() + " cannot yield to '" + property +
+ "' since it was not yet invoked.");
+ });
- for (var i = 0, l = this.args.length; i < l; ++i) {
- push.call(args, sinon.format(this.args[i]));
- }
+ spyApi.formatters = {
+ "c": function (spy) {
+ return sinon.timesInWords(spy.callCount);
+ },
- callStr = callStr + args.join(", ") + ")";
+ "n": function (spy) {
+ return spy.toString();
+ },
- if (typeof this.returnValue != "undefined") {
- callStr += " => " + sinon.format(this.returnValue);
+ "C": function (spy) {
+ var calls = [];
+
+ for (var i = 0, l = spy.callCount; i < l; ++i) {
+ var stringifiedCall = " " + spy.getCall(i).toString();
+ if (/\n/.test(calls[i - 1])) {
+ stringifiedCall = "\n" + stringifiedCall;
}
+ push.call(calls, stringifiedCall);
+ }
- if (this.exception) {
- callStr += " !" + this.exception.name;
+ return calls.length > 0 ? "\n" + calls.join("\n") : "";
+ },
- if (this.exception.message) {
- callStr += "(" + this.exception.message + ")";
- }
- }
+ "t": function (spy) {
+ var objects = [];
- return callStr;
+ for (var i = 0, l = spy.callCount; i < l; ++i) {
+ push.call(objects, sinon.format(spy.thisValues[i]));
}
- };
- callApi.invokeCallback = callApi.yield;
- return callApi;
- }());
- spy.spyCall = spyCall;
+ return objects.join(", ");
+ },
- // This steps outside the module sandbox and will be removed
- sinon.spyCall = spyCall;
+ "*": function (spy, args) {
+ var formatted = [];
+ for (var i = 0, l = args.length; i < l; ++i) {
+ push.call(formatted, sinon.format(args[i]));
+ }
+
+ return formatted.join(", ");
+ }
+ };
+
+ sinon.extend(spy, spyApi);
+
+ spy.spyCall = sinon.spyCall;
+
if (commonJSModule) {
module.exports = spy;
} else {
sinon.spy = spy;
}
@@ -1580,11 +1656,11 @@
* Stub functions
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
- * Copyright (c) 2010-2011 Christian Johansen
+ * Copyright (c) 2010-2013 Christian Johansen
*/
(function (sinon) {
var commonJSModule = typeof module == "object" && typeof require == "function";
@@ -1626,11 +1702,12 @@
return sinon.wrapMethod(object, property, wrapper);
}
function getChangingValue(stub, property) {
var index = stub.callCount - 1;
- var prop = index in stub[property] ? stub[property][index] : stub[property + "Last"];
+ var values = stub[property];
+ var prop = index in values ? values[index] : values[values.length - 1];
stub[property + "Last"] = prop;
return prop;
}
@@ -1683,12 +1760,10 @@
}
var nextTick = (function () {
if (typeof process === "object" && typeof process.nextTick === "function") {
return process.nextTick;
- } else if (typeof msSetImmediate === "function") {
- return msSetImmediate.bind(window);
} else if (typeof setImmediate === "function") {
return setImmediate;
} else {
return function (callback) {
setTimeout(callback, 0);
@@ -1702,12 +1777,10 @@
if (typeof func != "function") {
throw new TypeError(getCallbackError(stub, func, args));
}
- var index = stub.callCount - 1;
-
var callbackArguments = getChangingValue(stub, "callbackArguments");
var callbackContext = getChangingValue(stub, "callbackContexts");
if (stub.callbackAsync) {
nextTick(function() {
@@ -1769,10 +1842,29 @@
functionStub.toString = sinon.functionToString;
return functionStub;
},
+ resetBehavior: function () {
+ var i;
+
+ this.callArgAts = [];
+ this.callbackArguments = [];
+ this.callbackContexts = [];
+ this.callArgProps = [];
+
+ delete this.returnValue;
+ delete this.returnArgAt;
+ this.returnThis = false;
+
+ if (this.fakes) {
+ for (i = 0; i < this.fakes.length; i++) {
+ this.fakes[i].resetBehavior();
+ }
+ }
+ },
+
returns: function returns(value) {
this.returnValue = value;
return this;
},
@@ -1935,11 +2027,11 @@
* Mock functions.
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
- * Copyright (c) 2010-2011 Christian Johansen
+ * Copyright (c) 2010-2013 Christian Johansen
*/
(function (sinon) {
var commonJSModule = typeof module == "object" && typeof require == "function";
var push = [].push;
@@ -2303,11 +2395,12 @@
if (!this.expectsExactArgCount) {
push.call(args, "[...]");
}
var callStr = sinon.spyCall.toString.call({
- proxy: this.method, args: args
+ proxy: this.method || "anonymous mock expectation",
+ args: args
});
var message = callStr.replace(", [...", "[, ...") + " " +
expectedCallCountInWords(this);
@@ -2359,11 +2452,11 @@
* Collections of stubs, spies and mocks.
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
- * Copyright (c) 2010-2011 Christian Johansen
+ * Copyright (c) 2010-2013 Christian Johansen
*/
(function (sinon) {
var commonJSModule = typeof module == "object" && typeof require == "function";
var push = [].push;
@@ -2516,11 +2609,11 @@
* Inspired by jsUnitMockTimeOut from JsUnit
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
- * Copyright (c) 2010-2011 Christian Johansen
+ * Copyright (c) 2010-2013 Christian Johansen
*/
if (typeof sinon == "undefined") {
var sinon = {};
}
@@ -2657,10 +2750,12 @@
this.now = tickTo;
if (firstException) {
throw firstException;
}
+
+ return this.now;
},
firstTimerInRange: function (from, to) {
var timer, smallest, originalTimer;
@@ -2870,19 +2965,20 @@
}
(function () {
var push = [].push;
- sinon.Event = function Event(type, bubbles, cancelable) {
- this.initEvent(type, bubbles, cancelable);
+ sinon.Event = function Event(type, bubbles, cancelable, target) {
+ this.initEvent(type, bubbles, cancelable, target);
};
sinon.Event.prototype = {
- initEvent: function(type, bubbles, cancelable) {
+ initEvent: function(type, bubbles, cancelable, target) {
this.type = type;
this.bubbles = bubbles;
this.cancelable = cancelable;
+ this.target = target;
},
stopPropagation: function () {},
preventDefault: function () {
@@ -2934,11 +3030,11 @@
* Fake XMLHttpRequest object
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
- * Copyright (c) 2010-2011 Christian Johansen
+ * Copyright (c) 2010-2013 Christian Johansen
*/
if (typeof sinon == "undefined") {
this.sinon = {};
}
@@ -2982,10 +3078,22 @@
this.requestHeaders = {};
this.requestBody = null;
this.status = 0;
this.statusText = "";
+ var xhr = this;
+
+ ["loadstart", "load", "abort", "loadend"].forEach(function (eventName) {
+ xhr.addEventListener(eventName, function (event) {
+ var listener = xhr["on" + eventName];
+
+ if (listener && typeof listener == "function") {
+ listener(event);
+ }
+ });
+ });
+
if (typeof FakeXMLHttpRequest.onCreate == "function") {
FakeXMLHttpRequest.onCreate(this);
}
}
@@ -3135,10 +3243,17 @@
sinon.logError("Fake XHR onreadystatechange handler", e);
}
}
this.dispatchEvent(new sinon.Event("readystatechange"));
+
+ switch (this.readyState) {
+ case FakeXMLHttpRequest.DONE:
+ this.dispatchEvent(new sinon.Event("load", false, false, this));
+ this.dispatchEvent(new sinon.Event("loadend", false, false, this));
+ break;
+ }
},
setRequestHeader: function setRequestHeader(header, value) {
verifyState(this);
@@ -3163,10 +3278,12 @@
}
}
if (this.async) {
this.readyStateChange(FakeXMLHttpRequest.HEADERS_RECEIVED);
+ } else {
+ this.readyState = FakeXMLHttpRequest.HEADERS_RECEIVED;
}
},
// Currently treats ALL data as a DOMString (i.e. no Document)
send: function send(data) {
@@ -3188,10 +3305,12 @@
this.readyStateChange(FakeXMLHttpRequest.OPENED);
if (typeof this.onSend == "function") {
this.onSend(this);
}
+
+ this.dispatchEvent(new sinon.Event("loadstart", false, false, this));
},
abort: function abort() {
this.aborted = true;
this.responseText = null;
@@ -3202,10 +3321,15 @@
this.readyStateChange(sinon.FakeXMLHttpRequest.DONE);
this.sendFlag = false;
}
this.readyState = sinon.FakeXMLHttpRequest.UNSENT;
+
+ this.dispatchEvent(new sinon.Event("abort", false, false, this));
+ if (typeof this.onerror === "function") {
+ this.onerror();
+ }
},
getResponseHeader: function getResponseHeader(header) {
if (this.readyState < FakeXMLHttpRequest.HEADERS_RECEIVED) {
return null;
@@ -3282,10 +3406,14 @@
respond: function respond(status, headers, body) {
this.setResponseHeaders(headers || {});
this.status = typeof status == "number" ? status : 200;
this.statusText = FakeXMLHttpRequest.statusCodes[this.status];
this.setResponseBody(body || "");
+ if (typeof this.onload === "function"){
+ this.onload();
+ }
+
}
});
sinon.extend(FakeXMLHttpRequest, {
UNSENT: 0,
@@ -3408,11 +3536,11 @@
* answers have to be provided upfront.
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
- * Copyright (c) 2010-2011 Christian Johansen
+ * Copyright (c) 2010-2013 Christian Johansen
*/
if (typeof sinon == "undefined") {
var sinon = {};
}
@@ -3472,10 +3600,19 @@
}
return false;
}
+ function log(response, request) {
+ var str;
+
+ str = "Request:\n" + sinon.format(request) + "\n\n";
+ str += "Response:\n" + sinon.format(response) + "\n\n";
+
+ sinon.log(str);
+ }
+
return {
create: function () {
var server = create(this);
this.xhr = sinon.useFakeXMLHttpRequest();
server.requests = [];
@@ -3578,10 +3715,12 @@
}
}
}
if (request.readyState != 4) {
+ log(response, request);
+
request.respond(response[0], response[1], response[2]);
}
} catch (e) {
sinon.logError("Fake server request processing", e);
}
@@ -3613,11 +3752,11 @@
* setTimeout.
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
- * Copyright (c) 2010-2011 Christian Johansen
+ * Copyright (c) 2010-2013 Christian Johansen
*/
(function () {
function Server() {}
Server.prototype = sinon.fakeServer;
@@ -3693,11 +3832,11 @@
* timers and fake XHR implementation in one convenient object.
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
- * Copyright (c) 2010-2011 Christian Johansen
+ * Copyright (c) 2010-2013 Christian Johansen
*/
if (typeof module == "object" && typeof require == "function") {
var sinon = require("../sinon");
sinon.extend(sinon, require("./util/fake_timers"));
@@ -3817,11 +3956,11 @@
* Test function, sandboxes fakes
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
- * Copyright (c) 2010-2011 Christian Johansen
+ * Copyright (c) 2010-2013 Christian Johansen
*/
(function (sinon) {
var commonJSModule = typeof module == "object" && typeof require == "function";
@@ -3890,11 +4029,11 @@
* Test case, sandboxes all test functions
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
- * Copyright (c) 2010-2011 Christian Johansen
+ * Copyright (c) 2010-2013 Christian Johansen
*/
(function (sinon) {
var commonJSModule = typeof module == "object" && typeof require == "function";
@@ -3987,11 +4126,11 @@
* Assertions matching the test spy retrieval interface.
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
- * Copyright (c) 2010-2011 Christian Johansen
+ * Copyright (c) 2010-2013 Christian Johansen
*/
(function (sinon, global) {
var commonJSModule = typeof module == "object" && typeof require == "function";
var slice = Array.prototype.slice;
@@ -4080,11 +4219,18 @@
var expected = "", actual = "";
if (!sinon.calledInOrder(arguments)) {
try {
expected = [].join.call(arguments, ", ");
- actual = sinon.orderByFirstCall(slice.call(arguments)).join(", ");
+ var calls = slice.call(arguments);
+ var i = calls.length;
+ while (i) {
+ if (!calls[--i].called) {
+ calls.splice(i, 1);
+ }
+ }
+ actual = sinon.orderByFirstCall(calls).join(", ");
} catch (e) {
// If this fails, we'll just fall back to the blank string
}
failAssertion(this, "expected " + expected + " to be " +
@@ -4149,9 +4295,10 @@
if (commonJSModule) {
module.exports = assert;
} else {
sinon.assert = assert;
}
- }(typeof sinon == "object" && sinon || null, typeof window != "undefined" ? window : global));
+ }(typeof sinon == "object" && sinon || null, typeof window != "undefined" ? window : (typeof self != "undefined") ? self : global));
return sinon;}.call(typeof window != 'undefined' && window || {}));
-; FI"required_assets_digest; F"%37497ce33916e67d5b2d426652bac4d6I"
_version; F"%6776f581a4329e299531e1d52aa59832
+; FI"dependency_digest; F"%53ea03d26b55798cf2bf1f79f935b2cdI"required_paths; F[I"P/Users/jejacks0n/Projects/teabag/vendor/assets/javascripts/support/sinon.js; FI"dependency_paths; F[{I" path; FI"P/Users/jejacks0n/Projects/teabag/vendor/assets/javascripts/support/sinon.js; FI"
+mtime; FI"2013-05-07T23:15:45-06:00; FI"digest; F"%53ca19e435158ef3bad8162b2683559bI"
_version; F"%6776f581a4329e299531e1d52aa59832
\ No newline at end of file