These are chat archives for etorreborre/specs2

21st
Jun 2016
Edmondo Porcu
@edmondo1984
Jun 21 2016 13:00
Hello, how do I zip two matchers?
Eric Torreborre
@etorreborre
Jun 21 2016 13:08
This should work
import org.specs2.matcher._, MustMatchers._

implicit class ZippedMatchers[T1](m1: Matcher[T1]) {
  def zip[T2](m2: Matcher[T2]): Matcher[(T1, T2)] = { t1t2: (T1, T2) =>
    val (t1, t2) = t1t2
    (t1 must m1) and (t2 must m2)
  }
}
but you might want to adjust the failure message
Edmondo Porcu
@edmondo1984
Jun 21 2016 13:09
aren't these implicit ocnversoins
already available when mixing Speciification ?
Eric Torreborre
@etorreborre
Jun 21 2016 13:42
Yes I just added the imports here in case you want to do this outside a spec
Edmondo Porcu
@edmondo1984
Jun 21 2016 13:50
it looks like inside that spec
it doesn't work
Error:(60, 79) value zip is not a member of org.specs2.matcher.Matcher[String]
def matchCorrectExpectedData:Matcher[(String,File)] = matchCorrectFileName zip matchCorrectContent
^
Eric Torreborre
@etorreborre
Jun 21 2016 14:03
This definitely compiles for me
Or maybe you meant “is ZippedMatchers” imported when you mix-in Specification? The answer is no
you need to implement it as above
Edmondo Porcu
@edmondo1984
Jun 21 2016 14:23
AH
it is not
I thought this was already a part of specs2, apologies
where should I update the message? on the (t1 must m1).updateMessage() or on (t1 must m1) and ((t2 must m2)).updateMessage
Eric Torreborre
@etorreborre
Jun 21 2016 14:28
The second one