Class: RuboCop::RSpec::Wording
- Inherits:
-
Object
- Object
- RuboCop::RSpec::Wording
- Defined in:
- lib/rubocop/rspec/wording.rb
Overview
RSpec example wording rewriter
Instance Method Summary collapse
-
#initialize(text, ignore:, replace:) ⇒ Wording
constructor
A new instance of Wording.
- #rewrite ⇒ Object
Constructor Details
#initialize(text, ignore:, replace:) ⇒ Wording
Returns a new instance of Wording.
7 8 9 10 11 |
# File 'lib/rubocop/rspec/wording.rb', line 7 def initialize(text, ignore:, replace:) @text = text @ignores = ignore @replacements = replace end |
Instance Method Details
#rewrite ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rubocop/rspec/wording.rb', line 13 def rewrite text.split.tap do |words| first_word = words.shift words.unshift('not') if first_word.eql?("shouldn't") words.each_with_index do |value, key| next if ignores.include?(value) words[key] = simple_present(words.fetch(key)) break end end.join(' ') end |