Testing OmniAuth based login via Cucumber

March 3, 2011 Mike Gehard

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 Author

Biography

Previous
New in Pivotal Tracker: Reply to emails, delete comments, browse public projects!
New in Pivotal Tracker: Reply to emails, delete comments, browse public projects!

Team collaboration with Pivotal Tracker just got better - you can now post comments to stories right from y...

Next
Using Cucumber/Capybara with SauceLabs SauceOnDemand
Using Cucumber/Capybara with SauceLabs SauceOnDemand

SauceLabs is a cloud based way to test your site against different browsers. Up until now, they only suppo...

×

Subscribe to our Newsletter

!
Thank you!
Error - something went wrong!