Class: RuboCop::Cop::RSpec::AggregateFailuresTag
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::RSpec::AggregateFailuresTag
- Defined in:
- lib/rubocop/cop/rspec/aggregate_failures_tag.rb
Overview
Checks that the ‘:aggregate_failures` tag is only used on examples, not on example groups.
The ‘:aggregate_failures` tag only works on individual examples (`it`, `specify`, etc.), not on example groups (`describe`, `context`, etc.).
Constant Summary collapse
- MSG =
'The `:aggregate_failures` tag should only be used on examples, not on example groups.'- EXAMPLE_METHODS =
i[ it specify example scenario its fit fspecify fexample fscenario focus xit xspecify xexample xscenario skip pending ].freeze
- RSPEC_METHODS =
i[ describe context feature example_group xdescribe fdescribe it specify example scenario its fit fspecify fexample fscenario focus xit xspecify xexample xscenario skip pending ].freeze
Instance Method Summary collapse
Instance Method Details
#on_block(node) ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/rubocop/cop/rspec/aggregate_failures_tag.rb', line 78 def on_block(node) return unless rspec_block?(node) return unless aggregate_failures_tag?(node) return if example_method?(node) # Create a range that includes the method call up to and including the 'do' keyword send_node = node.send_node range = send_node.source_range.join(node.loc.begin) add_offense(range) end |