Restore Matcher prototype methods for IDE joy
This commit is contained in:
@@ -536,7 +536,7 @@ jasmine.version_= {
|
||||
"major": 0,
|
||||
"minor": 10,
|
||||
"build": 0,
|
||||
"revision": 1256879901
|
||||
"revision": 1256956024
|
||||
};
|
||||
/**
|
||||
* @namespace
|
||||
@@ -1003,8 +1003,8 @@ jasmine.Matchers.prototype.report = function(result, failing_message, details) {
|
||||
return result;
|
||||
};
|
||||
|
||||
jasmine.Matchers.addMatcher = function(matcherName, options) {
|
||||
jasmine.Matchers.prototype[matcherName] = function () {
|
||||
jasmine.Matchers.matcherFn_ = function(matcherName, options) {
|
||||
return function () {
|
||||
jasmine.util.extend(this, options);
|
||||
var matcherArgs = jasmine.util.argsToArray(arguments);
|
||||
var args = [this.actual].concat(matcherArgs);
|
||||
@@ -1026,12 +1026,14 @@ jasmine.Matchers.addMatcher = function(matcherName, options) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* toBe: compares the actual to the expected using ===
|
||||
* @param expected
|
||||
*/
|
||||
|
||||
jasmine.Matchers.addMatcher('toBe', {
|
||||
jasmine.Matchers.prototype.toBe = jasmine.Matchers.matcherFn_('toBe', {
|
||||
test: function (actual, expected) {
|
||||
return actual === expected;
|
||||
},
|
||||
@@ -1044,7 +1046,7 @@ jasmine.Matchers.addMatcher('toBe', {
|
||||
* toNotBe: compares the actual to the expected using !==
|
||||
* @param expected
|
||||
*/
|
||||
jasmine.Matchers.addMatcher('toNotBe', {
|
||||
jasmine.Matchers.prototype.toNotBe = jasmine.Matchers.matcherFn_('toNotBe', {
|
||||
test: function (actual, expected) {
|
||||
return actual !== expected;
|
||||
},
|
||||
@@ -1059,7 +1061,7 @@ jasmine.Matchers.addMatcher('toNotBe', {
|
||||
* @param expected
|
||||
*/
|
||||
|
||||
jasmine.Matchers.addMatcher('toEqual', {
|
||||
jasmine.Matchers.prototype.toEqual = jasmine.Matchers.matcherFn_('toEqual', {
|
||||
test: function (actual, expected) {
|
||||
return this.env.equals_(actual, expected);
|
||||
},
|
||||
@@ -1072,7 +1074,7 @@ jasmine.Matchers.addMatcher('toEqual', {
|
||||
* toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
|
||||
* @param expected
|
||||
*/
|
||||
jasmine.Matchers.addMatcher('toNotEqual', {
|
||||
jasmine.Matchers.prototype.toNotEqual = jasmine.Matchers.matcherFn_('toNotEqual', {
|
||||
test: function (actual, expected) {
|
||||
return !this.env.equals_(actual, expected);
|
||||
},
|
||||
@@ -1087,7 +1089,7 @@ jasmine.Matchers.addMatcher('toNotEqual', {
|
||||
*
|
||||
* @param reg_exp
|
||||
*/
|
||||
jasmine.Matchers.addMatcher('toMatch', {
|
||||
jasmine.Matchers.prototype.toMatch = jasmine.Matchers.matcherFn_('toMatch', {
|
||||
test: function(actual, expected) {
|
||||
return new RegExp(expected).test(actual);
|
||||
},
|
||||
@@ -1101,7 +1103,7 @@ jasmine.Matchers.addMatcher('toMatch', {
|
||||
* @param reg_exp
|
||||
*/
|
||||
|
||||
jasmine.Matchers.addMatcher('toNotMatch', {
|
||||
jasmine.Matchers.prototype.toNotMatch = jasmine.Matchers.matcherFn_('toNotMatch', {
|
||||
test: function(actual, expected) {
|
||||
return !(new RegExp(expected).test(actual));
|
||||
},
|
||||
@@ -1114,7 +1116,7 @@ jasmine.Matchers.addMatcher('toNotMatch', {
|
||||
* Matcher that compares the acutal to undefined.
|
||||
*/
|
||||
|
||||
jasmine.Matchers.addMatcher('toBeDefined', {
|
||||
jasmine.Matchers.prototype.toBeDefined = jasmine.Matchers.matcherFn_('toBeDefined', {
|
||||
test: function(actual) {
|
||||
return (actual !== undefined);
|
||||
},
|
||||
@@ -1127,7 +1129,7 @@ jasmine.Matchers.addMatcher('toBeDefined', {
|
||||
* Matcher that compares the acutal to undefined.
|
||||
*/
|
||||
|
||||
jasmine.Matchers.addMatcher('toBeUndefined', {
|
||||
jasmine.Matchers.prototype.toBeUndefined = jasmine.Matchers.matcherFn_('toBeUndefined', {
|
||||
test: function(actual) {
|
||||
return (actual === undefined);
|
||||
},
|
||||
@@ -1140,7 +1142,7 @@ jasmine.Matchers.addMatcher('toBeUndefined', {
|
||||
* Matcher that compares the actual to null.
|
||||
*
|
||||
*/
|
||||
jasmine.Matchers.addMatcher('toBeNull', {
|
||||
jasmine.Matchers.prototype.toBeNull = jasmine.Matchers.matcherFn_('toBeNull', {
|
||||
test: function(actual) {
|
||||
return (actual === null);
|
||||
},
|
||||
@@ -1152,7 +1154,7 @@ jasmine.Matchers.addMatcher('toBeNull', {
|
||||
/**
|
||||
* Matcher that boolean not-nots the actual.
|
||||
*/
|
||||
jasmine.Matchers.addMatcher('toBeTruthy', {
|
||||
jasmine.Matchers.prototype.toBeTruthy = jasmine.Matchers.matcherFn_('toBeTruthy', {
|
||||
test: function(actual) {
|
||||
return !!actual;
|
||||
},
|
||||
@@ -1165,7 +1167,7 @@ jasmine.Matchers.addMatcher('toBeTruthy', {
|
||||
/**
|
||||
* Matcher that boolean nots the actual.
|
||||
*/
|
||||
jasmine.Matchers.addMatcher('toBeFalsy', {
|
||||
jasmine.Matchers.prototype.toBeFalsy = jasmine.Matchers.matcherFn_('toBeFalsy', {
|
||||
test: function(actual) {
|
||||
return !actual;
|
||||
},
|
||||
@@ -1178,7 +1180,7 @@ jasmine.Matchers.addMatcher('toBeFalsy', {
|
||||
* Matcher that checks to see if the acutal, a Jasmine spy, was called.
|
||||
*/
|
||||
|
||||
jasmine.Matchers.addMatcher('wasCalled', {
|
||||
jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.matcherFn_('wasCalled', {
|
||||
getActual_: function() {
|
||||
var args = jasmine.util.argsToArray(arguments);
|
||||
if (args.length > 1) {
|
||||
@@ -1205,7 +1207,7 @@ jasmine.Matchers.addMatcher('wasCalled', {
|
||||
/**
|
||||
* Matcher that checks to see if the acutal, a Jasmine spy, was not called.
|
||||
*/
|
||||
jasmine.Matchers.addMatcher('wasNotCalled', {
|
||||
jasmine.Matchers.prototype.wasNotCalled = jasmine.Matchers.matcherFn_('wasNotCalled', {
|
||||
getActual_: function() {
|
||||
var args = jasmine.util.argsToArray(arguments);
|
||||
return args.splice(0, 1)[0];
|
||||
@@ -1226,7 +1228,7 @@ jasmine.Matchers.addMatcher('wasNotCalled', {
|
||||
}
|
||||
});
|
||||
|
||||
jasmine.Matchers.addMatcher('wasCalledWith', {
|
||||
jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.matcherFn_('wasCalledWith', {
|
||||
test: function() {
|
||||
var args = jasmine.util.argsToArray(arguments);
|
||||
var actual = args.splice(0, 1)[0];
|
||||
@@ -1261,7 +1263,7 @@ jasmine.Matchers.addMatcher('wasCalledWith', {
|
||||
* @param {Object} item
|
||||
*/
|
||||
|
||||
jasmine.Matchers.addMatcher('toContain', {
|
||||
jasmine.Matchers.prototype.toContain = jasmine.Matchers.matcherFn_('toContain', {
|
||||
test: function(actual, expected) {
|
||||
return this.env.contains_(actual, expected);
|
||||
},
|
||||
@@ -1275,7 +1277,7 @@ jasmine.Matchers.addMatcher('toContain', {
|
||||
*
|
||||
* @param {Object} item
|
||||
*/
|
||||
jasmine.Matchers.addMatcher('toNotContain', {
|
||||
jasmine.Matchers.prototype.toNotContain = jasmine.Matchers.matcherFn_('toNotContain', {
|
||||
test: function(actual, expected) {
|
||||
return !this.env.contains_(actual, expected);
|
||||
},
|
||||
@@ -1284,7 +1286,7 @@ jasmine.Matchers.addMatcher('toNotContain', {
|
||||
}
|
||||
});
|
||||
|
||||
jasmine.Matchers.addMatcher('toBeLessThan', {
|
||||
jasmine.Matchers.prototype.toBeLessThan = jasmine.Matchers.matcherFn_('toBeLessThan', {
|
||||
test: function(actual, expected) {
|
||||
return actual < expected;
|
||||
},
|
||||
@@ -1293,7 +1295,7 @@ jasmine.Matchers.addMatcher('toBeLessThan', {
|
||||
}
|
||||
});
|
||||
|
||||
jasmine.Matchers.addMatcher('toBeGreaterThan', {
|
||||
jasmine.Matchers.prototype.toBeGreaterThan = jasmine.Matchers.matcherFn_('toBeGreaterThan', {
|
||||
test: function(actual, expected) {
|
||||
return actual > expected;
|
||||
},
|
||||
@@ -1307,7 +1309,7 @@ jasmine.Matchers.addMatcher('toBeGreaterThan', {
|
||||
*
|
||||
* @param {String} expectedException
|
||||
*/
|
||||
jasmine.Matchers.addMatcher('toThrow', {
|
||||
jasmine.Matchers.prototype.toThrow = jasmine.Matchers.matcherFn_('toThrow', {
|
||||
getException_: function(actual, expected) {
|
||||
var exception;
|
||||
if (typeof actual != 'function') {
|
||||
|
||||
Reference in New Issue
Block a user