Class: Rubocop::Cop::RSpec::VerboseIncludeMetadata
- Inherits:
-
Base
- Object
- RuboCop::Cop::RSpec::Base
- Base
- Rubocop::Cop::RSpec::VerboseIncludeMetadata
- Extended by:
- RuboCop::Cop::AutoCorrector
- Defined in:
- lib/rubocop/cop/rspec/verbose_include_metadata.rb
Overview
Checks for verbose include metadata used in the specs.
Constant Summary collapse
- MSG =
'Use `%s` instead of `%s`.'
- SELECTORS =
%i[describe context feature example_group it specify example scenario its].freeze
Instance Method Summary collapse
Instance Method Details
#include_metadata(node) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/rubocop/cop/rspec/verbose_include_metadata.rb', line 27 def_node_matcher :include_metadata, <<-PATTERN (send {(const nil? :RSpec) nil?} {#{SELECTORS.map(&:inspect).join(' ')}} !const ... (hash $...)) PATTERN |
#invalid_metadata?(node) ⇒ Object
35 36 37 38 39 |
# File 'lib/rubocop/cop/rspec/verbose_include_metadata.rb', line 35 def_node_matcher :invalid_metadata?, <<-PATTERN (pair (sym $...) (true)) PATTERN |
#on_send(node) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/rubocop/cop/rspec/verbose_include_metadata.rb', line 41 def on_send(node) (node) do |match| add_offense(node, message: format(MSG, good(match), bad(match))) do |corrector| (node) do |match| corrector.replace(match, good(match)) end end end end |