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
I found that this does exactly what I want – post JSON to a controller's action.
post :create, {:format => 'json', :user => { :email => "test@test.com", :password => "foobar"}}