With ScalaTest, it's straightforward enough to test that an object is of a particular class with something like:
myPet shouldBe a [Dog]
But what I would like to do is verify that a collection of some base type has at least one of a particular sub type. I imagine the syntax could look something like this but it doesn't work:
myPets should contain a [Cat]
I can achieve the same result with 'exists' and 'shouldBe true' but it's not quite as expressive.
myPets.exists(_.isInstanceOf[Cat]) shouldBe true
Is this what I have to do or is there a feature of ScalaTest that I'm not aware of?
Thank you