File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 77- Add new ` RSpec/IncludeExamples ` cop to enforce using ` it_behaves_like ` over ` include_examples ` . ([ @dvandersluis ] )
88- Change ` RSpec/ScatteredSetup ` to allow ` around ` hooks to be scattered. ([ @ydah ] )
99- 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 ] )
1011
1112## 3.5.0 (2025-02-16)
1213
Original file line number Diff line number Diff line change @@ -153,7 +153,9 @@ def scope_change?(node)
153153 end
154154
155155 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 )
157159 end
158160
159161 def only_static_constants?
Original file line number Diff line number Diff line change 1010 expect_offense ( <<~RUBY )
1111 describe MyClass do
1212 controller(ApplicationController) do
13- bar = MyClass
13+ self. bar = MyClass
1414 end
1515
1616 before do
2727 expect_correction ( <<~RUBY )
2828 describe MyClass do
2929 controller(ApplicationController) do
30- bar = MyClass
30+ self. bar = MyClass
3131 end
3232
3333 before do
4040 end
4141 RUBY
4242 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
4364 end
4465
4566 context 'when SkipBlocks is `false`' do
You can’t perform that action at this time.
0 commit comments