# Speed up your integration tests with a jig

February 7, 2014

If you've written enough integration tests (with Capybara et al.), you must have noticed how much time your tests spend just logging into your web app. Even if it takes 1 second each time, it starts to add up. Here's a solution that I've written several times, now. I create a test "jig" that allows me to authenticate into my application with a single visit.

This is a simple override of the normal Devise session controller. Next I add a route that is only present in a development or testing environment.

There, that's about it. Now, whenever you need to authenticate to your system, say in a Capybara test, you can replace your multi-line login steps with a single visit "/users/auth?email=user@example.com".

And you will be authenticated!

I also use this during development to log in as different test users by creating bookmarks in my browser.

Speed up your integration tests with a jig - February 7, 2014 - Ken Mayer