Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specs2 should take Future[MatchResult[T]] #241

Closed
MasseGuillaume opened this issue Mar 11, 2014 · 5 comments
Closed

specs2 should take Future[MatchResult[T]] #241

MasseGuillaume opened this issue Mar 11, 2014 · 5 comments

Comments

@MasseGuillaume
Copy link

could not find implicit value for evidence parameter of type
org.specs2.execute.AsResult[scala.concurrent.Future[org.specs2.matcher.MatchResult[...]]]

when you have a Matcher[Future[T]] we can use await, but when we have a Future[MatchResult[T]] I think specs2 could handle it.

@etorreborre
Copy link
Owner

Done. This should be now as simple as (in 2.4-SNAPSHOT):

Future(1 must_== 1).await
Future(1 must_== 1).await(retries = 2, timeout = 1.second)

@MasseGuillaume
Copy link
Author

Wow that was fast. Thanks!

@MasseGuillaume
Copy link
Author

so it's

import org.specs2.time.NoTimeConversions

class _Spec extends Specification with NoTimeConversions {

I think it's better if you accept a specs2 duration and convert it internally.


also I think it's better if you let the user define the execution context

import concurrent.ExecutionContext.Implicits.global

specs2

trait ConcurrentContext {
  implicit val context: ExecutionContext
}

trait FutureMatchers extends Expectations { context: ConcurrentContext =>
 // ...
}

user

class _Spec extends Specification with ConcurrentContext{
  implicit lazy val context = ???
}

so he could use

  • ExecutionContext.Implicits.global
  • play.api.libs.concurrent.Execution.Implicits.defaultContext
  • etc

@etorreborre
Copy link
Owner

That's a very good suggestion and I added a trait to hold the execution context. On the Duration side of things I think that I'm going to remove specs2 conversions altogether. But I don't see how to avoid making it a breaking change :-(.

@MasseGuillaume
Copy link
Author

Thanks, Looking good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants