def haveBodyWith[T: TypeTag: Unmarshaller](content: T)(implicit await: Duration): Matcher[Future[HttpResponse]] =
===(content) ^^ { (f: Future[HttpResponse]) => { Await.result(f, await).entity.as[T].right.get } }
def haveBodyWith1(content: Foo): Matcher[HttpResponse] = {
===(content) ^^ { (_: HttpResponse).entity.as[Foo].right.get.copy(name = "") }
}case class Foo(id: Int, name: String)
If I had just the content without the future to compare, I'd done it this way (maybe something similar with a Seq of case classes), but the future make it a little more difficult.
What do you think?
Thanks!
--
You received this message because you are subscribed to a topic in the Google Groups "specs2-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/specs2-users/slc7bYB_ozE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to specs2-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and all its topics, send an email to specs2-users+unsubscribe@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to specs2-users...@googlegroups.com.
--Vēnī, vīdī, vīcī (Julius Caesar)
--
You received this message because you are subscribed to a topic in the Google Groups "specs2-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/specs2-users/slc7bYB_ozE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to specs2-users...@googlegroups.com.
import org.specs2.concurrent.ExecutionEnv
import scala.concurrent._
import org.specs2.matcher.{FutureMatchers, Matcher}
class FuturesSpec(implicit ee: ExecutionEnv) extends mutable.Specification with FutureMatchers {
"test" >> {
callApi must haveBodyWith1(Foo(""))
}
def haveBodyWith1(content: Foo): Matcher[Future[HttpResponse]] = {
===(content) ^^ { (_: HttpResponse).foo.copy(name = "") }
}.await
def callApi: Future[HttpResponse] =
future(HttpResponse(Foo("foo")))(ee.executionContext)
case class Foo(name: String)
case class HttpResponse(foo: Foo)
}
Can you use `^^` instead of `^^^`?
To unsubscribe from this group and all its topics, send an email to specs2-users+unsubscribe@googlegroups.com.
--Vēnī, vīdī, vīcī (Julius Caesar)
--
You received this message because you are subscribed to a topic in the Google Groups "specs2-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/specs2-users/slc7bYB_ozE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to specs2-users+unsubscribe@googlegroups.com.
This works for me:
To unsubscribe from this group and all its topics, send an email to specs2-users...@googlegroups.com.
--Vēnī, vīdī, vīcī (Julius Caesar)
--
You received this message because you are subscribed to a topic in the Google Groups "specs2-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/specs2-users/slc7bYB_ozE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to specs2-users...@googlegroups.com.
--Vēnī, vīdī, vīcī (Julius Caesar)
--
You received this message because you are subscribed to a topic in the Google Groups "specs2-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/specs2-users/slc7bYB_ozE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to specs2-users...@googlegroups.com.
def haveBodyWith1(content: Foo): Matcher[Future[HttpResponse]] = {
===(normalize(content)) ^^ { (response: HttpResponse) => normalize(response.foo) }
}.await
def normalize(foo: Foo) = foo.copy(name = "")
This works for me:
To unsubscribe from this group and all its topics, send an email to specs2-users+unsubscribe@googlegroups.com.
--Vēnī, vīdī, vīcī (Julius Caesar)
--
You received this message because you are subscribed to a topic in the Google Groups "specs2-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/specs2-users/slc7bYB_ozE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to specs2-users+unsubscribe@googlegroups.com.
--Vēnī, vīdī, vīcī (Julius Caesar)
--
You received this message because you are subscribed to a topic in the Google Groups "specs2-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/specs2-users/slc7bYB_ozE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to specs2-users+unsubscribe@googlegroups.com.
Is this better?
This works for me:
To unsubscribe from this group and all its topics, send an email to specs2-users...@googlegroups.com.
--Vēnī, vīdī, vīcī (Julius Caesar)
--
You received this message because you are subscribed to a topic in the Google Groups "specs2-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/specs2-users/slc7bYB_ozE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to specs2-users...@googlegroups.com.
--Vēnī, vīdī, vīcī (Julius Caesar)
--
You received this message because you are subscribed to a topic in the Google Groups "specs2-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/specs2-users/slc7bYB_ozE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to specs2-users...@googlegroups.com.
--Vēnī, vīdī, vīcī (Julius Caesar)
--
You received this message because you are subscribed to a topic in the Google Groups "specs2-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/specs2-users/slc7bYB_ozE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to specs2-users...@googlegroups.com.