I am writing some rspec for an API and trying to test HTTP request code directly in the rails console so I can see what I get back.
For example I have the following lines in my spec
json_data = '{"user": {"email": "#{user.email}", "password": "#{user.password}"}}'
post "api/v1/users/sign_in", json_data
@token = json(last_response)[:client][:auth_token]
get 'api/v1/users', {}, {'Authorization' => @token}
This code doesn't work because my 'json()' function is not parsing the response correctly. I want to take those 'post' and 'get' with JSON arguments and test them in rails console with Net::HTTP so I can see what responses are being returned and debug my spec code. Anyone know how to do that?
In case it matter the authorization token I am trying to use is generated by Devise.