Let's say I have a simple action in my controller that ends with:
render(contentType: "text/json") { message = 'some text' foo = 'bar' }
It displays correctly, according to the JSON documentation. However, when I try to execute the unit test this answer in ControllerUnitTest, I get an empty string with controller.response.contentAsString . I even tried controller.renderArgs , but it just contains contentType: "text/json" .
When I convert JSON to a map and sort it as JSON , then I can check it correctly. But is there a way to unit test the code in its current form?
source share