Skip to content

Commit 5f1d09c

Browse files
authored
Merge pull request #2104 from rubocop/2103
Fix a false positive for `RSpec/ExcessiveDocstringSpacing` when receivers are not RSpec methods
2 parents 50d347c + 26beee7 commit 5f1d09c

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Don't register offenses for `RSpec/DescribedClass` within `Data.define` blocks. ([@lovro-bikic])
99
- Add autocorrection support for `RSpec/IteratedExpectation` for single expectations. ([@lovro-bikic])
1010
- Exclude all cops from inspecting factorybot files, except if explicitly included. ([@Mth0158])
11+
- Fix a false positive for `RSpec/ExcessiveDocstringSpacing` when receivers are not RSpec methods. ([@ydah])
1112

1213
## 3.6.0 (2025-04-18)
1314

lib/rubocop/cop/rspec/excessive_docstring_spacing.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ExcessiveDocstringSpacing < Base
3030

3131
# @!method example_description(node)
3232
def_node_matcher :example_description, <<~PATTERN
33-
(send _ {#Examples.all #ExampleGroups.all} ${
33+
(send #rspec? {#Examples.all #ExampleGroups.all} ${
3434
$str
3535
$(dstr ({str dstr `sym} ...) ...)
3636
} ...)

spec/rubocop/cop/rspec/excessive_docstring_spacing_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,4 +772,14 @@
772772
end
773773
RUBY
774774
end
775+
776+
it 'does not register an offense when receiver is not non-RSpec' do
777+
expect_no_offenses(<<~RUBY)
778+
it 'does something' do
779+
Foo.describe(' does something')
780+
Bar.context(' does something')
781+
Baz.it(' does something')
782+
end
783+
RUBY
784+
end
775785
end

0 commit comments

Comments
 (0)