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
As of Rails 5, the way to do this is:
post new_widget_url, as: :json, params: { foo: "bar" }
This will also set the Content-type header correctly (to application/json).
Content-type
application/json