Move specFilter function to TrivialReporter.
This commit is contained in:
parent
e476f2375a
commit
b1a007dfb5
|
@ -10,25 +10,23 @@
|
|||
<script type="text/javascript"></script>
|
||||
<link href="/jasmine/lib/jasmine.css" rel="stylesheet"/>
|
||||
<script type="text/javascript">
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
var jsApiReporter = new jasmine.JsApiReporter();
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
var paramMap = {};
|
||||
var params = document.location.search.substring(1).split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
var jsApiReporter;
|
||||
(function() {
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jsApiReporter = new jasmine.JsApiReporter();
|
||||
var trivialReporter = new jasmine.TrivialReporter();
|
||||
|
||||
if (!paramMap["spec"]) return true;
|
||||
return spec.getFullName().indexOf(paramMap["spec"]) > -1;
|
||||
};
|
||||
jasmineEnv.addReporter(jsApiReporter);
|
||||
jasmineEnv.addReporter(trivialReporter);
|
||||
|
||||
jasmineEnv.addReporter(jsApiReporter);
|
||||
jasmineEnv.addReporter(new jasmine.TrivialReporter());
|
||||
window.onload = function() {
|
||||
jasmineEnv.execute();
|
||||
};
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
return trivialReporter.specFilter(spec);
|
||||
};
|
||||
|
||||
window.onload = function() {
|
||||
jasmineEnv.execute();
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
|
||||
<% spec_files.each do |spec_file| %>
|
||||
|
|
|
@ -59,6 +59,22 @@ jasmine.TrivialReporter.prototype.log = function() {
|
|||
console.log.apply(console, arguments);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
||||
return document.location;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||
var paramMap = {};
|
||||
var params = this.getLocation().search.substring(1).split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
if (!paramMap["spec"]) return true;
|
||||
return spec.getFullName().indexOf(paramMap["spec"]) > -1;
|
||||
};
|
||||
|
||||
//protect against console.log incidents
|
||||
if (!("console" in window) || !("firebug" in console)) {
|
||||
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
||||
|
|
|
@ -37,31 +37,11 @@
|
|||
jasmine.include('suites/RunnerTest.js', true);
|
||||
jasmine.include('suites/SpecRunningTest.js', true);
|
||||
jasmine.include('suites/SpyTest.js', true);
|
||||
jasmine.include('suites/TrivialReporterTest.js', true);
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
.spec {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.passed {
|
||||
background-color: lightgreen;
|
||||
}
|
||||
|
||||
.failed {
|
||||
background-color: pink;
|
||||
}
|
||||
|
||||
.resultMessage {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.stackTrace {
|
||||
white-space: pre;
|
||||
font-size: .8em;
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
<link href="../lib/jasmine.css" rel="stylesheet"/>
|
||||
|
||||
<body>
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
describe("TrivialReporter", function() {
|
||||
function fakeSpec(name) {
|
||||
return {
|
||||
getFullName: function() { return name; }
|
||||
};
|
||||
}
|
||||
|
||||
it("should allow for focused spec running", function() {
|
||||
var trivialReporter = new jasmine.TrivialReporter();
|
||||
spyOn(trivialReporter, 'getLocation').andReturn({search: "?spec=run%20this"});
|
||||
expect(trivialReporter.specFilter(fakeSpec("run this"))).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should not run specs that don't match the filter", function() {
|
||||
var trivialReporter = new jasmine.TrivialReporter();
|
||||
spyOn(trivialReporter, 'getLocation').andReturn({search: "?spec=run%20this"});
|
||||
expect(trivialReporter.specFilter(fakeSpec("not the right spec"))).toBeFalsy();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue