Module: Sorcery::TestHelpers::Rails::Integration
- Defined in:
- lib/sorcery/test_helpers/rails/integration.rb
Instance Method Summary collapse
-
#login_user(user = nil, route = nil, http_method = :post) ⇒ Object
Accepts arguments for user to login, route to use and HTTP method Defaults - @user, ‘sessions_url’ and POST.
-
#logout_user(route = nil, http_method = :get) ⇒ Object
Accepts route and HTTP method arguments Default - ‘logout_url’ and GET.
Instance Method Details
#login_user(user = nil, route = nil, http_method = :post) ⇒ Object
Accepts arguments for user to login, route to use and HTTP method Defaults - @user, ‘sessions_url’ and POST
8 9 10 11 12 13 14 15 |
# File 'lib/sorcery/test_helpers/rails/integration.rb', line 8 def login_user(user = nil, route = nil, http_method = :post) user ||= @user route ||= sessions_url username_attr = user.sorcery_config.username_attribute_names.first username = user.send(username_attr) page.driver.send(http_method, route, { :"#{username_attr}" => username, :password => 'secret' }) end |
#logout_user(route = nil, http_method = :get) ⇒ Object
Accepts route and HTTP method arguments Default - ‘logout_url’ and GET
19 20 21 22 |
# File 'lib/sorcery/test_helpers/rails/integration.rb', line 19 def logout_user(route = nil, http_method = :get) route ||= logout_url page.driver.send(http_method, route) end |