Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: adscott/jasmine-underscore
base: 41f3f6e5f5
...
head fork: adscott/jasmine-underscore
compare: 70e244161e
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
8 README.markdown
@@ -70,6 +70,14 @@ Underscore has a number of methods for interrogating state. Any underscore funct
- `toInclude(1)`
- `expect([1, 2, 3, 4]).toInclude(2);`
+
+- `toMatchAll`
+ - `expect([2, 4, 6]).toMatchAll(function (val) { return val%2 == 0; });`
+ - `expect([1, 4, 6]).not.toMatchAll(function (val) { return val%2 == 0; });`
+
+- `toMatchAny`
+ - `expect([2, 3, 5]).toMatchAny(function (val) { return val%2 == 0; });`
+ - `expect([1, 3, 5]).not.toMatchAny(function (val) { return val%2 == 0; });`
## Using examples
View
15 lib/jasmine-underscore.js
@@ -13,7 +13,7 @@
var allowedFunctions = {
booleanFunctions : {
- names: ['isEmpty',
+ names : ['isEmpty',
'isElement',
'isArray',
'isArguments',
@@ -26,7 +26,9 @@
'isNaN',
'isNull',
'isUndefined',
- 'include'],
+ 'include',
+ 'all',
+ 'any'],
registrationFunction: function (functionName, matcherName) {
jasmine.Matchers.prototype[matcherName] = function () {
return u(this.actual, functionName, arguments);
@@ -35,22 +37,23 @@
},
equalityFunctions : {
- names: ['compact',
+ names : ['compact',
'flatten',
'uniq',
'without'],
- registrationFunction: function (functionName, matcherName) {
+ registrationFunction : function (functionName, matcherName) {
jasmine.Matchers.prototype[matcherName] = function () {
return _(u(this.actual, functionName, arguments)).isEqual(this.actual);
};
}
}
-
},
overrides = {
'flatten' : 'toBeFlat',
'uniq' : 'toHaveUniqueValues',
- 'include' : 'toInclude'
+ 'include' : 'toInclude',
+ 'all' : 'toMatchAll',
+ 'any' : 'toMatchAny'
};
_(_).chain().keys().each(function (key) {
View
13 spec/jasmine-underscore-spec.js
@@ -77,6 +77,19 @@ describe('jasmine-underscore', function () {
expect([1, 2, 3, 4]).toInclude(2);
});
});
+
+ describe('predicate matchers', function () {
+ it('should match all', function () {
+ expect([1, 4, 6]).not.toMatchAll(function (val) { return val%2 == 0; });
+ expect([2, 4, 6]).toMatchAll(function (val) { return val%2 == 0; });
+ });
+
+ it('should match any', function () {
+ expect([1, 3, 5]).not.toMatchAny(function (val) { return val%2 == 0; });
+ expect([2, 3, 5]).toMatchAny(function (val) { return val%2 == 0; });
+ });
+
+ });
describe('negated matchers', function () {
it('should not be boolean', function () {

No commit comments for this range

Something went wrong with that request. Please try again.