Created
October 19, 2024 01:31
-
-
Save BranLiang/335bd8d15ac0a21db46a9232dd9d5884 to your computer and use it in GitHub Desktop.
Rails 8 basic authentication setup for system test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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