128 lines
3.9 KiB
JavaScript
128 lines
3.9 KiB
JavaScript
/*
|
|
Copyright (c) 2008-2013 Pivotal Labs
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
a copy of this software and associated documentation files (the
|
|
"Software"), to deal in the Software without restriction, including
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be
|
|
included in all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
// Jasmine boot.js for browser runners - exposes external/global interface, builds the Jasmine environment and executes it.
|
|
(function() {
|
|
window.jasmine = jasmineRequire.core(jasmineRequire);
|
|
jasmineRequire.html(jasmine);
|
|
|
|
var env = jasmine.getEnv();
|
|
|
|
var jasmineInterface = {
|
|
describe: function(description, specDefinitions) {
|
|
return env.describe(description, specDefinitions);
|
|
},
|
|
|
|
xdescribe: function(description, specDefinitions) {
|
|
return env.xdescribe(description, specDefinitions);
|
|
},
|
|
|
|
it: function(desc, func) {
|
|
return env.it(desc, func);
|
|
},
|
|
|
|
xit: function(desc, func) {
|
|
return env.xit(desc, func);
|
|
},
|
|
|
|
beforeEach: function(beforeEachFunction) {
|
|
return env.beforeEach(beforeEachFunction);
|
|
},
|
|
|
|
afterEach: function(afterEachFunction) {
|
|
return env.afterEach(afterEachFunction);
|
|
},
|
|
|
|
expect: function(actual) {
|
|
return env.expect(actual);
|
|
},
|
|
|
|
pending: function() {
|
|
return env.pending();
|
|
},
|
|
|
|
addMatchers: function(matchers) {
|
|
return env.addMatchers(matchers);
|
|
},
|
|
|
|
spyOn: function(obj, methodName) {
|
|
return env.spyOn(obj, methodName);
|
|
},
|
|
|
|
clock: env.clock,
|
|
jsApiReporter: new jasmine.JsApiReporter({
|
|
timer: new jasmine.Timer()
|
|
})
|
|
};
|
|
|
|
if (typeof window == "undefined" && typeof exports == "object") {
|
|
extend(exports, jasmineInterface);
|
|
} else {
|
|
extend(window, jasmineInterface);
|
|
}
|
|
|
|
var queryString = new jasmine.QueryString({
|
|
getWindowLocation: function() { return window.location; }
|
|
});
|
|
|
|
// TODO: move all of catching to raise so we don't break our brains
|
|
var catchingExceptions = queryString.getParam("catch");
|
|
env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
|
|
|
|
var htmlReporter = new jasmine.HtmlReporter({
|
|
env: env,
|
|
queryString: queryString,
|
|
onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
|
|
getContainer: function() { return document.body; },
|
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
|
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
|
timer: new jasmine.Timer()
|
|
});
|
|
|
|
env.addReporter(jasmineInterface.jsApiReporter);
|
|
env.addReporter(htmlReporter);
|
|
|
|
var specFilter = new jasmine.HtmlSpecFilter({
|
|
filterString: function() { return queryString.getParam("spec"); }
|
|
});
|
|
|
|
env.specFilter = function(spec) {
|
|
return specFilter.matches(spec.getFullName());
|
|
};
|
|
|
|
var currentWindowOnload = window.onload;
|
|
|
|
window.onload = function() {
|
|
if (currentWindowOnload) {
|
|
currentWindowOnload();
|
|
}
|
|
htmlReporter.initialize();
|
|
env.execute();
|
|
};
|
|
|
|
function extend(destination, source) {
|
|
for (var property in source) destination[property] = source[property];
|
|
return destination;
|
|
}
|
|
|
|
}());
|