Created
February 11, 2020 20:58
-
-
Save TylerPachal/5f6c014ab05e45f9017de42bff857a6d to your computer and use it in GitHub Desktop.
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
test "age is required" do | |
# Create changeset | |
params = %{"name" => "tyler"} | |
changset = Person.changeset(%Person{}, params) | |
# Changeset should be invalid | |
assert changeset.valid? == false | |
# Find the error message for the invalid field | |
error_message = Keyword.get(changeset.errors, :age) | |
# Make sure that the error message is useful and polite | |
assert error_message =~ "blank" | |
assert error_message =~ "please" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment