code_junkie

How to test JSON result from Rails functional tests?

Nov 12th, 2011
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. user = JSON.parse(@response.body)
  2. assert_equal "Mike", user['name']
  3.  
  4. def json_response
  5. ActiveSupport::JSON.decode @response.body
  6. end
  7.  
  8. assert_equal "Mike", json_response['name']
  9.  
  10. assert_equal '{"total_votes":1}', @response.body
Add Comment
Please, Sign In to add comment