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

Change to default EnforcedStyle: link_or_button for Capybara/ClickLinkOrButtonStyle cop #76

Merged
merged 1 commit into from
Oct 11, 2023

Conversation

ydah
Copy link
Member

@ydah ydah commented Oct 2, 2023

partically fix: #61 (comment)
fix: #61 (comment)


Before submitting the PR make sure the following are checked:

  • Feature branch is up-to-date with main (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Updated documentation.
  • Added an entry to the CHANGELOG.md if the new code introduces user-observable changes.
  • The build (bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).

If you have modified an existing cop's configuration options:

  • Set VersionChanged: "<<next>>" in config/default.yml.

@ydah ydah force-pushed the change_click_link_or_button_default branch from 465b87a to f94468d Compare October 2, 2023 13:26
@ydah ydah requested review from a team, pirj, bquorning and Darhazer and removed request for a team October 6, 2023 01:36
@ydah ydah merged commit 355d09b into main Oct 11, 2023
22 checks passed
@ydah ydah deleted the change_click_link_or_button_default branch October 11, 2023 07:28
@mvz mvz mentioned this pull request Oct 16, 2023
11 tasks
@mvz
Copy link

mvz commented Oct 16, 2023

For the record, this does not really fix my comment #61 (comment).

enescakir added a commit to ubicloud/ubicloud that referenced this pull request Jan 3, 2024
Dependabot sent a pull request for rubocop-related updates, and it
failed because of new corrections that could be applied.  This applies
them, and then Dependabot's rebase of the rubocop update should
succeed.

The default value for `Capybara/ClickLinkOrButtonStyle` has been changed
from `strict` to `link_or_button`, which has loosened its constraints.
However, we have been adhering to the `strict` style. I've reverted it
back to `strict` as the relaxed version necessitated numerous test
changes, which I found to be unnecessary.

rubocop/rubocop-capybara#76
enescakir added a commit to ubicloud/ubicloud that referenced this pull request Jan 3, 2024
Dependabot sent a pull request for rubocop-related updates, and it
failed because of new corrections that could be applied.  This applies
them, and then Dependabot's rebase of the rubocop update should
succeed.

The default value for `Capybara/ClickLinkOrButtonStyle` has been changed
from `strict` to `link_or_button`, which has loosened its constraints.
However, we have been adhering to the `strict` style. I've reverted it
back to `strict` as the relaxed version necessitated numerous test
changes, which I found to be unnecessary.

rubocop/rubocop-capybara#76
zspencer added a commit to zinc-collective/convene that referenced this pull request Jan 5, 2024
- rubocop/rubocop-capybara#76

I lean more towards @franzliedke's perspective that HTML is a semantic
language, and
[`<button>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button)/[`<input
type="submit">`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/submit)
and [`a`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a)
have distinct purposes..

Strict mode allows us to be intentional about what the interaction is
for (i.e. navigation? `click_link`! Manipulation? `click_button`!)

That said, I don't know how clickable elements that are not links or
buttons should work; for example the
[`<details>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details)
tag?!

Anyway, this also means we're not doing code changes with wishy-washy-defaults
G-Rath added a commit to ackama/rails-template that referenced this pull request Jan 11, 2024
rubocop/rubocop-capybara#76 changed the default
to enforce using the more generic `click_link_or_button` and `click_on`
because

> These methods offer a weaker coupling between the test and HTML,
allowing for a more faithful reflection of how the user behaves.

Which is very fair imo and inline with other testing frameworks like
`testing-library`.
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 this pull request may close these issues.

3 participants