Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CaseClauseError in assert_has when multiple matches #18

Closed
randycoulman opened this issue Feb 10, 2024 · 0 comments · Fixed by #20
Closed

CaseClauseError in assert_has when multiple matches #18

randycoulman opened this issue Feb 10, 2024 · 0 comments · Fixed by #20

Comments

@randycoulman
Copy link
Contributor

The docs for assert_has say "It'll raise an error if no elements are found, but it will not raise if more than one matching element is found."

But I'm seeing that an assert_has with multiple matching elements is raising a CaseClauseError when it gets back a {:found_many, ...} tuple.

If the docs are correct, it looks like it should be possible to add another clause to Assertions.assert_has. Probably something like:

{:found_many, _found}
  -> assert true

and a test case for this.

refute_has does have a clause for {:found_many, ...}, so no problems there.

I'll work on a PR to address this.

randycoulman added a commit to randycoulman/freedom_account that referenced this issue Feb 10, 2024
Mostly works, but I've run into a couple of issues:

- [`CaseClauseError` when multiple matches in `assert_has`](germsvel/phoenix_test#18)
- [No obvious way to follow redirects after a form submition](germsvel/phoenix_test#19)
randycoulman added a commit to randycoulman/phoenix_test that referenced this issue Feb 10, 2024
germsvel pushed a commit that referenced this issue Feb 10, 2024
Fixes #18

The docs for assert_has say "It'll raise an error if no elements are found, but it will not raise if more than one matching element is found."

But I'm seeing that an assert_has with multiple matching elements is raising a CaseClauseError when it gets back a {:found_many, ...} tuple.

This commit fixes that by adding the necessary clause.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant