authenticated.rb 708 B

123456789101112131415161718192021
  1. # This file registers a hook before each system test
  2. # which logs in with/authenticates the master@example.com account.
  3. # we need to make sure that Capybara is configured/started before
  4. # this hook. Otherwise a login try is performed while the app/puma
  5. # hasn't started yet.
  6. require_relative './driven_by'
  7. RSpec.configure do |config|
  8. config.before(:each, type: :system) do |example|
  9. # there is no way to authenticated in a not set up system
  10. next if !example.metadata.fetch(:set_up, true)
  11. authenticated = example.metadata.fetch(:authenticated_as, true)
  12. credentials = authenticated_as_get_user(authenticated, return_type: :credentials)
  13. login(credentials) if credentials
  14. end
  15. end