Class: RuboCop::Cop::Momocop::RSpecItTextPattern
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Momocop::RSpecItTextPattern
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/momocop/rspec_it_text_pattern.rb
Constant Summary collapse
- MSG =
'RSpec it block text must match pattern: %<pattern>s'
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rubocop/cop/momocop/rspec_it_text_pattern.rb', line 16 def on_send(node) return unless it_block?(node) arg = node.first_argument return unless arg&.str_type? text = arg.value.to_s pattern = cop_config['RequiredPattern'] return if text.match?(Regexp.new(pattern)) add_offense( node.first_argument.loc.expression, message: format(MSG, pattern:) ) end |