NLdoc.Test.Case.SpecExamples (NLdoc.Spec v3.1.1)

View Source

This module provides a test method for spec example tests. Import this module after use ExUnit.Case in your test module.

Summary

Functions

Returns the name of the given module.

This macro creates a suite of tests based on the given spec examples, use NLdoc.Test.Spec.Examples and NLdoc.Test.Spec.ValidationExamples to get the examples.

Functions

module_name(module)

@spec module_name(module()) :: String.t()

Returns the name of the given module.

Examples

iex> module_name(NLdoc.Spec.Table)
"NLdoc.Spec.Table"

iex> module_name(Kernel)
"Kernel"

test_spec_examples(spec_examples, name_prefix, assertion_func)

(macro)

This macro creates a suite of tests based on the given spec examples, use NLdoc.Test.Spec.Examples and NLdoc.Test.Spec.ValidationExamples to get the examples.

Each spec example contains a list of test cases for a given spec module, where each test case contains a scenario with a list of example objects. The macro will create a test for each example in the list, running the assertion_func on the result of calling new/1 on the spec module with the example object as an argument.

The assertion_func should take two arguments: the result of calling new/1 on the spec object and a context map with the keys module and scenario.