OeditusCredo.Helpers (OeditusCredo v0.6.0)

View Source

Shared helper functions for OeditusCredo checks.

Summary

Functions

Returns true if the given filename belongs to the test directory.

Functions

test_file?(filename)

@spec test_file?(String.t()) :: boolean()

Returns true if the given filename belongs to the test directory.

Matches files ending with _test.exs as well as any path containing a test/ segment (both /test/ for umbrella apps and a leading test/ for regular applications).

Examples

iex> OeditusCredo.Helpers.test_file?("test/test_helper.exs")
true

iex> OeditusCredo.Helpers.test_file?("test/my_app_test.exs")
true

iex> OeditusCredo.Helpers.test_file?("apps/my_app/test/support/factory.ex")
true

iex> OeditusCredo.Helpers.test_file?("lib/my_app/test_utils.ex")
false