-
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.
Raise AssertionError instead of RuntimeError (#13)
Currently, assertions `assert_has` and `refute_has` raise `RuntimeError` ``` 1) test index shows empty states (Manage.PageLiveTest) apps/manage/test/manage/live/page_test.exs:6 ** (RuntimeError) Could not find any elements with selector "span#bar". code: |> assert_has("span#bar", "foo") stacktrace: (phoenix_test 0.2.1) lib/phoenix_test/assertions.ex:17: PhoenixTest.Assertions.assert_has/3 test/manage/live/page_test.exs:9: (test) ``` This works, but it's more common for assertion helpers to raise `ExUnit.AssertionError` instead, as it signals that there is something wrong with what the test author is asserting vs. something wrong with the setup as such. This PR introduces `AssertionError` to the `Assertions` module, and only there. This is how output of the same test looks like: ``` 1) test index shows empty states (Manage.PageLiveTest) apps/manage/test/manage/live/page_test.exs:6 Could not find any elements with selector "span#bar". code: |> assert_has("span#bar", "foo") stacktrace: (phoenix_test 0.2.1) lib/phoenix_test/assertions.ex:18: PhoenixTest.Assertions.assert_has/3 test/manage/live/page_test.exs:9: (test) ```
- Loading branch information
1 parent
5c1c0a8
commit 117bc59
Showing
2 changed files
with
75 additions
and
50 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