These are chat archives for etorreborre/specs2

31st
Mar 2017
G. Richard Bellamy
@rbellamy
Mar 31 2017 00:37
okay, for future reference in case someone else has the same question about datatables:
class MySpec extends immutable.Specification with Tables {

  def is = s2"""
    Some data table should
      be used to create some other things ${dataTable | create}
      and destroy some others ${dataTable | destroy}
  """

  def create = { (a: String, b: Seq[String]) =>
    ok
  }

  def destroy = { (a: String, b: Seq[String]) =>
    ok
  }

  private val dataTable: Table2[String, Seq[String]] = {
    "a" | "b" |>
    "meh" ! Seq("foo", "bar") |
    "hem" ! Seq("baz", "bam")
  }
}
I haven't actually tested to see if this will work, but I don't see any reason why it shouldn't...
Eric Torreborre
@etorreborre
Mar 31 2017 05:40

@rbellamy if you want to test futures you can use matchers with .await

stats.map(_.nCreates) must beEqualTo(10).await

But you need to create your specification with an implicit ExecutionEnv

class MySpec(implicit ee: ExecutionEnv) extends Specification
Andreas Flierl
@asflierl
Mar 31 2017 08:30
@etorreborre thank you for the quick fix!
G. Richard Bellamy
@rbellamy
Mar 31 2017 20:44
@etorreborre that did it very nicely
G. Richard Bellamy
@rbellamy
Mar 31 2017 20:52
got any love for me on how I would use that pattern with an Akka ActorReffuture?
      val complete = actorRef ? EntityLoadActor.EntityLoadStatusQuery(CdcActor.MlsEntity)
      complete.onComplete {
        case Success(EntityLoadActor.EntityLoadWaiting(last: JobControl)) =>
          assert(last.action == JobControlActionType.COMPLETE)
        case Success(x) => logger.debug(s"x: $x")
        case Failure(e) => logger.error(e.getMessage, e); assert(false)
      }
I realize that I am probably asking for help with something that I would know how to do if I was more educated in Scala...
given that - how would I arrange a matcher result with the complete value? (which is a Future[Any])