Skip to content
Browse files

match matcher supports nonstrings and non RegExp objects.

  • Loading branch information...
1 parent f307d4a commit 2b4ae48f2f7916ea3c59bf89ccdf9977a83ec0d4 @btakita btakita committed May 7, 2008
Showing with 10 additions and 3 deletions.
  1. +3 −3 lib/screw.matchers.js
  2. +7 −0 spec/matchers_spec.js
View
6 lib/screw.matchers.js
@@ -39,10 +39,10 @@ Screw.Matchers = (function($) {
match: {
match: function(expected, actual) {
- if (expected.constructor == String)
- return actual.indexOf(expected) > -1;
+ if (expected.constructor == RegExp)
+ return expected.exec(actual.toString());
else
- return expected.exec(actual);
+ return actual.indexOf(expected) > -1;
},
failure_message: function(expected, actual, not) {
View
7 spec/matchers_spec.js
@@ -52,6 +52,13 @@ Screw.Unit(function() {
expect("The wheels of the bus").to_not(match, "oars");
});
});
+
+ describe('when given an integer', function() {
+ it("matches [expected]s containing [actual]s", function() {
+ expect("1 time").to(match, 1);
+ expect("2 times").to_not(match, 3);
+ });
+ });
describe(".failure_message", function() {
it('prints "expected "actual" to (not) match "expected"', function() {

0 comments on commit 2b4ae48

Please sign in to comment.
Something went wrong with that request. Please try again.