Module: Devise::Test::IntegrationHelpers

Defined in:
lib/devise/test/integration_helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/devise/test/integration_helpers.rb', line 22

def self.included(base)
  base.class_eval do
    include Warden::Test::Helpers

    setup :setup_integration_for_devise
    teardown :teardown_integration_for_devise
  end
end

Instance Method Details

#sign_in(resource, scope: nil) ⇒ Object

Signs in a specific resource, mimicking a successfull sign in operation through Devise::SessionsController#create.

  • resource - The resource that should be authenticated

  • scope - An optional Symbol with the scope where the resource

    should be signed in with.
    


37
38
39
40
41
# File 'lib/devise/test/integration_helpers.rb', line 37

def (resource, scope: nil)
  scope ||= Devise::Mapping.find_scope!(resource)

  (resource, scope: scope)
end

#sign_out(resource_or_scope) ⇒ Object

Signs out a specific scope from the session.

  • resource_or_scope - The resource or scope that should be signed out.



46
47
48
49
50
# File 'lib/devise/test/integration_helpers.rb', line 46

def sign_out(resource_or_scope)
  scope = Devise::Mapping.find_scope!(resource_or_scope)

  logout scope
end