This message was deleted.
# questions
s
This message was deleted.
t
Can you provide an example request and response?
p
Just run the tests.
./grailsw test-app
The controller and tests were generated using
./grailsw generate-controller User
. I populated the TODO, but the tests fail, and I do not understand why.
m
That is odd, the generated test does not seem like they are causing the view to render. If you add an explicit call to
view.render(...)
the failing tests passes.
Copy code
void "test the index action returns the correct response"() {
    given:
    controller.userService = Mock(UserService) {
        1 * list(_) >> []
        1 * count() >> 0
    }

    when: "the index action is executed"
    controller.index()

    and: "the view is rendered"
    controller.modelAndView.view.render model, request, response

    then:"the response is correct"
    response.text == '[]'
}