I did it! Here's how to do it with vanilla rails. Note the other type of accept mime. You can parse JSON if you want. Comparing like strings was enough.
test "vote comment up" do # @request.headers["Content-Type"] = "application/json" @request.headers["Accept"] = "application/javascript" post :up, {post_id: 1, id: 1}, {user_id: 5} assert_response :success assert_equal @response.body, '{"error":true,"errorPath":"/users/5/balance","userVotes":1,"totalVotes":0}' end
If you want to test during development, I use the Client-Client Advanced Client Extension .
source share