Permalink
Browse files

Change completely to the left of to to the right of matcher

  • Loading branch information...
1 parent 0f64ea1 commit 20fbe2780ecbdbfc01e4f79da488c5f3804f03c8 @joshuaclayton committed Jun 7, 2010
Showing with 10 additions and 12 deletions.
  1. +1 −1 README.markdown
  2. +4 −6 specit.js
  3. +5 −5 specit.tests.js
View
@@ -65,7 +65,7 @@ I don't have the patience to write my own JS testing framework so I figured I'd
* beEmpty (checks if an array, object literal, or string is empty)
* beOnThePage (checks that an element is present on a page)
* beToTheLeftOf (checks that an element is to the left of another element)
-* beCompletelyToTheLeftOf (checks that an element is completely to the left of another element)
+* beToTheRightOf (checks that an element is to the right of another element)
## Other supported features
View
@@ -101,7 +101,7 @@
beOnThePage: "Expected {actual} {not} to be on the page",
beEmpty: "Expected {actual} {not} to be empty",
beToTheLeftOf: "Expected {actual} {not} to be to the left of {expected}",
- beCompletelyToTheLeftOf:"Expected {actual} {not} to be completely to the left of {expected}",
+ beToTheRightOf: "Expected {actual} {not} to be to the right of {expected}",
}, message, options = arguments[3];
message = matcherMessages[matcher];
@@ -222,11 +222,9 @@
expected: {value: $(arguments[0]).selector, parse: true},
actual: {value: $(this).selector, parse: true}});
},
- beCompletelyToTheLeftOf: function() {
- console.log($(this).offset());
- console.log($(arguments[0]).offset());
- Matcher("beCompletelyToTheLeftOf", "ok",
- {assert: ($(this).offset().left + $(this).width()) < $(arguments[0]).offset().left,
+ beToTheRightOf: function() {
+ Matcher("beToTheRightOf", "ok",
+ {assert: ($(this).offset().left > ($(arguments[0]).offset().left + $(arguments[0]).width())),
expected: {value: $(arguments[0]).selector, parse: true},
actual: {value: $(this).selector, parse: true}});
},
View
@@ -266,11 +266,11 @@ describe("SpecIt should know relative positions", function() {
$(".left-right-broken .left").shouldNot(beToTheLeftOf, ".left-right-broken .right");
});
- it("should know if an element is completely to the left of another", function() {
- $(".left-right-correct .left").should(beCompletelyToTheLeftOf, ".left-right-correct .right");
- $(".left-right-correct .text-1").shouldNot(beCompletelyToTheLeftOf, ".left-right-correct .text-2");
+ it("should know if an element is to the right of", function() {
+ $(".left-right-correct .right").should(beToTheRightOf, ".left-right-correct .left");
+ $(".left-right-correct .text-2").shouldNot(beToTheRightOf, ".left-right-correct .text-1");
- $(".left-right-correct .right").shouldNot(beCompletelyToTheLeftOf, ".left-right-correct .left");
- $(".left-right-broken .left").shouldNot(beCompletelyToTheLeftOf, ".left-right-broken .right");
+ $(".left-right-correct .left").shouldNot(beToTheRightOf, ".left-right-correct .right");
+ $(".left-right-broken .right").shouldNot(beToTheRightOf, ".left-right-broken .left");
});
});

0 comments on commit 20fbe27

Please sign in to comment.