Questions tagged [spray-test]
27 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
- 218
- 2
- 7
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
- 25,788
- 10
- 70
- 111
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…

Janaka Priyadarshana
- 540
- 2
- 7
- 15
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
- 5,401
- 8
- 41
- 59
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,674
- 3
- 31
- 37
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
- 8,669
- 16
- 68
- 98
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
- 37,610
- 35
- 136
- 207
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
- 567
- 1
- 7
- 19
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
- 669
- 7
- 25
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
- 817
- 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
- 10,239
- 14
- 60
- 76
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,745
- 2
- 12
- 14
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
- 1,034
- 13
- 27
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…

Janaka Priyadarshana
- 540
- 2
- 7
- 15