6.5 Exercises

Add a test for the email downcasing from Listing 6.20, as shown in
Listing 6.30. This test uses the reload method for reloading a value
from the database and the eq method for testing equality. By commenting
out the before_save line, verify that Listing 6.30 tests the right
thing.
By running the test suite, verify that the before_save callback can be
written as shown in Listing 6.31.
As noted in Section 6.2.4, the email regex in Listing 6.14 allows
invalid email addresses with consecutive dots, i.e., addresses of the
form “foo@bar..com”. Add this address to the list of invalid address in
Listing 6.13 to get a failing test, and then use the more complicated
regex shown in Listing 6.32 to get the test to pass.