Module: Devise::Test::IntegrationHelpers

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

Instance Method Summary collapse

Instance Method Details

#setup_integration_for_deviseObject (protected)



54
55
56
# File 'lib/devise/test/integration_helpers.rb', line 54

def setup_integration_for_devise
  Warden.test_mode!
end

#sign_in(resource, scope: nil) ⇒ Object

Signs in a specific resource, mimicking a successful 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

#teardown_integration_for_deviseObject (protected)



58
59
60
# File 'lib/devise/test/integration_helpers.rb', line 58

def teardown_integration_for_devise
  Warden.test_reset!
end