Class: RuboCop::Cop::Capybara::RSpec::MatchStyle
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Capybara::RSpec::MatchStyle
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/capybara/rspec/match_style.rb
Overview
Checks for usage of deprecated style methods in RSpec matchers.
Constant Summary collapse
- MSG =
'Use `%<good>s` instead of `%<bad>s`.'- RESTRICT_ON_SEND =
%i[has_style? have_style].freeze
- PREFERRED_METHOD =
{ 'has_style?' => 'matches_style?', 'have_style' => 'match_style' }.freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/rubocop/cop/capybara/rspec/match_style.rb', line 35 def on_send(node) method_node = node.loc.selector preferred = PREFERRED_METHOD[method_node.source] add_offense(method_node, message: (preferred, method_node)) do |corrector| corrector.replace(method_node, preferred) end end |