Skip to content

Commit

Permalink
Verify the pretty printed JSON output
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas committed Sep 20, 2016
1 parent 8064007 commit 360229f
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.server.Directives
import org.scalatest.{ Matchers, WordSpec }

class SprayJsonPrettyMarshalSpec extends WordSpec with Matchers {
class SprayJsonPrettyMarshalSpec extends server.RoutingSpec {

"spray-json example" in {
//#example
Expand All @@ -29,13 +29,23 @@ class SprayJsonPrettyMarshalSpec extends WordSpec with Matchers {
get {
pathSingleSlash {
complete {
// should complete with spray.json.JsValue = { "name": "akka", "id": 42 }
PrettyPrintedItem("akka", 42) // will render as JSON
}
}
}
// format: ON
//#example
}

val service = new MyJsonService

// verify the pretty printed JSON
Get("/") ~> service.route ~> check {
responseAs[String] shouldEqual
"""{
| "name": "akka",
| "id": 42
|}""".stripMargin
}
//#example
}
}

0 comments on commit 360229f

Please sign in to comment.