巫术规格运行速度很慢

时间:2012-11-23 04:33:38

标签: ruby-on-rails rspec factory-bot sorcery

我正在尝试设置我的应用程序以使用Sorcery。当我将authenticates_with_sorcery!添加到我的用户模型时,我的规格开始运行非常慢(大约每秒一个)。是否有某种配置或设置可能导致与Sorcery?

这是我的用户模型:

# 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

和我的用户工厂:

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

1 个答案:

答案 0 :(得分:2)

我的第一个猜测是慢速密码加密。例如,在设计中,我们有config.stretches配置变量,在测试环境中可以设置为较小的数字。

检查What does the "stretches" of database_authenticatable of devise mean?