NET-A-PORTER / spray-actor-per-request

Example spray application that uses the actor per request model
Other
131 stars 27 forks source link

Please provide an example of a TestSpec to be able to test a route. #2

Closed mayacr86 closed 9 years ago

mayacr86 commented 9 years ago

It has been very difficult for me to create a testSpec for a particular route. I would like to run something as simple as this (but don't know how, can't find any good reference):

class MyRoutesTestSpec extends Specification with Specs2RouteTest with HttpService with MyRoute {
  "MyRoute" should {
    "return a 'HELLO' response for GET requests to /api/id/###" in {
      Get("/api/id/123") ~> routes ~> check {
        responseAs[String] === "HELLO"
      }
    }
}
binarymelon commented 9 years ago

@mayacr86 Did you come up with a workaround to this?

theon commented 9 years ago

Hi,

I committed an quick example using scalatest in c9226b30c0f09e2f708cc09c641331265a2fb833. It should also work with specs2.

The only slightly ugly is overriding petsWithOwner to inject a TestProbe. It could be done nicer either by using a constructor argument for the petsWithOwner Props in RestRouting or by using the Cake Pattern

binarymelon commented 9 years ago

Awesome. Thanks a lot. On Mar 12, 2015 9:21 PM, "Ian Forsey" notifications@github.com wrote:

Hi,

I committed an quick example using scalatest in c9226b3 https://github.com/NET-A-PORTER/spray-actor-per-request/commit/c9226b30c0f09e2f708cc09c641331265a2fb833. It should also work with specs2.

The only slightly ugly is overriding petsWithOwner to inject a TestProbe. It could be done nicer either by using a constructor argument for the petsWithOwner Props in RestRouting or by using the Cake Pattern

— Reply to this email directly or view it on GitHub https://github.com/NET-A-PORTER/spray-actor-per-request/issues/2#issuecomment-78711058 .

mayacr86 commented 9 years ago

great! thanks! :)