Move specFilter function to TrivialReporter.
This commit is contained in:
parent
e476f2375a
commit
b1a007dfb5
@ -10,25 +10,23 @@
|
|||||||
<script type="text/javascript"></script>
|
<script type="text/javascript"></script>
|
||||||
<link href="/jasmine/lib/jasmine.css" rel="stylesheet"/>
|
<link href="/jasmine/lib/jasmine.css" rel="stylesheet"/>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var jasmineEnv = jasmine.getEnv();
|
var jsApiReporter;
|
||||||
var jsApiReporter = new jasmine.JsApiReporter();
|
(function() {
|
||||||
jasmineEnv.specFilter = function(spec) {
|
var jasmineEnv = jasmine.getEnv();
|
||||||
var paramMap = {};
|
jsApiReporter = new jasmine.JsApiReporter();
|
||||||
var params = document.location.search.substring(1).split('&');
|
var trivialReporter = new jasmine.TrivialReporter();
|
||||||
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;
|
jasmineEnv.addReporter(jsApiReporter);
|
||||||
return spec.getFullName().indexOf(paramMap["spec"]) > -1;
|
jasmineEnv.addReporter(trivialReporter);
|
||||||
};
|
|
||||||
|
|
||||||
jasmineEnv.addReporter(jsApiReporter);
|
jasmineEnv.specFilter = function(spec) {
|
||||||
jasmineEnv.addReporter(new jasmine.TrivialReporter());
|
return trivialReporter.specFilter(spec);
|
||||||
window.onload = function() {
|
};
|
||||||
jasmineEnv.execute();
|
|
||||||
};
|
window.onload = function() {
|
||||||
|
jasmineEnv.execute();
|
||||||
|
};
|
||||||
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<% spec_files.each do |spec_file| %>
|
<% spec_files.each do |spec_file| %>
|
||||||
|
@ -59,6 +59,22 @@ jasmine.TrivialReporter.prototype.log = function() {
|
|||||||
console.log.apply(console, arguments);
|
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
|
//protect against console.log incidents
|
||||||
if (!("console" in window) || !("firebug" in console)) {
|
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"];
|
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/RunnerTest.js', true);
|
||||||
jasmine.include('suites/SpecRunningTest.js', true);
|
jasmine.include('suites/SpecRunningTest.js', true);
|
||||||
jasmine.include('suites/SpyTest.js', true);
|
jasmine.include('suites/SpyTest.js', true);
|
||||||
|
jasmine.include('suites/TrivialReporterTest.js', true);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style type="text/css">
|
|
||||||
.spec {
|
|
||||||
margin: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.passed {
|
<link href="../lib/jasmine.css" rel="stylesheet"/>
|
||||||
background-color: lightgreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
.failed {
|
|
||||||
background-color: pink;
|
|
||||||
}
|
|
||||||
|
|
||||||
.resultMessage {
|
|
||||||
white-space: pre;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stackTrace {
|
|
||||||
white-space: pre;
|
|
||||||
font-size: .8em;
|
|
||||||
margin-left: 10px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
19
spec/suites/TrivialReporterTest.js
Normal file
19
spec/suites/TrivialReporterTest.js
Normal file
@ -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
Block a user