Skip to content
Browse files

Added the be_empty matcher.

  • Loading branch information...
1 parent 8fd460d commit e374b49baed90a095bdba4809f0b15e05163becc @btakita btakita committed
Showing with 15 additions and 0 deletions.
  1. +8 −0 lib/screw.builder.js
  2. +7 −0 spec/screwunit_spec.js
View
8 lib/screw.builder.js
@@ -93,6 +93,14 @@ var Screw = {
if (actual[i] != expected[i]) { return false }
return actual.length == expected.length;
}
+ },
+ be_empty: {
+ match: function(expected, actual) {
+ if(actual.length == undefined) {
+ throw(actual.toString() + " does not respond to length");
+ }
+ return actual.length == 0;
+ }
}
}
};
View
7 spec/screwunit_spec.js
@@ -10,6 +10,13 @@ Screw.Unit(function() {
expect([1, 2, 4]).to(equal, [1, 2, 3]);
expect([1, 2, 3]).to_not(equal, [3, 2, 1]);
});
+
+ describe("#be_empty", function() {
+ it("matches on Array#lenth == 0", function() {
+ expect([]).to(be_empty);
+ expect([1]).to_not(be_empty);
+ })
+ });
});
describe('#run', function() {

0 comments on commit e374b49

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