View Source SchemaAssertions.ChangesetAssertions (Schema Assertions v0.1.3)

Assertions for changeset validity.

Link to this section Summary

Functions

Assert that a changeset's fields match the expected values. The field values are obtained via Ecto.Changeset.fetch_field!/2 and are the values from either the changes or the data.

Assert that a changeset is invalid, including asserting on all of its validation errors

Assert that a changeset is valid

A helper that transforms changeset errors into a map of messages.

Link to this section Functions

Link to this function

assert_changeset_fields(changeset, fields)

View Source

Assert that a changeset's fields match the expected values. The field values are obtained via Ecto.Changeset.fetch_field!/2 and are the values from either the changes or the data.

Link to this function

assert_changeset_invalid(tuple_or_changeset, expected_errors \\ nil)

View Source

Assert that a changeset is invalid, including asserting on all of its validation errors

Example: assert_changeset_invalid(changeset, start_date: ["please enter dates as mm/dd/yyyy"])

Link to this function

assert_changeset_valid(changeset)

View Source

Assert that a changeset is valid

Example: assert_changeset_valid(changeset)

A helper that transforms changeset errors into a map of messages.

assert {:error, changeset} = Accounts.create_user(%{password: "short"})
assert "password is too short" in errors_on(changeset).password
assert %{password: ["password is too short"]} = errors_on(changeset)