Here is a quick tip for speeding up your test suite if you use Authlogic. In production we use it’s BCrypt provider, but it’s designed to be slow. That’s when it comes to preventing an attacker from trying to compromise you user’s passwords, but slow is not a word we want to hear when it comes to tests. Authlogic makes it really easy to swap out the provider.
We just have to provide a module the responds to encrypt
and matches?
. Here is what I use:
1 2 3 4 5 6 7 8 9 |
|
Then to swap it in we just have to assign it like:
1
|
|
I keep the module in spec/support and load it in my spec helper. You can adjust to your testing framework of choice. I hope that this tip will make your tests just a little faster. It shaves a solid minute off our rspec run at Crunched.