FlowAssertions.NoValueA (Flow Assertions v0.7.1) View Source

These assertions assume a convention of initializing keys in a map to an "I have no value" value, with the expectation that they will later be given real values.

Such a convention is useful in multi-step construction of, for example, ExUnit assertion errors. They are structures initialized to :ex_unit_no_meaningful_value. The values are then set by an assertion error. Moreover, they can be reset by code that rescues an error. Several functions in this package make use of that. See FlowAssertions.Define.BodyParts.adjust_assertion_error/2 for an example.

Use this module with use, providing the no-value value:

use FlowAssertions.NoValueA, no_value: :_nothing
...
result |> assert_no_value([:key1, key2])

If you use the same no-value value widely, consider using this module once and importing that:

defmodule My.NoValueA do 
  use FlowAssertions.NoValueA, no_value: :ex_unit_no_meaningful_value
end

defmodule MyTestModule
  import My.NoValueA
  ...
  result |> assert_no_value([:key1, key2])

If you don't use use, you can provide the no-value value on each call:

import FlowAssertions.NoValueA
...
result |> assert_no_value([:key1, :key2], :ex_unit_no_meaningful_value)

The default no-value value is nil.

Link to this section Summary

Functions

Assert that one or more keys in a map have no value.

Assert that one or more keys in a map have been assigned values.

Link to this section Functions

Link to this function

assert_no_value(map, key, no_value \\ nil)

View Source

Assert that one or more keys in a map have no value.

Note that the second argument can be either a singleton key or a list.

Link to this function

assert_values_assigned(map, keys, no_value \\ nil)

View Source

Assert that one or more keys in a map have been assigned values.

Note that the second argument can be either a singleton key or a list.

The optional third argument gives the "value that is no value". It's used to signify that the structure has never had its initial value "changed".

Link to this function

refute_no_value(map, keys, no_value \\ nil)

View Source
This function is deprecated. Use `assert_values_assigned/3` instead..