Fix specs filtering

We need to check newer versions of Jasmine and if they're broken, it
would be nice to contribute, but for now I'll just do this quick fix.
This commit is contained in:
Piotr Sarnacki 2012-08-12 02:21:43 +02:00
parent c4a57550e5
commit f7422e15c7
3 changed files with 62 additions and 5 deletions

View File

@ -712,8 +712,36 @@ jasmine.Env = function() {
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL;
this.lastUpdate = 0;
this.specFilter = function() {
return true;
function focusedSpecName() {
var specName;
(function memoizeFocusedSpec() {
if (specName) {
return;
}
var paramMap = [];
var params = window.cachedSearch.substring(1).split('&');
for (var i = 0; i < params.length; i++) {
var p = params[i].split('=');
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
}
specName = paramMap.spec;
})();
if(specName)
specName = specName.replace(/%20/g, ' ');
return specName;
}
this.specFilter = function(spec) {
if(!focusedSpecName()) return true;
return spec.getFullName().indexOf(focusedSpecName()) === 0;
};
this.nextSpecId_ = 0;

View File

@ -712,8 +712,36 @@ jasmine.Env = function() {
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL;
this.lastUpdate = 0;
this.specFilter = function() {
return true;
function focusedSpecName() {
var specName;
(function memoizeFocusedSpec() {
if (specName) {
return;
}
var paramMap = [];
var params = window.cachedSearch.substring(1).split('&');
for (var i = 0; i < params.length; i++) {
var p = params[i].split('=');
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
}
specName = paramMap.spec;
})();
if(specName)
specName = specName.replace(/%20/g, ' ');
return specName;
}
this.specFilter = function(spec) {
if(!focusedSpecName()) return true;
return spec.getFullName().indexOf(focusedSpecName()) === 0;
};
this.nextSpecId_ = 0;

View File

@ -13,6 +13,7 @@
</head>
<body>
<script>
window.cachedSearch = window.location.search;
minispade.require('mocks')
for(key in minispade.modules)
@ -20,7 +21,7 @@
minispade.require(key);
var console_reporter = new jasmine.ConsoleReporter()
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
jasmine.getEnv().addReporter(new jasmine.HtmlReporter());
/* jasmine.getEnv().addReporter(console_reporter); */
jasmine.getEnv().execute();
</script>