-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We use `Html.raw/1` for formatting more errors. The output is much nicer and easier to understand at a glance. We also extract the `ignore_whitespace/1` helper that was introduced into a `TestHelpers` module.
- Loading branch information
Showing
6 changed files
with
54 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
defmodule PhoenixTest.TestHelpers do | ||
@moduledoc false | ||
|
||
@doc """ | ||
Converts a multi-line string into a whitespace-forgiving regex | ||
""" | ||
def ignore_whitespace(string) do | ||
string | ||
|> String.split("\n") | ||
|> Enum.map(&String.trim/1) | ||
|> Enum.reject(fn s -> s == "" end) | ||
|> Enum.map(fn s -> "\\s*" <> s <> "\\s*" end) | ||
|> Enum.join("\n") | ||
|> Regex.compile!([:dotall]) | ||
end | ||
end |