If you haven’t looked at OmniAuth for authentication with sites like Google, Github and Facebook, then you should take a look. It is pretty killer.
This morning we needed to write a Cucumber scenario to test that a user could log into the system using Google Apps.
We did a quick spike on getting OminAuth integrated, which was a super simple process, and poked around in the browser to make sure it was working OK.
Thanks to Jose Valim for providing some guidance, via the Devise test suite, on how to get this all up and running.
The basics can be found in this Gist:
I put that code in /features/support/omniauth.rb and then all I need to do is label any scenarios that need to deal with login with an @omniauth_test tag and we are all set.
As our features count grows, I could see us doing this before/after all Cucumber scenarios.
Note: You need to be using 0.2.0.beta5 of OmniAuth to get this to work. Earlier versions don’t have the testing functionality built in.
Also Note: This same functionality can be used in good, old RSpec integration tests or Steak tests as well.
About the AuthorMore Content by Mike Gehard