OptimumCredo.Check.Readability.ImplementationHelperInAssertion (OptimumCredo v0.5.0)

View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of low and works with any version of Elixir.

Explanation

A test that builds its expectation with the same function the implementation uses proves nothing. Hardcode the expected value.

Bad: assert html =~ Money.format(price) Good: assert html =~ "$5.00"

Check-Specific Parameters

Use the following parameters to configure this check:

:helper_pattern

Regex source for function names that format/compute expectations.

This parameter defaults to "^(format|humanize|display|label|render|title|slug|translate|to_)".

:modules

Extra implementation modules (atoms or strings) to watch.

This parameter defaults to [].

:watch_namespace

Also watch aliased/imported modules sharing the test module's application namespace.

This parameter defaults to true.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.