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

Add Capybara/AmbiguousClick cop and make soft-deprecated Capybara/ClickLinkOrButtonStyle cop. If you want to use EnforcedStyle: strict, use Capybara/AmbiguousClick cop instead #99

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

ydah
Copy link
Member

@ydah ydah commented Jan 15, 2024

Motivation: #81


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 created a new cop:

  • Added the new cop to config/default.yml.
  • The cop is configured as Enabled: pending in config/default.yml.
  • The cop documents examples of good and bad code.
  • The tests assert both that bad code is reported and that good code is not reported.
  • Set VersionAdded: "<<next>>" in default/config.yml.

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

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

Capybara/ClickLinkOrButtonStyle:
Description: Checks for methods of button or link clicks.
Enabled: pending
Enabled: false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memo) This is a change from pending, but is this acceptable for a minor update? (not a breaking change?)

@@ -9,11 +9,17 @@ Capybara:
- "**/*_steps.rb"
- "**/features/step_definitions/**/*"

Capybara/AmbiguousClick:
Description: Specify the exact target to click on.
Enabled: false
Copy link
Member Author

@ydah ydah Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memo) It is not to be enabled by default. It is only a transition destination when Capybara/ClickLinkOrButtonStyle is EnforcedStyle: strict.

@ydah ydah added this to the 3.0 milestone Mar 22, 2024
jgarber623 pushed a commit to CargoSense/rubocop-cargosense that referenced this pull request May 6, 2024
This rule's default enforce style, `link_or_button` [1], introduced a
number of problems [2]. Specifically, I noticed issues switching to
`click_on` from `click_button` [3]. The hack solution is to ignore or
disable the rule in some places but not in others. Not great.

As a result, the rule is slated for removal [4] and replacement [5] by
a new rule. In the interim, configuring this rule to enforce a strict
use of `click_button` and `click_link` is preferential (and, honestly,
more communicative).

In this author's opinion, user interface specs should be explicit about
the markup under test.

[1] https://docs.rubocop.org/rubocop-capybara/cops_capybara.html#capybaraclicklinkorbuttonstyle
[2] rubocop/rubocop-capybara#61
[3] rubocop/rubocop-capybara#61 (comment)
[4] rubocop/rubocop-capybara#81
[5] rubocop/rubocop-capybara#99
jgarber623 pushed a commit to CargoSense/rubocop-cargosense that referenced this pull request May 6, 2024
## Description

This rule's default enforce style, `link_or_button` [1], introduced a
number of problems [2]. Specifically, I noticed issues switching to
`click_on` from `click_button` [3]. The hack solution is to ignore or
disable the rule in some places but not in others. Not great.

As a result, the rule is slated for removal [4] and replacement [5] by a
new rule. In the interim, configuring this rule to enforce a strict use
of `click_button` and `click_link` is preferential (and, honestly, more
communicative).

In this author's opinion, user interface specs should be explicit about
the markup under test.

[1]
https://docs.rubocop.org/rubocop-capybara/cops_capybara.html#capybaraclicklinkorbuttonstyle
[2] rubocop/rubocop-capybara#61
[3] rubocop/rubocop-capybara#61 (comment)
[4] rubocop/rubocop-capybara#81
[5] rubocop/rubocop-capybara#99

## Commits

- Configure `Capybara/ClickLinkOrButtonStyle`
- Bump version to v1.1.0
…ClickLinkOrButtonStyle` cop. If you want to use `EnforcedStyle: strict`, use `Capybara/AmbiguousClick` cop instead
@ydah ydah merged commit 0932d93 into main Jun 12, 2024
26 checks passed
@ydah ydah deleted the to_ambiguous_click branch June 12, 2024 12:50
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.

1 participant