Future, await and Specs2 3.5

172 views
Skip to first unread message

oze...@gmail.com

unread,
Apr 28, 2015, 11:42:39 AM4/28/15
to specs2...@googlegroups.com
Hi there, I have recently upgraded to specs2 v3.5 and I'm having some bad time trying to make some of my test code work when testing Futures.
Sorry, I'm not a scala guru so it may be that this is a scala syntax issue but I don't see how to solve this.

I've read in the user guide that to use the await method I need to have an implicit ExecutionEnvironment.

It works quite well when I have simple test such as this one:

...
import org.specs2.concurrent.ExecutionEnv
...
"MyTest" should {
    "succeed" in { implicit ee: ExecutionEnv =>
        Future.successful(true) must beTrue.await
    }
}
...

but how do you do when you have a Context/Scope object in a code similar to this one:

"MyTest" should {
    "succeed" in new ConfigObj with AnotherObj {
        Future.successful(true) must beTrue.await
    }
}

any clue ?
thanks in advance.
Cheers, ozb


etorreborre

unread,
Apr 28, 2015, 6:26:15 PM4/28/15
to specs2...@googlegroups.com
Hi,

This will work

class TestMutableSpec extends mutable.Specification {
  "MyTest" should {
    "succeed" in { implicit ev: ExecutionEnv => new Scope {
      Future.successful(true) must beTrue.await
    }}
  }
}

However with the next release you will be able to write:

class TestMutableSpec(implicit ev: ExecutionEnv) extends mutable.Specification {
  "MyTest" should {
    "succeed" in new Scope {
      Future.successful(true) must beTrue.await
    }
  }
}

Eric.

etorreborre

unread,
Apr 28, 2015, 9:17:06 PM4/28/15
to specs2...@googlegroups.com
You can test that with 3.5-20150429005731-d441bf4.

oze...@gmail.com

unread,
Apr 29, 2015, 3:50:26 AM4/29/15
to specs2...@googlegroups.com
Ok thanks a lot.
Looking forward to test the new syntax !
Reply all
Reply to author
Forward
0 new messages