Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow additional matchers to be added without monkey patching prototype. #14

Merged
merged 1 commit into from
Sep 11, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions test-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,32 @@ define("ember-cli/test-loader",
function() {
"use strict";

var TestLoader = function() {
var moduleIncludeMatchers = [];
var moduleExcludeMatchers = [];

function addModuleIncludeMatcher(fn) {
moduleIncludeMatchers.push(fn);
};

function addModuleExcludeMatcher(fn) {
moduleExcludeMatchers.push(fn);
};

function checkMatchers(matchers, moduleName) {
var matcher;

for (var i = 0, l = matchers.length; i < l; i++) {
matcher = matchers[i];

if (matcher(moduleName)) {
return true;
}
}

return false;
}

function TestLoader() {
this._didLogMissingUnsee = false;
};

Expand All @@ -18,7 +43,11 @@ define("ember-cli/test-loader",
var moduleName;

for (moduleName in requirejs.entries) {
if (this.shouldLoadModule(moduleName)) {
if (checkMatchers(moduleExcludeMatchers, moduleName)) {
continue;
}

if (checkMatchers(moduleIncludeMatchers, moduleName) || this.shouldLoadModule(moduleName)) {
this.require(moduleName);
this.unsee(moduleName);
}
Expand Down Expand Up @@ -54,8 +83,10 @@ define("ember-cli/test-loader",
};

return {
'default': TestLoader
}
'default': TestLoader,
addModuleIncludeMatcher: addModuleIncludeMatcher,
addModuleExcludeMatcher: addModuleExcludeMatcher
};
}
);
})();