Class: RuboCop::Cop::RSpecRails::InferredSpecType
- Inherits:
-
RuboCop::Cop::RSpec::Base
- Object
- RuboCop::Cop::RSpec::Base
- RuboCop::Cop::RSpecRails::InferredSpecType
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rspec_rails/inferred_spec_type.rb
Overview
Identifies redundant spec type.
After setting up rspec-rails, you will have enabled ‘config.infer_spec_type_from_file_location!` by default in spec/rails_helper.rb. This cop works in conjunction with this config. If you disable this config, disable this cop as well.
Constant Summary collapse
- MSG =
'Remove redundant spec type.'
Instance Method Summary collapse
- #on_block(node) ⇒ Object (also: #on_numblock)
Instance Method Details
#on_block(node) ⇒ Object Also known as: on_numblock
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rubocop/cop/rspec_rails/inferred_spec_type.rb', line 59 def on_block(node) return unless example_group?(node) pair_node = describe_with_type(node) return unless pair_node return unless inferred_type?(pair_node) removable_node = detect_removable_node(pair_node) add_offense(removable_node) do |corrector| autocorrect(corrector, removable_node) end end |