Sha256: ef5282d1d860e087e156251b4f18caca75d5291747d1443381d0b54916c7ea05
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
module Sorcery module TestHelpers # a patch to fix a bug in testing that happens when you 'destroy' a session twice. # After the first destroy, the session is an ordinary hash, and then when destroy is called again there's an exception. class ::Hash def destroy clear end end def create_new_user(attributes_hash = nil) user_attributes_hash = attributes_hash || {:username => 'gizmo', :email => "bla@bla.com", :password => 'secret'} @user = User.new(user_attributes_hash) @user.save! @user end def create_new_external_user(provider, attributes_hash = nil) user_attributes_hash = attributes_hash || {:username => 'gizmo', :authentications_attributes => [{:provider => provider, :uid => 123}]} @user = User.new(user_attributes_hash) @user.save! @user end def sorcery_model_property_set(property, *values) User.class_eval do sorcery_config.send(:"#{property}=", *values) end end private # reload user class between specs # so it will be possible to test the different submodules in isolation def reload_user_class Object.send(:remove_const,:User) load 'user.rb' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sorcery-0.3.1 | lib/sorcery/test_helpers.rb |
sorcery-0.3.0 | lib/sorcery/test_helpers.rb |