Skip to content

Commit

Permalink
Add docs to Credo.Test.Case
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrene committed Dec 23, 2024
1 parent bb54b0f commit d484d0a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/credo/test/case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,44 @@ defmodule Credo.Test.Case do

@doc """
Asserts the presence of a single issue.
This is useful for saying "in this snippet, there is exactly one issue":
source_file
|> run_check(FooBar)
|> assert_issue()
If `callback` is given, calls it with the found issue:
source_file
|> run_check(FooBar)
|> assert_issue(fn issue ->
assert issue.line_no == 3
assert issue.trigger == "foo"
end)
"""
def assert_issue(issues, callback \\ nil) do
Assertions.assert_issue(issues, callback)
end

@doc """
Asserts the presence of more than one issue.
This is useful for saying "in this snippet, there is more than one issue":
source_file
|> run_check(FooBar)
|> assert_issues()
If `callback` is given, calls it with the found issues:
source_file
|> run_check(FooBar)
|> assert_issues(fn issues ->
assert Enum.count(issues) == 3
end)
"""
def assert_issues(issues, callback \\ nil) do
Assertions.assert_issues(issues, callback)
Expand Down

0 comments on commit d484d0a

Please sign in to comment.