Skip to content

Commit d484d0a

Browse files
committed
Add docs to Credo.Test.Case
1 parent bb54b0f commit d484d0a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lib/credo/test/case.ex

+31
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,44 @@ defmodule Credo.Test.Case do
145145

146146
@doc """
147147
Asserts the presence of a single issue.
148+
149+
This is useful for saying "in this snippet, there is exactly one issue":
150+
151+
source_file
152+
|> run_check(FooBar)
153+
|> assert_issue()
154+
155+
If `callback` is given, calls it with the found issue:
156+
157+
source_file
158+
|> run_check(FooBar)
159+
|> assert_issue(fn issue ->
160+
assert issue.line_no == 3
161+
assert issue.trigger == "foo"
162+
end)
163+
148164
"""
149165
def assert_issue(issues, callback \\ nil) do
150166
Assertions.assert_issue(issues, callback)
151167
end
152168

153169
@doc """
154170
Asserts the presence of more than one issue.
171+
172+
This is useful for saying "in this snippet, there is more than one issue":
173+
174+
source_file
175+
|> run_check(FooBar)
176+
|> assert_issues()
177+
178+
If `callback` is given, calls it with the found issues:
179+
180+
source_file
181+
|> run_check(FooBar)
182+
|> assert_issues(fn issues ->
183+
assert Enum.count(issues) == 3
184+
end)
185+
155186
"""
156187
def assert_issues(issues, callback \\ nil) do
157188
Assertions.assert_issues(issues, callback)

0 commit comments

Comments
 (0)