I plan to use JSON data in both request and response in my project and having some problems in testing.
After searching for a while, I find the following code which uses
Assuming you have a controller named api, a method named new, and you're in the test for the api controller:
@request.env["RAW_POST_DATA"] = '{ "foo" : "bar" }' post :new
did the trick for me.