Module: Sorcery::TestHelpers::Internal

Defined in:
lib/sorcery/test_helpers/internal.rb,
lib/sorcery.rb,
lib/sorcery/test_helpers/internal/rails.rb,
lib/sorcery/test_helpers/internal/sinatra.rb,
lib/sorcery/test_helpers/internal/sinatra_modular.rb

Overview

Internal TestHelpers are used to test the gem, internally, and should not be used to test apps using sorcery. This file will be included in the spec_helper file.

Defined Under Namespace

Modules: Rails, Sinatra, SinatraModular

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/sorcery/test_helpers/internal.rb', line 6

def self.included(base)
  # reducing default cost for specs speed
  CryptoProviders::BCrypt.class_eval do
    class << self
      def cost
        1
      end
    end
  end
end

Instance Method Details

#create_new_external_user(provider, attributes_hash = nil) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/sorcery/test_helpers/internal.rb', line 33

def create_new_external_user(provider, attributes_hash = nil)
  user_attributes_hash = attributes_hash || {:username => 'gizmo'}
  @user = User.new(user_attributes_hash)
  @user.save!
  @user.authentications.create!({:provider => provider, :uid => 123})
  @user
end

#create_new_user(attributes_hash = nil) ⇒ Object



26
27
28
29
30
31
# File 'lib/sorcery/test_helpers/internal.rb', line 26

def create_new_user(attributes_hash = nil)
  user_attributes_hash = attributes_hash || {:username => 'gizmo', :email => "[email protected]", :password => 'secret'}
  @user = User.new(user_attributes_hash)
  @user.save!
  @user
end

#sorcery_model_property_set(property, *values) ⇒ Object



41
42
43
44
45
# File 'lib/sorcery/test_helpers/internal.rb', line 41

def sorcery_model_property_set(property, *values)
  User.class_eval do
    sorcery_config.send(:"#{property}=", *values)
  end
end