teaspoon-qunit 1.18.0

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 (46) hide show
  1. checksums.yaml +7 -0
  2. data/lib/teaspoon-qunit.rb +4 -0
  3. data/lib/teaspoon/qunit/assets/qunit/1.12.0.js +2212 -0
  4. data/lib/teaspoon/qunit/assets/qunit/1.13.0.js +2210 -0
  5. data/lib/teaspoon/qunit/assets/qunit/1.14.0.js +2288 -0
  6. data/lib/teaspoon/qunit/assets/qunit/1.15.0.js +2495 -0
  7. data/lib/teaspoon/qunit/assets/qunit/1.16.0.js +2819 -0
  8. data/lib/teaspoon/qunit/assets/qunit/1.17.1.js +2875 -0
  9. data/lib/teaspoon/qunit/assets/qunit/1.18.0.js +3828 -0
  10. data/lib/teaspoon/qunit/assets/qunit/MIT.LICENSE +21 -0
  11. data/lib/teaspoon/qunit/assets/teaspoon-qunit.js +1529 -0
  12. data/lib/teaspoon/qunit/assets/teaspoon/qunit.coffee +19 -0
  13. data/lib/teaspoon/qunit/assets/teaspoon/qunit/initialize.coffee +11 -0
  14. data/lib/teaspoon/qunit/assets/teaspoon/qunit/reporters/html.coffee +20 -0
  15. data/lib/teaspoon/qunit/assets/teaspoon/qunit/reporters/html/failure_view.coffee +10 -0
  16. data/lib/teaspoon/qunit/assets/teaspoon/qunit/reporters/html/spec_view.coffee +21 -0
  17. data/lib/teaspoon/qunit/assets/teaspoon/qunit/reporters/html/suite_view.coffee +8 -0
  18. data/lib/teaspoon/qunit/assets/teaspoon/qunit/responder.coffee +48 -0
  19. data/lib/teaspoon/qunit/assets/teaspoon/qunit/runner.coffee +12 -0
  20. data/lib/teaspoon/qunit/assets/teaspoon/qunit/spec.coffee +45 -0
  21. data/lib/teaspoon/qunit/assets/teaspoon/qunit/suite.coffee +16 -0
  22. data/lib/teaspoon/qunit/framework.rb +36 -0
  23. data/lib/teaspoon/qunit/templates/test_helper.coffee +29 -0
  24. data/lib/teaspoon/qunit/templates/test_helper.js +30 -0
  25. data/lib/teaspoon/qunit/version.rb +5 -0
  26. data/spec/console_spec.rb +75 -0
  27. data/spec/installation_spec.rb +35 -0
  28. data/spec/integration_spec.rb +73 -0
  29. data/spec/spec_helper.rb +11 -0
  30. data/test/javascripts/integration/_implementation.coffee +1 -0
  31. data/test/javascripts/integration/first_integration.coffee +14 -0
  32. data/test/javascripts/integration/second_integration.coffee +6 -0
  33. data/test/javascripts/integration/test_helper.coffee +9 -0
  34. data/test/javascripts/qunit/fixture_test.coffee +10 -0
  35. data/test/javascripts/qunit/reporters/console_test.coffee +3 -0
  36. data/test/javascripts/qunit/reporters/html/failure_view_test.coffee +3 -0
  37. data/test/javascripts/qunit/reporters/html/spec_view_test.coffee +3 -0
  38. data/test/javascripts/qunit/reporters/html/suite_view_test.coffee +3 -0
  39. data/test/javascripts/qunit/reporters/html_test.coffee +3 -0
  40. data/test/javascripts/qunit/responder_test.coffee +153 -0
  41. data/test/javascripts/qunit/runner_test.coffee +24 -0
  42. data/test/javascripts/qunit/spec_test.coffee +53 -0
  43. data/test/javascripts/qunit/suite_test.coffee +10 -0
  44. data/test/javascripts/test_helper.coffee +4 -0
  45. data/test/teaspoon_env.rb +12 -0
  46. metadata +124 -0
@@ -0,0 +1,21 @@
1
+ Copyright 2013 jQuery Foundation and other contributors
2
+ http://jquery.com/
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,1529 @@
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 QUnit === "undefined" || QUnit === null) {
1164
+ throw new Teaspoon.Error('QUnit not found -- use `suite.use_framework :qunit` and adjust or remove the `suite.javascripts` directive.');
1165
+ }
1166
+
1167
+ if (this.Teaspoon == null) {
1168
+ this.Teaspoon = {};
1169
+ }
1170
+
1171
+ this.Teaspoon.Qunit = {
1172
+ version: function() {
1173
+ var versions;
1174
+ versions = this.rawVersion().split('.');
1175
+ return {
1176
+ major: versions[0],
1177
+ minor: versions[1],
1178
+ patch: versions[2]
1179
+ };
1180
+ },
1181
+ rawVersion: function() {
1182
+ return QUnit.version || _qunit_version;
1183
+ }
1184
+ };
1185
+
1186
+ if ((base = this.Teaspoon.Qunit).Reporters == null) {
1187
+ base.Reporters = {};
1188
+ }
1189
+
1190
+ if ((base1 = this.Teaspoon.Qunit.Reporters).HTML == null) {
1191
+ base1.HTML = {};
1192
+ }
1193
+
1194
+ }).call(this);
1195
+ (function() {
1196
+ var originalReset;
1197
+
1198
+ Teaspoon.setFramework(Teaspoon.Qunit);
1199
+
1200
+ QUnit.config.autostart = false;
1201
+
1202
+ QUnit.config.altertitle = false;
1203
+
1204
+ QUnit.config.filter = Teaspoon.Runner.prototype.getParams()["grep"];
1205
+
1206
+ originalReset = QUnit.reset;
1207
+
1208
+ QUnit.reset = function() {
1209
+ originalReset();
1210
+ return Teaspoon.Fixture.cleanup();
1211
+ };
1212
+
1213
+ }).call(this);
1214
+ (function() {
1215
+ 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; },
1216
+ hasProp = {}.hasOwnProperty;
1217
+
1218
+ Teaspoon.Qunit.Reporters.HTML = (function(superClass) {
1219
+ extend(HTML, superClass);
1220
+
1221
+ function HTML() {
1222
+ return HTML.__super__.constructor.apply(this, arguments);
1223
+ }
1224
+
1225
+ HTML.prototype.reportRunnerResults = function(runner) {
1226
+ var version;
1227
+ version = Teaspoon.Qunit.version();
1228
+ if (version.major = 1 && version.minor < 16) {
1229
+ this.total.exist = this.total.run = runner.total;
1230
+ }
1231
+ return HTML.__super__.reportRunnerResults.apply(this, arguments);
1232
+ };
1233
+
1234
+ HTML.prototype.readConfig = function() {
1235
+ HTML.__super__.readConfig.apply(this, arguments);
1236
+ return QUnit.config.notrycatch = this.config["use-catch"];
1237
+ };
1238
+
1239
+ HTML.prototype.envInfo = function() {
1240
+ return "qunit " + (Teaspoon.Qunit.rawVersion() || "[unknown version]");
1241
+ };
1242
+
1243
+ return HTML;
1244
+
1245
+ })(Teaspoon.Reporters.HTML);
1246
+
1247
+ }).call(this);
1248
+ (function() {
1249
+ 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; },
1250
+ hasProp = {}.hasOwnProperty;
1251
+
1252
+ Teaspoon.Qunit.Reporters.HTML.FailureView = (function(superClass) {
1253
+ extend(FailureView, superClass);
1254
+
1255
+ function FailureView() {
1256
+ return FailureView.__super__.constructor.apply(this, arguments);
1257
+ }
1258
+
1259
+ FailureView.prototype.build = function() {
1260
+ var error, html, i, len, ref;
1261
+ FailureView.__super__.build.call(this, "spec");
1262
+ html = "<h1 class=\"teaspoon-clearfix\"><a href=\"" + this.spec.link + "\">" + (this.htmlSafe(this.spec.fullDescription)) + "</a></h1>";
1263
+ ref = this.spec.errors();
1264
+ for (i = 0, len = ref.length; i < len; i++) {
1265
+ error = ref[i];
1266
+ html += "<div><strong>" + error.message + "</strong><br/>" + (this.htmlSafe(error.stack || "Stack trace unavailable")) + "</div>";
1267
+ }
1268
+ return this.el.innerHTML = html;
1269
+ };
1270
+
1271
+ return FailureView;
1272
+
1273
+ })(Teaspoon.Reporters.HTML.FailureView);
1274
+
1275
+ }).call(this);
1276
+ (function() {
1277
+ 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; },
1278
+ hasProp = {}.hasOwnProperty;
1279
+
1280
+ Teaspoon.Qunit.Reporters.HTML.SpecView = (function(superClass) {
1281
+ extend(SpecView, superClass);
1282
+
1283
+ function SpecView() {
1284
+ return SpecView.__super__.constructor.apply(this, arguments);
1285
+ }
1286
+
1287
+ SpecView.prototype.buildErrors = function() {
1288
+ var div, error, html, i, len, ref;
1289
+ div = this.createEl("div");
1290
+ html = "";
1291
+ ref = this.spec.errors();
1292
+ for (i = 0, len = ref.length; i < len; i++) {
1293
+ error = ref[i];
1294
+ html += "<strong>" + error.message + "</strong><br/>" + (this.htmlSafe(error.stack || "Stack trace unavailable")) + "<br/>";
1295
+ }
1296
+ div.innerHTML = html;
1297
+ return this.append(div);
1298
+ };
1299
+
1300
+ SpecView.prototype.buildParent = function() {
1301
+ var parent, view;
1302
+ parent = this.spec.parent;
1303
+ if (!parent) {
1304
+ return this.reporter;
1305
+ }
1306
+ if (this.views.suites[parent.description]) {
1307
+ return this.views.suites[parent.description];
1308
+ } else {
1309
+ view = new Teaspoon.Qunit.Reporters.HTML.SuiteView(parent, this.reporter);
1310
+ return this.views.suites[parent.description] = view;
1311
+ }
1312
+ };
1313
+
1314
+ return SpecView;
1315
+
1316
+ })(Teaspoon.Reporters.HTML.SpecView);
1317
+
1318
+ }).call(this);
1319
+ (function() {
1320
+ 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; },
1321
+ hasProp = {}.hasOwnProperty;
1322
+
1323
+ Teaspoon.Qunit.Reporters.HTML.SuiteView = (function(superClass) {
1324
+ extend(SuiteView, superClass);
1325
+
1326
+ function SuiteView(suite, reporter) {
1327
+ this.suite = suite;
1328
+ this.reporter = reporter;
1329
+ this.views = this.reporter.views;
1330
+ this.views.suites[this.suite.description] = this;
1331
+ this.build();
1332
+ }
1333
+
1334
+ return SuiteView;
1335
+
1336
+ })(Teaspoon.Reporters.HTML.SuiteView);
1337
+
1338
+ }).call(this);
1339
+ (function() {
1340
+ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
1341
+
1342
+ Teaspoon.Qunit.Responder = (function() {
1343
+ function Responder(qunit, reporter) {
1344
+ var version;
1345
+ this.reporter = reporter;
1346
+ this.assertionDone = bind(this.assertionDone, this);
1347
+ this.specDone = bind(this.specDone, this);
1348
+ this.suiteDone = bind(this.suiteDone, this);
1349
+ this.suiteStarted = bind(this.suiteStarted, this);
1350
+ this.runnerDone = bind(this.runnerDone, this);
1351
+ this.runnerStarted = bind(this.runnerStarted, this);
1352
+ version = Teaspoon.Qunit.version();
1353
+ if (version.major = 1 && version.minor > 15) {
1354
+ qunit.begin(this.runnerStarted);
1355
+ } else {
1356
+ this.reporter.reportRunnerStarting({
1357
+ total: null
1358
+ });
1359
+ }
1360
+ qunit.done(this.runnerDone);
1361
+ qunit.moduleStart(this.suiteStarted);
1362
+ qunit.moduleDone(this.suiteDone);
1363
+ qunit.testDone(this.specDone);
1364
+ qunit.log(this.assertionDone);
1365
+ this.assertions = [];
1366
+ }
1367
+
1368
+ Responder.prototype.runnerStarted = function(runner) {
1369
+ return this.reporter.reportRunnerStarting({
1370
+ total: runner.totalTests
1371
+ });
1372
+ };
1373
+
1374
+ Responder.prototype.runnerDone = function(runner) {
1375
+ return this.reporter.reportRunnerResults(runner);
1376
+ };
1377
+
1378
+ Responder.prototype.suiteStarted = function(suite) {
1379
+ return this.reporter.reportSuiteStarting(new Teaspoon.Qunit.Suite(suite));
1380
+ };
1381
+
1382
+ Responder.prototype.suiteDone = function(suite) {
1383
+ return this.reporter.reportSuiteResults(new Teaspoon.Qunit.Suite(suite));
1384
+ };
1385
+
1386
+ Responder.prototype.specDone = function(spec) {
1387
+ spec.assertions = this.assertions;
1388
+ this.assertions = [];
1389
+ spec = new Teaspoon.Qunit.Spec(spec);
1390
+ this.reporter.reportSpecStarting(spec);
1391
+ return this.reporter.reportSpecResults(spec);
1392
+ };
1393
+
1394
+ Responder.prototype.assertionDone = function(assertion) {
1395
+ return this.assertions.push(assertion);
1396
+ };
1397
+
1398
+ return Responder;
1399
+
1400
+ })();
1401
+
1402
+ }).call(this);
1403
+ (function() {
1404
+ 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; },
1405
+ hasProp = {}.hasOwnProperty;
1406
+
1407
+ Teaspoon.Qunit.Runner = (function(superClass) {
1408
+ extend(Runner, superClass);
1409
+
1410
+ function Runner() {
1411
+ Runner.__super__.constructor.apply(this, arguments);
1412
+ QUnit.start();
1413
+ }
1414
+
1415
+ Runner.prototype.setup = function() {
1416
+ var reporter;
1417
+ reporter = new (this.getReporter())();
1418
+ return new Teaspoon.Qunit.Responder(QUnit, reporter);
1419
+ };
1420
+
1421
+ return Runner;
1422
+
1423
+ })(Teaspoon.Runner);
1424
+
1425
+ }).call(this);
1426
+ (function() {
1427
+ Teaspoon.Qunit.Spec = (function() {
1428
+ function Spec(spec1) {
1429
+ this.spec = spec1;
1430
+ this.fullDescription = this.spec.module + " " + this.spec.name;
1431
+ this.description = this.spec.name + " (" + this.spec.failed + ", " + this.spec.passed + ", " + this.spec.total + ")";
1432
+ this.link = "?grep=" + (encodeURIComponent(this.spec.module + ": " + this.spec.name));
1433
+ this.parent = this.spec.module ? new Teaspoon.Qunit.Suite({
1434
+ description: this.spec.module
1435
+ }) : null;
1436
+ this.suiteName = this.spec.module;
1437
+ this.viewId = this.spec.viewId;
1438
+ this.pending = false;
1439
+ }
1440
+
1441
+ Spec.prototype.errors = function() {
1442
+ var i, item, len, ref, results;
1443
+ if (!this.spec.failed) {
1444
+ return [];
1445
+ }
1446
+ ref = this.spec.assertions;
1447
+ results = [];
1448
+ for (i = 0, len = ref.length; i < len; i++) {
1449
+ item = ref[i];
1450
+ if (item.result) {
1451
+ continue;
1452
+ }
1453
+ this.provideFallbackMessage(item);
1454
+ results.push({
1455
+ message: item.message,
1456
+ stack: item.source
1457
+ });
1458
+ }
1459
+ return results;
1460
+ };
1461
+
1462
+ Spec.prototype.getParents = function() {
1463
+ if (!this.parent) {
1464
+ return [];
1465
+ }
1466
+ return [this.parent];
1467
+ };
1468
+
1469
+ Spec.prototype.result = function() {
1470
+ var status;
1471
+ status = "failed";
1472
+ if (this.spec.failed === 0) {
1473
+ status = "passed";
1474
+ }
1475
+ return {
1476
+ status: status,
1477
+ skipped: false
1478
+ };
1479
+ };
1480
+
1481
+ Spec.prototype.provideFallbackMessage = function(item) {
1482
+ if (item.message) {
1483
+ return;
1484
+ }
1485
+ if (item.actual && item.expected) {
1486
+ return item.message || (item.message = "Expected " + (JSON.stringify(item.actual)) + " to equal " + (JSON.stringify(item.expected)));
1487
+ } else {
1488
+ return item.message = 'failed';
1489
+ }
1490
+ };
1491
+
1492
+ return Spec;
1493
+
1494
+ })();
1495
+
1496
+ Teaspoon.Spec = (function() {
1497
+ function Spec(spec) {
1498
+ return spec;
1499
+ }
1500
+
1501
+ return Spec;
1502
+
1503
+ })();
1504
+
1505
+ }).call(this);
1506
+ (function() {
1507
+ Teaspoon.Qunit.Suite = (function() {
1508
+ function Suite(suite1) {
1509
+ this.suite = suite1;
1510
+ this.fullDescription = this.suite.description || this.suite.name;
1511
+ this.description = this.suite.description || this.suite.name;
1512
+ this.link = "?grep=" + (encodeURIComponent(this.fullDescription));
1513
+ this.parent = null;
1514
+ }
1515
+
1516
+ return Suite;
1517
+
1518
+ })();
1519
+
1520
+ Teaspoon.Suite = (function() {
1521
+ function Suite(suite) {
1522
+ return new Teaspoon.Qunit.Suite(suite);
1523
+ }
1524
+
1525
+ return Suite;
1526
+
1527
+ })();
1528
+
1529
+ }).call(this);