Class: RuboCop::Cop::Discourse::NoSystemSpecMetadata
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Discourse::NoSystemSpecMetadata
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/discourse/no_system_spec_metadata.rb
Overview
System spec metadata is inferred from the file path, so explicit ‘type: :system` and `system: true` metadata on `RSpec.describe` is redundant.
Constant Summary collapse
- MSG =
"Remove redundant `type: :system` and `system: true` metadata from `RSpec.describe`."- RESTRICT_ON_SEND =
%i[describe].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rubocop/cop/discourse/no_system_spec_metadata.rb', line 39 def on_send(node) return unless describe?(node) return unless node.last_argument&.hash_type? hash = node.last_argument offending_pairs = hash.pairs.select { |pair| system_type_pair?(pair) || system_true_pair?(pair) } return if offending_pairs.empty? add_offense(offending_pairs.first) do |corrector| corrector.replace(node, corrected_send_source(node, hash, offending_pairs)) end end |