Class: RuboCop::Cop::Capybara::ClickLinkOrButtonStyle
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Capybara::ClickLinkOrButtonStyle
- Includes:
- ConfigurableEnforcedStyle
- Defined in:
- lib/rubocop/cop/capybara/click_link_or_button_style.rb
Overview
Checks for methods of button or link clicks.
This cop is deprecated. We plan to remove this in the next major version update to 3.0.
The migration target is Capybara/AmbiguousClick. It is only migration target when ‘EnforcedStyle: strict`. If you are using this cop, please plan for migration. There is no migration target when `EnforcedStyle: link_or_button`.
By default, prefer to use click_link_or_button or click_on. These methods offer a weaker coupling between the test and HTML, allowing for a more faithful reflection of how the user behaves.
You can set ‘EnforcedStyle: strict` to prefer the use of click_link and click_button, but this is a deprecated setting.
Constant Summary collapse
- MSG_STRICT =
'Use `click_link` or `click_button` instead of `%<method>s`.'- MSG_CLICK_LINK_OR_BUTTON =
'Use `click_link_or_button` or `click_on` instead of `%<method>s`.'- STRICT_METHODS =
i[click_link ].freeze
- CLICK_LINK_OR_BUTTON =
i[ click_on].freeze
- RESTRICT_ON_SEND =
(STRICT_METHODS + CLICK_LINK_OR_BUTTON).freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
52 53 54 55 56 |
# File 'lib/rubocop/cop/capybara/click_link_or_button_style.rb', line 52 def on_send(node) return unless offense?(node) add_offense(node, message: (node)) end |