I have the following this matcher:
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 } }
}
I extract the result from the HttpResponse and then compare it to the expected content. This far, this matcher worked perfectly. Now, I have a specific use case where the content of the response is a sequence of case classes, and I want to ignore one of the properties of the case class. I can't get this work:
def haveBodyWith(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!