Skip to content

Commit 8d05f42

Browse files
committed
Fix RSpec/IncludeExamples offenses
1 parent 9229477 commit 8d05f42

9 files changed

+46
-46
lines changed

spec/rubocop/cop/rspec/base_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
113113
RUBY
114114
end
115115

116-
include_examples 'it detects `describe`'
116+
it_behaves_like 'it detects `describe`'
117117
end
118118

119119
context 'when `epic` is set as an alias to example group' do
@@ -133,7 +133,7 @@ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
133133
RUBY
134134
end
135135

136-
include_examples 'it detects `describe`'
136+
it_behaves_like 'it detects `describe`'
137137
end
138138
end
139139
end

spec/rubocop/cop/rspec/empty_line_after_hook_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@
310310
end
311311

312312
context 'when AllowConsecutiveOneLiners option has default value `true`' do
313-
include_examples 'always require empty line after hook groups'
314-
include_examples 'never allows consecutive multiline blocks'
313+
it_behaves_like 'always require empty line after hook groups'
314+
it_behaves_like 'never allows consecutive multiline blocks'
315315

316316
it 'allows multiple one-liner blocks' do
317317
expect_offense(<<~RUBY)
@@ -381,8 +381,8 @@
381381
context 'when AllowConsecutiveOneLiners option `false`' do
382382
let(:cop_config) { { 'AllowConsecutiveOneLiners' => false } }
383383

384-
include_examples 'always require empty line after hook groups'
385-
include_examples 'never allows consecutive multiline blocks'
384+
it_behaves_like 'always require empty line after hook groups'
385+
it_behaves_like 'never allows consecutive multiline blocks'
386386

387387
it 'registers an offense for multiple one-liner same hook blocks' do
388388
expect_offense(<<~RUBY)

spec/rubocop/cop/rspec/hook_argument_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
end
3030

3131
shared_examples 'an example hook' do
32-
include_examples 'ignored hooks'
33-
include_examples 'detects style', 'before(:each) { foo }', 'each'
34-
include_examples 'detects style', 'before(:example) { foo }', 'example'
35-
include_examples 'detects style', 'before { foo }', 'implicit'
32+
it_behaves_like 'ignored hooks'
33+
it_behaves_like 'detects style', 'before(:each) { foo }', 'each'
34+
it_behaves_like 'detects style', 'before(:example) { foo }', 'example'
35+
it_behaves_like 'detects style', 'before { foo }', 'implicit'
3636
end
3737

3838
context 'when EnforcedStyle is :implicit' do
@@ -87,7 +87,7 @@
8787
RUBY
8888
end
8989

90-
include_examples 'an example hook'
90+
it_behaves_like 'an example hook'
9191

9292
context 'when Ruby 2.7', :ruby27 do
9393
it 'detects :each for hooks' do
@@ -172,7 +172,7 @@
172172
RUBY
173173
end
174174

175-
include_examples 'an example hook'
175+
it_behaves_like 'an example hook'
176176

177177
context 'when Ruby 2.7', :ruby27 do
178178
it 'does not flag :each for hooks' do
@@ -257,7 +257,7 @@
257257
RUBY
258258
end
259259

260-
include_examples 'an example hook'
260+
it_behaves_like 'an example hook'
261261

262262
context 'when Ruby 2.7', :ruby27 do
263263
it 'does not flag :example for hooks' do

spec/rubocop/cop/rspec/implicit_expect_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
expect_no_offenses('it { is_expected.not_to be_truthy }')
4141
end
4242

43-
include_examples 'detects style', 'it { should be_truthy }', 'should'
43+
it_behaves_like 'detects style', 'it { should be_truthy }', 'should'
4444
end
4545

4646
context 'when EnforcedStyle is should' do
@@ -89,12 +89,12 @@
8989
expect_no_offenses('it { should_not be_truthy }')
9090
end
9191

92-
include_examples 'detects style',
93-
'it { is_expected.to be_truthy }',
94-
'is_expected'
92+
it_behaves_like 'detects style',
93+
'it { is_expected.to be_truthy }',
94+
'is_expected'
9595

96-
include_examples 'detects style',
97-
'it { should be_truthy }',
98-
'should'
96+
it_behaves_like 'detects style',
97+
'it { should be_truthy }',
98+
'should'
9999
end
100100
end

spec/rubocop/cop/rspec/message_expectation_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
expect_no_offenses('allow(foo).to receive(:bar)')
1818
end
1919

20-
include_examples 'detects style', 'allow(foo).to receive(:bar)', 'allow'
21-
include_examples 'detects style', 'expect(foo).to receive(:bar)', 'expect'
20+
it_behaves_like 'detects style', 'allow(foo).to receive(:bar)', 'allow'
21+
it_behaves_like 'detects style', 'expect(foo).to receive(:bar)', 'expect'
2222
end
2323

2424
context 'when EnforcedStyle is expect' do
@@ -37,7 +37,7 @@
3737
expect_no_offenses('expect(foo).to receive(:bar)')
3838
end
3939

40-
include_examples 'detects style', 'expect(foo).to receive(:bar)', 'expect'
41-
include_examples 'detects style', 'allow(foo).to receive(:bar)', 'allow'
40+
it_behaves_like 'detects style', 'expect(foo).to receive(:bar)', 'expect'
41+
it_behaves_like 'detects style', 'allow(foo).to receive(:bar)', 'allow'
4242
end
4343
end

spec/rubocop/cop/rspec/message_spies_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@
6767
expect_no_offenses('expect(foo).to have_received(:bar)')
6868
end
6969

70-
include_examples 'detects style', 'expect(foo).to receive(:bar)', 'receive'
70+
it_behaves_like 'detects style', 'expect(foo).to receive(:bar)', 'receive'
7171

72-
include_examples 'detects style',
73-
'expect(foo).to have_received(:bar)',
74-
'have_received'
72+
it_behaves_like 'detects style',
73+
'expect(foo).to have_received(:bar)',
74+
'have_received'
7575
end
7676

7777
context 'when EnforcedStyle is receive' do
@@ -140,10 +140,10 @@
140140
expect_no_offenses('expect(foo).to receive(:bar)')
141141
end
142142

143-
include_examples 'detects style', 'expect(foo).to receive(:bar)', 'receive'
143+
it_behaves_like 'detects style', 'expect(foo).to receive(:bar)', 'receive'
144144

145-
include_examples 'detects style',
146-
'expect(foo).to have_received(:bar)',
147-
'have_received'
145+
it_behaves_like 'detects style',
146+
'expect(foo).to have_received(:bar)',
147+
'have_received'
148148
end
149149
end

spec/rubocop/cop/rspec/predicate_matcher_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
context 'when strict is true' do
187187
let(:strict) { true }
188188

189-
include_examples 'inflected common'
189+
it_behaves_like 'inflected common'
190190

191191
it 'accepts strict checking boolean matcher' do
192192
expect_no_offenses(<<~RUBY)
@@ -203,7 +203,7 @@
203203
context 'when strict is false' do
204204
let(:strict) { false }
205205

206-
include_examples 'inflected common'
206+
it_behaves_like 'inflected common'
207207

208208
it 'registers an offense for a predicate method in actual' do
209209
expect_offense(<<~RUBY)
@@ -489,13 +489,13 @@
489489
context 'when strict is true' do
490490
let(:strict) { true }
491491

492-
include_examples 'explicit', 'be(true)', 'be(false)'
492+
it_behaves_like 'explicit', 'be(true)', 'be(false)'
493493
end
494494

495495
context 'when strict is false' do
496496
let(:strict) { false }
497497

498-
include_examples 'explicit', 'be_truthy', 'be_falsey'
498+
it_behaves_like 'explicit', 'be_truthy', 'be_falsey'
499499
end
500500
end
501501
end

spec/rubocop/cop/rspec/subject_declaration_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
end
5252
end
5353

54-
include_examples 'flag unclear subject declaration', :subject
55-
include_examples 'flag unclear subject declaration', 'subject'
56-
include_examples 'flag unclear subject declaration', :subject!
57-
include_examples 'flag unclear subject declaration', 'subject!'
54+
it_behaves_like 'flag unclear subject declaration', :subject
55+
it_behaves_like 'flag unclear subject declaration', 'subject'
56+
it_behaves_like 'flag unclear subject declaration', :subject!
57+
it_behaves_like 'flag unclear subject declaration', 'subject!'
5858

5959
context 'when subject helper is used directly' do
6060
it 'does not register an offense on named subject' do

spec/rubocop/rspec/hook_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ def hook(source)
6464
end
6565
end
6666

67-
include_examples 'standardizes scope', 'before(:each) { }', :each
68-
include_examples 'standardizes scope', 'around(:example) { }', :each
69-
include_examples 'standardizes scope', 'after { }', :each
67+
it_behaves_like 'standardizes scope', 'before(:each) { }', :each
68+
it_behaves_like 'standardizes scope', 'around(:example) { }', :each
69+
it_behaves_like 'standardizes scope', 'after { }', :each
7070

71-
include_examples 'standardizes scope', 'before(:all) { }', :context
72-
include_examples 'standardizes scope', 'around(:context) { }', :context
71+
it_behaves_like 'standardizes scope', 'before(:all) { }', :context
72+
it_behaves_like 'standardizes scope', 'around(:context) { }', :context
7373

74-
include_examples 'standardizes scope', 'after(:suite) { }', :suite
74+
it_behaves_like 'standardizes scope', 'after(:suite) { }', :suite
7575
end
7676

7777
describe '#metadata' do

0 commit comments

Comments
 (0)