Instead of dev boot use a custom helper to defined j$
This commit is contained in:
parent
fb853ad5b5
commit
305bd73142
7
spec/helpers/defineJasmineUnderTest.js
Normal file
7
spec/helpers/defineJasmineUnderTest.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
(function() {
|
||||||
|
// By the time onload is called, jasmineRequire will be redefined to point
|
||||||
|
// to the Jasmine source files (and not jasmine.js). So re-require
|
||||||
|
window.j$ = jasmineRequire.core(jasmineRequire);
|
||||||
|
jasmineRequire.html(j$);
|
||||||
|
jasmineRequire.console(jasmineRequire, j$);
|
||||||
|
})();
|
||||||
@@ -34,7 +34,7 @@ describe("New HtmlReporter", function() {
|
|||||||
it("starts the timer when jasmine begins", function() {
|
it("starts the timer when jasmine begins", function() {
|
||||||
var env = new jasmine.Env(),
|
var env = new jasmine.Env(),
|
||||||
startTimerSpy = jasmine.createSpy("start-timer-spy"),
|
startTimerSpy = jasmine.createSpy("start-timer-spy"),
|
||||||
reporter = new jasmine.HtmlReporter({
|
reporter = new j$.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
timer: { start: startTimerSpy }
|
timer: { start: startTimerSpy }
|
||||||
|
|||||||
@@ -1,124 +0,0 @@
|
|||||||
// 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();
|
|
||||||
},
|
|
||||||
|
|
||||||
spyOn: function(obj, methodName) {
|
|
||||||
return env.spyOn(obj, methodName);
|
|
||||||
},
|
|
||||||
|
|
||||||
jsApiReporter: new jasmine.JsApiReporter({
|
|
||||||
timer: new jasmine.Timer()
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
if (typeof window == "undefined" && typeof exports == "object") {
|
|
||||||
extend(exports, jasmineInterface);
|
|
||||||
} else {
|
|
||||||
extend(window, jasmineInterface);
|
|
||||||
}
|
|
||||||
|
|
||||||
jasmine.addCustomEqualityTester = function(tester) {
|
|
||||||
env.addCustomEqualityTester(tester);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.addMatchers = function(matchers) {
|
|
||||||
return env.addMatchers(matchers);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.clock = function() {
|
|
||||||
return env.clock;
|
|
||||||
};
|
|
||||||
|
|
||||||
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,
|
|
||||||
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());
|
|
||||||
};
|
|
||||||
|
|
||||||
window.setTimeout = window.setTimeout;
|
|
||||||
window.setInterval = window.setInterval;
|
|
||||||
window.clearTimeout = window.clearTimeout;
|
|
||||||
window.clearInterval = window.clearInterval;
|
|
||||||
|
|
||||||
var currentWindowOnload = window.onload;
|
|
||||||
|
|
||||||
window.onload = function() {
|
|
||||||
if (currentWindowOnload) {
|
|
||||||
currentWindowOnload();
|
|
||||||
}
|
|
||||||
htmlReporter.initialize();
|
|
||||||
|
|
||||||
// By the time onload is called, jasmineRequire will be redefined to point
|
|
||||||
// to the Jasmine source files (and not jasmine.js). So re-require
|
|
||||||
window.j$ = jasmineRequire.core(jasmineRequire);
|
|
||||||
jasmineRequire.html(j$);
|
|
||||||
jasmineRequire.console(jasmineRequire, j$);
|
|
||||||
|
|
||||||
env.execute();
|
|
||||||
};
|
|
||||||
|
|
||||||
function extend(destination, source) {
|
|
||||||
for (var property in source) destination[property] = source[property];
|
|
||||||
return destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
}());
|
|
||||||
@@ -15,9 +15,6 @@ src_files:
|
|||||||
- 'html/**.js'
|
- 'html/**.js'
|
||||||
- '**/*.js'
|
- '**/*.js'
|
||||||
stylesheets:
|
stylesheets:
|
||||||
boot_dir: 'spec/support'
|
|
||||||
boot_files:
|
|
||||||
- 'dev_boot.js'
|
|
||||||
helpers:
|
helpers:
|
||||||
- 'helpers/**/*.js'
|
- 'helpers/**/*.js'
|
||||||
spec_files:
|
spec_files:
|
||||||
|
|||||||
Reference in New Issue
Block a user