Rails 7 #125 Test Devise authentication with Controller and System tests

17/04/2023 (about 1 year ago)
rails testing tdd test devise login

When setting up a new Rails app with Devise, you should set up your test suite to work with authentication and write controller (integration) and system tests for the authentication flow.

Here’s a reusable approach to setting up your test suite for the long run!

Episode source code: https://github.com/corsego/125-test-devise-authentication/commits/main
Based on this blogpost: https://blog.corsego.com/minitest-faker-factory-bot-devise

0:00 tests in generated controllers
1:34 update routes and make tests work
3:49 install devise
6:15 fix duplicate index users on email in fixtures
7:03 test unauthenticated access
9:15 devise login in tests
10:48 system (browser) tests
19:43 run system tests without browser popup
20:20 test, test:system, test:all


0
Sign in to join the conversation