Class: Rubocop::Cop::RSpec::ExampleStartingCharacter
- Inherits:
-
Base
- Object
- RuboCop::Cop::RSpec::Base
- Base
- Rubocop::Cop::RSpec::ExampleStartingCharacter
- Extended by:
- RuboCop::Cop::AutoCorrector
- Defined in:
- lib/rubocop/cop/rspec/example_starting_character.rb
Overview
Checks for common mistakes in example descriptions.
This cop will correct docstrings that begin/end with space or words that start with a capital letter.
Constant Summary collapse
- MSG =
'Only start words with lowercase alpha with no leading/trailing spaces when describing your tests.'
Instance Method Summary collapse
- #it_description(node) ⇒ Object
- #on_block(node) ⇒ Object (also: #on_numblock)
Instance Method Details
#it_description(node) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/rubocop/cop/rspec/example_starting_character.rb', line 56 def_node_matcher :it_description, <<-PATTERN (block (send _ :it ${ (str $_) (dstr (str $_ ) ...) } ...) ...) PATTERN |
#on_block(node) ⇒ Object Also known as: on_numblock
63 64 65 66 67 |
# File 'lib/rubocop/cop/rspec/example_starting_character.rb', line 63 def on_block(node) it_description(node) do |description_node, | add_wording_offense(description_node, MSG) if invalid_description?(text(description_node)) end end |