Skip to content

Commit

Permalink
Add useful error when no expect type was left
Browse files Browse the repository at this point in the history
  • Loading branch information
MainShayne233 committed Nov 18, 2019
1 parent 5ec03bf commit 4894e2a
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions lib/markdown_test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ defmodule MarkdownTest do
quote do
(unquote_splicing(describes))
end
rescue
error in RuntimeError ->
raise %CompileError{
description: """
Something went wrong when testing the markdown in #{path}.
Underyling error:
#{error.message}
"""
}
end

defp test_module_name(parent_module, test_block, path) do
Expand Down Expand Up @@ -198,8 +211,17 @@ defmodule MarkdownTest do
end)

raw_test_cases
|> Enum.map(fn {expression, expected} ->
{Enum.reverse(expression), Enum.reverse(expected)}
|> Enum.map(fn
{expression, nil} ->
raise %RuntimeError{
message: """
Could not determine expected value for example starting on
line #{starting_line(expression)} of the markdown file.
"""
}

{expression, expected} ->
{Enum.reverse(expression), Enum.reverse(expected)}
end)
|> Enum.reverse()
end
Expand Down

0 comments on commit 4894e2a

Please sign in to comment.