Guest User

Untitled

a guest
Feb 19th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. # Check we cant create a user with an invalid e-mail address
  2. u = User.new
  3. u.password = u.password_confirmation = "Dummy001"
  4.  
  5. # Invalid e-mail addresses
  6. invalid = [ "example", # No @ or domain
  7. "example@", # No domain
  8. "example@example", # No dot or TLD
  9. "example@example.", # No TLD
  10. "@example.com", # No user name
  11. "123@123.123", # No TLD ends in numbers
  12. ("a"*30) + "@" + ("b"*66) + ".com", # Too long - 101 Characters
  13. "ab@cd.com", # Too short - 9 Characters
  14. "example@@example.com", # Two @'s
  15. "example@!!!.com", # Invalid characters
  16. "!!!@example.com", # Invalid characters
  17. "example@example.!!!" ] # Invalid characters
  18. invalid.each do |s|
  19. u.email = s
  20. assert !u.save, "Save succeeded on: " + s
  21. assert u.errors.invalid?("email"), "Incorrect field was invalid on: " + s
Add Comment
Please, Sign In to add comment