Permalink
Browse files

Add less than matcher

  • Loading branch information...
1 parent 199ebcc commit 4be1de550fe4827ce5e4cc7f2d6428e4b93bfa3a @joshuaclayton committed Jun 6, 2010
Showing with 20 additions and 1 deletion.
  1. +1 −0 README.markdown
  2. +8 −1 specit.js
  3. +11 −0 specit.tests.js
View
@@ -32,6 +32,7 @@ I don't have the patience to write my own JS testing framework so I figured I'd
* beA, beAn (checks type)
* match (checks against a regular expression)
* respondTo (checks that a function exists)
+* beLessThan (checks a number is less than another)
## What's it do?
View
@@ -83,7 +83,8 @@
beA: "Expected {actual} {not} to be a",
beAn: "Expected {actual} {not} to be an",
match: "Expected {actual} {not} to match {expected}",
- respondTo: "Expected {expected} {not} to be a method of {actual}"
+ respondTo: "Expected {expected} {not} to be a method of {actual}",
+ beLessThan: "Expected {actual} {not} to be less than {expected}"
}, message, options = arguments[3];
message = matcherMessages[matcher];
@@ -149,6 +150,12 @@
expected: {value: arguments[0], parse: true},
actual: {value: this, parse: true}});
},
+ beLessThan: function() {
+ Matcher("beLessThan", "ok",
+ {assert: this < arguments[0],
+ expected: {value: arguments[0], parse: true},
+ actual: {value: this, parse: true}});
+ },
}
});
View
@@ -102,4 +102,15 @@ describe("SpecIt", function() {
john.shouldNot(respondTo, "age");
john.shouldNot(respondTo, "sayGoodbye");
});
+
+ it("should match on less than", function() {
+ ( 2).should(beLessThan, 5);
+ ( -5).should(beLessThan, 0);
+ ( 0).should(beLessThan, 0.1);
+ "awesome".should(beLessThan, "great");
+ ( 5).shouldNot(beLessThan, 3);
+ (0.1).shouldNot(beLessThan, 0);
+ (0.1).shouldNot(beLessThan, 0.05);
+ ( 5).shouldNot(beLessThan, 5);
+ });
});

0 comments on commit 4be1de5

Please sign in to comment.