Loading
Check blocks with _1 and it in RSpec/ExampleStartingCharacter
What does this MR do?
- Makes
RSpec/ExampleStartingCharactercheck examples that use numbered parameters (_1) or Ruby 3.4'sit, which it skipped until now. - Fixes its autocorrect raising
FrozenErrorin projects that target Ruby 3.4.
Related to #94 (closed). !293 (merged) fixes Cop/AvoidReturnFromBlocks the same way.
it('Does something') { |x| expect(x).to be } # offense, before and after
it('Does something') { expect(_1).to be } # offense only after this MRCause and fix
- Skipped blocks: the cop sends
numblockanditblocknodes toon_block, but theit_descriptionmatcher only matched(block ...). It now matches(any_block ...). FrozenError: the autocorrect calledstrip!on the string node's value. When parsing Ruby 3.4, that value is frozen, so correcting a plain-string description raisedFrozenError, for regular blocks too. It now usesstrip. Theitexamples need Ruby 3.4, so they hit this.
Specs
The new example runs with _1, and with it under :ruby34. Reverting the matcher fails both. Reverting strip fails the Ruby 3.4 one with FrozenError.
Impact: projects using gitlab-styles may get new offenses for descriptions of examples that use _1 or it.
Edited by Abdul Wadood