Search code examples
ruby-on-railsrspecfactory-botsorcery

Sorcery specs running really slow


I'm trying to set up my application to use Sorcery. When I add authenticates_with_sorcery! to my user model, my specs start to run really slow (about one per second). Is there some kind of configuration or set up that could cause this with Sorcery?

Here's my user model:

# This model represents a user of the application, disregarding that person's use of the system. For
# instance, a user could be a job hunter, an employer, an administrator, or some other stakeholder.
class User < ActiveRecord::Base
  authenticates_with_sorcery!

  attr_accessible :email, :password, :password_confirmation

  # validations
  validates :email, 
            :presence => true, 
            :uniqueness => true, 
            :format => /[^@]+@[^@]+\.[^@]+/

  validates :password, :presence => true, :confirmation => true

  validates :password_confirmation, :presence => true

  # before filters
  before_save :sanitize_email

  private

  # Strips and removes HTML tags from the email parameter.
  def sanitize_email
    self.email = email.strip

    # remove anything that looks like an email
    self.email = email.gsub(/<[^<>]+>/, "")
  end
end

and my user factory:

require 'factory_girl'
require 'ffaker'

FactoryGirl.define do

  sequence :email do |n|
    "email#{n}@example.com"
  end

  factory :user do |f|
    email
    password "password"
    password_confirmation "password"
  end
end

Solution

  • My first guess is slow password encryption. For instance in devise we have config.stretches configuration variable which in the test env could be set to a small number.

    check What does the "stretches" of database_authenticatable of devise mean?