Describing changeset validations
Last updated
Was this helpful?
Last updated
Was this helpful?
A particular test's expected results can be described with changeset
(lines 4-5):
That constructs (in effect) this assertion pipeline:
Notice that the assert_valid
wasn't made explicit. It's implied by the name of the category: :success
(line 1). (Similarly, the:validation_failure
category implies assert_invalid
.)
The changeset
function supports all of the . Just leave off the assert_
prefix and the changeset
argument. For example:
Because this code reuses ecto_flow_assertions
and ecto_flow_assertions
reuses ExUnit
's reporting machinery, you get good error messages:
That's important because test generation frameworks are notorious for creating errors that are hard to understand.