Class: RuboCop::Cop::RSpec::EmptyExample
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::RSpec::EmptyExample
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/rspec/empty_example_cops.rb
Constant Summary collapse
- MSG =
Checks if an example does not include any expectations.
'Empty example detected.'
Instance Method Summary collapse
Instance Method Details
#on_block(node) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rubocop/cop/rspec/empty_example_cops.rb', line 53 def on_block(node) description = it_description(node) return if description.nil? unless example_present?(node) add_offense(node, message: MSG) do |corrector| corrector.replace( range_by_whole_lines(node.location.expression), "it #{description.last&.source}" ) end end end |