seratch / scalatest

Automatically exported from code.google.com/p/scalatest
Apache License 2.0
0 stars 0 forks source link

Chaining traversable matchers #17

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I think that the Matchers library is missing some core functionality that's 
provided in other matcher libraries (Hamcrest, Specs2) - namely, the ability to 
chain matchers.

I'd like to be able to provide a Matcher[T] instead of T for matchers like 
contains(). 

Also, an adapter from Hamcrest Matchers to ScalaTest Matchers (using implicits) 
can come in handy for those who have a rich library of domain matchers, like we 
do.

Original issue reported on code.google.com by shai.yal...@gmail.com on 31 Dec 2012 at 7:48

GoogleCodeExporter commented 8 years ago
Can you supply a specific example of how you'd like to chain traversable 
matchers?

Original comment by b...@artima.com on 31 Dec 2012 at 7:56

GoogleCodeExporter commented 8 years ago
val cats = List(
   Cat(name = "Felix", age = 7).
   Cat(name = "Silvester", age = 9),
   Cat(name = "Garfield", age = 10)
)

// some possibilities
cats must contain(catWith(name = "Felix"))
cats must contain(catWithAge(gt(8)))
cats must contain(catWith(_.name equal("Garfield"))

Original comment by shai.yal...@gmail.com on 31 Dec 2012 at 9:38

GoogleCodeExporter commented 8 years ago
Sorry for the delay in responding (still on vacation). We are in fact putting 
together a way to do that kind of thing right now. Should make it into 2.0.M6, 
which should come out before the end of January.

Original comment by b...@artima.com on 6 Jan 2013 at 10:44