Throw error if you add a custom matcher or equality outside of a runnable

[#66789174]
This commit is contained in:
Christopher Amavisca and Greg Cobb
2014-03-05 14:37:17 -08:00
parent a2ac5ef3b6
commit a9e0112a9b
3 changed files with 59 additions and 0 deletions

View File

@@ -42,10 +42,16 @@ getJasmineRequireObj().Env = function(j$) {
};
this.addCustomEqualityTester = function(tester) {
if(!currentRunnable()) {
throw new Error('Custom Equalities must be added in a before function or a spec');
}
runnableResources[currentRunnable().id].customEqualityTesters.push(tester);
};
this.addMatchers = function(matchersToAdd) {
if(!currentRunnable()) {
throw new Error('Matchers must be added in a before function or a spec');
}
var customMatchers = runnableResources[currentRunnable().id].customMatchers;
for (var matcherName in matchersToAdd) {
customMatchers[matcherName] = matchersToAdd[matcherName];