Macaw.Component.Conformance (macaw_component v0.1.2)

Copy Markdown View Source

The component conformance kit (spec/04): the contract and the rendering rules as checks, so a component author proves conformance by running it.

defmodule MyApp.CardsConformanceTest do
  use ExUnit.Case, async: true

  use Macaw.Component.Conformance,
    component: MyApp.Cards,
    fixtures: [%{settings: %{"columns" => 2}, deliveries: %{"items" => delivery}}]
end

Two layers. check(check, component, opts) answers one check's findings, {check, {where, what}} terms, [] for a component that passes; check(component, opts) runs every check, then each check set's; format/1 words a finding. use writes one test per check. The kit references no ExUnit function itself, so it loads in production; it is compiled only when lazy_html is present.

A check runs the component's callbacks in the caller's process: a raise is the test's failure, with its stacktrace.

Summary

Types

A finding: the check, then where (the fixture, kind and mode) and what failed.

Functions

Writes one test per check, then per check of each set in check_sets:, in a describe block, each failing with its findings. Takes component: (required) and the options of check/2.

Every check, then each check set's in check_sets:, over a component.

One check's findings over a component.

The check sets, in order.

The twelve checks, in order.

A check set's checks, in order.

A finding as a line a person reads.

Types

finding()

@type finding() :: {atom(), {{String.t(), atom() | nil, atom() | nil}, term()}}

A finding: the check, then where (the fixture, kind and mode) and what failed.

Functions

__using__(opts)

(macro)

Writes one test per check, then per check of each set in check_sets:, in a describe block, each failing with its findings. Takes component: (required) and the options of check/2.

check(component, opts)

@spec check(module(), keyword()) :: [finding()]

Every check, then each check set's in check_sets:, over a component.

check(check, component, opts)

@spec check(atom(), module(), keyword()) :: [finding()]

One check's findings over a component.

check_sets()

@spec check_sets() :: [atom()]

The check sets, in order.

checks()

@spec checks() :: [atom(), ...]

The twelve checks, in order.

checks(set)

@spec checks(atom()) :: [atom(), ...]

A check set's checks, in order.

format(arg)

@spec format(finding()) :: String.t()

A finding as a line a person reads.