Route test failing even though the actual route is working

(Ali A) #1


I have the following route defined:

val feedback: Route = path("feedback") {
        post(complete("in feedback"))

I’m trying to test it:

test("testFeedback") {
        Get() ~> ~> check {
            handled should be(false)

        Post() ~> ~> check {
            println("rejections: " + rejections.mkString(","))
            handled should be(true)

The first test, on GET, passes (here i’m just making sure GET is rejected)

However the second test, on POST, also fails because handled was false.

If I try to access either the status, contentType, etc, then on either GET or POST, it just fails with an exception saying ‘request was rejected’.

However if I run the live server and hit a POST to /feedback, that works just fine and I get the message.

Any ideas… am I doing something wrong?

(Josep Prat) #2


You need to call it with Post("feedback").
When using Post() only, it issues a post to the / URL.

(Ali A) #3

Wow, I feel stupid.

Thank you! :)