OeditusCredo.Helpers
(OeditusCredo v0.11.2)
View Source
Shared helper functions for OeditusCredo checks.
Summary
Functions
Safely converts module alias parts (or an alias AST / atom / tuple) to a string representation.
Returns true if the given filename belongs to the test directory.
Functions
Safely converts module alias parts (or an alias AST / atom / tuple) to a string representation.
Handles simple atoms (e.g. :Repo -> "Repo"), AST nodes (e.g. {:__MODULE__, _, nil} -> "__MODULE__"),
and lists of parts (e.g. [{:__MODULE__, _, nil}, :Pigeon] -> "__MODULE__.Pigeon").
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