Questions tagged [spray-test]

26 questions
20
votes
7 answers

How can I fix the missing implicit value for parameter ta: TildeArrow in a test spec

I'm working on a simple test spec using spray and I can't get it to compile correctly, don't know if I'm doing anything wrong. My version of scala is 2.9.3 and spray 1.0.1 (Updating either of them is not a suitable option). Here's my test spec's…
marcelaconejo
  • 219
  • 2
  • 6
6
votes
1 answer

How can I simulate a POST request with a json body in SprayTest?

If I have an endpoint that unmarshalls json like this: (path("signup")& post) { entity(as[Credentials]) { credentials => … How can I test that with a Spray test spec: "The Authentication service" should { "create a new account if none…
iwein
  • 24,288
  • 9
  • 67
  • 108
4
votes
2 answers

How to get http request header info from the server side with spray RestAPI

I am new to Scala and Spray. I have written a simple REST API according to the instructions given in this blog post. http://www.smartjava.org/content/first-steps-rest-spray-and-scala And all are working as expected. Now I want to modify the program…
4
votes
1 answer

Spray-Test gzip decode

I try write test for spray class FullTestKitExampleSpec extends Specification with Specs2RouteTest with UserController with HttpService { def actorRefFactory = system "The service" should { "return a greeting for GET requests to the root…
Rinat Mukhamedgaliev
  • 4,615
  • 8
  • 37
  • 57
3
votes
1 answer

Injecting mock actors into a Spray route for testing

Multiple groups in my department have started using Spray to develop REST based web services and are all running into a similar problem and there really haven't been great solutions to come out of it so far. Suppose you had the following: FooService…
geoffjentry
  • 4,481
  • 2
  • 28
  • 36
2
votes
1 answer

ExceptionHandler doesn't work with spray test-kit?

I'm trying Spray's ExceptionHandler using an example in this guide: http://spray.io/documentation/1.2.2/spray-routing/key-concepts/exception-handling/ class MyServiceActor extends Actor with MyService { def actorRefFactory = context def…
null
  • 7,598
  • 14
  • 55
  • 94
2
votes
1 answer

spray.io upgrade causes missing mock library in specs2

I use specs2 in my spray.io project. It all works fine and when I use the following versions. val akkaV = "2.3.6" val sprayV = "1.3.2" val specs2V = "2.3.11" However, recently I tried to upgrade the akka and spray version to the following. val…
dingdong
  • 169
  • 10
2
votes
1 answer

Spray route testing with Akka TestProbe

In my Spray route, I delegate to an actor to process the request. The RequestContext is sent in the message to that actor. path("mypath") { parameters("thing".as[String]) { thing => ctx => myActor ! ProcessThingAndResondToContext(thing, ctx) …
Synesso
  • 34,066
  • 32
  • 124
  • 194
2
votes
0 answers

How to add test-case of a route only with pathEnd

I have a route get { pathEnd { respondWithMediaType(`text/html`) { // XML is marshalled to `text/xml` by default, so we simply override here complete("[]") } } } I am trying to add a test-case for this route like this Get() ~>…
Ayush Mishra
  • 289
  • 4
  • 13
2
votes
1 answer

Basic Spray-Testkit usage to test a route does not work

I am trying to use spray route and want to test it with Spray-TestKit. I am using : - Scala 2.10.3 - Akka 2.3.3 - Spray 1.3.1 I create a trait extending HttpService, where I define a route : trait MyService extends HttpService with CoreAccess { …
Joel
  • 449
  • 4
  • 20
2
votes
1 answer

Scalatest and SprayIO fails

I have problem with my test suite. No matter what I do I always get the same error message Request was not handled. This is my test suite: class EventsServiceSpec extends FlatSpec with ScalatestRouteTest with EventsService with Matchers { def…
bkowalikpl
  • 807
  • 5
  • 11
2
votes
0 answers

Can I modify subcut modules in spray route test?

I have a Specs2RouteTest "test a route with some modified dependencies" in { bindingModule.modifyBindings { implicit module => module.bind[AuthorizationService].toModuleSingle { createMockAuthService("1") } val req =…
danb
  • 9,613
  • 13
  • 57
  • 75
1
vote
0 answers

Scoverage and Spray Testkit

I'm having trouble running scoverage plugin with the spray testkit. Whenever I run my tests with the scoverage enabled, the tests fails. Without scoverage enabled, it passes. I tried adding this to my test, at the top of my class to increase the…
JWC
  • 1,735
  • 2
  • 12
  • 13
1
vote
0 answers

Request was not handled with spray-testkit

My service route: get( path("add" / IntNumber / IntNumber)( (a, b) => complete((a + b).toString()) ) ) ~ post( path("add") ( formFields('a.as[Int], 'b.as[Int]) { (a, b) => complete((a + b).toString()) }) ) my spec: import…
python_kaa
  • 910
  • 11
  • 22
1
vote
2 answers

Scala - How spray call path goes (Debugging spray code)

I am new to Scala, Spray and functional programming. And I am so sad that I still can not understand event the basic example of Spray RestAPI. I have written the program according to the instructions given in this blog…
1
2