specs2 integration
i-am-the-slime opened this issue · comments
Hey David,
is there some easy integration with specs2 for Nyaya?
It's hard to convert results from mustSatisfy
since they are of type Unit
.
Came up with something like this:
case class Satisfier[A](p:Prop[A], g:Gen[A])
object Satisfier{
implicit def inst[A] = new AsResult[Satisfier[A]] {
override def asResult(t: => Satisfier[A]): Result = {
try{
t.g.mustSatisfy(t.p)
org.specs2.execute.Success(t.p.toString)
} catch {
case e:AssertionError =>
org.specs2.execute.Failure(e.getMessage, e.getLocalizedMessage, e.getStackTrace.toList)
}
}
}
}
Not sure if that treats the cases right.
Is there any news on this front?
Oh I forgot to reply to you ages ago. Sorry about that.
I haven't written anything myself but you can get access to the result without side-effects. The API is a bit messy at the moment but it looks like this:
https://github.com/japgolly/nyaya/blob/master/nyaya-test/src/main/scala/nyaya/test/PropTest.scala#L16-L17
Then you could pattern-match on the result like this and transform it into what's needed for Specs2.