teaspoon-mocha 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/lib/teaspoon-mocha.rb +4 -0
  3. data/lib/teaspoon/mocha/assets/mocha/1.10.0.js +5374 -0
  4. data/lib/teaspoon/mocha/assets/mocha/1.17.1.js +5813 -0
  5. data/lib/teaspoon/mocha/assets/mocha/1.18.2.js +5841 -0
  6. data/lib/teaspoon/mocha/assets/mocha/1.19.0.js +5843 -0
  7. data/lib/teaspoon/mocha/assets/mocha/2.0.1.js +6070 -0
  8. data/lib/teaspoon/mocha/assets/mocha/2.1.0.js +6299 -0
  9. data/lib/teaspoon/mocha/assets/mocha/2.2.4.js +6565 -0
  10. data/lib/teaspoon/mocha/assets/mocha/MIT.LICENSE +22 -0
  11. data/lib/teaspoon/mocha/assets/support/chai-1.10.0.js +4800 -0
  12. data/lib/teaspoon/mocha/assets/support/chai-jq-0.0.7.js +524 -0
  13. data/lib/teaspoon/mocha/assets/support/chai.js +4782 -0
  14. data/lib/teaspoon/mocha/assets/support/expect.js +1284 -0
  15. data/lib/teaspoon/mocha/assets/support/sinon-chai.js +126 -0
  16. data/lib/teaspoon/mocha/assets/teaspoon-mocha.js +1435 -0
  17. data/lib/teaspoon/mocha/assets/teaspoon/mocha.coffee +10 -0
  18. data/lib/teaspoon/mocha/assets/teaspoon/mocha/fixture.coffee +14 -0
  19. data/lib/teaspoon/mocha/assets/teaspoon/mocha/intiialize.coffee +4 -0
  20. data/lib/teaspoon/mocha/assets/teaspoon/mocha/reporters/html.coffee +14 -0
  21. data/lib/teaspoon/mocha/assets/teaspoon/mocha/reporters/spec_view.coffee +6 -0
  22. data/lib/teaspoon/mocha/assets/teaspoon/mocha/responder.coffee +38 -0
  23. data/lib/teaspoon/mocha/assets/teaspoon/mocha/runner.coffee +16 -0
  24. data/lib/teaspoon/mocha/assets/teaspoon/mocha/spec.coffee +34 -0
  25. data/lib/teaspoon/mocha/assets/teaspoon/mocha/suite.coffee +8 -0
  26. data/lib/teaspoon/mocha/framework.rb +31 -0
  27. data/lib/teaspoon/mocha/templates/spec_helper.coffee +40 -0
  28. data/lib/teaspoon/mocha/templates/spec_helper.js +40 -0
  29. data/lib/teaspoon/mocha/version.rb +5 -0
  30. metadata +88 -0
@@ -0,0 +1,126 @@
1
+ (function (sinonChai) {
2
+ "use strict";
3
+
4
+ // Module systems magic dance.
5
+
6
+ if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
7
+ // NodeJS
8
+ module.exports = sinonChai;
9
+ } else if (typeof define === "function" && define.amd) {
10
+ // AMD
11
+ define(function () {
12
+ return sinonChai;
13
+ });
14
+ } else {
15
+ // Other environment (usually <script> tag): plug in to global chai instance directly.
16
+ chai.use(sinonChai);
17
+ }
18
+ }(function sinonChai(chai, utils) {
19
+ "use strict";
20
+
21
+ var slice = Array.prototype.slice;
22
+
23
+ function isSpy(putativeSpy) {
24
+ return typeof putativeSpy === "function" &&
25
+ typeof putativeSpy.getCall === "function" &&
26
+ typeof putativeSpy.calledWithExactly === "function";
27
+ }
28
+
29
+ function timesInWords(count) {
30
+ return count === 1 ? "once" :
31
+ count === 2 ? "twice" :
32
+ count === 3 ? "thrice" :
33
+ (count || 0) + " times";
34
+ }
35
+
36
+ function isCall(putativeCall) {
37
+ return putativeCall && isSpy(putativeCall.proxy);
38
+ }
39
+
40
+ function assertCanWorkWith(assertion) {
41
+ if (!isSpy(assertion._obj) && !isCall(assertion._obj)) {
42
+ throw new TypeError(utils.inspect(assertion._obj) + " is not a spy or a call to a spy!");
43
+ }
44
+ }
45
+
46
+ function getMessages(spy, action, nonNegatedSuffix, always, args) {
47
+ var verbPhrase = always ? "always have " : "have ";
48
+ nonNegatedSuffix = nonNegatedSuffix || "";
49
+ if (isSpy(spy.proxy)) {
50
+ spy = spy.proxy;
51
+ }
52
+
53
+ function printfArray(array) {
54
+ return spy.printf.apply(spy, array);
55
+ }
56
+
57
+ return {
58
+ affirmative: printfArray(["expected %n to " + verbPhrase + action + nonNegatedSuffix].concat(args)),
59
+ negative: printfArray(["expected %n to not " + verbPhrase + action].concat(args))
60
+ };
61
+ }
62
+
63
+ function sinonProperty(name, action, nonNegatedSuffix) {
64
+ utils.addProperty(chai.Assertion.prototype, name, function () {
65
+ assertCanWorkWith(this);
66
+
67
+ var messages = getMessages(this._obj, action, nonNegatedSuffix, false);
68
+ this.assert(this._obj[name], messages.affirmative, messages.negative);
69
+ });
70
+ }
71
+
72
+ function sinonPropertyAsBooleanMethod(name, action, nonNegatedSuffix) {
73
+ utils.addMethod(chai.Assertion.prototype, name, function (arg) {
74
+ assertCanWorkWith(this);
75
+
76
+ var messages = getMessages(this._obj, action, nonNegatedSuffix, false, [timesInWords(arg)]);
77
+ this.assert(this._obj[name] === arg, messages.affirmative, messages.negative);
78
+ });
79
+ }
80
+
81
+ function createSinonMethodHandler(sinonName, action, nonNegatedSuffix) {
82
+ return function () {
83
+ assertCanWorkWith(this);
84
+
85
+ var alwaysSinonMethod = "always" + sinonName[0].toUpperCase() + sinonName.substring(1);
86
+ var shouldBeAlways = utils.flag(this, "always") && typeof this._obj[alwaysSinonMethod] === "function";
87
+ var sinonMethod = shouldBeAlways ? alwaysSinonMethod : sinonName;
88
+
89
+ var messages = getMessages(this._obj, action, nonNegatedSuffix, shouldBeAlways, slice.call(arguments));
90
+ this.assert(this._obj[sinonMethod].apply(this._obj, arguments), messages.affirmative, messages.negative);
91
+ };
92
+ }
93
+
94
+ function sinonMethodAsProperty(name, action, nonNegatedSuffix) {
95
+ var handler = createSinonMethodHandler(name, action, nonNegatedSuffix);
96
+ utils.addProperty(chai.Assertion.prototype, name, handler);
97
+ }
98
+
99
+ function exceptionalSinonMethod(chaiName, sinonName, action, nonNegatedSuffix) {
100
+ var handler = createSinonMethodHandler(sinonName, action, nonNegatedSuffix);
101
+ utils.addMethod(chai.Assertion.prototype, chaiName, handler);
102
+ }
103
+
104
+ function sinonMethod(name, action, nonNegatedSuffix) {
105
+ exceptionalSinonMethod(name, name, action, nonNegatedSuffix);
106
+ }
107
+
108
+ utils.addProperty(chai.Assertion.prototype, "always", function () {
109
+ utils.flag(this, "always", true);
110
+ });
111
+
112
+ sinonProperty("called", "been called", " at least once, but it was never called");
113
+ sinonPropertyAsBooleanMethod("callCount", "been called exactly %1", ", but it was called %c%C");
114
+ sinonProperty("calledOnce", "been called exactly once", ", but it was called %c%C");
115
+ sinonProperty("calledTwice", "been called exactly twice", ", but it was called %c%C");
116
+ sinonProperty("calledThrice", "been called exactly thrice", ", but it was called %c%C");
117
+ sinonMethodAsProperty("calledWithNew", "been called with new");
118
+ sinonMethod("calledBefore", "been called before %1");
119
+ sinonMethod("calledAfter", "been called after %1");
120
+ sinonMethod("calledOn", "been called with %1 as this", ", but it was called with %t instead");
121
+ sinonMethod("calledWith", "been called with arguments %*", "%C");
122
+ sinonMethod("calledWithExactly", "been called with exact arguments %*", "%C");
123
+ sinonMethod("calledWithMatch", "been called with arguments matching %*", "%C");
124
+ sinonMethod("returned", "returned %1");
125
+ exceptionalSinonMethod("thrown", "threw", "thrown %1");
126
+ }));
@@ -0,0 +1,1435 @@
1
+ (function() {
2
+ this.Teaspoon = (function() {
3
+ function Teaspoon() {}
4
+
5
+ Teaspoon.defer = false;
6
+
7
+ Teaspoon.slow = 75;
8
+
9
+ Teaspoon.root = window.location.pathname.replace(/\/+(index\.html)?$/, "").replace(/\/[^\/]*$/, "");
10
+
11
+ Teaspoon.started = false;
12
+
13
+ Teaspoon.finished = false;
14
+
15
+ Teaspoon.Reporters = {};
16
+
17
+ Teaspoon.Date = Date;
18
+
19
+ Teaspoon.location = window.location;
20
+
21
+ Teaspoon.messages = [];
22
+
23
+ Teaspoon.execute = function() {
24
+ if (!Teaspoon.framework) {
25
+ throw "No framework registered. Expected a framework to register itself, but nothing has.";
26
+ }
27
+ if (Teaspoon.defer) {
28
+ Teaspoon.defer = false;
29
+ return;
30
+ }
31
+ if (Teaspoon.started) {
32
+ Teaspoon.reload();
33
+ }
34
+ Teaspoon.started = true;
35
+ return new (Teaspoon.resolveClass("Runner"))();
36
+ };
37
+
38
+ Teaspoon.reload = function() {
39
+ return window.location.reload();
40
+ };
41
+
42
+ Teaspoon.onWindowLoad = function(method) {
43
+ var originalOnload;
44
+ originalOnload = window.onload;
45
+ return window.onload = function() {
46
+ if (originalOnload && originalOnload.call) {
47
+ originalOnload();
48
+ }
49
+ return method();
50
+ };
51
+ };
52
+
53
+ Teaspoon.resolveDependenciesFromParams = function(all) {
54
+ var dep, deps, file, j, k, len, len1, parts, path, paths;
55
+ if (all == null) {
56
+ all = [];
57
+ }
58
+ deps = [];
59
+ if ((paths = Teaspoon.location.search.match(/[\?&]file(\[\])?=[^&\?]*/gi)) === null) {
60
+ return all;
61
+ }
62
+ for (j = 0, len = paths.length; j < len; j++) {
63
+ path = paths[j];
64
+ parts = decodeURIComponent(path.replace(/\+/g, " ")).match(/\/(.+)\.(js|js.coffee|coffee)$/i);
65
+ if (parts === null) {
66
+ continue;
67
+ }
68
+ file = parts[1].substr(parts[1].lastIndexOf("/") + 1);
69
+ for (k = 0, len1 = all.length; k < len1; k++) {
70
+ dep = all[k];
71
+ if (dep.indexOf(file) >= 0) {
72
+ deps.push(dep);
73
+ }
74
+ }
75
+ }
76
+ return deps;
77
+ };
78
+
79
+ Teaspoon.log = function() {
80
+ var e;
81
+ Teaspoon.messages.push(arguments[0]);
82
+ try {
83
+ return console.log.apply(console, arguments);
84
+ } catch (_error) {
85
+ e = _error;
86
+ throw new Error("Unable to use console.log for logging");
87
+ }
88
+ };
89
+
90
+ Teaspoon.getMessages = function() {
91
+ var messages;
92
+ messages = Teaspoon.messages;
93
+ Teaspoon.messages = [];
94
+ return messages;
95
+ };
96
+
97
+ Teaspoon.setFramework = function(namespace) {
98
+ Teaspoon.framework = namespace;
99
+ return window.fixture = Teaspoon.resolveClass("Fixture");
100
+ };
101
+
102
+ Teaspoon.resolveClass = function(klass) {
103
+ var framework_override, teaspoon_core;
104
+ if (framework_override = Teaspoon.checkNamespace(Teaspoon.framework, klass)) {
105
+ return framework_override;
106
+ } else if (teaspoon_core = Teaspoon.checkNamespace(Teaspoon, klass)) {
107
+ return teaspoon_core;
108
+ }
109
+ throw "Could not find the class you're looking for: " + klass;
110
+ };
111
+
112
+ Teaspoon.checkNamespace = function(root, klass) {
113
+ var i, j, len, namespace, namespaces, scope;
114
+ namespaces = klass.split('.');
115
+ scope = root;
116
+ for (i = j = 0, len = namespaces.length; j < len; i = ++j) {
117
+ namespace = namespaces[i];
118
+ if (!(scope = scope[namespace])) {
119
+ return false;
120
+ }
121
+ }
122
+ return scope;
123
+ };
124
+
125
+ return Teaspoon;
126
+
127
+ })();
128
+
129
+ }).call(this);
130
+ (function() {
131
+ Teaspoon.Runner = (function() {
132
+ Runner.run = false;
133
+
134
+ function Runner() {
135
+ if (this.constructor.run) {
136
+ return;
137
+ }
138
+ this.constructor.run = true;
139
+ this.fixturePath = Teaspoon.root + "/fixtures";
140
+ this.params = Teaspoon.params = this.getParams();
141
+ this.setup();
142
+ }
143
+
144
+ Runner.prototype.getParams = function() {
145
+ var i, len, name, param, params, ref, ref1, value;
146
+ params = {};
147
+ ref = Teaspoon.location.search.substring(1).split("&");
148
+ for (i = 0, len = ref.length; i < len; i++) {
149
+ param = ref[i];
150
+ ref1 = param.split("="), name = ref1[0], value = ref1[1];
151
+ params[decodeURIComponent(name)] = decodeURIComponent(value);
152
+ }
153
+ return params;
154
+ };
155
+
156
+ Runner.prototype.getReporter = function() {
157
+ if (this.params["reporter"]) {
158
+ return this.findReporter(this.params["reporter"]);
159
+ } else {
160
+ if (window.navigator.userAgent.match(/PhantomJS/)) {
161
+ return this.findReporter("Console");
162
+ } else {
163
+ return this.findReporter("HTML");
164
+ }
165
+ }
166
+ };
167
+
168
+ Runner.prototype.setup = function() {};
169
+
170
+ Runner.prototype.findReporter = function(type) {
171
+ return Teaspoon.resolveClass("Reporters." + type);
172
+ };
173
+
174
+ return Runner;
175
+
176
+ })();
177
+
178
+ }).call(this);
179
+ (function() {
180
+ var slice = [].slice;
181
+
182
+ Teaspoon.Fixture = (function() {
183
+ var addContent, cleanup, create, load, loadComplete, preload, putContent, set, xhr, xhrRequest;
184
+
185
+ Fixture.cache = {};
186
+
187
+ Fixture.el = null;
188
+
189
+ Fixture.$el = null;
190
+
191
+ Fixture.json = [];
192
+
193
+ Fixture.preload = function() {
194
+ var i, len, results, url, urls;
195
+ urls = 1 <= arguments.length ? slice.call(arguments, 0) : [];
196
+ results = [];
197
+ for (i = 0, len = urls.length; i < len; i++) {
198
+ url = urls[i];
199
+ results.push(preload(url));
200
+ }
201
+ return results;
202
+ };
203
+
204
+ Fixture.load = function() {
205
+ var append, i, index, j, len, results, url, urls;
206
+ urls = 2 <= arguments.length ? slice.call(arguments, 0, i = arguments.length - 1) : (i = 0, []), append = arguments[i++];
207
+ if (append == null) {
208
+ append = false;
209
+ }
210
+ if (typeof append !== "boolean") {
211
+ urls.push(append);
212
+ append = false;
213
+ }
214
+ results = [];
215
+ for (index = j = 0, len = urls.length; j < len; index = ++j) {
216
+ url = urls[index];
217
+ results.push(load(url, append || index > 0));
218
+ }
219
+ return results;
220
+ };
221
+
222
+ Fixture.set = function() {
223
+ var append, html, htmls, i, index, j, len, results;
224
+ htmls = 2 <= arguments.length ? slice.call(arguments, 0, i = arguments.length - 1) : (i = 0, []), append = arguments[i++];
225
+ if (append == null) {
226
+ append = false;
227
+ }
228
+ if (typeof append !== "boolean") {
229
+ htmls.push(append);
230
+ append = false;
231
+ }
232
+ results = [];
233
+ for (index = j = 0, len = htmls.length; j < len; index = ++j) {
234
+ html = htmls[index];
235
+ results.push(set(html, append || index > 0));
236
+ }
237
+ return results;
238
+ };
239
+
240
+ Fixture.cleanup = function() {
241
+ return cleanup();
242
+ };
243
+
244
+ function Fixture() {
245
+ window.fixture.load.apply(window, arguments);
246
+ }
247
+
248
+ xhr = null;
249
+
250
+ preload = function(url) {
251
+ return load(url, false, true);
252
+ };
253
+
254
+ load = function(url, append, preload) {
255
+ var cached, value;
256
+ if (preload == null) {
257
+ preload = false;
258
+ }
259
+ if (cached = window.fixture.cache[url]) {
260
+ return loadComplete(url, cached.type, cached.content, append, preload);
261
+ }
262
+ value = null;
263
+ xhrRequest(url, function() {
264
+ if (xhr.readyState !== 4) {
265
+ return;
266
+ }
267
+ if (xhr.status !== 200) {
268
+ throw "Unable to load fixture \"" + url + "\".";
269
+ }
270
+ return value = loadComplete(url, xhr.getResponseHeader("content-type"), xhr.responseText, append, preload);
271
+ });
272
+ return value;
273
+ };
274
+
275
+ loadComplete = function(url, type, content, append, preload) {
276
+ window.fixture.cache[url] = {
277
+ type: type,
278
+ content: content
279
+ };
280
+ if (type.match(/application\/json;/)) {
281
+ return Fixture.json[Fixture.json.push(JSON.parse(content)) - 1];
282
+ }
283
+ if (preload) {
284
+ return content;
285
+ }
286
+ if (append) {
287
+ addContent(content);
288
+ } else {
289
+ putContent(content);
290
+ }
291
+ return window.fixture.el;
292
+ };
293
+
294
+ set = function(content, append) {
295
+ if (append) {
296
+ return addContent(content);
297
+ } else {
298
+ return putContent(content);
299
+ }
300
+ };
301
+
302
+ putContent = function(content) {
303
+ cleanup();
304
+ create();
305
+ return window.fixture.el.innerHTML = content;
306
+ };
307
+
308
+ addContent = function(content) {
309
+ if (!window.fixture.el) {
310
+ create();
311
+ }
312
+ return window.fixture.el.innerHTML += content;
313
+ };
314
+
315
+ create = function() {
316
+ var ref;
317
+ window.fixture.el = document.createElement("div");
318
+ if (typeof window.$ === 'function') {
319
+ window.fixture.$el = $(window.fixture.el);
320
+ }
321
+ window.fixture.el.id = "teaspoon-fixtures";
322
+ return (ref = document.body) != null ? ref.appendChild(window.fixture.el) : void 0;
323
+ };
324
+
325
+ cleanup = function() {
326
+ var base, ref, ref1;
327
+ (base = window.fixture).el || (base.el = document.getElementById("teaspoon-fixtures"));
328
+ if ((ref = window.fixture.el) != null) {
329
+ if ((ref1 = ref.parentNode) != null) {
330
+ ref1.removeChild(window.fixture.el);
331
+ }
332
+ }
333
+ return window.fixture.el = null;
334
+ };
335
+
336
+ xhrRequest = function(url, callback) {
337
+ var e;
338
+ if (window.XMLHttpRequest) {
339
+ xhr = new XMLHttpRequest();
340
+ } else if (window.ActiveXObject) {
341
+ try {
342
+ xhr = new ActiveXObject("Msxml2.XMLHTTP");
343
+ } catch (_error) {
344
+ e = _error;
345
+ try {
346
+ xhr = new ActiveXObject("Microsoft.XMLHTTP");
347
+ } catch (_error) {
348
+ e = _error;
349
+ }
350
+ }
351
+ }
352
+ if (!xhr) {
353
+ throw "Unable to make Ajax Request";
354
+ }
355
+ xhr.onreadystatechange = callback;
356
+ xhr.open("GET", Teaspoon.root + "/fixtures/" + url, false);
357
+ return xhr.send();
358
+ };
359
+
360
+ return Fixture;
361
+
362
+ })();
363
+
364
+ }).call(this);
365
+ (function() {
366
+ Teaspoon.hook = function(name, payload) {
367
+ var xhr, xhrRequest;
368
+ if (payload == null) {
369
+ payload = {};
370
+ }
371
+ xhr = null;
372
+ xhrRequest = function(url, payload, callback) {
373
+ var e;
374
+ if (window.XMLHttpRequest) {
375
+ xhr = new XMLHttpRequest();
376
+ } else if (window.ActiveXObject) {
377
+ try {
378
+ xhr = new ActiveXObject("Msxml2.XMLHTTP");
379
+ } catch (_error) {
380
+ e = _error;
381
+ try {
382
+ xhr = new ActiveXObject("Microsoft.XMLHTTP");
383
+ } catch (_error) {
384
+ e = _error;
385
+ }
386
+ }
387
+ }
388
+ if (!xhr) {
389
+ throw "Unable to make Ajax Request";
390
+ }
391
+ xhr.onreadystatechange = callback;
392
+ xhr.open("POST", Teaspoon.root + "/" + url, false);
393
+ xhr.setRequestHeader("Content-Type", "application/json");
394
+ return xhr.send(JSON.stringify({
395
+ args: payload
396
+ }));
397
+ };
398
+ return xhrRequest(Teaspoon.suites.active + "/" + name, payload, function() {
399
+ if (xhr.readyState !== 4) {
400
+ return;
401
+ }
402
+ if (xhr.status !== 200) {
403
+ throw "Unable to call hook \"" + url + "\".";
404
+ }
405
+ });
406
+ };
407
+
408
+ }).call(this);
409
+ (function() {
410
+ Teaspoon.Reporters.BaseView = (function() {
411
+ function BaseView() {
412
+ this.elements = {};
413
+ this.build();
414
+ }
415
+
416
+ BaseView.prototype.build = function(className) {
417
+ return this.el = this.createEl("li", className);
418
+ };
419
+
420
+ BaseView.prototype.appendTo = function(el) {
421
+ return el.appendChild(this.el);
422
+ };
423
+
424
+ BaseView.prototype.append = function(el) {
425
+ return this.el.appendChild(el);
426
+ };
427
+
428
+ BaseView.prototype.createEl = function(type, className) {
429
+ var el;
430
+ if (className == null) {
431
+ className = "";
432
+ }
433
+ el = document.createElement(type);
434
+ el.className = className;
435
+ return el;
436
+ };
437
+
438
+ BaseView.prototype.findEl = function(id) {
439
+ var base;
440
+ this.elements || (this.elements = {});
441
+ return (base = this.elements)[id] || (base[id] = document.getElementById("teaspoon-" + id));
442
+ };
443
+
444
+ BaseView.prototype.setText = function(id, value) {
445
+ var el;
446
+ el = this.findEl(id);
447
+ return el.innerHTML = value;
448
+ };
449
+
450
+ BaseView.prototype.setHtml = function(id, value, add) {
451
+ var el;
452
+ if (add == null) {
453
+ add = false;
454
+ }
455
+ el = this.findEl(id);
456
+ if (add) {
457
+ return el.innerHTML += value;
458
+ } else {
459
+ return el.innerHTML = value;
460
+ }
461
+ };
462
+
463
+ BaseView.prototype.setClass = function(id, value) {
464
+ var el;
465
+ el = this.findEl(id);
466
+ return el.className = value;
467
+ };
468
+
469
+ BaseView.prototype.htmlSafe = function(str) {
470
+ var el;
471
+ el = document.createElement("div");
472
+ el.appendChild(document.createTextNode(str));
473
+ return el.innerHTML;
474
+ };
475
+
476
+ return BaseView;
477
+
478
+ })();
479
+
480
+ }).call(this);
481
+ (function() {
482
+ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
483
+ extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
484
+ hasProp = {}.hasOwnProperty;
485
+
486
+ Teaspoon.Reporters.HTML = (function(superClass) {
487
+ extend(HTML, superClass);
488
+
489
+ function HTML() {
490
+ this.changeSuite = bind(this.changeSuite, this);
491
+ this.toggleConfig = bind(this.toggleConfig, this);
492
+ this.reportRunnerResults = bind(this.reportRunnerResults, this);
493
+ this.start = new Teaspoon.Date().getTime();
494
+ this.config = {
495
+ "use-catch": true,
496
+ "build-full-report": false,
497
+ "display-progress": true
498
+ };
499
+ this.total = {
500
+ exist: 0,
501
+ run: 0,
502
+ passes: 0,
503
+ failures: 0,
504
+ skipped: 0
505
+ };
506
+ this.views = {
507
+ specs: {},
508
+ suites: {}
509
+ };
510
+ this.filters = [];
511
+ this.setFilters();
512
+ this.readConfig();
513
+ HTML.__super__.constructor.apply(this, arguments);
514
+ }
515
+
516
+ HTML.prototype.build = function() {
517
+ var ref;
518
+ this.buildLayout();
519
+ this.setText("env-info", this.envInfo());
520
+ this.setText("version", Teaspoon.version);
521
+ this.findEl("toggles").onclick = this.toggleConfig;
522
+ this.findEl("suites").innerHTML = this.buildSuiteSelect();
523
+ if ((ref = this.findEl("suite-select")) != null) {
524
+ ref.onchange = this.changeSuite;
525
+ }
526
+ this.el = this.findEl("report-all");
527
+ this.showConfiguration();
528
+ this.buildProgress();
529
+ return this.buildFilters();
530
+ };
531
+
532
+ HTML.prototype.reportRunnerStarting = function(runner) {
533
+ this.total.exist = runner.total || 0;
534
+ if (this.total.exist) {
535
+ return this.setText("stats-duration", "...");
536
+ }
537
+ };
538
+
539
+ HTML.prototype.reportRunnerResults = function() {
540
+ if (!this.total.run) {
541
+ return;
542
+ }
543
+ this.setText("stats-duration", this.elapsedTime());
544
+ if (!this.total.failures) {
545
+ this.setStatus("passed");
546
+ }
547
+ this.setText("stats-passes", this.total.passes);
548
+ this.setText("stats-failures", this.total.failures);
549
+ if (this.total.run < this.total.exist) {
550
+ this.total.skipped = this.total.exist - this.total.run;
551
+ this.total.run = this.total.exist;
552
+ }
553
+ this.setText("stats-skipped", this.total.skipped);
554
+ return this.updateProgress();
555
+ };
556
+
557
+ HTML.prototype.reportSuiteStarting = function(suite) {};
558
+
559
+ HTML.prototype.reportSuiteResults = function(suite) {};
560
+
561
+ HTML.prototype.reportSpecStarting = function(spec) {
562
+ if (this.config["build-full-report"]) {
563
+ this.reportView = new (Teaspoon.resolveClass("Reporters.HTML.SpecView"))(spec, this);
564
+ }
565
+ return this.specStart = new Teaspoon.Date().getTime();
566
+ };
567
+
568
+ HTML.prototype.reportSpecResults = function(spec) {
569
+ this.total.run += 1;
570
+ this.updateProgress();
571
+ return this.updateStatus(spec);
572
+ };
573
+
574
+ HTML.prototype.buildLayout = function() {
575
+ var el;
576
+ el = this.createEl("div");
577
+ el.id = "teaspoon-interface";
578
+ el.innerHTML = (Teaspoon.resolveClass("Reporters.HTML")).template();
579
+ return document.body.appendChild(el);
580
+ };
581
+
582
+ HTML.prototype.buildSuiteSelect = function() {
583
+ var filename, i, len, options, path, ref, selected, suite;
584
+ if (Teaspoon.suites.all.length === 1) {
585
+ return "";
586
+ }
587
+ filename = "";
588
+ if (/index\.html$/.test(window.location.pathname)) {
589
+ filename = "/index.html";
590
+ }
591
+ options = [];
592
+ ref = Teaspoon.suites.all;
593
+ for (i = 0, len = ref.length; i < len; i++) {
594
+ suite = ref[i];
595
+ path = [Teaspoon.root, suite].join("/");
596
+ selected = Teaspoon.suites.active === suite ? " selected" : "";
597
+ options.push("<option" + selected + " value=\"" + path + filename + "\">" + suite + "</option>");
598
+ }
599
+ return "<select id=\"teaspoon-suite-select\">" + (options.join("")) + "</select>";
600
+ };
601
+
602
+ HTML.prototype.buildProgress = function() {
603
+ this.progress = Teaspoon.Reporters.HTML.ProgressView.create(this.config["display-progress"]);
604
+ return this.progress.appendTo(this.findEl("progress"));
605
+ };
606
+
607
+ HTML.prototype.buildFilters = function() {
608
+ if (this.filters.length) {
609
+ this.setClass("filter", "teaspoon-filtered");
610
+ }
611
+ return this.setHtml("filter-list", "<li>" + (this.filters.join("</li><li>")), true);
612
+ };
613
+
614
+ HTML.prototype.elapsedTime = function() {
615
+ return (((new Teaspoon.Date().getTime() - this.start) / 1000).toFixed(3)) + "s";
616
+ };
617
+
618
+ HTML.prototype.updateStat = function(name, value) {
619
+ if (!this.config["display-progress"]) {
620
+ return;
621
+ }
622
+ return this.setText("stats-" + name, value);
623
+ };
624
+
625
+ HTML.prototype.updateStatus = function(spec) {
626
+ var elapsed, ref, ref1, ref2, result;
627
+ result = spec.result();
628
+ if (result.skipped) {
629
+ this.updateStat("skipped", this.total.skipped += 1);
630
+ return;
631
+ }
632
+ elapsed = new Teaspoon.Date().getTime() - this.specStart;
633
+ if (result.status === "passed") {
634
+ this.updateStat("passes", this.total.passes += 1);
635
+ return (ref = this.reportView) != null ? ref.updateState("passed", elapsed) : void 0;
636
+ } else if (result.status === "pending") {
637
+ return (ref1 = this.reportView) != null ? ref1.updateState("pending", elapsed) : void 0;
638
+ } else {
639
+ this.updateStat("failures", this.total.failures += 1);
640
+ if ((ref2 = this.reportView) != null) {
641
+ ref2.updateState("failed", elapsed);
642
+ }
643
+ if (!this.config["build-full-report"]) {
644
+ new (Teaspoon.resolveClass("Reporters.HTML.FailureView"))(spec).appendTo(this.findEl("report-failures"));
645
+ }
646
+ return this.setStatus("failed");
647
+ }
648
+ };
649
+
650
+ HTML.prototype.updateProgress = function() {
651
+ return this.progress.update(this.total.exist, this.total.run);
652
+ };
653
+
654
+ HTML.prototype.showConfiguration = function() {
655
+ var key, ref, results, value;
656
+ ref = this.config;
657
+ results = [];
658
+ for (key in ref) {
659
+ value = ref[key];
660
+ results.push(this.setClass(key, value ? "active" : ""));
661
+ }
662
+ return results;
663
+ };
664
+
665
+ HTML.prototype.setStatus = function(status) {
666
+ return document.body.className = "teaspoon-" + status;
667
+ };
668
+
669
+ HTML.prototype.setFilters = function() {
670
+ if (Teaspoon.params["file"]) {
671
+ this.filters.push("by file: " + Teaspoon.params["file"]);
672
+ }
673
+ if (Teaspoon.params["grep"]) {
674
+ return this.filters.push("by match: " + Teaspoon.params["grep"]);
675
+ }
676
+ };
677
+
678
+ HTML.prototype.readConfig = function() {
679
+ var config;
680
+ if (config = this.store("teaspoon")) {
681
+ return this.config = config;
682
+ }
683
+ };
684
+
685
+ HTML.prototype.toggleConfig = function(e) {
686
+ var button, name;
687
+ button = e.target;
688
+ if (button.tagName.toLowerCase() !== "button") {
689
+ return;
690
+ }
691
+ name = button.getAttribute("id").replace(/^teaspoon-/, "");
692
+ this.config[name] = !this.config[name];
693
+ this.store("teaspoon", this.config);
694
+ return Teaspoon.reload();
695
+ };
696
+
697
+ HTML.prototype.changeSuite = function(e) {
698
+ var options;
699
+ options = e.target.options;
700
+ return window.location.href = options[options.selectedIndex].value;
701
+ };
702
+
703
+ HTML.prototype.store = function(name, value) {
704
+ var ref;
705
+ if (((ref = window.localStorage) != null ? ref.setItem : void 0) != null) {
706
+ return this.localstore(name, value);
707
+ } else {
708
+ return this.cookie(name, value);
709
+ }
710
+ };
711
+
712
+ HTML.prototype.cookie = function(name, value) {
713
+ var date, match;
714
+ if (value == null) {
715
+ value = void 0;
716
+ }
717
+ if (value === void 0) {
718
+ name = name.replace(/([.*+?^=!:${}()|[\]\/\\])/g, "\\$1");
719
+ match = document.cookie.match(new RegExp("(?:^|;)\\s?" + name + "=(.*?)(?:;|$)", "i"));
720
+ return match && JSON.parse(unescape(match[1]).split(" ")[0]);
721
+ } else {
722
+ date = new Teaspoon.Date();
723
+ date.setDate(date.getDate() + 365);
724
+ return document.cookie = name + "=" + (escape(JSON.stringify(value))) + "; expires=" + (date.toUTCString()) + "; path=/;";
725
+ }
726
+ };
727
+
728
+ HTML.prototype.localstore = function(name, value) {
729
+ if (value == null) {
730
+ value = void 0;
731
+ }
732
+ if (value === void 0) {
733
+ return JSON.parse(unescape(localStorage.getItem(name)));
734
+ } else {
735
+ return localStorage.setItem(name, escape(JSON.stringify(value)));
736
+ }
737
+ };
738
+
739
+ return HTML;
740
+
741
+ })(Teaspoon.Reporters.BaseView);
742
+
743
+ }).call(this);
744
+ (function() {
745
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
746
+ hasProp = {}.hasOwnProperty;
747
+
748
+ Teaspoon.Reporters.HTML.FailureView = (function(superClass) {
749
+ extend(FailureView, superClass);
750
+
751
+ function FailureView(spec) {
752
+ this.spec = spec;
753
+ FailureView.__super__.constructor.apply(this, arguments);
754
+ }
755
+
756
+ FailureView.prototype.build = function() {
757
+ var error, html, i, len, ref;
758
+ FailureView.__super__.build.call(this, "spec");
759
+ html = "<h1 class=\"teaspoon-clearfix\"><a href=\"" + this.spec.link + "\">" + (this.htmlSafe(this.spec.fullDescription)) + "</a></h1>";
760
+ ref = this.spec.errors();
761
+ for (i = 0, len = ref.length; i < len; i++) {
762
+ error = ref[i];
763
+ html += "<div><strong>" + (this.htmlSafe(error.message)) + "</strong><br/>" + (this.htmlSafe(error.stack || "Stack trace unavailable")) + "</div>";
764
+ }
765
+ return this.el.innerHTML = html;
766
+ };
767
+
768
+ return FailureView;
769
+
770
+ })(Teaspoon.Reporters.BaseView);
771
+
772
+ }).call(this);
773
+ (function() {
774
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
775
+ hasProp = {}.hasOwnProperty;
776
+
777
+ Teaspoon.Reporters.HTML.ProgressView = (function(superClass) {
778
+ extend(ProgressView, superClass);
779
+
780
+ function ProgressView() {
781
+ return ProgressView.__super__.constructor.apply(this, arguments);
782
+ }
783
+
784
+ ProgressView.create = function(displayProgress) {
785
+ if (displayProgress == null) {
786
+ displayProgress = true;
787
+ }
788
+ if (!displayProgress) {
789
+ return new Teaspoon.Reporters.HTML.ProgressView();
790
+ }
791
+ if (Teaspoon.Reporters.HTML.RadialProgressView.supported) {
792
+ return new Teaspoon.Reporters.HTML.RadialProgressView();
793
+ } else {
794
+ return new Teaspoon.Reporters.HTML.SimpleProgressView();
795
+ }
796
+ };
797
+
798
+ ProgressView.prototype.build = function() {
799
+ return this.el = this.createEl("div", "teaspoon-indicator teaspoon-logo");
800
+ };
801
+
802
+ ProgressView.prototype.update = function() {};
803
+
804
+ return ProgressView;
805
+
806
+ })(Teaspoon.Reporters.BaseView);
807
+
808
+ }).call(this);
809
+ (function() {
810
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
811
+ hasProp = {}.hasOwnProperty;
812
+
813
+ Teaspoon.Reporters.HTML.RadialProgressView = (function(superClass) {
814
+ extend(RadialProgressView, superClass);
815
+
816
+ function RadialProgressView() {
817
+ return RadialProgressView.__super__.constructor.apply(this, arguments);
818
+ }
819
+
820
+ RadialProgressView.supported = !!document.createElement("canvas").getContext;
821
+
822
+ RadialProgressView.prototype.build = function() {
823
+ this.el = this.createEl("div", "teaspoon-indicator radial-progress");
824
+ return this.el.innerHTML = "<canvas id=\"teaspoon-progress-canvas\"></canvas>\n<em id=\"teaspoon-progress-percent\">0%</em>";
825
+ };
826
+
827
+ RadialProgressView.prototype.appendTo = function() {
828
+ var canvas, e;
829
+ RadialProgressView.__super__.appendTo.apply(this, arguments);
830
+ this.size = 80;
831
+ try {
832
+ canvas = this.findEl("progress-canvas");
833
+ canvas.width = canvas.height = canvas.style.width = canvas.style.height = this.size;
834
+ this.ctx = canvas.getContext("2d");
835
+ this.ctx.strokeStyle = "#fff";
836
+ return this.ctx.lineWidth = 1.5;
837
+ } catch (_error) {
838
+ e = _error;
839
+ }
840
+ };
841
+
842
+ RadialProgressView.prototype.update = function(total, run) {
843
+ var half, percent;
844
+ percent = total ? Math.ceil((run * 100) / total) : 0;
845
+ this.setHtml("progress-percent", percent + "%");
846
+ if (!this.ctx) {
847
+ return;
848
+ }
849
+ half = this.size / 2;
850
+ this.ctx.clearRect(0, 0, this.size, this.size);
851
+ this.ctx.beginPath();
852
+ this.ctx.arc(half, half, half - 1, 0, Math.PI * 2 * (percent / 100), false);
853
+ return this.ctx.stroke();
854
+ };
855
+
856
+ return RadialProgressView;
857
+
858
+ })(Teaspoon.Reporters.HTML.ProgressView);
859
+
860
+ }).call(this);
861
+ (function() {
862
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
863
+ hasProp = {}.hasOwnProperty;
864
+
865
+ Teaspoon.Reporters.HTML.SimpleProgressView = (function(superClass) {
866
+ extend(SimpleProgressView, superClass);
867
+
868
+ function SimpleProgressView() {
869
+ return SimpleProgressView.__super__.constructor.apply(this, arguments);
870
+ }
871
+
872
+ SimpleProgressView.prototype.build = function() {
873
+ this.el = this.createEl("div", "simple-progress");
874
+ return this.el.innerHTML = "<em id=\"teaspoon-progress-percent\">0%</em>\n<span id=\"teaspoon-progress-span\" class=\"teaspoon-indicator\"></span>";
875
+ };
876
+
877
+ SimpleProgressView.prototype.update = function(total, run) {
878
+ var percent;
879
+ percent = total ? Math.ceil((run * 100) / total) : 0;
880
+ return this.setHtml("progress-percent", percent + "%");
881
+ };
882
+
883
+ return SimpleProgressView;
884
+
885
+ })(Teaspoon.Reporters.HTML.ProgressView);
886
+
887
+ }).call(this);
888
+ (function() {
889
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
890
+ hasProp = {}.hasOwnProperty;
891
+
892
+ Teaspoon.Reporters.HTML.SpecView = (function(superClass) {
893
+ var viewId;
894
+
895
+ extend(SpecView, superClass);
896
+
897
+ viewId = 0;
898
+
899
+ function SpecView(spec, reporter) {
900
+ this.spec = spec;
901
+ this.reporter = reporter;
902
+ this.views = this.reporter.views;
903
+ this.spec.viewId = viewId += 1;
904
+ this.views.specs[this.spec.viewId] = this;
905
+ SpecView.__super__.constructor.apply(this, arguments);
906
+ }
907
+
908
+ SpecView.prototype.build = function() {
909
+ var classes;
910
+ classes = ["spec"];
911
+ if (this.spec.pending) {
912
+ classes.push("state-pending");
913
+ }
914
+ SpecView.__super__.build.call(this, classes.join(" "));
915
+ this.el.innerHTML = "<a href=\"" + this.spec.link + "\">" + (this.htmlSafe(this.spec.description)) + "</a>";
916
+ this.parentView = this.buildParent();
917
+ return this.parentView.append(this.el);
918
+ };
919
+
920
+ SpecView.prototype.buildParent = function() {
921
+ var parent, view;
922
+ parent = this.spec.parent;
923
+ if (parent.viewId) {
924
+ return this.views.suites[parent.viewId];
925
+ } else {
926
+ view = new (Teaspoon.resolveClass("Reporters.HTML.SuiteView"))(parent, this.reporter);
927
+ return this.views.suites[view.suite.viewId] = view;
928
+ }
929
+ };
930
+
931
+ SpecView.prototype.buildErrors = function() {
932
+ var div, error, html, i, len, ref;
933
+ div = this.createEl("div");
934
+ html = "";
935
+ ref = this.spec.errors();
936
+ for (i = 0, len = ref.length; i < len; i++) {
937
+ error = ref[i];
938
+ html += "<strong>" + (this.htmlSafe(error.message)) + "</strong><br/>" + (this.htmlSafe(error.stack || "Stack trace unavailable"));
939
+ }
940
+ div.innerHTML = html;
941
+ return this.append(div);
942
+ };
943
+
944
+ SpecView.prototype.updateState = function(state, elapsed) {
945
+ var base, classes, result;
946
+ result = this.spec.result();
947
+ classes = ["state-" + state];
948
+ if (elapsed > Teaspoon.slow) {
949
+ classes.push("slow");
950
+ }
951
+ if (state === "passed") {
952
+ this.el.innerHTML += "<span>" + elapsed + "ms</span>";
953
+ }
954
+ this.el.className = classes.join(" ");
955
+ if (result.status === "failed") {
956
+ this.buildErrors();
957
+ }
958
+ return typeof (base = this.parentView).updateState === "function" ? base.updateState(state) : void 0;
959
+ };
960
+
961
+ return SpecView;
962
+
963
+ })(Teaspoon.Reporters.BaseView);
964
+
965
+ }).call(this);
966
+ (function() {
967
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
968
+ hasProp = {}.hasOwnProperty;
969
+
970
+ Teaspoon.Reporters.HTML.SuiteView = (function(superClass) {
971
+ var viewId;
972
+
973
+ extend(SuiteView, superClass);
974
+
975
+ viewId = 0;
976
+
977
+ function SuiteView(suite, reporter) {
978
+ this.suite = suite;
979
+ this.reporter = reporter;
980
+ this.views = this.reporter.views;
981
+ this.suite.viewId = viewId += 1;
982
+ this.views.suites[this.suite.viewId] = this;
983
+ this.suite = new (Teaspoon.resolveClass("Suite"))(this.suite);
984
+ SuiteView.__super__.constructor.apply(this, arguments);
985
+ }
986
+
987
+ SuiteView.prototype.build = function() {
988
+ SuiteView.__super__.build.call(this, "suite");
989
+ this.el.innerHTML = "<h1><a href=\"" + this.suite.link + "\">" + (this.htmlSafe(this.suite.description)) + "</a></h1>";
990
+ this.parentView = this.buildParent();
991
+ return this.parentView.append(this.el);
992
+ };
993
+
994
+ SuiteView.prototype.buildParent = function() {
995
+ var parent, view;
996
+ parent = this.suite.parent;
997
+ if (!parent) {
998
+ return this.reporter;
999
+ }
1000
+ if (parent.viewId) {
1001
+ return this.views.suites[parent.viewId];
1002
+ } else {
1003
+ view = new (Teaspoon.resolveClass("Reporters.HTML.SuiteView"))(parent, this.reporter);
1004
+ return this.views.suites[view.suite.viewId] = view;
1005
+ }
1006
+ };
1007
+
1008
+ SuiteView.prototype.append = function(el) {
1009
+ if (!this.ol) {
1010
+ SuiteView.__super__.append.call(this, this.ol = this.createEl("ol"));
1011
+ }
1012
+ return this.ol.appendChild(el);
1013
+ };
1014
+
1015
+ SuiteView.prototype.updateState = function(state) {
1016
+ var base;
1017
+ if (this.state === "failed") {
1018
+ return;
1019
+ }
1020
+ this.el.className = (this.el.className.replace(/\s?state-\w+/, "")) + " state-" + state;
1021
+ if (typeof (base = this.parentView).updateState === "function") {
1022
+ base.updateState(state);
1023
+ }
1024
+ return this.state = state;
1025
+ };
1026
+
1027
+ return SuiteView;
1028
+
1029
+ })(Teaspoon.Reporters.BaseView);
1030
+
1031
+ }).call(this);
1032
+ (function() {
1033
+ Teaspoon.Reporters.HTML.template = function() {
1034
+ return "<div class=\"teaspoon-clearfix\">\n <div id=\"teaspoon-title\">\n <h1><a href=\"" + Teaspoon.root + "\" id=\"teaspoon-root-link\">Teaspoon</a></h1>\n <ul>\n <li>version: <b id=\"teaspoon-version\"></b></li>\n <li id=\"teaspoon-env-info\"></li>\n </ul>\n </div>\n <div id=\"teaspoon-progress\"></div>\n <ul id=\"teaspoon-stats\">\n <li>passes: <b id=\"teaspoon-stats-passes\">0</b></li>\n <li>failures: <b id=\"teaspoon-stats-failures\">0</b></li>\n <li>skipped: <b id=\"teaspoon-stats-skipped\">0</b></li>\n <li>duration: <b id=\"teaspoon-stats-duration\">&infin;</b></li>\n </ul>\n</div>\n\n<div id=\"teaspoon-controls\" class=\"teaspoon-clearfix\">\n <div id=\"teaspoon-toggles\">\n <button id=\"teaspoon-use-catch\" title=\"Toggle using try/catch wrappers when possible\">Try/Catch</button>\n <button id=\"teaspoon-build-full-report\" title=\"Toggle building the full report\">Full Report</button>\n <button id=\"teaspoon-display-progress\" title=\"Toggle displaying progress as tests run\">Progress</button>\n </div>\n <div id=\"teaspoon-suites\"></div>\n</div>\n\n<hr/>\n\n<div id=\"teaspoon-filter\">\n <h1>Applied Filters [<a href=\"" + window.location.pathname + "\" id=\"teaspoon-filter-clear\">remove</a>]</h1>\n <ul id=\"teaspoon-filter-list\"></ul>\n</div>\n\n<div id=\"teaspoon-report\">\n <ol id=\"teaspoon-report-failures\"></ol>\n <ol id=\"teaspoon-report-all\"></ol>\n</div>";
1035
+ };
1036
+
1037
+ }).call(this);
1038
+ (function() {
1039
+ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
1040
+
1041
+ Teaspoon.Reporters.Console = (function() {
1042
+ function Console() {
1043
+ this.reportRunnerResults = bind(this.reportRunnerResults, this);
1044
+ this.start = new Teaspoon.Date();
1045
+ this.suites = {};
1046
+ }
1047
+
1048
+ Console.prototype.reportRunnerStarting = function(runner) {
1049
+ return this.log({
1050
+ type: "runner",
1051
+ total: runner.total || (typeof runner.specs === "function" ? runner.specs().length : void 0) || 0,
1052
+ start: JSON.parse(JSON.stringify(this.start))
1053
+ });
1054
+ };
1055
+
1056
+ Console.prototype.reportRunnerResults = function() {
1057
+ this.log({
1058
+ type: "result",
1059
+ elapsed: ((new Teaspoon.Date().getTime() - this.start.getTime()) / 1000).toFixed(5),
1060
+ coverage: window.__coverage__
1061
+ });
1062
+ return Teaspoon.finished = true;
1063
+ };
1064
+
1065
+ Console.prototype.reportSuiteStarting = function(suite) {};
1066
+
1067
+ Console.prototype.reportSuiteResults = function(suite) {};
1068
+
1069
+ Console.prototype.reportSpecStarting = function(spec) {};
1070
+
1071
+ Console.prototype.reportSuites = function() {
1072
+ var i, index, len, ref, results, suite;
1073
+ ref = this.spec.getParents();
1074
+ results = [];
1075
+ for (index = i = 0, len = ref.length; i < len; index = ++i) {
1076
+ suite = ref[index];
1077
+ if (this.suites[suite.fullDescription]) {
1078
+ continue;
1079
+ }
1080
+ this.suites[suite.fullDescription] = true;
1081
+ results.push(this.log({
1082
+ type: "suite",
1083
+ label: suite.description,
1084
+ level: index
1085
+ }));
1086
+ }
1087
+ return results;
1088
+ };
1089
+
1090
+ Console.prototype.reportSpecResults = function(spec1) {
1091
+ var result;
1092
+ this.spec = spec1;
1093
+ result = this.spec.result();
1094
+ if (result.skipped) {
1095
+ return;
1096
+ }
1097
+ this.reportSuites();
1098
+ switch (result.status) {
1099
+ case "pending":
1100
+ return this.trackPending();
1101
+ case "failed":
1102
+ return this.trackFailure();
1103
+ default:
1104
+ return this.log({
1105
+ type: "spec",
1106
+ suite: this.spec.suiteName,
1107
+ label: this.spec.description,
1108
+ status: result.status,
1109
+ skipped: result.skipped
1110
+ });
1111
+ }
1112
+ };
1113
+
1114
+ Console.prototype.trackPending = function() {
1115
+ var result;
1116
+ result = this.spec.result();
1117
+ return this.log({
1118
+ type: "spec",
1119
+ suite: this.spec.suiteName,
1120
+ label: this.spec.description,
1121
+ status: result.status,
1122
+ skipped: result.skipped
1123
+ });
1124
+ };
1125
+
1126
+ Console.prototype.trackFailure = function() {
1127
+ var error, i, len, ref, result, results;
1128
+ result = this.spec.result();
1129
+ ref = this.spec.errors();
1130
+ results = [];
1131
+ for (i = 0, len = ref.length; i < len; i++) {
1132
+ error = ref[i];
1133
+ results.push(this.log({
1134
+ type: "spec",
1135
+ suite: this.spec.suiteName,
1136
+ label: this.spec.description,
1137
+ status: result.status,
1138
+ skipped: result.skipped,
1139
+ link: this.spec.fullDescription,
1140
+ message: error.message,
1141
+ trace: error.stack || error.message || "Stack Trace Unavailable"
1142
+ }));
1143
+ }
1144
+ return results;
1145
+ };
1146
+
1147
+ Console.prototype.log = function(obj) {
1148
+ if (obj == null) {
1149
+ obj = {};
1150
+ }
1151
+ obj["_teaspoon"] = true;
1152
+ return Teaspoon.log(JSON.stringify(obj));
1153
+ };
1154
+
1155
+ return Console;
1156
+
1157
+ })();
1158
+
1159
+ }).call(this);
1160
+ (function() {
1161
+ var base, base1;
1162
+
1163
+ if (typeof mocha === "undefined" || mocha === null) {
1164
+ throw new Teaspoon.Error('Mocha not found -- use `suite.use_framework :mocha` and adjust or remove the `suite.javascripts` directive.');
1165
+ }
1166
+
1167
+ if (this.Teaspoon == null) {
1168
+ this.Teaspoon = {};
1169
+ }
1170
+
1171
+ if ((base = this.Teaspoon).Mocha == null) {
1172
+ base.Mocha = {};
1173
+ }
1174
+
1175
+ if ((base1 = this.Teaspoon.Mocha).Reporters == null) {
1176
+ base1.Reporters = {};
1177
+ }
1178
+
1179
+ }).call(this);
1180
+ (function() {
1181
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1182
+ hasProp = {}.hasOwnProperty;
1183
+
1184
+ Teaspoon.Mocha.Fixture = (function(superClass) {
1185
+ extend(Fixture, superClass);
1186
+
1187
+ function Fixture() {
1188
+ return Fixture.__super__.constructor.apply(this, arguments);
1189
+ }
1190
+
1191
+ Fixture.load = function() {
1192
+ var args;
1193
+ args = arguments;
1194
+ if (window.env.started) {
1195
+ return Fixture.__super__.constructor.load.apply(this, arguments);
1196
+ } else {
1197
+ return beforeEach((function(_this) {
1198
+ return function() {
1199
+ return fixture.__super__.constructor.load.apply(_this, args);
1200
+ };
1201
+ })(this));
1202
+ }
1203
+ };
1204
+
1205
+ Fixture.set = function() {
1206
+ var args;
1207
+ args = arguments;
1208
+ if (window.env.started) {
1209
+ return Fixture.__super__.constructor.set.apply(this, arguments);
1210
+ } else {
1211
+ return beforeEach((function(_this) {
1212
+ return function() {
1213
+ return fixture.__super__.constructor.set.apply(_this, args);
1214
+ };
1215
+ })(this));
1216
+ }
1217
+ };
1218
+
1219
+ return Fixture;
1220
+
1221
+ })(Teaspoon.Fixture);
1222
+
1223
+ }).call(this);
1224
+ (function() {
1225
+ Teaspoon.setFramework(Teaspoon.Mocha);
1226
+
1227
+ window.env = mocha.setup("bdd");
1228
+
1229
+ }).call(this);
1230
+ (function() {
1231
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1232
+ hasProp = {}.hasOwnProperty;
1233
+
1234
+ Teaspoon.Mocha.Reporters.HTML = (function(superClass) {
1235
+ extend(HTML, superClass);
1236
+
1237
+ function HTML() {
1238
+ return HTML.__super__.constructor.apply(this, arguments);
1239
+ }
1240
+
1241
+ HTML.prototype.reportSpecResults = function(spec) {
1242
+ if (spec.pending) {
1243
+ if (this.config["build-full-report"]) {
1244
+ this.reportView = new Teaspoon.Mocha.Reporters.HTML.SpecView(spec, this);
1245
+ }
1246
+ }
1247
+ return HTML.__super__.reportSpecResults.call(this, spec);
1248
+ };
1249
+
1250
+ HTML.prototype.envInfo = function() {
1251
+ return "mocha " + (_mocha_version || "[unknown version]");
1252
+ };
1253
+
1254
+ return HTML;
1255
+
1256
+ })(Teaspoon.Reporters.HTML);
1257
+
1258
+ }).call(this);
1259
+ (function() {
1260
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1261
+ hasProp = {}.hasOwnProperty;
1262
+
1263
+ Teaspoon.Mocha.Reporters.HTML.SpecView = (function(superClass) {
1264
+ extend(SpecView, superClass);
1265
+
1266
+ function SpecView() {
1267
+ return SpecView.__super__.constructor.apply(this, arguments);
1268
+ }
1269
+
1270
+ SpecView.prototype.updateState = function(state) {
1271
+ return SpecView.__super__.updateState.call(this, state, this.spec.spec.duration);
1272
+ };
1273
+
1274
+ return SpecView;
1275
+
1276
+ })(Teaspoon.Reporters.HTML.SpecView);
1277
+
1278
+ }).call(this);
1279
+ (function() {
1280
+ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
1281
+
1282
+ Teaspoon.Mocha.Responder = (function() {
1283
+ function Responder(runner) {
1284
+ this.specFailed = bind(this.specFailed, this);
1285
+ this.specFinished = bind(this.specFinished, this);
1286
+ this.specStarted = bind(this.specStarted, this);
1287
+ this.suiteDone = bind(this.suiteDone, this);
1288
+ this.suiteStarted = bind(this.suiteStarted, this);
1289
+ this.runnerDone = bind(this.runnerDone, this);
1290
+ this.reporter.reportRunnerStarting({
1291
+ total: runner.total
1292
+ });
1293
+ runner.on("end", this.runnerDone);
1294
+ runner.on("suite", this.suiteStarted);
1295
+ runner.on("suite end", this.suiteDone);
1296
+ runner.on("test", this.specStarted);
1297
+ runner.on("fail", this.specFailed);
1298
+ runner.on("test end", this.specFinished);
1299
+ }
1300
+
1301
+ Responder.prototype.runnerDone = function() {
1302
+ return this.reporter.reportRunnerResults();
1303
+ };
1304
+
1305
+ Responder.prototype.suiteStarted = function(suite) {
1306
+ return this.reporter.reportSuiteStarting(new Teaspoon.Mocha.Suite(suite));
1307
+ };
1308
+
1309
+ Responder.prototype.suiteDone = function(suite) {
1310
+ return this.reporter.reportSuiteResults(new Teaspoon.Mocha.Suite(suite));
1311
+ };
1312
+
1313
+ Responder.prototype.specStarted = function(spec) {
1314
+ return this.reporter.reportSpecStarting(new Teaspoon.Mocha.Spec(spec));
1315
+ };
1316
+
1317
+ Responder.prototype.specFinished = function(spec) {
1318
+ spec = new Teaspoon.Mocha.Spec(spec);
1319
+ if (spec.result().status !== "failed") {
1320
+ return this.reporter.reportSpecResults(spec);
1321
+ }
1322
+ };
1323
+
1324
+ Responder.prototype.specFailed = function(spec, err) {
1325
+ spec.err = err;
1326
+ return this.reporter.reportSpecResults(new Teaspoon.Mocha.Spec(spec));
1327
+ };
1328
+
1329
+ return Responder;
1330
+
1331
+ })();
1332
+
1333
+ }).call(this);
1334
+ (function() {
1335
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1336
+ hasProp = {}.hasOwnProperty;
1337
+
1338
+ Teaspoon.Mocha.Runner = (function(superClass) {
1339
+ extend(Runner, superClass);
1340
+
1341
+ function Runner() {
1342
+ Runner.__super__.constructor.apply(this, arguments);
1343
+ window.env.run();
1344
+ window.env.started = true;
1345
+ afterEach(function() {
1346
+ return Teaspoon.Mocha.Fixture.cleanup();
1347
+ });
1348
+ }
1349
+
1350
+ Runner.prototype.setup = function() {
1351
+ var reporter;
1352
+ reporter = new (this.getReporter())();
1353
+ Teaspoon.Mocha.Responder.prototype.reporter = reporter;
1354
+ return window.env.setup({
1355
+ reporter: Teaspoon.Mocha.Responder
1356
+ });
1357
+ };
1358
+
1359
+ return Runner;
1360
+
1361
+ })(Teaspoon.Runner);
1362
+
1363
+ }).call(this);
1364
+ (function() {
1365
+ Teaspoon.Mocha.Spec = (function() {
1366
+ function Spec(spec) {
1367
+ this.spec = spec;
1368
+ this.fullDescription = this.spec.fullTitle();
1369
+ this.description = this.spec.title;
1370
+ this.link = "?grep=" + (encodeURIComponent(this.fullDescription));
1371
+ this.parent = this.spec.parent;
1372
+ this.suiteName = this.parent.fullTitle();
1373
+ this.viewId = this.spec.viewId;
1374
+ this.pending = this.spec.pending;
1375
+ }
1376
+
1377
+ Spec.prototype.errors = function() {
1378
+ if (!this.spec.err) {
1379
+ return [];
1380
+ }
1381
+ return [this.spec.err];
1382
+ };
1383
+
1384
+ Spec.prototype.getParents = function() {
1385
+ var parent;
1386
+ if (this.parents) {
1387
+ return this.parents;
1388
+ }
1389
+ this.parents || (this.parents = []);
1390
+ parent = this.parent;
1391
+ while (parent) {
1392
+ parent = new Teaspoon.Mocha.Suite(parent);
1393
+ this.parents.unshift(parent);
1394
+ parent = parent.parent;
1395
+ }
1396
+ return this.parents;
1397
+ };
1398
+
1399
+ Spec.prototype.result = function() {
1400
+ var status;
1401
+ status = "failed";
1402
+ if (this.spec.state === "passed" || this.spec.state === "skipped") {
1403
+ status = "passed";
1404
+ }
1405
+ if (this.spec.pending) {
1406
+ status = "pending";
1407
+ }
1408
+ return {
1409
+ status: status,
1410
+ skipped: this.spec.state === "skipped"
1411
+ };
1412
+ };
1413
+
1414
+ return Spec;
1415
+
1416
+ })();
1417
+
1418
+ }).call(this);
1419
+ (function() {
1420
+ Teaspoon.Mocha.Suite = (function() {
1421
+ function Suite(suite) {
1422
+ var ref;
1423
+ this.suite = suite;
1424
+ this.fullDescription = this.suite.fullTitle();
1425
+ this.description = this.suite.title;
1426
+ this.link = "?grep=" + (encodeURIComponent(this.fullDescription));
1427
+ this.parent = ((ref = this.suite.parent) != null ? ref.root : void 0) ? null : this.suite.parent;
1428
+ this.viewId = this.suite.viewId;
1429
+ }
1430
+
1431
+ return Suite;
1432
+
1433
+ })();
1434
+
1435
+ }).call(this);