rubocop-rspec 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/config/default.yml +117 -92
- data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +7 -7
- data/lib/rubocop/cop/rspec/capybara/visibility_matcher.rb +3 -2
- data/lib/rubocop/cop/rspec/empty_line_after_subject.rb +3 -9
- data/lib/rubocop/cop/rspec/leading_subject.rb +3 -7
- data/lib/rubocop/cop/rspec/mixin/inside_example_group.rb +2 -2
- data/lib/rubocop/cop/rspec/subject_stub.rb +44 -18
- data/lib/rubocop/cop/rspec/yield.rb +1 -1
- data/lib/rubocop/rspec/config_formatter.rb +3 -4
- data/lib/rubocop/rspec/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4786aaf8f829745dafce927499fd98671a0b8ab08a61a9c99eafc26fb7235926
|
4
|
+
data.tar.gz: 38e23b1194fb915f42f4399fe6be1b6c950de10d367300a01226549e15747f93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39bb13d4cfe09307955f392935c626fb8b920e2b38a33323464e15fb9a7248c88db27259cab8c118df4ebb5888c11973e04e2e5f3ce58e64e1f18486801ac3c7
|
7
|
+
data.tar.gz: 51fa7212f5b0576b0fbfcf88c57cff79612934695f8f8f1b6c3106006b5e6dd1eff08c06cfe60fcd8a994e3eccd51810c61b208e398b708090f3e257d0bed3e8
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## Master (Unreleased)
|
4
4
|
|
5
|
+
## 2.8.0 (2022-01-24)
|
6
|
+
|
7
|
+
* Fix `RSpec/FactoryBot/SyntaxMethods` and `RSpec/Capybara/FeatureMethods` to inspect shared groups. ([@pirj][])
|
8
|
+
* Fix `RSpec/LeadingSubject` failure in non-spec code. ([@pirj][])
|
9
|
+
* Add bad example to `RSpec/SubjectStub` cop. ([@oshiro3][])
|
10
|
+
* Replace non-styleguide cops `StyleGuide` attribute with `Reference`. ([@pirj][])
|
11
|
+
* Fix `RSpec/SubjectStub` to disallow stubbing of subjects defined in parent example groups. ([@pirj][])
|
12
|
+
|
5
13
|
## 2.7.0 (2021-12-26)
|
6
14
|
|
7
15
|
* Add new `RSpec/FactoryBot/SyntaxMethods` cop. ([@leoarnold][])
|
@@ -658,3 +666,4 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
658
666
|
[@r7kamura]: https://github.com/r7kamura
|
659
667
|
[@leoarnold]: https://github.com/leoarnold
|
660
668
|
[@harry-graham]: https://github.com/harry-graham
|
669
|
+
[@oshiro3]: https://github.com/oshiro3
|
data/config/default.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
---
|
2
2
|
RSpec:
|
3
3
|
Enabled: true
|
4
|
+
StyleGuideBaseURL: https://rspec.rubystyle.guide
|
4
5
|
Include: &1
|
5
6
|
- "**/*_spec.rb"
|
6
7
|
- "**/spec/**/*"
|
@@ -113,37 +114,39 @@ RSpec/AlignLeftLetBrace:
|
|
113
114
|
Description: Checks that left braces for adjacent single line lets are aligned.
|
114
115
|
Enabled: false
|
115
116
|
VersionAdded: '1.16'
|
116
|
-
|
117
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AlignLeftLetBrace
|
117
118
|
|
118
119
|
RSpec/AlignRightLetBrace:
|
119
120
|
Description: Checks that right braces for adjacent single line lets are aligned.
|
120
121
|
Enabled: false
|
121
122
|
VersionAdded: '1.16'
|
122
|
-
|
123
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AlignRightLetBrace
|
123
124
|
|
124
125
|
RSpec/AnyInstance:
|
125
126
|
Description: Check that instances are not being stubbed globally.
|
126
127
|
Enabled: true
|
127
128
|
VersionAdded: '1.4'
|
128
|
-
StyleGuide: https://
|
129
|
+
StyleGuide: https://rspec.rubystyle.guide/#any_instance_of
|
130
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AnyInstance
|
129
131
|
|
130
132
|
RSpec/AroundBlock:
|
131
133
|
Description: Checks that around blocks actually run the test.
|
132
134
|
Enabled: true
|
133
135
|
VersionAdded: '1.11'
|
134
|
-
|
136
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AroundBlock
|
135
137
|
|
136
138
|
RSpec/Be:
|
137
139
|
Description: Check for expectations where `be` is used without argument.
|
138
140
|
Enabled: true
|
139
141
|
VersionAdded: '1.25'
|
140
|
-
StyleGuide: https://
|
142
|
+
StyleGuide: https://rspec.rubystyle.guide/#be-matcher
|
143
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Be
|
141
144
|
|
142
145
|
RSpec/BeEql:
|
143
146
|
Description: Check for expectations where `be(...)` can replace `eql(...)`.
|
144
147
|
Enabled: true
|
145
148
|
VersionAdded: '1.7'
|
146
|
-
|
149
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeEql
|
147
150
|
|
148
151
|
RSpec/BeforeAfterAll:
|
149
152
|
Description: Check that before/after(:all) isn't being used.
|
@@ -153,13 +156,15 @@ RSpec/BeforeAfterAll:
|
|
153
156
|
- spec/rails_helper.rb
|
154
157
|
- spec/support/**/*.rb
|
155
158
|
VersionAdded: '1.12'
|
156
|
-
StyleGuide: https://
|
159
|
+
StyleGuide: https://rspec.rubystyle.guide/#avoid-hooks-with-context-scope
|
160
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeforeAfterAll
|
157
161
|
|
158
162
|
RSpec/ContextMethod:
|
159
163
|
Description: "`context` should not be used for specifying methods."
|
160
164
|
Enabled: true
|
161
165
|
VersionAdded: '1.36'
|
162
|
-
StyleGuide: https://
|
166
|
+
StyleGuide: https://rspec.rubystyle.guide/#example-group-naming
|
167
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ContextMethod
|
163
168
|
|
164
169
|
RSpec/ContextWording:
|
165
170
|
Description: Checks that `context` docstring starts with an allowed prefix.
|
@@ -170,7 +175,8 @@ RSpec/ContextWording:
|
|
170
175
|
- without
|
171
176
|
VersionAdded: '1.20'
|
172
177
|
VersionChanged: 1.20.1
|
173
|
-
StyleGuide: https://
|
178
|
+
StyleGuide: https://rspec.rubystyle.guide/#context-descriptions
|
179
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ContextWording
|
174
180
|
|
175
181
|
RSpec/DescribeClass:
|
176
182
|
Description: Check that the first argument to the top-level describe is a constant.
|
@@ -199,19 +205,19 @@ RSpec/DescribeClass:
|
|
199
205
|
- task
|
200
206
|
VersionAdded: '1.0'
|
201
207
|
VersionChanged: '2.7'
|
202
|
-
|
208
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeClass
|
203
209
|
|
204
210
|
RSpec/DescribeMethod:
|
205
211
|
Description: Checks that the second argument to `describe` specifies a method.
|
206
212
|
Enabled: true
|
207
213
|
VersionAdded: '1.0'
|
208
|
-
|
214
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeMethod
|
209
215
|
|
210
216
|
RSpec/DescribeSymbol:
|
211
217
|
Description: Avoid describing symbols.
|
212
218
|
Enabled: true
|
213
219
|
VersionAdded: '1.15'
|
214
|
-
|
220
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeSymbol
|
215
221
|
|
216
222
|
RSpec/DescribedClass:
|
217
223
|
Description: Checks that tests use `described_class`.
|
@@ -224,64 +230,69 @@ RSpec/DescribedClass:
|
|
224
230
|
SafeAutoCorrect: false
|
225
231
|
VersionAdded: '1.0'
|
226
232
|
VersionChanged: '1.11'
|
227
|
-
|
233
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribedClass
|
228
234
|
|
229
235
|
RSpec/DescribedClassModuleWrapping:
|
230
236
|
Description: Avoid opening modules and defining specs within them.
|
231
237
|
Enabled: false
|
232
238
|
VersionAdded: '1.37'
|
233
|
-
|
239
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribedClassModuleWrapping
|
234
240
|
|
235
241
|
RSpec/Dialect:
|
236
242
|
Description: This cop enforces custom RSpec dialects.
|
237
243
|
Enabled: false
|
238
244
|
PreferredMethods: {}
|
239
245
|
VersionAdded: '1.33'
|
240
|
-
|
246
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Dialect
|
241
247
|
|
242
248
|
RSpec/EmptyExampleGroup:
|
243
249
|
Description: Checks if an example group does not include any tests.
|
244
250
|
Enabled: true
|
245
251
|
VersionAdded: '1.7'
|
246
252
|
VersionChanged: '2.0'
|
247
|
-
|
253
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyExampleGroup
|
248
254
|
|
249
255
|
RSpec/EmptyHook:
|
250
256
|
Description: Checks for empty before and after hooks.
|
251
257
|
Enabled: true
|
252
258
|
VersionAdded: '1.39'
|
253
|
-
|
259
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyHook
|
254
260
|
|
255
261
|
RSpec/EmptyLineAfterExample:
|
256
262
|
Description: Checks if there is an empty line after example blocks.
|
257
263
|
Enabled: true
|
258
264
|
AllowConsecutiveOneLiners: true
|
259
265
|
VersionAdded: '1.36'
|
260
|
-
StyleGuide: https://
|
266
|
+
StyleGuide: https://rspec.rubystyle.guide/#empty-lines-around-examples
|
267
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterExample
|
261
268
|
|
262
269
|
RSpec/EmptyLineAfterExampleGroup:
|
263
270
|
Description: Checks if there is an empty line after example group blocks.
|
264
271
|
Enabled: true
|
265
272
|
VersionAdded: '1.27'
|
266
|
-
StyleGuide: https://
|
273
|
+
StyleGuide: https://rspec.rubystyle.guide/#empty-lines-between-describes
|
274
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterExampleGroup
|
267
275
|
|
268
276
|
RSpec/EmptyLineAfterFinalLet:
|
269
277
|
Description: Checks if there is an empty line after the last let block.
|
270
278
|
Enabled: true
|
271
279
|
VersionAdded: '1.14'
|
272
|
-
StyleGuide: https://
|
280
|
+
StyleGuide: https://rspec.rubystyle.guide/#empty-line-after-let
|
281
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterFinalLet
|
273
282
|
|
274
283
|
RSpec/EmptyLineAfterHook:
|
275
284
|
Description: Checks if there is an empty line after hook blocks.
|
276
285
|
Enabled: true
|
277
286
|
VersionAdded: '1.27'
|
278
|
-
StyleGuide: https://
|
287
|
+
StyleGuide: https://rspec.rubystyle.guide/#empty-line-after-let
|
288
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterHook
|
279
289
|
|
280
290
|
RSpec/EmptyLineAfterSubject:
|
281
291
|
Description: Checks if there is an empty line after subject block.
|
282
292
|
Enabled: true
|
283
293
|
VersionAdded: '1.14'
|
284
|
-
StyleGuide: https://
|
294
|
+
StyleGuide: https://rspec.rubystyle.guide/#empty-line-after-let
|
295
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterSubject
|
285
296
|
|
286
297
|
RSpec/ExampleLength:
|
287
298
|
Description: Checks for long examples.
|
@@ -290,7 +301,7 @@ RSpec/ExampleLength:
|
|
290
301
|
CountAsOne: []
|
291
302
|
VersionAdded: '1.5'
|
292
303
|
VersionChanged: '2.3'
|
293
|
-
|
304
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleLength
|
294
305
|
|
295
306
|
RSpec/ExampleWithoutDescription:
|
296
307
|
Description: Checks for examples without a description.
|
@@ -301,13 +312,13 @@ RSpec/ExampleWithoutDescription:
|
|
301
312
|
- single_line_only
|
302
313
|
- disallow
|
303
314
|
VersionAdded: '1.22'
|
304
|
-
|
315
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWithoutDescription
|
305
316
|
|
306
317
|
RSpec/ExcessiveDocstringSpacing:
|
307
318
|
Description: Checks for excessive whitespace in example descriptions.
|
308
319
|
Enabled: pending
|
309
320
|
VersionAdded: '2.5'
|
310
|
-
|
321
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExcessiveDocstringSpacing
|
311
322
|
|
312
323
|
RSpec/ExampleWording:
|
313
324
|
Description: Checks for common mistakes in example descriptions.
|
@@ -320,7 +331,8 @@ RSpec/ExampleWording:
|
|
320
331
|
IgnoredWords: []
|
321
332
|
VersionAdded: '1.0'
|
322
333
|
VersionChanged: '1.2'
|
323
|
-
StyleGuide: https://
|
334
|
+
StyleGuide: https://rspec.rubystyle.guide/#should-in-example-docstrings
|
335
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWording
|
324
336
|
|
325
337
|
RSpec/ExpectActual:
|
326
338
|
Description: Checks for `expect(...)` calls containing literal values.
|
@@ -328,7 +340,7 @@ RSpec/ExpectActual:
|
|
328
340
|
Exclude:
|
329
341
|
- spec/routing/**/*
|
330
342
|
VersionAdded: '1.7'
|
331
|
-
|
343
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectActual
|
332
344
|
|
333
345
|
RSpec/ExpectChange:
|
334
346
|
Description: Checks for consistent style of change matcher.
|
@@ -340,19 +352,19 @@ RSpec/ExpectChange:
|
|
340
352
|
SafeAutoCorrect: false
|
341
353
|
VersionAdded: '1.22'
|
342
354
|
VersionChanged: '2.5'
|
343
|
-
|
355
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectChange
|
344
356
|
|
345
357
|
RSpec/ExpectInHook:
|
346
358
|
Description: Do not use `expect` in hooks such as `before`.
|
347
359
|
Enabled: true
|
348
360
|
VersionAdded: '1.16'
|
349
|
-
|
361
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectInHook
|
350
362
|
|
351
363
|
RSpec/ExpectOutput:
|
352
364
|
Description: Checks for opportunities to use `expect { ... }.to output`.
|
353
365
|
Enabled: true
|
354
366
|
VersionAdded: '1.10'
|
355
|
-
|
367
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectOutput
|
356
368
|
|
357
369
|
RSpec/FilePath:
|
358
370
|
Description: Checks that spec file paths are consistent and well-formed.
|
@@ -367,14 +379,14 @@ RSpec/FilePath:
|
|
367
379
|
SpecSuffixOnly: false
|
368
380
|
VersionAdded: '1.2'
|
369
381
|
VersionChanged: '1.40'
|
370
|
-
|
382
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FilePath
|
371
383
|
|
372
384
|
RSpec/Focus:
|
373
385
|
Description: Checks if examples are focused.
|
374
386
|
Enabled: true
|
375
387
|
VersionAdded: '1.5'
|
376
388
|
VersionChanged: '2.1'
|
377
|
-
|
389
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Focus
|
378
390
|
|
379
391
|
RSpec/HookArgument:
|
380
392
|
Description: Checks the arguments passed to `before`, `around`, and `after`.
|
@@ -385,25 +397,27 @@ RSpec/HookArgument:
|
|
385
397
|
- each
|
386
398
|
- example
|
387
399
|
VersionAdded: '1.7'
|
388
|
-
StyleGuide: https://
|
400
|
+
StyleGuide: https://rspec.rubystyle.guide/#redundant-beforeeach
|
401
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HookArgument
|
389
402
|
|
390
403
|
RSpec/HooksBeforeExamples:
|
391
404
|
Description: Checks for before/around/after hooks that come after an example.
|
392
405
|
Enabled: true
|
393
406
|
VersionAdded: '1.29'
|
394
|
-
|
407
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HooksBeforeExamples
|
395
408
|
|
396
409
|
RSpec/IdenticalEqualityAssertion:
|
397
410
|
Description: Checks for equality assertions with identical expressions on both sides.
|
398
411
|
Enabled: pending
|
399
412
|
VersionAdded: '2.4'
|
400
|
-
|
413
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IdenticalEqualityAssertion
|
401
414
|
|
402
415
|
RSpec/ImplicitBlockExpectation:
|
403
416
|
Description: Check that implicit block expectation syntax is not used.
|
404
417
|
Enabled: true
|
405
418
|
VersionAdded: '1.35'
|
406
|
-
StyleGuide: https://
|
419
|
+
StyleGuide: https://rspec.rubystyle.guide/#implicit-block-expectations
|
420
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitBlockExpectation
|
407
421
|
|
408
422
|
RSpec/ImplicitExpect:
|
409
423
|
Description: Check that a consistent implicit expectation style is used.
|
@@ -413,7 +427,8 @@ RSpec/ImplicitExpect:
|
|
413
427
|
- is_expected
|
414
428
|
- should
|
415
429
|
VersionAdded: '1.8'
|
416
|
-
StyleGuide: https://
|
430
|
+
StyleGuide: https://rspec.rubystyle.guide/#use-expect
|
431
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitExpect
|
417
432
|
|
418
433
|
RSpec/ImplicitSubject:
|
419
434
|
Description: Checks for usage of implicit subject (`is_expected` / `should`).
|
@@ -425,13 +440,13 @@ RSpec/ImplicitSubject:
|
|
425
440
|
- disallow
|
426
441
|
VersionAdded: '1.29'
|
427
442
|
VersionChanged: '1.30'
|
428
|
-
|
443
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitSubject
|
429
444
|
|
430
445
|
RSpec/InstanceSpy:
|
431
446
|
Description: Checks for `instance_double` used with `have_received`.
|
432
447
|
Enabled: true
|
433
448
|
VersionAdded: '1.12'
|
434
|
-
|
449
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InstanceSpy
|
435
450
|
|
436
451
|
RSpec/InstanceVariable:
|
437
452
|
Description: Checks for instance variable usage in specs.
|
@@ -439,7 +454,8 @@ RSpec/InstanceVariable:
|
|
439
454
|
AssignmentOnly: false
|
440
455
|
VersionAdded: '1.0'
|
441
456
|
VersionChanged: '1.7'
|
442
|
-
StyleGuide: https://
|
457
|
+
StyleGuide: https://rspec.rubystyle.guide/#instance-variables
|
458
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InstanceVariable
|
443
459
|
|
444
460
|
RSpec/ItBehavesLike:
|
445
461
|
Description: Checks that only one `it_behaves_like` style is used.
|
@@ -449,45 +465,47 @@ RSpec/ItBehavesLike:
|
|
449
465
|
- it_behaves_like
|
450
466
|
- it_should_behave_like
|
451
467
|
VersionAdded: '1.13'
|
452
|
-
|
468
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ItBehavesLike
|
453
469
|
|
454
470
|
RSpec/IteratedExpectation:
|
455
471
|
Description: Check that `all` matcher is used instead of iterating over an array.
|
456
472
|
Enabled: true
|
457
473
|
VersionAdded: '1.14'
|
458
|
-
|
474
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IteratedExpectation
|
459
475
|
|
460
476
|
RSpec/LeadingSubject:
|
461
477
|
Description: Enforce that subject is the first definition in the test.
|
462
478
|
Enabled: true
|
463
479
|
VersionAdded: '1.7'
|
464
480
|
VersionChanged: '1.14'
|
465
|
-
StyleGuide: https://
|
481
|
+
StyleGuide: https://rspec.rubystyle.guide/#leading-subject
|
482
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LeadingSubject
|
466
483
|
|
467
484
|
RSpec/LeakyConstantDeclaration:
|
468
485
|
Description: Checks that no class, module, or constant is declared.
|
469
486
|
Enabled: true
|
470
487
|
VersionAdded: '1.35'
|
471
|
-
StyleGuide: https://
|
488
|
+
StyleGuide: https://rspec.rubystyle.guide/#declare-constants
|
489
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LeakyConstantDeclaration
|
472
490
|
|
473
491
|
RSpec/LetBeforeExamples:
|
474
492
|
Description: Checks for `let` definitions that come after an example.
|
475
493
|
Enabled: true
|
476
494
|
VersionAdded: '1.16'
|
477
495
|
VersionChanged: '1.22'
|
478
|
-
|
496
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetBeforeExamples
|
479
497
|
|
480
498
|
RSpec/LetSetup:
|
481
499
|
Description: Checks unreferenced `let!` calls being used for test setup.
|
482
500
|
Enabled: true
|
483
501
|
VersionAdded: '1.7'
|
484
|
-
|
502
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetSetup
|
485
503
|
|
486
504
|
RSpec/MessageChain:
|
487
505
|
Description: Check that chains of messages are not being stubbed.
|
488
506
|
Enabled: true
|
489
507
|
VersionAdded: '1.7'
|
490
|
-
|
508
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageChain
|
491
509
|
|
492
510
|
RSpec/MessageExpectation:
|
493
511
|
Description: Checks for consistent message expectation style.
|
@@ -498,7 +516,7 @@ RSpec/MessageExpectation:
|
|
498
516
|
- expect
|
499
517
|
VersionAdded: '1.7'
|
500
518
|
VersionChanged: '1.8'
|
501
|
-
|
519
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageExpectation
|
502
520
|
|
503
521
|
RSpec/MessageSpies:
|
504
522
|
Description: Checks that message expectations are set using spies.
|
@@ -508,19 +526,19 @@ RSpec/MessageSpies:
|
|
508
526
|
- have_received
|
509
527
|
- receive
|
510
528
|
VersionAdded: '1.9'
|
511
|
-
|
529
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageSpies
|
512
530
|
|
513
531
|
RSpec/MissingExampleGroupArgument:
|
514
532
|
Description: Checks that the first argument to an example group is not empty.
|
515
533
|
Enabled: true
|
516
534
|
VersionAdded: '1.28'
|
517
|
-
|
535
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MissingExampleGroupArgument
|
518
536
|
|
519
537
|
RSpec/MultipleDescribes:
|
520
538
|
Description: Checks for multiple top-level example groups.
|
521
539
|
Enabled: true
|
522
540
|
VersionAdded: '1.0'
|
523
|
-
|
541
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleDescribes
|
524
542
|
|
525
543
|
RSpec/MultipleExpectations:
|
526
544
|
Description: Checks if examples contain too many `expect` calls.
|
@@ -528,7 +546,8 @@ RSpec/MultipleExpectations:
|
|
528
546
|
Max: 1
|
529
547
|
VersionAdded: '1.7'
|
530
548
|
VersionChanged: '1.21'
|
531
|
-
StyleGuide: https://
|
549
|
+
StyleGuide: https://rspec.rubystyle.guide/#expectation-per-example
|
550
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleExpectations
|
532
551
|
|
533
552
|
RSpec/MultipleMemoizedHelpers:
|
534
553
|
Description: Checks if example groups contain too many `let` and `subject` calls.
|
@@ -536,20 +555,22 @@ RSpec/MultipleMemoizedHelpers:
|
|
536
555
|
AllowSubject: true
|
537
556
|
Max: 5
|
538
557
|
VersionAdded: '1.43'
|
539
|
-
StyleGuide: https://
|
558
|
+
StyleGuide: https://rspec.rubystyle.guide/#let-blocks
|
559
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleMemoizedHelpers
|
540
560
|
|
541
561
|
RSpec/MultipleSubjects:
|
542
562
|
Description: Checks if an example group defines `subject` multiple times.
|
543
563
|
Enabled: true
|
544
564
|
VersionAdded: '1.16'
|
545
|
-
|
565
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleSubjects
|
546
566
|
|
547
567
|
RSpec/NamedSubject:
|
548
568
|
Description: Checks for explicitly referenced test subjects.
|
549
569
|
Enabled: true
|
550
570
|
IgnoreSharedExamples: true
|
551
571
|
VersionAdded: 1.5.3
|
552
|
-
StyleGuide: https://
|
572
|
+
StyleGuide: https://rspec.rubystyle.guide/#use-subject
|
573
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject
|
553
574
|
|
554
575
|
RSpec/NestedGroups:
|
555
576
|
Description: Checks for nested example groups.
|
@@ -557,7 +578,7 @@ RSpec/NestedGroups:
|
|
557
578
|
Max: 3
|
558
579
|
VersionAdded: '1.7'
|
559
580
|
VersionChanged: '1.10'
|
560
|
-
|
581
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NestedGroups
|
561
582
|
|
562
583
|
RSpec/NotToNot:
|
563
584
|
Description: Checks for consistent method usage for negating expectations.
|
@@ -567,19 +588,19 @@ RSpec/NotToNot:
|
|
567
588
|
- not_to
|
568
589
|
- to_not
|
569
590
|
VersionAdded: '1.4'
|
570
|
-
|
591
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NotToNot
|
571
592
|
|
572
593
|
RSpec/OverwritingSetup:
|
573
594
|
Description: Checks if there is a let/subject that overwrites an existing one.
|
574
595
|
Enabled: true
|
575
596
|
VersionAdded: '1.14'
|
576
|
-
|
597
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/OverwritingSetup
|
577
598
|
|
578
599
|
RSpec/Pending:
|
579
600
|
Description: Checks for any pending or skipped examples.
|
580
601
|
Enabled: false
|
581
602
|
VersionAdded: '1.25'
|
582
|
-
|
603
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Pending
|
583
604
|
|
584
605
|
RSpec/PredicateMatcher:
|
585
606
|
Description: Prefer using predicate matcher over using predicate method directly.
|
@@ -592,49 +613,50 @@ RSpec/PredicateMatcher:
|
|
592
613
|
- explicit
|
593
614
|
SafeAutoCorrect: false
|
594
615
|
VersionAdded: '1.16'
|
595
|
-
StyleGuide: https://
|
616
|
+
StyleGuide: https://rspec.rubystyle.guide/#predicate-matchers
|
617
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/PredicateMatcher
|
596
618
|
|
597
619
|
RSpec/ReceiveCounts:
|
598
620
|
Description: Check for `once` and `twice` receive counts matchers usage.
|
599
621
|
Enabled: true
|
600
622
|
VersionAdded: '1.26'
|
601
|
-
|
623
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReceiveCounts
|
602
624
|
|
603
625
|
RSpec/ReceiveNever:
|
604
626
|
Description: Prefer `not_to receive(...)` over `receive(...).never`.
|
605
627
|
Enabled: true
|
606
628
|
VersionAdded: '1.28'
|
607
|
-
|
629
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReceiveNever
|
608
630
|
|
609
631
|
RSpec/RepeatedDescription:
|
610
632
|
Description: Check for repeated description strings in example groups.
|
611
633
|
Enabled: true
|
612
634
|
VersionAdded: '1.9'
|
613
|
-
|
635
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedDescription
|
614
636
|
|
615
637
|
RSpec/RepeatedExample:
|
616
638
|
Description: Check for repeated examples within example groups.
|
617
639
|
Enabled: true
|
618
640
|
VersionAdded: '1.10'
|
619
|
-
|
641
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedExample
|
620
642
|
|
621
643
|
RSpec/RepeatedExampleGroupBody:
|
622
644
|
Description: Check for repeated describe and context block body.
|
623
645
|
Enabled: true
|
624
646
|
VersionAdded: '1.38'
|
625
|
-
|
647
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedExampleGroupBody
|
626
648
|
|
627
649
|
RSpec/RepeatedExampleGroupDescription:
|
628
650
|
Description: Check for repeated example group descriptions.
|
629
651
|
Enabled: true
|
630
652
|
VersionAdded: '1.38'
|
631
|
-
|
653
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedExampleGroupDescription
|
632
654
|
|
633
655
|
RSpec/RepeatedIncludeExample:
|
634
656
|
Description: Check for repeated include of shared examples.
|
635
657
|
Enabled: true
|
636
658
|
VersionAdded: '1.44'
|
637
|
-
|
659
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedIncludeExample
|
638
660
|
|
639
661
|
RSpec/ReturnFromStub:
|
640
662
|
Description: Checks for consistent style of stub's return setting.
|
@@ -645,63 +667,65 @@ RSpec/ReturnFromStub:
|
|
645
667
|
- block
|
646
668
|
VersionAdded: '1.16'
|
647
669
|
VersionChanged: '1.22'
|
648
|
-
|
670
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReturnFromStub
|
649
671
|
|
650
672
|
RSpec/ScatteredLet:
|
651
673
|
Description: Checks for let scattered across the example group.
|
652
674
|
Enabled: true
|
653
675
|
VersionAdded: '1.14'
|
654
676
|
VersionChanged: '1.39'
|
655
|
-
|
677
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredLet
|
656
678
|
|
657
679
|
RSpec/ScatteredSetup:
|
658
680
|
Description: Checks for setup scattered across multiple hooks in an example group.
|
659
681
|
Enabled: true
|
660
682
|
VersionAdded: '1.10'
|
661
|
-
|
683
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredSetup
|
662
684
|
|
663
685
|
RSpec/SharedContext:
|
664
686
|
Description: Checks for proper shared_context and shared_examples usage.
|
665
687
|
Enabled: true
|
666
688
|
VersionAdded: '1.13'
|
667
|
-
|
689
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SharedContext
|
668
690
|
|
669
691
|
RSpec/SharedExamples:
|
670
692
|
Description: Enforces use of string to titleize shared examples.
|
671
693
|
Enabled: true
|
672
694
|
VersionAdded: '1.25'
|
673
|
-
|
695
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SharedExamples
|
674
696
|
|
675
697
|
RSpec/SingleArgumentMessageChain:
|
676
698
|
Description: Checks that chains of messages contain more than one element.
|
677
699
|
Enabled: true
|
678
700
|
VersionAdded: '1.9'
|
679
701
|
VersionChanged: '1.10'
|
680
|
-
|
702
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SingleArgumentMessageChain
|
681
703
|
|
682
704
|
RSpec/StubbedMock:
|
683
705
|
Description: Checks that message expectations do not have a configured response.
|
684
706
|
Enabled: true
|
685
707
|
VersionAdded: '1.44'
|
686
|
-
|
708
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/StubbedMock
|
687
709
|
|
688
710
|
RSpec/SubjectDeclaration:
|
689
711
|
Description: Ensure that subject is defined using subject helper.
|
690
712
|
Enabled: pending
|
691
713
|
VersionAdded: '2.5'
|
692
|
-
|
714
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SubjectDeclaration
|
693
715
|
|
694
716
|
RSpec/SubjectStub:
|
695
717
|
Description: Checks for stubbed test subjects.
|
696
718
|
Enabled: true
|
697
719
|
VersionAdded: '1.7'
|
698
|
-
|
720
|
+
VersionChanged: '2.8'
|
721
|
+
StyleGuide: https://rspec.rubystyle.guide/#dont-stub-subject
|
722
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SubjectStub
|
699
723
|
|
700
724
|
RSpec/UnspecifiedException:
|
701
725
|
Description: Checks for a specified error in checking raised errors.
|
702
726
|
Enabled: true
|
703
727
|
VersionAdded: '1.30'
|
704
|
-
|
728
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/UnspecifiedException
|
705
729
|
|
706
730
|
RSpec/VariableDefinition:
|
707
731
|
Description: Checks that memoized helpers names are symbols or strings.
|
@@ -711,7 +735,7 @@ RSpec/VariableDefinition:
|
|
711
735
|
- symbols
|
712
736
|
- strings
|
713
737
|
VersionAdded: '1.40'
|
714
|
-
|
738
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VariableDefinition
|
715
739
|
|
716
740
|
RSpec/VariableName:
|
717
741
|
Description: Checks that memoized helper names use the configured style.
|
@@ -723,7 +747,7 @@ RSpec/VariableName:
|
|
723
747
|
IgnoredPatterns: []
|
724
748
|
VersionAdded: '1.40'
|
725
749
|
VersionChanged: '1.43'
|
726
|
-
|
750
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VariableName
|
727
751
|
|
728
752
|
RSpec/VerifiedDoubles:
|
729
753
|
Description: Prefer using verifying doubles over normal doubles.
|
@@ -732,19 +756,20 @@ RSpec/VerifiedDoubles:
|
|
732
756
|
IgnoreSymbolicNames: false
|
733
757
|
VersionAdded: 1.2.1
|
734
758
|
VersionChanged: '1.5'
|
735
|
-
StyleGuide: https://
|
759
|
+
StyleGuide: https://rspec.rubystyle.guide/#doubles
|
760
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VerifiedDoubles
|
736
761
|
|
737
762
|
RSpec/VoidExpect:
|
738
763
|
Description: This cop checks void `expect()`.
|
739
764
|
Enabled: true
|
740
765
|
VersionAdded: '1.16'
|
741
|
-
|
766
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VoidExpect
|
742
767
|
|
743
768
|
RSpec/Yield:
|
744
769
|
Description: This cop checks for calling a block within a stub.
|
745
770
|
Enabled: true
|
746
771
|
VersionAdded: '1.32'
|
747
|
-
|
772
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Yield
|
748
773
|
|
749
774
|
RSpec/Capybara:
|
750
775
|
Enabled: true
|
@@ -756,7 +781,7 @@ RSpec/Capybara/CurrentPathExpectation:
|
|
756
781
|
Enabled: true
|
757
782
|
VersionAdded: '1.18'
|
758
783
|
VersionChanged: '2.0'
|
759
|
-
|
784
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/CurrentPathExpectation
|
760
785
|
|
761
786
|
RSpec/Capybara/FeatureMethods:
|
762
787
|
Description: Checks for consistent method usage in feature specs.
|
@@ -764,14 +789,14 @@ RSpec/Capybara/FeatureMethods:
|
|
764
789
|
EnabledMethods: []
|
765
790
|
VersionAdded: '1.17'
|
766
791
|
VersionChanged: '2.0'
|
767
|
-
|
792
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/FeatureMethods
|
768
793
|
|
769
794
|
RSpec/Capybara/VisibilityMatcher:
|
770
|
-
Description: Checks for boolean visibility in
|
795
|
+
Description: Checks for boolean visibility in Capybara finders.
|
771
796
|
Enabled: true
|
772
797
|
VersionAdded: '1.39'
|
773
798
|
VersionChanged: '2.0'
|
774
|
-
|
799
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/VisibilityMatcher
|
775
800
|
|
776
801
|
RSpec/FactoryBot:
|
777
802
|
Enabled: true
|
@@ -787,7 +812,7 @@ RSpec/FactoryBot/AttributeDefinedStatically:
|
|
787
812
|
- features/support/factories/**/*.rb
|
788
813
|
VersionAdded: '1.28'
|
789
814
|
VersionChanged: '2.0'
|
790
|
-
|
815
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/AttributeDefinedStatically
|
791
816
|
|
792
817
|
RSpec/FactoryBot/CreateList:
|
793
818
|
Description: Checks for create_list usage.
|
@@ -804,7 +829,7 @@ RSpec/FactoryBot/CreateList:
|
|
804
829
|
- n_times
|
805
830
|
VersionAdded: '1.25'
|
806
831
|
VersionChanged: '2.0'
|
807
|
-
|
832
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/CreateList
|
808
833
|
|
809
834
|
RSpec/FactoryBot/FactoryClassName:
|
810
835
|
Description: Use string value when setting the class attribute explicitly.
|
@@ -815,14 +840,14 @@ RSpec/FactoryBot/FactoryClassName:
|
|
815
840
|
- features/support/factories/**/*.rb
|
816
841
|
VersionAdded: '1.37'
|
817
842
|
VersionChanged: '2.0'
|
818
|
-
|
843
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/FactoryClassName
|
819
844
|
|
820
845
|
RSpec/FactoryBot/SyntaxMethods:
|
821
846
|
Description: Use shorthands from `FactoryBot::Syntax::Methods` in your specs.
|
822
847
|
Enabled: pending
|
823
848
|
SafeAutoCorrect: false
|
824
849
|
VersionAdded: '2.7'
|
825
|
-
|
850
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/SyntaxMethods
|
826
851
|
|
827
852
|
RSpec/Rails:
|
828
853
|
Enabled: true
|
@@ -833,7 +858,7 @@ RSpec/Rails/AvoidSetupHook:
|
|
833
858
|
Description: Checks that tests use RSpec `before` hook over Rails `setup` method.
|
834
859
|
Enabled: pending
|
835
860
|
VersionAdded: '2.4'
|
836
|
-
|
861
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/AvoidSetupHook
|
837
862
|
|
838
863
|
RSpec/Rails/HttpStatus:
|
839
864
|
Description: Enforces use of symbolic or numeric value to describe HTTP status.
|
@@ -844,4 +869,4 @@ RSpec/Rails/HttpStatus:
|
|
844
869
|
- symbolic
|
845
870
|
VersionAdded: '1.23'
|
846
871
|
VersionChanged: '2.0'
|
847
|
-
|
872
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus
|
@@ -6,13 +6,13 @@ module RuboCop
|
|
6
6
|
module Capybara
|
7
7
|
# Checks that no expectations are set on Capybara's `current_path`.
|
8
8
|
#
|
9
|
-
# The
|
10
|
-
# teamcapybara/capybara/master/Capybara/RSpecMatchers#have_current_path-
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
9
|
+
# The
|
10
|
+
# https://www.rubydoc.info/github/teamcapybara/capybara/master/Capybara/RSpecMatchers#have_current_path-instance_method[`have_current_path` matcher]
|
11
|
+
# should be used on `page` to set expectations on Capybara's
|
12
|
+
# current path, since it uses
|
13
|
+
# https://github.com/teamcapybara/capybara/blob/master/README.md#asynchronous-javascript-ajax-and-friends[Capybara's waiting functionality]
|
14
|
+
# which ensures that preceding actions (like `click_link`) have
|
15
|
+
# completed.
|
16
16
|
#
|
17
17
|
# @example
|
18
18
|
# # bad
|
@@ -4,7 +4,7 @@ module RuboCop
|
|
4
4
|
module Cop
|
5
5
|
module RSpec
|
6
6
|
module Capybara
|
7
|
-
# Checks for boolean visibility in
|
7
|
+
# Checks for boolean visibility in Capybara finders.
|
8
8
|
#
|
9
9
|
# Capybara lets you find elements that match a certain visibility using
|
10
10
|
# the `:visible` option. `:visible` accepts both boolean and symbols as
|
@@ -12,7 +12,8 @@ module RuboCop
|
|
12
12
|
# false` does not find just invisible elements, but both visible and
|
13
13
|
# invisible elements. For expressiveness and clarity, use one of the
|
14
14
|
# symbol values, `:all`, `:hidden` or `:visible`.
|
15
|
-
#
|
15
|
+
# Read more in
|
16
|
+
# https://www.rubydoc.info/gems/capybara/Capybara%2FNode%2FFinders:all[the documentation].
|
16
17
|
#
|
17
18
|
# @example
|
18
19
|
#
|
@@ -17,24 +17,18 @@ module RuboCop
|
|
17
17
|
class EmptyLineAfterSubject < Base
|
18
18
|
extend AutoCorrector
|
19
19
|
include EmptyLineSeparation
|
20
|
+
include InsideExampleGroup
|
20
21
|
|
21
22
|
MSG = 'Add an empty line after `%<subject>s`.'
|
22
23
|
|
23
24
|
def on_block(node)
|
24
|
-
return unless subject?(node)
|
25
|
+
return unless subject?(node)
|
26
|
+
return unless inside_example_group?(node)
|
25
27
|
|
26
28
|
missing_separating_line_offense(node) do |method|
|
27
29
|
format(MSG, subject: method)
|
28
30
|
end
|
29
31
|
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def in_spec_block?(node)
|
34
|
-
node.each_ancestor(:block).any? do |ancestor|
|
35
|
-
Examples.all(ancestor.method_name)
|
36
|
-
end
|
37
|
-
end
|
38
32
|
end
|
39
33
|
end
|
40
34
|
end
|
@@ -33,11 +33,13 @@ module RuboCop
|
|
33
33
|
#
|
34
34
|
class LeadingSubject < Base
|
35
35
|
extend AutoCorrector
|
36
|
+
include InsideExampleGroup
|
36
37
|
|
37
38
|
MSG = 'Declare `subject` above any other `%<offending>s` declarations.'
|
38
39
|
|
39
40
|
def on_block(node)
|
40
|
-
return unless subject?(node)
|
41
|
+
return unless subject?(node)
|
42
|
+
return unless inside_example_group?(node)
|
41
43
|
|
42
44
|
check_previous_nodes(node)
|
43
45
|
end
|
@@ -78,12 +80,6 @@ module RuboCop
|
|
78
80
|
spec_group?(node) ||
|
79
81
|
include?(node)
|
80
82
|
end
|
81
|
-
|
82
|
-
def in_spec_block?(node)
|
83
|
-
node.each_ancestor(:block).any? do |ancestor|
|
84
|
-
example?(ancestor)
|
85
|
-
end
|
86
|
-
end
|
87
83
|
end
|
88
84
|
end
|
89
85
|
end
|
@@ -9,11 +9,11 @@ module RuboCop
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def inside_example_group?(node)
|
12
|
-
return
|
12
|
+
return spec_group?(node) if example_group_root?(node)
|
13
13
|
|
14
14
|
root = node.ancestors.find { |parent| example_group_root?(parent) }
|
15
15
|
|
16
|
-
|
16
|
+
spec_group?(root)
|
17
17
|
end
|
18
18
|
|
19
19
|
def example_group_root?(node)
|
@@ -7,6 +7,9 @@ module RuboCop
|
|
7
7
|
module RSpec
|
8
8
|
# Checks for stubbed test subjects.
|
9
9
|
#
|
10
|
+
# Checks nested subject stubs for innermost subject definition
|
11
|
+
# when subject is also defined in parent example groups.
|
12
|
+
#
|
10
13
|
# @see https://robots.thoughtbot.com/don-t-stub-the-system-under-test
|
11
14
|
# @see https://samphippen.com/introducing-rspec-smells-and-where-to-find-them#smell-1-stubject
|
12
15
|
# @see https://github.com/rubocop-hq/rspec-style-guide#dont-stub-subject
|
@@ -22,6 +25,20 @@ module RuboCop
|
|
22
25
|
# end
|
23
26
|
# end
|
24
27
|
#
|
28
|
+
# # bad
|
29
|
+
# describe Article do
|
30
|
+
# subject(:foo) { Article.new }
|
31
|
+
#
|
32
|
+
# context 'nested subject' do
|
33
|
+
# subject(:article) { Article.new }
|
34
|
+
#
|
35
|
+
# it 'indicates that the author is unknown' do
|
36
|
+
# allow(article).to receive(:author).and_return(nil)
|
37
|
+
# expect(article.description).to include('by an unknown author')
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
#
|
25
42
|
# # good
|
26
43
|
# describe Article do
|
27
44
|
# subject(:article) { Article.new(author: nil) }
|
@@ -36,27 +53,35 @@ module RuboCop
|
|
36
53
|
|
37
54
|
MSG = 'Do not stub methods of the object under test.'
|
38
55
|
|
39
|
-
# @!method subject(node)
|
56
|
+
# @!method subject?(node)
|
40
57
|
# Find a named or unnamed subject definition
|
41
58
|
#
|
42
59
|
# @example anonymous subject
|
43
|
-
# subject(parse('subject { foo }').ast) do |name|
|
60
|
+
# subject?(parse('subject { foo }').ast) do |name|
|
44
61
|
# name # => :subject
|
45
62
|
# end
|
46
63
|
#
|
47
64
|
# @example named subject
|
48
|
-
# subject(parse('subject(:thing) { foo }').ast) do |name|
|
65
|
+
# subject?(parse('subject(:thing) { foo }').ast) do |name|
|
49
66
|
# name # => :thing
|
50
67
|
# end
|
51
68
|
#
|
52
69
|
# @param node [RuboCop::AST::Node]
|
53
70
|
#
|
54
71
|
# @yield [Symbol] subject name
|
55
|
-
def_node_matcher :subject
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
72
|
+
def_node_matcher :subject?, <<-PATTERN
|
73
|
+
(block
|
74
|
+
(send nil?
|
75
|
+
{:subject (sym $_) | $:subject}
|
76
|
+
) args ...)
|
77
|
+
PATTERN
|
78
|
+
|
79
|
+
# @!method let?(node)
|
80
|
+
# Find a memoized helper
|
81
|
+
def_node_matcher :let?, <<-PATTERN
|
82
|
+
(block
|
83
|
+
(send nil? :let (sym $_)
|
84
|
+
) args ...)
|
60
85
|
PATTERN
|
61
86
|
|
62
87
|
# @!method message_expectation?(node, method_name)
|
@@ -73,7 +98,7 @@ module RuboCop
|
|
73
98
|
def_node_matcher :message_expectation?, <<-PATTERN
|
74
99
|
(send
|
75
100
|
{
|
76
|
-
(send nil? { :expect :allow } (send nil?
|
101
|
+
(send nil? { :expect :allow } (send nil? %))
|
77
102
|
(send nil? :is_expected)
|
78
103
|
}
|
79
104
|
#Runners.all
|
@@ -89,7 +114,8 @@ module RuboCop
|
|
89
114
|
PATTERN
|
90
115
|
|
91
116
|
def on_top_level_group(node)
|
92
|
-
@explicit_subjects =
|
117
|
+
@explicit_subjects = find_all_explicit(node, &method(:subject?))
|
118
|
+
@subject_overrides = find_all_explicit(node, &method(:let?))
|
93
119
|
|
94
120
|
find_subject_expectations(node) do |stub|
|
95
121
|
add_offense(stub)
|
@@ -98,12 +124,12 @@ module RuboCop
|
|
98
124
|
|
99
125
|
private
|
100
126
|
|
101
|
-
def
|
127
|
+
def find_all_explicit(node)
|
102
128
|
node.each_descendant(:block).with_object({}) do |child, h|
|
103
|
-
name =
|
129
|
+
name = yield(child)
|
104
130
|
next unless name
|
105
131
|
|
106
|
-
outer_example_group = child.each_ancestor.find do |a|
|
132
|
+
outer_example_group = child.each_ancestor(:block).find do |a|
|
107
133
|
example_group?(a)
|
108
134
|
end
|
109
135
|
|
@@ -113,14 +139,14 @@ module RuboCop
|
|
113
139
|
end
|
114
140
|
|
115
141
|
def find_subject_expectations(node, subject_names = [], &block)
|
116
|
-
subject_names =
|
142
|
+
subject_names = [*subject_names, *@explicit_subjects[node]]
|
143
|
+
subject_names -= @subject_overrides[node] if @subject_overrides[node]
|
117
144
|
|
118
|
-
|
119
|
-
|
120
|
-
end
|
145
|
+
names = Set[*subject_names, :subject]
|
146
|
+
expectation_detected = message_expectation?(node, names)
|
121
147
|
return yield(node) if expectation_detected
|
122
148
|
|
123
|
-
node.each_child_node do |child|
|
149
|
+
node.each_child_node(:send, :def, :block, :begin) do |child|
|
124
150
|
find_subject_expectations(child, subject_names, &block)
|
125
151
|
end
|
126
152
|
end
|
@@ -8,7 +8,7 @@ module RuboCop
|
|
8
8
|
class ConfigFormatter
|
9
9
|
EXTENSION_ROOT_DEPARTMENT = %r{^(RSpec/)}.freeze
|
10
10
|
SUBDEPARTMENTS = %(RSpec/Capybara RSpec/FactoryBot RSpec/Rails)
|
11
|
-
|
11
|
+
COP_DOC_BASE_URL = 'https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/'
|
12
12
|
|
13
13
|
def initialize(config, descriptions)
|
14
14
|
@config = config
|
@@ -27,9 +27,8 @@ module RuboCop
|
|
27
27
|
cops.each_with_object(config.dup) do |cop, unified|
|
28
28
|
next if SUBDEPARTMENTS.include?(cop)
|
29
29
|
|
30
|
-
unified[cop]
|
31
|
-
|
32
|
-
.merge('StyleGuide' => STYLE_GUIDE_BASE_URL + cop.sub('RSpec/', ''))
|
30
|
+
unified[cop].merge!(descriptions.fetch(cop))
|
31
|
+
unified[cop]['Reference'] = COP_DOC_BASE_URL + cop.sub('RSpec/', '')
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Backus
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-01-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|