app/assets/javascripts/teabag-jasmine.js in teabag-0.3.5 vs app/assets/javascripts/teabag-jasmine.js in teabag-0.3.6

- old
+ new

@@ -2620,18 +2620,33 @@ Teabag.location = window.location; Teabag.console = window.console; + Teabag.messages = []; + Teabag.execute = function() { if (this.defer) { this.defer = false; return; } return new Teabag.Runner(); }; + Teabag.log = function() { + var _ref; + this.messages.push(arguments[0]); + return (_ref = this.console).log.apply(_ref, arguments); + }; + + Teabag.getMessages = function() { + var messages; + messages = this.messages; + this.messages = []; + return messages; + }; + return Teabag; })(); }).call(this); @@ -2661,112 +2676,31 @@ params[decodeURIComponent(name)] = decodeURIComponent(value); } return params; }; - Runner.prototype.setup = function() {}; - - return Runner; - - })(); - -}).call(this); -(function() { - - Teabag.Reporters.NormalizedSpec = (function() { - - function NormalizedSpec(spec) { - var _base, _base1; - this.spec = spec; - this.fullDescription = (typeof (_base = this.spec).getFullName === "function" ? _base.getFullName() : void 0) || this.spec.fullTitle(); - this.description || (this.description = this.spec.description || this.spec.title); - this.link = "?grep=" + (encodeURIComponent(this.fullDescription)); - this.parent = this.spec.suite || this.spec.parent; - this.suiteName = (typeof (_base1 = this.parent).getFullName === "function" ? _base1.getFullName() : void 0) || this.parent.fullTitle(); - this.viewId = this.spec.viewId; - this.pending = this.spec.pending; - } - - NormalizedSpec.prototype.errors = function() { - var item, _i, _len, _ref, _results; - if (this.spec.err) { - return [this.spec.err]; - } - if (!this.spec.results) { - return []; - } - _ref = this.spec.results().getItems(); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - item = _ref[_i]; - if (item.passed()) { - continue; - } - _results.push({ - message: item.message, - stack: item.trace.stack - }); - } - return _results; - }; - - NormalizedSpec.prototype.result = function() { - var results, skipped, status; - status = "failed"; - if (this.spec.results) { - results = this.spec.results(); - if (results.passed()) { - status = "passed"; - } - skipped = results.skipped; + Runner.prototype.getReporter = function() { + if (this.params["reporter"]) { + return Teabag.Reporters[this.params["reporter"]]; } else { - if (this.spec.state === "passed" || this.spec.state === "skipped") { - status = "passed"; - } - skipped = this.spec.state === "skipped"; - } - if (this.spec.pending) { - status = "pending"; - } - return { - status: status, - skipped: skipped - }; - }; - - return NormalizedSpec; - - })(); - - Teabag.Reporters.NormalizedSuite = (function() { - - function NormalizedSuite(suite) { - var _base; - this.suite = suite; - this.fullDescription = (typeof (_base = this.suite).getFullName === "function" ? _base.getFullName() : void 0) || this.suite.fullTitle(); - this.description = this.suite.description || this.suite.title; - this.link = "?grep=" + (encodeURIComponent(this.fullDescription)); - this.parent = this.getParent(); - this.viewId = this.suite.viewId; - } - - NormalizedSuite.prototype.getParent = function() { - if (this.suite.parent) { - if (this.suite.parent.root) { - return null; + if (window.navigator.userAgent.match(/PhantomJS/)) { + return Teabag.Reporters.Console; } else { - return this.suite.parent; + return Teabag.Reporters.HTML; } - } else { - return this.suite.parentSuite; } }; - return NormalizedSuite; + Runner.prototype.setup = function() {}; + return Runner; + })(); +}).call(this); +(function() { + Teabag.Reporters.BaseView = (function() { function BaseView() { this.elements = {}; this.build(); @@ -2801,11 +2735,11 @@ }; BaseView.prototype.setText = function(id, value) { var el; el = this.findEl(id); - return el.innerText = value; + return el.innerHTML = value; }; BaseView.prototype.setHtml = function(id, value, add) { var el; if (add == null) { @@ -2836,97 +2770,10 @@ })(); }).call(this); (function() { - var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - Teabag.Reporters.Console = (function() { - - function Console() { - this.reportRunnerResults = __bind(this.reportRunnerResults, this); - this.start = new Teabag.Date().getTime(); - } - - Console.prototype.reportSpecResults = function(spec) { - var result; - this.spec = new Teabag.Reporters.NormalizedSpec(spec); - result = this.spec.result(); - switch (result.status) { - case "pending": - return this.trackPending(); - case "failed": - return this.trackFailure(); - default: - return this.log({ - type: "spec", - suite: this.spec.suiteName, - spec: this.spec.description, - status: result.status, - skipped: result.skipped, - full_description: this.spec.fullDescription - }); - } - }; - - Console.prototype.trackPending = function() { - var result; - result = this.spec.result(); - return this.log({ - type: "spec", - suite: this.spec.suiteName, - spec: this.spec.description, - status: result.status, - skipped: result.skipped, - full_description: this.spec.fullDescription - }); - }; - - Console.prototype.trackFailure = function() { - var error, result, _i, _len, _ref, _results; - result = this.spec.result(); - _ref = this.spec.errors(); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - error = _ref[_i]; - _results.push(this.log({ - type: "spec", - suite: this.spec.suiteName, - spec: this.spec.description, - status: result.status, - skipped: result.skipped, - full_description: this.spec.fullDescription, - link: this.spec.link, - message: error.message, - trace: error.stack || error.message || "Stack Trace Unavailable" - })); - } - return _results; - }; - - Console.prototype.reportRunnerResults = function() { - this.log({ - type: "results", - elapsed: ((new Teabag.Date().getTime() - this.start) / 1000).toFixed(5) - }); - return Teabag.finished = true; - }; - - Console.prototype.log = function(obj) { - if (obj == null) { - obj = {}; - } - obj["_teabag"] = true; - return Teabag.console.log(JSON.stringify(obj)); - }; - - return Console; - - })(); - -}).call(this); -(function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = {}.hasOwnProperty, __extends = 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; }; Teabag.Reporters.HTML = (function(_super) { @@ -2987,11 +2834,11 @@ return this.setText("stats-duration", "..."); } }; HTML.prototype.reportSpecStarting = function(spec) { - spec = new Teabag.Reporters.NormalizedSpec(spec); + spec = new Teabag.Spec(spec); if (this.config["build-full-report"]) { this.reportView = new Teabag.Reporters.HTML.SpecView(spec, this); } return this.specStart = new Teabag.Date().getTime(); }; @@ -3031,11 +2878,11 @@ return this.setText("stats-" + name, value); }; HTML.prototype.updateStatus = function(spec) { var elapsed, result, _ref, _ref1; - spec = new Teabag.Reporters.NormalizedSpec(spec); + spec = new Teabag.Spec(spec); result = spec.result(); if (result.skipped || result.status === "pending") { this.updateStat("skipped", this.total.skipped += 1); return; } @@ -3115,11 +2962,11 @@ match = document.cookie.match(new RegExp("(?:^|;)\\s?" + name + "=(.*?)(?:;|$)", "i")); return match && JSON.parse(unescape(match[1]).split(" ")[0]); } else { date = new Teabag.Date(); date.setDate(date.getDate() + 365); - return document.cookie = "" + name + "=" + (escape(JSON.stringify(value))) + "; path=/; expires=" + (date.toUTCString()) + ";"; + return document.cookie = "" + name + "=" + (escape(JSON.stringify(value))) + "; path=\"/\"; expires=" + (date.toUTCString()) + ";"; } }; return HTML; @@ -3357,11 +3204,11 @@ this.suite = suite; this.reporter = reporter; this.views = this.reporter.views; this.suite.viewId = viewId += 1; this.views.suites[this.suite.viewId] = this; - this.suite = new Teabag.Reporters.NormalizedSuite(suite); + this.suite = new Teabag.Suite(suite); SuiteView.__super__.constructor.apply(this, arguments); } SuiteView.prototype.build = function() { SuiteView.__super__.build.call(this, "suite"); @@ -3407,10 +3254,123 @@ })(Teabag.Reporters.BaseView); }).call(this); (function() { + var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + + Teabag.Reporters.Console = (function() { + + function Console() { + this.reportRunnerResults = __bind(this.reportRunnerResults, this); + this.start = new Teabag.Date(); + this.suites = {}; + } + + Console.prototype.reportRunnerStarting = function(runner) { + return this.log({ + type: "runner", + total: runner.total || runner.specs().length, + start: JSON.parse(JSON.stringify(this.start)) + }); + }; + + Console.prototype.reportSuites = function() { + var index, suite, _i, _len, _ref, _results; + _ref = this.spec.getParents(); + _results = []; + for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) { + suite = _ref[index]; + if (this.suites[suite.fullDescription]) { + continue; + } + this.suites[suite.fullDescription] = true; + _results.push(this.log({ + type: "suite", + label: suite.description, + level: index + })); + } + return _results; + }; + + Console.prototype.reportSpecResults = function(spec) { + var result; + this.spec = new Teabag.Spec(spec); + result = this.spec.result(); + this.reportSuites(); + switch (result.status) { + case "pending": + return this.trackPending(); + case "failed": + return this.trackFailure(); + default: + return this.log({ + type: "spec", + suite: this.spec.suiteName, + label: this.spec.description, + status: result.status, + skipped: result.skipped + }); + } + }; + + Console.prototype.trackPending = function() { + var result; + result = this.spec.result(); + return this.log({ + type: "spec", + suite: this.spec.suiteName, + label: this.spec.description, + status: result.status, + skipped: result.skipped + }); + }; + + Console.prototype.trackFailure = function() { + var error, result, _i, _len, _ref, _results; + result = this.spec.result(); + _ref = this.spec.errors(); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + error = _ref[_i]; + _results.push(this.log({ + type: "spec", + suite: this.spec.suiteName, + label: this.spec.description, + status: result.status, + skipped: result.skipped, + link: this.spec.link, + message: error.message, + trace: error.stack || error.message || "Stack Trace Unavailable" + })); + } + return _results; + }; + + Console.prototype.reportRunnerResults = function() { + this.log({ + type: "result", + elapsed: ((new Teabag.Date().getTime() - this.start.getTime()) / 1000).toFixed(5) + }); + return Teabag.finished = true; + }; + + Console.prototype.log = function(obj) { + if (obj == null) { + obj = {}; + } + obj["_teabag"] = true; + return Teabag.log(JSON.stringify(obj)); + }; + + return Console; + + })(); + +}).call(this); +(function() { var __hasProp = {}.hasOwnProperty, __extends = 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; }; Teabag.Reporters.HTML = (function(_super) { @@ -3459,15 +3419,11 @@ if (grep = this.params["grep"]) { env.specFilter = function(spec) { return spec.getFullName().indexOf(grep) === 0; }; } - if (navigator.userAgent.match(/PhantomJS/)) { - reporter = new Teabag.Reporters.Console(); - } else { - reporter = new Teabag.Reporters.HTML(); - } + reporter = new (this.getReporter())(); if (typeof reporter.setFilter === "function") { reporter.setFilter(this.params["grep"]); } env.addReporter(reporter); return this.addFixtureSupport(); @@ -3484,7 +3440,90 @@ }; return Runner; })(Teabag.Runner); + + Teabag.Spec = (function() { + + function Spec(spec) { + this.spec = spec; + this.fullDescription = this.spec.getFullName(); + this.description = this.spec.description; + this.link = "?grep=" + (encodeURIComponent(this.fullDescription)); + this.parent = this.spec.suite; + this.suiteName = this.parent.getFullName(); + this.viewId = this.spec.viewId; + this.pending = this.spec.pending; + } + + Spec.prototype.errors = function() { + var item, _i, _len, _ref, _results; + if (!this.spec.results) { + return []; + } + _ref = this.spec.results().getItems(); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + item = _ref[_i]; + if (item.passed()) { + continue; + } + _results.push({ + message: item.message, + stack: item.trace.stack + }); + } + return _results; + }; + + Spec.prototype.getParents = function() { + var parent; + if (this.parents) { + return this.parents; + } + this.parents || (this.parents = []); + parent = this.parent; + while (parent) { + parent = new Teabag.Suite(parent); + this.parents.unshift(parent); + parent = parent.parent; + } + return this.parents; + }; + + Spec.prototype.result = function() { + var results, status; + results = this.spec.results(); + status = "failed"; + if (results.passed()) { + status = "passed"; + } + if (this.spec.pending) { + status = "pending"; + } + return { + status: status, + skipped: results.skipped + }; + }; + + return Spec; + + })(); + + Teabag.Suite = (function() { + + function Suite(suite) { + this.suite = suite; + this.fullDescription = this.suite.getFullName(); + this.description = this.suite.description; + this.link = "?grep=" + (encodeURIComponent(this.fullDescription)); + this.parent = this.suite.parentSuite; + this.viewId = this.suite.viewId; + } + + return Suite; + + })(); }).call(this);