Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a POST request with form field content with Spray?

I've got a Spray service that expects a POST with certain form fields filled out. I'm trying to work out how to create an appropriate POST in my test spec in order to test this.

What I have so far

  Post("/customer") ~> sealRoute(myRoute) ~> check {
    responseAs[String] must contain("Success message")
  }

Which does a POST to the /customer route, as expected. How do I add form fields to this?

like image 398
Ren Avatar asked Jan 24 '14 03:01

Ren


1 Answers

You can use the spray.http.FormData class:

Post("/customer", FormData(Seq("field1"->"value1", "field2"->"value2")) ~>
  sealRoute(myRoute) ~> check {
    responseAs[String] must contain("Success message")
  }
like image 87
kong Avatar answered Nov 08 '22 18:11

kong