Permalink
Browse files

Add greater than matcher

  • Loading branch information...
1 parent 2363948 commit 83d01c23f50343066c39e28844579bfad990b724 @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
@@ -34,6 +34,7 @@ I don't have the patience to write my own JS testing framework so I figured I'd
* respondTo (checks that a function exists)
* beLessThan (checks a number is less than another)
* beLessThanOrEqualTo (checks a number is less than or equal to another)
+* beGreaterThan (checks a number is greater than another)
## What's it do?
View
@@ -85,7 +85,8 @@
match: "Expected {actual} {not} to match {expected}",
respondTo: "Expected {expected} {not} to be a method of {actual}",
beLessThan: "Expected {actual} {not} to be less than {expected}",
- beLessThanOrEqualTo: "Expected {actual} {not} to be less than or equal to {expected}"
+ beLessThanOrEqualTo: "Expected {actual} {not} to be less than or equal to {expected}",
+ beGreaterThan: "Expected {actual} {not} to be greater than {expected}",
}, message, options = arguments[3];
message = matcherMessages[matcher];
@@ -163,6 +164,12 @@
expected: {value: arguments[0], parse: true},
actual: {value: this, parse: true}});
},
+ beGreaterThan: function() {
+ Matcher("beGreaterThan", "ok",
+ {assert: this > arguments[0],
+ expected: {value: arguments[0], parse: true},
+ actual: {value: this, parse: true}});
+ },
}
});
View
@@ -127,4 +127,15 @@ describe("SpecIt", function() {
(0.1).shouldNot(beLessThanOrEqualTo, 0);
(0.1).shouldNot(beLessThanOrEqualTo, 0.05);
});
+
+ it("should match on greater than", function() {
+ ( 2).should(beGreaterThan, 1);
+ ( -5).should(beGreaterThan, -10);
+ ( 0).should(beGreaterThan, -0.1);
+ "awesome".should(beGreaterThan, "absolute");
+ ( 5).shouldNot(beGreaterThan, 30);
+ (0.1).shouldNot(beGreaterThan, 0.2);
+ (0.01).shouldNot(beGreaterThan, 0.05);
+ ( 5).shouldNot(beGreaterThan, 5);
+ });
});

0 comments on commit 83d01c2

Please sign in to comment.