@StatelessCode
  @StatelessCode
Stateless Code | Write System Tests for Devise User to Change Email @StatelessCode | Uploaded November 2022 | Updated October 2024, 9 hours ago.
Our next Devise feature to test is the ability for users to change their email address associated with their user account. This is mostly a rearrangement and adaptation of tests that we have already done with our sign up tests and our change password tests.

One thing we realize early on is that our original plan of putting the change email and change password tests in the same test class is going to make that class too big. So we split them out into their own classes and files. We use the `git mv` command to rename our file from change_email_password_test.rb to change_password_test.rb.

When we get to the test for invalid email format, we decide to create a test helper method in ApplicationSystemTestCase for retrieving the validation message from an input instead of using the more verbose chain of methods we had in our original implementation of UserSignUpTest.

This video covers:
00:00:12 Introduction
00:01:15 Demonstrate the functionality to be tested
00:07:07 Write the stubs of the tests and split the email and password tests into their own test classes
00:14:09 Adapt the setup and helper methods for ChangeEmailTest
00:15:26 Implement the user can change email to a valid address test
00:19:32 Fix failure due to incorrect assumption about navigation location after confirming new email
00:21:38 Implement email change fails if invalid confirmation token test and refactor out common code to a helper method
00:24:51 Implement the other unhappy path methods except for invalid email format and add test about blank old password on the password change test
00:28:05 Implement invalid email format test and create get_input_validation_message method on ApplicationSystemTestCase
00:31:28 Update UserSignUpTest to use the new method and run the full test suite
00:32:52 Fix RuboCop violations, including a refactor of the happy_path_confirmed method
00:36:54 Review changes, commit, push, and update project

#ruby #rails7 #rails #rubyonrails #rubygems #codecast #screencast #github #opensource #minitest #TDD #agile #NerdDice #DnD #roleplaying #softwaredevelopment #learntocode #tailwind #postgresql #rubocop #devise #turbo #controllers #views #selenium #capybara #systemtest

See other related StatelessCode videos:
- Write Browser Tests for Devise Sign Up youtu.be/hd62zAGfTQk
- Write Devise System Tests for Password Change via Form youtu.be/GcPfRc2cKp8

This video is CC0 - No rights reserved. (YouTube doesn't allow this option when publishing.) All code is released under the UNLICENSE. Stateless Code denies the concept of "intellectual property". Copying is not stealing.
Write System Tests for Devise User to Change EmailWhy So Stateless?Codecast: Getting Started with Rails 7 05: Show a Single ArticleCodecast: Getting Started with Rails 7 15: Prepare for ConcernsCodecast: Create a RubyGem 64: Add NerdDice to the Ruby Toolbox CatalogRework Tailwind Helper to Stop at the BorderCodecast: Create a RubyGem 55: Refactor and Break a Module up into Smaller FilesGenerosity and the Sovereignty of GodCreate a RubyGem 97: Update Bundle Before Performing ReleasesCodecast: statelesscode.com WordPress 21: Resize Picture, Add Sidebar, Fix h1 TagsCodecast: Create a RubyGem 09: Fix RuboCop issues and release a patch versionCodecast: Create a RubyGem 76: Fix Bonus and Penalty when Number of Dice Not Specified

Write System Tests for Devise User to Change Email @StatelessCode

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER