When a user goes to /auth/facebook, it gets redirected to FB, then back to my /auth/facebook/callback if successful.
How can I write an RSpec test that will follow all of these redirects to verify my user has been authenticated?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would recommend an alternative, simpler approach.
What if you tested callback controller directly to see how it reacts to different values passed to it in the omniauth.auth or if env[“omniauth.auth”] is missing or incorrect. Following redirects would be equivalent of testing omniauth plugin, which does not test YOUR system.
For example, here is what we have in our tests (this is just a few examples, we have many more that verify other variations of omniauth hash and user state prior to sign-in attempt, such as invitation status, user account being disabled by the admins, etc.):
with
stub_env_for_omniauthmethod defined as follows: