File tree Expand file tree Collapse file tree 3 files changed +37
-6
lines changed Expand file tree Collapse file tree 3 files changed +37
-6
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Master (Unreleased)
4
4
5
+ - Fix false-negative and error for ` RSpec/MetadataStyle ` when non-literal args are used in metadata in ` EnforceStyle: hash ` . ([ @cbliard ] )
6
+
5
7
## 3.0.4 (2024-08-05)
6
8
7
9
- Fix false-negative for ` UnspecifiedException ` when matcher is chained. ([ @r7kamura ] )
@@ -911,6 +913,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
911
913
[ @bquorning ] : https://github.com/bquorning
912
914
[ @brentwheeldon ] : https://github.com/BrentWheeldon
913
915
[ @brianhawley ] : https://github.com/BrianHawley
916
+ [ @cbliard ] : https://github.com/cbliard
914
917
[ @cfabianski ] : https://github.com/cfabianski
915
918
[ @clupprich ] : https://github.com/clupprich
916
919
[ @composerinteralia ] : https://github.com/composerinteralia
Original file line number Diff line number Diff line change @@ -45,13 +45,8 @@ class MetadataStyle < Base # rubocop:disable Metrics/ClassLength
45
45
PATTERN
46
46
47
47
def on_metadata ( symbols , hash )
48
- # RSpec example groups accept two string arguments. In such a case,
49
- # the rspec_metadata matcher will interpret the second string
50
- # argument as a metadata symbol.
51
- symbols . shift if symbols . first &.str_type?
52
-
53
48
symbols . each do |symbol |
54
- on_metadata_symbol ( symbol )
49
+ on_metadata_symbol ( symbol ) if symbol . sym_type?
55
50
end
56
51
57
52
return unless hash
Original file line number Diff line number Diff line change 94
94
end
95
95
end
96
96
97
+ context 'with non-literal metadata and symbol metadata' do
98
+ it 'registers no offense' do
99
+ expect_no_offenses ( <<~RUBY )
100
+ describe 'Something', a, :b do
101
+ end
102
+ RUBY
103
+ end
104
+ end
105
+
97
106
context 'with boolean keyword arguments metadata and symbol metadata' do
98
107
it 'registers offense' do
99
108
expect_offense ( <<~RUBY )
243
252
end
244
253
end
245
254
255
+ context 'with 2 non-literal metadata' do
256
+ it 'registers no offense' do
257
+ expect_no_offenses ( <<~RUBY )
258
+ describe 'Something', a, b do
259
+ end
260
+ RUBY
261
+ end
262
+ end
263
+
246
264
context 'with symbol metadata after 2 string arguments' do
247
265
it 'registers offense' do
248
266
expect_offense ( <<~RUBY )
258
276
end
259
277
end
260
278
279
+ context 'with symbol metadata after non-literal metadata' do
280
+ it 'registers offense' do
281
+ expect_offense ( <<~RUBY )
282
+ describe 'Something', a, :b do
283
+ ^^ Use hash style for metadata.
284
+ end
285
+ RUBY
286
+
287
+ expect_correction ( <<~RUBY )
288
+ describe 'Something', a, b: true do
289
+ end
290
+ RUBY
291
+ end
292
+ end
293
+
261
294
context 'with symbol metadata with parentheses' do
262
295
it 'registers offense' do
263
296
expect_offense ( <<~RUBY )
You can’t perform that action at this time.
0 commit comments