Skip to content

Instantly share code, notes, and snippets.

@BranLiang
Created October 19, 2024 01:31
Show Gist options
  • Select an option

  • Save BranLiang/335bd8d15ac0a21db46a9232dd9d5884 to your computer and use it in GitHub Desktop.

Select an option

Save BranLiang/335bd8d15ac0a21db46a9232dd9d5884 to your computer and use it in GitHub Desktop.
Rails 8 basic authentication setup for system test
require "test_helper"
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ]
def login_as(user)
visit new_session_url
fill_in "email_address", with: user.email_address
fill_in "password", with: "password"
click_on "Sign in"
# assert not seeing "Sign in" again (Must have, or you will be immediately redirected)
assert_no_text "Sign in"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment