The pain:
val someString = "how are you today?"
val expectedWordsInStringList = List("how", "you")
How can i match that the string contains all the expected words ?
//would of liked to have: (there is no method containAllElements)
someString must containAllElements(expectedWordsInStringList)
Ended up writing this test (and not happy about the result)
class HowToMatchListOfMatcher extends Specification {
"HowToMatchListOfMatcher" should {
"not use reduce to match on list of matchers" in {
val testString = "some string with 1 and 2"
val containList:List[String] = List("1", "2")
val matcherList:List[Matcher[String]] = List(contain("1"), contain("2"))
def matchAll(matcherList: List[Matcher[String]]) = matcherList.reduce((m1,m2)=> m1 and m2)
//how can i match this without reduce ? or with using the containList
testString must matchAll(matcherList)
}
}
}
Aucun commentaire:
Enregistrer un commentaire