Hi Ismael,
That sounds more like an allElementsOf. The allOf/only/etc. constructs all take varargs except for theSameElementsAs and theSameElementsInOrderAs. The word "elements" in there is a cue it will be looking inside a collection. So the consistently named construct would be:
list should contain allElementsOf(splitList)
Do you think something like that would help? I'll want to think about it, but even though "allOf(splitList: _*)" is fewer characters than "allElementsOf(splitList)", I might rather see the latter in code. But it might mean adding several more, which would add some clutter:
allElementsOf
noElementsOf
atLeastOneElementOf
atMostOneElementOf
onlyElementsOf
I'm not sure how I'd name one for inOrder and inOrderOnly that takes a collection, maybe "inOrderAllElementsOf" and "inOrderOnlyElementsOf" I suppose. But those are getting close to being non-obvious in meaning.
About the general problem, I think the fact that it takes an Any* bit you when you put the wrong type in there, because it will compile. You don't find out until the test fails. That's actually what the type-checked === addresses for equality checks, but in the case of contain matcher expressions, I ended up reducing the type checking to address this "feature" of ScalaTest 1.x:
scala> import org.scalatest._
import org.scalatest._
scala> import Matchers._
<console>:10: error: not found: value Matchers
import Matchers._
^
scala> import matchers.ShouldMatchers._
import matchers.ShouldMatchers._
scala> List("1", 2, 3.0) should contain (2)
<console>:14: error: overloaded method value should with alternatives:
(notWord: org.scalatest.matchers.ShouldMatchers.NotWord)org.scalatest.matchers.ShouldMatchers.ResultOfNotWordForSeq[Any,List[Any]] <and>
(haveWord: org.scalatest.matchers.ShouldMatchers.HaveWord)org.scalatest.matchers.ShouldMatchers.ResultOfHaveWordForSeq[Any] <and>
(beWord: org.scalatest.matchers.ShouldMatchers.BeWord)org.scalatest.matchers.ShouldMatchers.ResultOfBeWordForAnyRef[List[Any]] <and>
(rightMatcher: org.scalatest.matchers.Matcher[List[Any]])Unit
cannot be applied to (org.scalatest.matchers.Matcher[Traversable[Int]])
List("1", 2, 3.0) should contain (2)
^