Skip to content

Commit 8cf53c8

Browse files
committed
Use RuboCop RSpec 3.8.0 for development
1 parent c248750 commit 8cf53c8

8 files changed

Lines changed: 40 additions & 55 deletions

File tree

.rubocop.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ inherit_from: .rubocop_todo.yml
55
plugins:
66
- rubocop-internal_affairs
77
- rubocop-performance
8-
9-
require:
108
- rubocop-rspec
119

1210
AllCops:

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ gem 'prism'
1111
gem 'rake'
1212
gem 'rspec'
1313
gem 'rubocop', github: 'rubocop/rubocop'
14-
gem 'rubocop-rspec', '~> 3.3.0'
14+
gem 'rubocop-rspec', '~> 3.8.0'
1515
gem 'simplecov'
1616
gem 'test-queue'
1717
gem 'yard', '~> 0.9'

spec/project_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
let(:path) { File.expand_path('../CHANGELOG.md', __dir__) }
242242
let(:entries) { lines.grep(/^\*/).map(&:chomp) }
243243

244-
include_examples 'has Changelog format'
244+
it_behaves_like 'has Changelog format'
245245

246246
context 'future entries' do
247247
let(:allowed_cop_names) do
@@ -256,7 +256,9 @@
256256
RuboCop::ConfigObsoletion.legacy_cop_names
257257
end
258258

259+
# rubocop:disable RSpec/LeakyLocalVariable
259260
dir = File.expand_path('../changelog', __dir__)
261+
# rubocop:enable RSpec/LeakyLocalVariable
260262

261263
it 'does not have a directory' do
262264
expect(Dir["#{dir}/*"].none? { |path| File.directory?(path) }).to be(true)
@@ -266,7 +268,7 @@
266268
context "For #{path}" do
267269
let(:path) { path }
268270

269-
include_examples 'has Changelog format'
271+
it_behaves_like 'has Changelog format'
270272

271273
it 'has a link to the issue or pull request address at the beginning' do
272274
repo = 'rubocop/rubocop-performance'

spec/rubocop/cop/performance/compare_with_block_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
end
5656
end
5757

58-
include_examples 'compare with block', 'sort', 'sort_by'
59-
include_examples 'compare with block', 'sort!', 'sort_by!'
60-
include_examples 'compare with block', 'max', 'max_by'
61-
include_examples 'compare with block', 'min', 'min_by'
62-
include_examples 'compare with block', 'minmax', 'minmax_by'
58+
it_behaves_like 'compare with block', 'sort', 'sort_by'
59+
it_behaves_like 'compare with block', 'sort!', 'sort_by!'
60+
it_behaves_like 'compare with block', 'max', 'max_by'
61+
it_behaves_like 'compare with block', 'min', 'min_by'
62+
it_behaves_like 'compare with block', 'minmax', 'minmax_by'
6363
end

spec/rubocop/cop/performance/end_with_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@
237237
context 'when `SafeMultiline: false`' do
238238
let(:safe_multiline) { false }
239239

240-
include_examples('different match methods', '.match?')
241-
include_examples('different match methods', ' =~')
242-
include_examples('different match methods', '.match')
240+
it_behaves_like('different match methods', '.match?')
241+
it_behaves_like('different match methods', ' =~')
242+
it_behaves_like('different match methods', '.match')
243243

244244
it 'allows match without a receiver' do
245245
expect_no_offenses('expect(subject.spin).to match(/\n\z/)')

spec/rubocop/cop/performance/regexp_match_spec.rb

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
end
1717

1818
shared_examples 'all legacy match methods' do |name, cond, correction|
19-
include_examples 'offense', "#{name} in if condition", <<-RUBY, <<-RUBY2
19+
it_behaves_like 'offense', "#{name} in if condition", <<~RUBY, <<~RUBY2
2020
if #{cond}
2121
do_something
2222
end
@@ -26,7 +26,7 @@
2626
end
2727
RUBY2
2828

29-
include_examples 'offense', "#{name} in unless condition", <<-RUBY, <<-RUBY2
29+
it_behaves_like 'offense', "#{name} in unless condition", <<~RUBY, <<~RUBY2
3030
unless #{cond}
3131
do_something
3232
end
@@ -36,19 +36,19 @@
3636
end
3737
RUBY2
3838

39-
include_examples 'offense', "#{name} in if condition", <<-RUBY, <<-RUBY2
39+
it_behaves_like 'offense', "#{name} in if condition", <<~RUBY, <<~RUBY2
4040
do_something if #{cond}
4141
RUBY
4242
do_something if #{correction}
4343
RUBY2
4444

45-
include_examples 'offense', "#{name} in unless condition", <<-RUBY, <<-RUBY2
45+
it_behaves_like 'offense', "#{name} in unless condition", <<~RUBY, <<~RUBY2
4646
do_something unless #{cond}
4747
RUBY
4848
do_something unless #{correction}
4949
RUBY2
5050

51-
include_examples 'offense', "#{name} in elsif condition", <<-RUBY, <<-RUBY2
51+
it_behaves_like 'offense', "#{name} in elsif condition", <<~RUBY, <<~RUBY2
5252
if cond
5353
do_something
5454
elsif #{cond}
@@ -62,7 +62,7 @@
6262
end
6363
RUBY2
6464

65-
include_examples 'offense', "#{name} in case condition", <<-RUBY, <<-RUBY2
65+
it_behaves_like 'offense', "#{name} in case condition", <<~RUBY, <<~RUBY2
6666
case
6767
when #{cond}
6868
do_something
@@ -74,14 +74,13 @@
7474
end
7575
RUBY2
7676

77-
include_examples 'offense', "#{name} in ternary operator", <<-RUBY, <<-RUBY2
77+
it_behaves_like 'offense', "#{name} in ternary operator", <<~RUBY, <<~RUBY2
7878
#{cond} ? do_something : do_something2
7979
RUBY
8080
#{correction} ? do_something : do_something2
8181
RUBY2
8282

83-
include_examples 'offense', "#{name} in method definition",
84-
<<-RUBY, <<-RUBY2
83+
it_behaves_like 'offense', "#{name} in method definition", <<~RUBY, <<~RUBY2
8584
def foo
8685
if #{cond}
8786
do_something
@@ -146,9 +145,8 @@ def foo
146145
RUBY
147146
end
148147

149-
include_examples 'offense',
150-
"#{name} in if guard condition with " \
151-
"#{var} is used in another method", <<-RUBY, <<-RUBY2
148+
# rubocop:disable Layout/LineLength
149+
it_behaves_like 'offense', "#{name} in if guard condition with #{var} is used in another method", <<~RUBY, <<~RUBY2
152150
def foo
153151
return if #{cond}
154152
end
@@ -165,6 +163,7 @@ def bar
165163
do_something(#{var})
166164
end
167165
RUBY2
166+
# rubocop:enable Layout/LineLength
168167

169168
it "accepts #{name} in method with #{var} in block" do
170169
expect_no_offenses(<<~RUBY)
@@ -179,8 +178,7 @@ def foo
179178
RUBY
180179
end
181180

182-
include_examples 'offense',
183-
"#{name} in method before `#{var}`", <<-RUBY, <<-RUBY2
181+
it_behaves_like 'offense', "#{name} in method before `#{var}`", <<~RUBY, <<~RUBY2
184182
def foo
185183
do_something(#{var})
186184
if #{cond}
@@ -196,9 +194,7 @@ def foo
196194
end
197195
RUBY2
198196

199-
include_examples 'offense',
200-
"#{name} in method, `#{var}` is in other method",
201-
<<-RUBY, <<-RUBY2
197+
it_behaves_like 'offense', "#{name} in method, `#{var}` is in other method", <<~RUBY, <<~RUBY2
202198
def foo
203199
if #{cond}
204200
do_something2
@@ -220,9 +216,7 @@ def bar
220216
end
221217
RUBY2
222218

223-
include_examples 'offense',
224-
"#{name} in class method, `#{var}` is in other method",
225-
<<-RUBY, <<-RUBY2
219+
it_behaves_like 'offense', "#{name} in class method, `#{var}` is in other method", <<~RUBY, <<~RUBY2
226220
def self.foo
227221
if #{cond}
228222
do_something2
@@ -244,9 +238,7 @@ def self.bar
244238
end
245239
RUBY2
246240

247-
include_examples 'offense',
248-
"#{name} in class, `#{var}` is in method",
249-
<<-RUBY, <<-RUBY2
241+
it_behaves_like 'offense', "#{name} in class, `#{var}` is in method", <<~RUBY, <<~RUBY2
250242
class Foo
251243
if #{cond}
252244
do_something
@@ -268,9 +260,7 @@ def foo
268260
end
269261
RUBY2
270262

271-
include_examples 'offense',
272-
"#{name} in module, `#{var}` is in method",
273-
<<-RUBY, <<-RUBY2
263+
it_behaves_like 'offense', "#{name} in module, `#{var}` is in method", <<~RUBY, <<~RUBY2
274264
module Foo
275265
if #{cond}
276266
do_something
@@ -292,8 +282,7 @@ def foo
292282
end
293283
RUBY2
294284

295-
include_examples 'offense', "#{name}, #{var} reference is overridden",
296-
<<-RUBY, <<-RUBY2
285+
it_behaves_like 'offense', "#{name}, #{var} reference is overridden", <<~RUBY, <<~RUBY2
297286
if #{cond}
298287
do_something
299288
#{cond}
@@ -310,20 +299,16 @@ def foo
310299
end
311300

312301
it_behaves_like('all legacy match methods', 'String#match method call', '"foo".match(re)', '"foo".match?(re)')
313-
it_behaves_like('all legacy match methods',
314-
'String#match method call with position',
302+
it_behaves_like('all legacy match methods', 'String#match method call with position',
315303
'"foo".match(re, 1)', '"foo".match?(re, 1)')
316304
it_behaves_like('all legacy match methods', 'Regexp#match method call', '/re/.match(foo)', '/re/.match?(foo)')
317-
it_behaves_like('all legacy match methods',
318-
'Regexp#match method call with position',
305+
it_behaves_like('all legacy match methods', 'Regexp#match method call with position',
319306
'/re/.match(foo, 1)', '/re/.match?(foo, 1)')
320307
it_behaves_like('all legacy match methods', 'Symbol#match method call', ':foo.match(re)', ':foo.match?(re)')
321-
it_behaves_like('all legacy match methods',
322-
'Symbol#match method call with position',
308+
it_behaves_like('all legacy match methods', 'Symbol#match method call with position',
323309
':foo.match(re, 1)', ':foo.match?(re, 1)')
324310
it_behaves_like('all legacy match methods', 'match method call for a variable', 'foo.match(/re/)', 'foo.match?(/re/)')
325-
it_behaves_like('all legacy match methods',
326-
'match method call for a variable with position',
311+
it_behaves_like('all legacy match methods', 'match method call for a variable with position',
327312
'foo.match(/re/, 1)', 'foo.match?(/re/, 1)')
328313
it_behaves_like('all legacy match methods', 'matching by =~`', '/re/ =~ foo', '/re/.match?(foo)')
329314
it_behaves_like('all legacy match methods', 'matching by =~`', 'foo =~ /re/', '/re/.match?(foo)')

spec/rubocop/cop/performance/start_with_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@
193193
context 'when `SafeMultiline: false`' do
194194
let(:safe_multiline) { false }
195195

196-
include_examples('different match methods', '.match?')
197-
include_examples('different match methods', ' =~')
198-
include_examples('different match methods', '.match')
196+
it_behaves_like('different match methods', '.match?')
197+
it_behaves_like('different match methods', ' =~')
198+
it_behaves_like('different match methods', '.match')
199199

200200
it 'allows match without a receiver' do
201201
expect_no_offenses('expect(subject.spin).to match(/\A\n/)')

spec/rubocop/cop/performance/string_include_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@
143143
end
144144
end
145145

146-
include_examples('different match methods', '.match?')
147-
include_examples('different match methods', ' =~')
148-
include_examples('different match methods', '.match')
146+
it_behaves_like('different match methods', '.match?')
147+
it_behaves_like('different match methods', ' =~')
148+
it_behaves_like('different match methods', '.match')
149149

150150
it 'registers an offense and corrects /abc/ === str' do
151151
expect_offense(<<~RUBY)

0 commit comments

Comments
 (0)