Class: RuboCop::Cop::RSpec::ExampleWording
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::RSpec::ExampleWording
- Defined in:
- lib/rubocop/cop/rspec/example_wording.rb
Overview
Do not use should when describing your tests. see: betterspecs.org/#should
The autocorrect is experimental - use with care! It can be configured with CustomTransform (e.g. have => has) and IgnoredWords (e.g. only).
Constant Summary collapse
- MSG =
'Do not use should when describing your tests.'.freeze
Instance Method Summary collapse
- #autocorrect(range) ⇒ Object
-
#on_block(node) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/LineLength.
Instance Method Details
#autocorrect(range) ⇒ Object
42 43 44 45 46 |
# File 'lib/rubocop/cop/rspec/example_wording.rb', line 42 def autocorrect(range) lambda do |corrector| corrector.replace(range, (range)) end end |
#on_block(node) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/LineLength
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rubocop/cop/rspec/example_wording.rb', line 24 def on_block(node) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/LineLength method, = *node _, method_name, *args = *method return unless method_name == :it arguments = *args.first = arguments.first.to_s return unless .downcase.start_with?('should') arg1 = args.first.loc.expression = Parser::Source::Range.new(arg1.source_buffer, arg1.begin_pos + 1, arg1.end_pos - 1) add_offense(, , MSG) end |