4

I have the next code:

//models
case class Foo(name: String, age: Option[Int] = None)

//routing
trait FooRouting extends HttpService {
   def index(foos: List[Foo]): twirl.api.Html = html.foo.render(foos) 

   val route = 
     path("") {
       get { complete( index(Foo.all) } } 
     }
}

In index method, i render foo.scala.html template with Twirl. I want test this behaviour:

 //tests
 class FooTests extends FunSpec with Matchers
  with ScalatestRouteTest { 
    def actorRefFactory = system

    val t0 = Foo("test0")
    val t1 = Foo("test1") 

    it("test foo") {
      Get() ~> r ~> check {
        responseAs[List[Foo]] should be(List(t0, t1))
      }
     }
 }

But i got error:

Tests.scala:49: could not find implicit value for evidence parameter of type spray.httpx.unmarshalling.FromResponseUnmarshaller[List[pack.Foo]] [error] responseAs[List[Foo]] should be(List(t0, t1))

I define implicit method:

implicit val foo2response = new FromResponseUnmarshaller[List[Foo]] {
  def apply(r: HttpResponse): Deserialized[List[Foo]] = {
   ???
  }
}

But i do not know what i should write into body. Thanks.

lito
  • 989
  • 8
  • 21

0 Answers0