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.
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 click_button].freeze
- CLICK_LINK_OR_BUTTON =
%i[click_link_or_button click_on].freeze
- RESTRICT_ON_SEND =
(STRICT_METHODS + CLICK_LINK_OR_BUTTON).freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
44 45 46 47 48 |
# File 'lib/rubocop/cop/capybara/click_link_or_button_style.rb', line 44 def on_send(node) return unless offense?(node) add_offense(node, message: (node)) end |