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…
![](../../users/profiles/3381012.webp)
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…
![](../../users/profiles/291244.webp)
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…
![](../../users/profiles/1985974.webp)
Janaka Priyadarshana
- 530
- 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…
![](../../users/profiles/1029235.webp)
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…
![](../../users/profiles/144642.webp)
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…
![](../../users/profiles/844005.webp)
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…
![](../../users/profiles/3427617.webp)
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)
…
![](../../users/profiles/45525.webp)
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() ~>…
![](../../users/profiles/1714250.webp)
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 {
…
![](../../users/profiles/3489316.webp)
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…
![](../../users/profiles/1091059.webp)
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 =…
![](../../users/profiles/2031.webp)
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…
![](../../users/profiles/611891.webp)
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…
![](../../users/profiles/2056222.webp)
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…
![](../../users/profiles/1985974.webp)
Janaka Priyadarshana
- 530
- 2
- 7
- 15