6
如果我有一個JSON解組這樣的端點:如何在SprayTest中使用json主體模擬POST請求?
(path("signup")& post) {
entity(as[Credentials]) { credentials =>
…
我如何可以測試用噴霧測試規範:
"The Authentication service" should {
"create a new account if none exists" in {
Post("/api/authentication/signup", """{"email":"foo", "password":"foo:" }""") ~> authenticationRoute ~> check {
handled === true
}
}
}
這顯然不會有幾個原因的工作。什麼是正確的方法?
我相信這不再適用於最新版本。取而代之的是:'''Post(「/ api/authentication/signup」,HttpEntity(MediaTypes.'application/json',「」「{」email「:」foo「,」password「:」foo「}」 「))))''' –
@GregaKešpret它可以完美的與任何版本兼容。目前在噴1.3.1 with akka 2.3.3 – 4lex1v
@AlexIv HttpBody所在的對象在哪裏? –