Class: RuboCop::Cop::RSpec::ExampleWithoutDescription
- Includes:
- ConfigurableEnforcedStyle
- Defined in:
- lib/rubocop/cop/rspec/example_without_description.rb
Overview
Checks for examples without a description.
RSpec allows for auto-generated example descriptions when there is no description provided or the description is an empty one.
This cop removes empty descriptions. It also defines whether auto-generated description is allowed, based on the configured style.
This cop can be configured using the ‘EnforcedStyle` option
Constant Summary collapse
- MSG_DEFAULT_ARGUMENT =
'Omit the argument when you want to ' \ 'have auto-generated description.'
- MSG_ADD_DESCRIPTION =
'Add a description.'
Constants inherited from Cop
Cop::DEFAULT_CONFIGURATION, Cop::DEFAULT_PATTERN_RE
Constants included from RSpec::Language
RSpec::Language::ALL, RSpec::Language::RSPEC
Instance Method Summary collapse
Methods inherited from Cop
Instance Method Details
#on_block(node) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rubocop/cop/rspec/example_without_description.rb', line 59 def on_block(node) return unless example?(node) check_example_without_description(node.send_node) example_description(node.send_node) do |, | return unless .to_s.empty? add_offense(, message: MSG_DEFAULT_ARGUMENT) end end |