If you are using BCrypt Ruby you can have some significant time savings when running your unit tests by lowering the cost. By default
BCrypt::Password.create(unencrypted_password) will use a cost of 10. I dropped a RSpec test suite from 25 seconds to just 4 by just setting the cost to be the minimum (4) in test mode.
def password=(unencrypted_password) @password = unencrypted_password unless unencrypted_password.blank? if Rails.env.test? cost = BCrypt::Engine::MIN_COST else cost = BCrypt::Engine::DEFAULT_COST end self.password_digest = BCrypt::Password.create(unencrypted_password, cost: cost) end end