File tree 3 files changed +27
-3
lines changed
3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 7
7
- Add new ` RSpec/IncludeExamples ` cop to enforce using ` it_behaves_like ` over ` include_examples ` . ([ @dvandersluis ] )
8
8
- Change ` RSpec/ScatteredSetup ` to allow ` around ` hooks to be scattered. ([ @ydah ] )
9
9
- Fix an error ` RSpec/ChangeByZero ` cop when without expect block. ([ @lee266 ] )
10
+ - Fix a false positive for ` RSpec/DescribedClass ` when ` SkipBlocks ` is true and numblocks are used. ([ @earlopain ] )
10
11
11
12
## 3.5.0 (2025-02-16)
12
13
Original file line number Diff line number Diff line change @@ -153,7 +153,9 @@ def scope_change?(node)
153
153
end
154
154
155
155
def skippable_block? ( node )
156
- node . block_type? && !rspec_block? ( node ) && cop_config [ 'SkipBlocks' ]
156
+ return false unless cop_config [ 'SkipBlocks' ]
157
+
158
+ node . any_block_type? && !rspec_block? ( node )
157
159
end
158
160
159
161
def only_static_constants?
Original file line number Diff line number Diff line change 10
10
expect_offense ( <<~RUBY )
11
11
describe MyClass do
12
12
controller(ApplicationController) do
13
- bar = MyClass
13
+ self. bar = MyClass
14
14
end
15
15
16
16
before do
27
27
expect_correction ( <<~RUBY )
28
28
describe MyClass do
29
29
controller(ApplicationController) do
30
- bar = MyClass
30
+ self. bar = MyClass
31
31
end
32
32
33
33
before do
40
40
end
41
41
RUBY
42
42
end
43
+
44
+ it 'ignores offenses within non-rspec numblocks' do
45
+ expect_offense ( <<~RUBY )
46
+ describe MyClass do
47
+ controller(ApplicationController) do
48
+ do_some_work(_1)
49
+ self.bar = MyClass
50
+ end
51
+
52
+ before do
53
+ MyClass
54
+ ^^^^^^^ Use `described_class` instead of `MyClass`.
55
+
56
+ Foo.custom_block do
57
+ do_some_work(_1)
58
+ MyClass
59
+ end
60
+ end
61
+ end
62
+ RUBY
63
+ end
43
64
end
44
65
45
66
context 'when SkipBlocks is `false`' do
You can’t perform that action at this time.
0 commit comments