Created
August 30, 2011 15:33
-
-
Save mneedham/1181179 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ContainsElementMatchingCriteria { | |
| def apply[T](allCriteria: Seq[Criteria[T]]) = { | |
| new Matcher[Seq[T]] { | |
| def apply(actual: Seq[T]) = { | |
| MatchResult( | |
| actual.exists((result: T) => allCriteria.forall(_.matches(result))), | |
| "No search result exists with criteria " + allCriteria + " in " + actual, | |
| "An element exists with criteria " + allCriteria + " in " + actual | |
| ) | |
| } | |
| } | |
| } | |
| } | |
| def thereShouldBeASearchResult(criterias: Criteria[SearchResultSection]*) = { | |
| val searchResults = searchResultsPage.searchResults() | |
| searchResults.exists(resultSection => criterias.forall(criteria => criteria.matches(resultSection))) should be(true) | |
| } | |
| vs | |
| def thereShouldBeASearchResult(criterias: Criteria[SearchResultSection]*) = { | |
| val searchResults = searchResultsPage.searchResults() | |
| searchResults.should containAll(criterias) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment