So, I have a set of Akka Http routes written in scala. Which looks like this
val route: Route = {
handleRejections(PrimaryRejectionHandler.handler) {
handleExceptions(PrimaryExceptionHandler.handler) {
cors() {
encodeResponseWith(Gzip) {
pathPrefix("v1") {
new v1Routes().handler
} ~
path("ping") {
complete("pong")
}
}
}
}
}
}
Now I want to test this using scala-test and akka testkit.
class HttpRouteTest extends WordSpec with Matchers with ScalatestRouteTest {
"GET /ping" should {
"return 200 pong" in new Context {
Get("/ping") ~> httpRoute ~> check {
responseAs[String] shouldBe "pong"
status.intValue() shouldBe 200
}
}
}
trait Context {
val httpRoute: Route = new HttpRoute().route
}
}
Now since, I am encoding my responses with gzip in the route, the test is getting gibberish when it's trying to convert to string. As a result the test does not pass.
Is there any solution to this? Thanks in advance.