These are chat archives for etorreborre/specs2

31st
Oct 2018
Brian P. Holt
@bpholt
Oct 31 2018 18:26

Would it be generally useful to have something like this in the cats subproject? I’ve added it to one of my projects and it seems to work, but I’m not sure if there is some downside I’m missing.

implicit def ioToResult[T](io: IO[MatchResult[T]]): Result = io.unsafeToFuture().await

This lets you write a test like

Foo” should {
  “do something great” >> {
    for {
      foo ← IO(…)
    } yield foo must_== “bar”
  }
}

Or does this already exist and I’m just missing something?

Christopher Davenport
@ChristopherDavenport
Oct 31 2018 18:40
It would be generally useful.
I reproduce that functionality quite a bit.
Brian P. Holt
@bpholt
Oct 31 2018 18:50
Ok, I’ll try to put together a PR. Thanks!
Ben Hutchison
@benhutchison
Oct 31 2018 20:40
@bpholt useful. My concern is that await
Won't work on scalajs, which specs is trying to support
Brian P. Holt
@bpholt
Oct 31 2018 20:41
Yeah that occurred to me too
Ben Hutchison
@benhutchison
Oct 31 2018 20:41
See discussion above about future. Same for IO really
Brian P. Holt
@bpholt
Oct 31 2018 20:42
The await takes advantage of the built-in timeouts, which is nice
Ben Hutchison
@benhutchison
Oct 31 2018 20:43
By all means add a jvm only solution now, but longer term we need nonblocking async support in specs
Haven't seen Eric on gitter in a while, I'll raise an issue to try to get his thoughts and input
Brian P. Holt
@bpholt
Oct 31 2018 20:46
JVM-only is a good idea