app/assets/javascripts/teabag-jasmine.js in teabag-0.7.0 vs app/assets/javascripts/teabag-jasmine.js in teabag-0.7.1
- old
+ new
@@ -2599,13 +2599,11 @@
"minor": 3,
"build": 1,
"revision": 1354556913
};
(function() {
-
this.Teabag = (function() {
-
function Teabag() {}
Teabag.defer = false;
Teabag.slow = 75;
@@ -2633,10 +2631,11 @@
return new Teabag.Runner();
};
Teabag.resolveDependenciesFromParams = function(all) {
var dep, deps, file, parts, path, paths, _i, _j, _len, _len1;
+
if (all == null) {
all = [];
}
deps = [];
if ((paths = this.location.search.match(/[\?&]file(\[\])?=[^&\?]*/gi)) === null) {
@@ -2658,20 +2657,24 @@
}
return deps;
};
Teabag.log = function() {
+ var e;
+
this.messages.push(arguments[0]);
try {
return console.log.apply(console, arguments);
- } catch (e) {
+ } catch (_error) {
+ e = _error;
throw new Error("Unable to use console.log for logging");
}
};
Teabag.getMessages = function() {
var messages;
+
messages = this.messages;
this.messages = [];
return messages;
};
@@ -2679,13 +2682,11 @@
})();
}).call(this);
(function() {
-
Teabag.Runner = (function() {
-
Runner.run = false;
function Runner() {
if (this.constructor.run) {
return;
@@ -2696,10 +2697,11 @@
this.setup();
}
Runner.prototype.getParams = function() {
var name, param, params, value, _i, _len, _ref, _ref1;
+
params = {};
_ref = Teabag.location.search.substring(1).split("&");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
param = _ref[_i];
_ref1 = param.split("="), name = _ref1[0], value = _ref1[1];
@@ -2742,10 +2744,11 @@
fixture.json = [];
fixture.preload = function() {
var url, urls, _i, _len, _results;
+
urls = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
_results = [];
for (_i = 0, _len = urls.length; _i < _len; _i++) {
url = urls[_i];
_results.push(preload(url));
@@ -2753,10 +2756,11 @@
return _results;
};
fixture.load = function() {
var append, index, url, urls, _i, _j, _len, _results;
+
urls = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), append = arguments[_i++];
if (append == null) {
append = false;
}
if (typeof append !== "boolean") {
@@ -2771,10 +2775,11 @@
return _results;
};
fixture.set = function() {
var append, html, htmls, index, _i, _j, _len, _results;
+
htmls = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), append = arguments[_i++];
if (append == null) {
append = false;
}
if (typeof append !== "boolean") {
@@ -2803,10 +2808,11 @@
return load(url, false, true);
};
load = function(url, append, preload) {
var cached, value;
+
if (preload == null) {
preload = false;
}
if (cached = Teabag.fixture.cache[url]) {
return loadComplete(url, cached.type, cached.content, append, preload);
@@ -2864,40 +2870,45 @@
return Teabag.fixture.el.innerHTML += content;
};
create = function() {
var _ref;
+
Teabag.fixture.el = document.createElement("div");
if (typeof window.$ === 'function') {
Teabag.fixture.$el = $(Teabag.fixture.el);
}
Teabag.fixture.el.id = "teabag-fixtures";
return (_ref = document.body) != null ? _ref.appendChild(Teabag.fixture.el) : void 0;
};
cleanup = function() {
var _base, _ref, _ref1;
+
(_base = Teabag.fixture).el || (_base.el = document.getElementById("teabag-fixtures"));
if ((_ref = Teabag.fixture.el) != null) {
if ((_ref1 = _ref.parentNode) != null) {
_ref1.removeChild(Teabag.fixture.el);
}
}
return Teabag.fixture.el = null;
};
xhrRequest = function(url, callback) {
+ var e;
+
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
+ } catch (_error) {
+ e = _error;
try {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e) {
-
+ } catch (_error) {
+ e = _error;
}
}
}
if (!xhr) {
throw "Unable to make Ajax Request";
@@ -2911,13 +2922,11 @@
}).call(this);
}).call(this);
(function() {
-
Teabag.Reporters.BaseView = (function() {
-
function BaseView() {
this.elements = {};
this.build();
}
@@ -2933,32 +2942,36 @@
return this.el.appendChild(el);
};
BaseView.prototype.createEl = function(type, className) {
var el;
+
if (className == null) {
className = "";
}
el = document.createElement(type);
el.className = className;
return el;
};
BaseView.prototype.findEl = function(id) {
var _base;
+
this.elements || (this.elements = {});
return (_base = this.elements)[id] || (_base[id] = document.getElementById("teabag-" + id));
};
BaseView.prototype.setText = function(id, value) {
var el;
+
el = this.findEl(id);
return el.innerHTML = value;
};
BaseView.prototype.setHtml = function(id, value, add) {
var el;
+
if (add == null) {
add = false;
}
el = this.findEl(id);
if (add) {
@@ -2968,16 +2981,18 @@
}
};
BaseView.prototype.setClass = function(id, value) {
var el;
+
el = this.findEl(id);
return el.className = value;
};
BaseView.prototype.htmlSafe = function(str) {
var el;
+
el = document.createElement("div");
el.appendChild(document.createTextNode(str));
return el.innerHTML;
};
@@ -2990,18 +3005,15 @@
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) {
-
__extends(HTML, _super);
function HTML() {
this.toggleConfig = __bind(this.toggleConfig, this);
-
- this.reportRunnerResults = __bind(this.reportRunnerResults, this);
- this.start = new Teabag.Date().getTime();
+ this.reportRunnerResults = __bind(this.reportRunnerResults, this); this.start = new Teabag.Date().getTime();
this.config = {
"use-catch": true,
"build-full-report": false,
"display-progress": true
};
@@ -3022,10 +3034,11 @@
HTML.__super__.constructor.apply(this, arguments);
}
HTML.prototype.build = function() {
var _ref;
+
this.buildLayout();
this.setText("env-info", this.envInfo());
this.setText("version", Teabag.version);
this.findEl("toggles").onclick = this.toggleConfig;
this.findEl("suites").innerHTML = this.buildSuiteSelect();
@@ -3039,18 +3052,20 @@
return this.buildFilters();
};
HTML.prototype.buildLayout = function() {
var el;
+
el = this.createEl("div");
el.id = "teabag-interface";
el.innerHTML = Teabag.Reporters.HTML.template;
return document.body.appendChild(el);
};
HTML.prototype.buildSuiteSelect = function() {
var options, suite, _i, _len, _ref;
+
if (Teabag.suites.all.length === 1) {
return "";
}
options = [];
_ref = Teabag.suites.all;
@@ -3123,10 +3138,11 @@
return this.setText("stats-" + name, value);
};
HTML.prototype.updateStatus = function(spec) {
var elapsed, result, _ref, _ref1;
+
spec = new Teabag.Spec(spec);
result = spec.result();
if (result.skipped || result.status === "pending") {
this.updateStat("skipped", this.total.skipped += 1);
return;
@@ -3151,10 +3167,11 @@
return this.progress.update(this.total.exist, this.total.run);
};
HTML.prototype.showConfiguration = function() {
var key, value, _ref, _results;
+
_ref = this.config;
_results = [];
for (key in _ref) {
value = _ref[key];
_results.push(this.setClass(key, value ? "active" : ""));
@@ -3166,10 +3183,11 @@
return document.body.className = "teabag-" + status;
};
HTML.prototype.setFilters = function() {
var link;
+
link = [Teabag.root, Teabag.suites.active].join('/');
if (Teabag.params["file"]) {
this.filters.push("<a href='" + link + "'>remove</a> by file: " + Teabag.params["file"]);
}
if (Teabag.params["grep"]) {
@@ -3177,17 +3195,19 @@
}
};
HTML.prototype.readConfig = function() {
var config;
+
if (config = this.cookie("teabag")) {
return this.config = config;
}
};
HTML.prototype.toggleConfig = function(e) {
var button, name;
+
button = e.target;
if (button.tagName.toLowerCase() !== "button") {
return;
}
name = button.getAttribute("id").replace(/^teabag-/, "");
@@ -3204,10 +3224,11 @@
return window.location.href = window.location.href;
};
HTML.prototype.cookie = function(name, value) {
var date, match;
+
if (value == null) {
value = void 0;
}
if (value === void 0) {
name = name.replace(/([.*+?^=!:${}()|[\]\/\\])/g, "\\$1");
@@ -3224,19 +3245,20 @@
})(Teabag.Reporters.BaseView);
}).call(this);
(function() {
- var __hasProp = {}.hasOwnProperty,
+ var _ref, _ref1, _ref2,
+ __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.ProgressView = (function(_super) {
-
__extends(ProgressView, _super);
function ProgressView() {
- return ProgressView.__super__.constructor.apply(this, arguments);
+ _ref = ProgressView.__super__.constructor.apply(this, arguments);
+ return _ref;
}
ProgressView.create = function(displayProgress) {
if (displayProgress == null) {
displayProgress = true;
@@ -3260,64 +3282,67 @@
return ProgressView;
})(Teabag.Reporters.BaseView);
Teabag.Reporters.HTML.SimpleProgressView = (function(_super) {
-
__extends(SimpleProgressView, _super);
function SimpleProgressView() {
- return SimpleProgressView.__super__.constructor.apply(this, arguments);
+ _ref1 = SimpleProgressView.__super__.constructor.apply(this, arguments);
+ return _ref1;
}
SimpleProgressView.prototype.build = function() {
this.el = this.createEl("div", "simple-progress");
return this.el.innerHTML = "<em id=\"teabag-progress-percent\">0%</em>\n<span id=\"teabag-progress-span\" class=\"teabag-indicator\"></span>";
};
SimpleProgressView.prototype.update = function(total, run) {
var percent;
+
percent = total ? Math.ceil((run * 100) / total) : 0;
return this.setHtml("progress-percent", "" + percent + "%");
};
return SimpleProgressView;
})(Teabag.Reporters.HTML.ProgressView);
Teabag.Reporters.HTML.RadialProgressView = (function(_super) {
-
__extends(RadialProgressView, _super);
function RadialProgressView() {
- return RadialProgressView.__super__.constructor.apply(this, arguments);
+ _ref2 = RadialProgressView.__super__.constructor.apply(this, arguments);
+ return _ref2;
}
RadialProgressView.supported = !!document.createElement("canvas").getContext;
RadialProgressView.prototype.build = function() {
this.el = this.createEl("div", "teabag-indicator radial-progress");
return this.el.innerHTML = "<canvas id=\"teabag-progress-canvas\"></canvas>\n<em id=\"teabag-progress-percent\">0%</em>";
};
RadialProgressView.prototype.appendTo = function() {
- var canvas;
+ var canvas, e;
+
RadialProgressView.__super__.appendTo.apply(this, arguments);
this.size = 80;
try {
canvas = this.findEl("progress-canvas");
canvas.width = canvas.height = canvas.style.width = canvas.style.height = this.size;
this.ctx = canvas.getContext("2d");
this.ctx.strokeStyle = "#fff";
return this.ctx.lineWidth = 1.5;
- } catch (e) {
-
+ } catch (_error) {
+ e = _error;
}
};
RadialProgressView.prototype.update = function(total, run) {
var half, percent;
+
percent = total ? Math.ceil((run * 100) / total) : 0;
this.setHtml("progress-percent", "" + percent + "%");
if (!this.ctx) {
return;
}
@@ -3353,10 +3378,11 @@
SpecView.__super__.constructor.apply(this, arguments);
}
SpecView.prototype.build = function() {
var classes;
+
classes = ["spec"];
if (this.spec.pending) {
classes.push("state-pending");
}
SpecView.__super__.build.call(this, classes.join(" "));
@@ -3365,10 +3391,11 @@
return this.parentView.append(this.el);
};
SpecView.prototype.buildParent = function() {
var parent, view;
+
parent = this.spec.parent;
if (parent.viewId) {
return this.views.suites[parent.viewId];
} else {
view = new Teabag.Reporters.HTML.SuiteView(parent, this.reporter);
@@ -3376,10 +3403,11 @@
}
};
SpecView.prototype.buildErrors = function() {
var div, error, html, _i, _len, _ref;
+
div = this.createEl("div");
html = "";
_ref = this.spec.errors();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
error = _ref[_i];
@@ -3389,10 +3417,11 @@
return this.append(div);
};
SpecView.prototype.updateState = function(state, elapsed) {
var classes, result, _base;
+
result = this.spec.result();
classes = ["state-" + state];
if (elapsed > Teabag.slow) {
classes.push("slow");
}
@@ -3414,20 +3443,20 @@
(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.FailureView = (function(_super) {
-
__extends(FailureView, _super);
function FailureView(spec) {
this.spec = spec;
FailureView.__super__.constructor.apply(this, arguments);
}
FailureView.prototype.build = function() {
var error, html, _i, _len, _ref;
+
FailureView.__super__.build.call(this, "spec");
html = "<h1 class=\"teabag-clearfix\"><a href=\"" + this.spec.link + "\">" + this.spec.fullDescription + "</a></h1>";
_ref = this.spec.errors();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
error = _ref[_i];
@@ -3469,10 +3498,11 @@
return this.parentView.append(this.el);
};
SuiteView.prototype.buildParent = function() {
var parent, view;
+
parent = this.suite.parent;
if (!parent) {
return this.reporter;
}
if (parent.viewId) {
@@ -3490,10 +3520,11 @@
return this.ol.appendChild(el);
};
SuiteView.prototype.updateState = function(state) {
var _base;
+
if (this.state === "failed") {
return;
}
this.el.className = "" + (this.el.className.replace(/\s?state-\w+/, "")) + " state-" + state;
if (typeof (_base = this.parentView).updateState === "function") {
@@ -3506,22 +3537,19 @@
})(Teabag.Reporters.BaseView);
}).call(this);
(function() {
-
Teabag.Reporters.HTML.template = "<div class=\"teabag-clearfix\">\n <div id=\"teabag-title\">\n <h1><a href=\"\" id=\"teabag-root-link\">Teabag</a></h1>\n <ul>\n <li>version: <b id=\"teabag-version\"></b></li>\n <li id=\"teabag-env-info\"></li>\n </ul>\n </div>\n <div id=\"teabag-progress\"></div>\n <ul id=\"teabag-stats\">\n <li>passes: <b id=\"teabag-stats-passes\">0</b></li>\n <li>failures: <b id=\"teabag-stats-failures\">0</b></li>\n <li>skipped: <b id=\"teabag-stats-skipped\">0</b></li>\n <li>duration: <b id=\"teabag-stats-duration\">∞</b></li>\n </ul>\n</div>\n\n<div id=\"teabag-controls\" class=\"teabag-clearfix\">\n <div id=\"teabag-toggles\">\n <button id=\"teabag-use-catch\" title=\"Toggle using try/catch wrappers when possible\">Try/Catch</button>\n <button id=\"teabag-build-full-report\" title=\"Toggle building the full report\">Full Report</button>\n <button id=\"teabag-display-progress\" title=\"Toggle displaying progress as tests run\">Progress</button>\n </div>\n <div id=\"teabag-suites\"></div>\n</div>\n\n<hr/>\n\n<div id=\"teabag-filter\">\n <h1>Filtering</h1>\n <ul id=\"teabag-filter-list\"></ul>\n</div>\n\n<div id=\"teabag-report\">\n <ol id=\"teabag-report-failures\"></ol>\n <ol id=\"teabag-report-all\"></ol>\n</div>";
}).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.reportRunnerResults = __bind(this.reportRunnerResults, this); this.start = new Teabag.Date();
this.suites = {};
}
Console.prototype.reportRunnerStarting = function(runner) {
return this.log({
@@ -3531,10 +3559,11 @@
});
};
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]) {
@@ -3550,10 +3579,11 @@
return _results;
};
Console.prototype.reportSpecResults = function(spec) {
var result;
+
this.spec = new Teabag.Spec(spec);
result = this.spec.result();
if (result.skipped) {
return;
}
@@ -3574,10 +3604,11 @@
}
};
Console.prototype.trackPending = function() {
var result;
+
result = this.spec.result();
return this.log({
type: "spec",
suite: this.spec.suiteName,
label: this.spec.description,
@@ -3586,10 +3617,11 @@
});
};
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];
@@ -3628,28 +3660,30 @@
})();
}).call(this);
(function() {
- var __hasProp = {}.hasOwnProperty,
+ var _ref,
+ __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) {
-
__extends(HTML, _super);
function HTML() {
- return HTML.__super__.constructor.apply(this, arguments);
+ _ref = HTML.__super__.constructor.apply(this, arguments);
+ return _ref;
}
HTML.prototype.readConfig = function() {
HTML.__super__.readConfig.apply(this, arguments);
return jasmine.CATCH_EXCEPTIONS = this.config["use-catch"];
};
HTML.prototype.envInfo = function() {
var ver, verString;
+
ver = jasmine.getEnv().version();
verString = [ver.major, ver.minor, ver.build].join(".");
return "jasmine " + verString + " revision " + ver.revision;
};
@@ -3657,25 +3691,25 @@
})(Teabag.Reporters.HTML);
}).call(this);
(function() {
- var env,
+ var env, _ref,
__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.Runner = (function(_super) {
-
__extends(Runner, _super);
function Runner() {
Runner.__super__.constructor.apply(this, arguments);
env.execute();
}
Runner.prototype.setup = function() {
var grep, reporter;
+
env.updateInterval = 1000;
if (grep = this.params["grep"]) {
env.specFilter = function(spec) {
return spec.getFullName().indexOf(grep) === 0;
};
@@ -3698,11 +3732,10 @@
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));
@@ -3712,10 +3745,11 @@
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 = [];
@@ -3732,10 +3766,11 @@
return _results;
};
Spec.prototype.getParents = function() {
var parent;
+
if (this.parents) {
return this.parents;
}
this.parents || (this.parents = []);
parent = this.parent;
@@ -3747,10 +3782,11 @@
return this.parents;
};
Spec.prototype.result = function() {
var results, status;
+
results = this.spec.results();
status = "failed";
if (results.passed()) {
status = "passed";
}
@@ -3766,11 +3802,10 @@
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));
@@ -3781,22 +3816,23 @@
return Suite;
})();
Teabag.fixture = (function(_super) {
-
__extends(fixture, _super);
function fixture() {
- return fixture.__super__.constructor.apply(this, arguments);
+ _ref = fixture.__super__.constructor.apply(this, arguments);
+ return _ref;
}
window.fixture = fixture;
fixture.load = function() {
var args,
_this = this;
+
args = arguments;
if (!(env.currentSuite || env.currentSpec)) {
throw "Teabag can't load fixtures outside of describe.";
}
if (env.currentSuite) {
@@ -3816,9 +3852,10 @@
};
fixture.set = function() {
var args,
_this = this;
+
args = arguments;
if (!(env.currentSuite || env.currentSpec)) {
throw "Teabag can't load fixtures outside of describe.";
}
if (env.currentSuite) {