diff --git a/package.json b/package.json index 95b6df1..e6afc63 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "Marcin Wosinek (https://github.com/marcin-wosinek)", "Mathieu Robin (https://github.com/MathRobin)", "Sam L'ecuyer (https://github.com/samlecuyer)", - "Vilmos Ioo (https://github.com/vilmosioo)" + "Vilmos Ioo (https://github.com/vilmosioo)", + "Jacob Ward (https://github.com/jacobwarduk" ], "dependencies": { "jasmine-matchers-loader": "0.1.0" diff --git a/src/api.js b/src/api.js index e1d0fda..35ab333 100644 --- a/src/api.js +++ b/src/api.js @@ -112,6 +112,7 @@ module.exports = { toBeNumber: require('./toBeNumber'), toBeObject: require('./toBeObject'), toBeOddNumber: require('./toBeOddNumber'), + toBeRegExp: require('./toBeRegExp'), toBeSameLengthAs: require('./toBeSameLengthAs'), toBeShorterThan: require('./toBeShorterThan'), toBeString: require('./toBeString'), diff --git a/src/toBeRegExp.js b/src/toBeRegExp.js new file mode 100644 index 0000000..9ef5cdf --- /dev/null +++ b/src/toBeRegExp.js @@ -0,0 +1,4 @@ +// public +module.exports = function toBeRegExp(actual) { + return actual instanceof RegExp; +}; diff --git a/test/index.js b/test/index.js index 114252b..6b5639b 100644 --- a/test/index.js +++ b/test/index.js @@ -53,6 +53,7 @@ module.exports = { toBeNumber: require('./toBeNumber.spec'), toBeObject: require('./toBeObject.spec'), toBeOddNumber: require('./toBeOddNumber.spec'), + toBeRegExp: require('./toBeRegExp.spec'), toBeSameLengthAs: require('./toBeSameLengthAs.spec'), toBeShorterThan: require('./toBeShorterThan.spec'), toBeString: require('./toBeString.spec'), diff --git a/test/toBeRegExp.spec.js b/test/toBeRegExp.spec.js new file mode 100644 index 0000000..c6096ec --- /dev/null +++ b/test/toBeRegExp.spec.js @@ -0,0 +1,18 @@ +// spec +describe('toBeRegExp', function () { + describe('when invoked', function () { + describe('when value is an instance of RegExp', function () { + it('should confirm', function () { + expect(new RegExp()).toBeRegExp(); + expect(/abc/).toBeRegExp(); + }); + }); + describe('when value is not an instance of RegExp', function () { + it('should deny', function () { + expect(null).not.toBeRegExp(); + expect(function () {}).not.toBeRegExp(); + expect('abc').not.toBeRegExp(); + }); + }); + }); +});