rubocop-rspec 1.36.0 → 1.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/config/default.yml +87 -76
- data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +1 -1
- data/lib/rubocop/cop/rspec/described_class_module_wrapping.rb +36 -0
- data/lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb +39 -0
- data/lib/rubocop/cop/rspec/implicit_expect.rb +1 -1
- data/lib/rubocop/cop/rspec/pending.rb +1 -1
- data/lib/rubocop/cop/rspec/predicate_matcher.rb +5 -1
- data/lib/rubocop/cop/rspec/rails/http_status.rb +4 -4
- data/lib/rubocop/cop/rspec/subject_stub.rb +4 -1
- data/lib/rubocop/cop/rspec_cops.rb +2 -0
- data/lib/rubocop/rspec/config_formatter.rb +1 -1
- data/lib/rubocop/rspec/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 396ca6beb4f3a3bf18ff5bfb0a28481a15060795c84a4e5f1d5a0c44b25ad0f4
|
4
|
+
data.tar.gz: 4efa382210002292fede62a31709e452bd1482ec979f0de2512a3447c4efdf13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e38bd510d3b6061d2f24cd6b50f11fa147c4cd8c679a892e51e4b528e454f2aa8343ad367373d03cdb9b1075fa52fc01f2db049945a59363ec5e4299e41f4544
|
7
|
+
data.tar.gz: b0c0bccd971f132dbfdc3854dac1c2260482e7f5667f9146a5aec6d9da550cb2016002023648bf6aaca210311dc4e859d44536883095b9d3cf31bea5c8b410d9
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
## Master (Unreleased)
|
4
4
|
|
5
|
+
## 1.37.0 (2019-11-25)
|
6
|
+
|
7
|
+
* Implement `RSpec/DescribedClassModuleWrapping` to disallow RSpec statements within a module. ([@kellysutton][])
|
8
|
+
* Fix documentation rake task to support Rubocop 0.75. ([@nickcampbell18][])
|
9
|
+
* Fix `RSpec/SubjectStub` to detect implicit subjects stubbed. ([@QQism][])
|
10
|
+
* Fix `RSpec/Pending` not flagging `skip` with string values. ([@pirj][])
|
11
|
+
* Add `AllowedExplicitMatchers` config option for `RSpec/PredicateMatcher`. ([@mkrawc][])
|
12
|
+
* Add `FactoryBot/FactoryClassName` cop. ([@jfragoulis][])
|
13
|
+
|
5
14
|
## 1.36.0 (2019-09-27)
|
6
15
|
|
7
16
|
* Fix `RSpec/DescribedClass`'s error when `described_class` is used as part of a constant. ([@pirj][])
|
@@ -452,3 +461,8 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
452
461
|
[@foton]: https://github.com/foton
|
453
462
|
[@nc-holodakg]: https://github.com/nc-holodakg
|
454
463
|
[@onumis]: https://github.com/onumis
|
464
|
+
[@nickcampbell18]: https://github.com/nickcampbell18
|
465
|
+
[@QQism]: https://github.com/QQism
|
466
|
+
[@kellysutton]: https://github.com/kellysutton
|
467
|
+
[@mkrawc]: https://github.com/mkrawc
|
468
|
+
[@jfragoulis]: https://github.com/jfragoulis
|
data/config/default.yml
CHANGED
@@ -13,32 +13,32 @@ AllCops:
|
|
13
13
|
RSpec/AlignLeftLetBrace:
|
14
14
|
Description: Checks that left braces for adjacent single line lets are aligned.
|
15
15
|
Enabled: false
|
16
|
-
StyleGuide:
|
16
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AlignLeftLetBrace
|
17
17
|
|
18
18
|
RSpec/AlignRightLetBrace:
|
19
19
|
Description: Checks that right braces for adjacent single line lets are aligned.
|
20
20
|
Enabled: false
|
21
|
-
StyleGuide:
|
21
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AlignRightLetBrace
|
22
22
|
|
23
23
|
RSpec/AnyInstance:
|
24
24
|
Description: Check that instances are not being stubbed globally.
|
25
25
|
Enabled: true
|
26
|
-
StyleGuide:
|
26
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AnyInstance
|
27
27
|
|
28
28
|
RSpec/AroundBlock:
|
29
29
|
Description: Checks that around blocks actually run the test.
|
30
30
|
Enabled: true
|
31
|
-
StyleGuide:
|
31
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AroundBlock
|
32
32
|
|
33
33
|
RSpec/Be:
|
34
34
|
Description: Check for expectations where `be` is used without argument.
|
35
35
|
Enabled: true
|
36
|
-
StyleGuide:
|
36
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Be
|
37
37
|
|
38
38
|
RSpec/BeEql:
|
39
39
|
Description: Check for expectations where `be(...)` can replace `eql(...)`.
|
40
40
|
Enabled: true
|
41
|
-
StyleGuide:
|
41
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeEql
|
42
42
|
|
43
43
|
RSpec/BeforeAfterAll:
|
44
44
|
Description: Check that before/after(:all) isn't being used.
|
@@ -47,12 +47,12 @@ RSpec/BeforeAfterAll:
|
|
47
47
|
- spec/spec_helper.rb
|
48
48
|
- spec/rails_helper.rb
|
49
49
|
- spec/support/**/*.rb
|
50
|
-
StyleGuide:
|
50
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeforeAfterAll
|
51
51
|
|
52
52
|
RSpec/ContextMethod:
|
53
53
|
Description: "`context` should not be used for specifying methods."
|
54
54
|
Enabled: true
|
55
|
-
StyleGuide:
|
55
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ContextMethod
|
56
56
|
|
57
57
|
RSpec/ContextWording:
|
58
58
|
Description: Checks that `context` docstring starts with an allowed prefix.
|
@@ -61,22 +61,22 @@ RSpec/ContextWording:
|
|
61
61
|
- when
|
62
62
|
- with
|
63
63
|
- without
|
64
|
-
StyleGuide:
|
64
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ContextWording
|
65
65
|
|
66
66
|
RSpec/DescribeClass:
|
67
67
|
Description: Check that the first argument to the top level describe is a constant.
|
68
68
|
Enabled: true
|
69
|
-
StyleGuide:
|
69
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeClass
|
70
70
|
|
71
71
|
RSpec/DescribeMethod:
|
72
72
|
Description: Checks that the second argument to `describe` specifies a method.
|
73
73
|
Enabled: true
|
74
|
-
StyleGuide:
|
74
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeMethod
|
75
75
|
|
76
76
|
RSpec/DescribeSymbol:
|
77
77
|
Description: Avoid describing symbols.
|
78
78
|
Enabled: true
|
79
|
-
StyleGuide:
|
79
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeSymbol
|
80
80
|
|
81
81
|
RSpec/DescribedClass:
|
82
82
|
Description: Checks that tests use `described_class`.
|
@@ -86,51 +86,56 @@ RSpec/DescribedClass:
|
|
86
86
|
SupportedStyles:
|
87
87
|
- described_class
|
88
88
|
- explicit
|
89
|
-
StyleGuide:
|
89
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribedClass
|
90
|
+
|
91
|
+
RSpec/DescribedClassModuleWrapping:
|
92
|
+
Description: Avoid opening modules and defining specs within them.
|
93
|
+
Enabled: false
|
94
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribedClassModuleWrapping
|
90
95
|
|
91
96
|
RSpec/Dialect:
|
92
97
|
Description: This cop enforces custom RSpec dialects.
|
93
98
|
Enabled: false
|
94
99
|
PreferredMethods: {}
|
95
|
-
StyleGuide:
|
100
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Dialect
|
96
101
|
|
97
102
|
RSpec/EmptyExampleGroup:
|
98
103
|
Description: Checks if an example group does not include any tests.
|
99
104
|
Enabled: true
|
100
105
|
CustomIncludeMethods: []
|
101
|
-
StyleGuide:
|
106
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyExampleGroup
|
102
107
|
|
103
108
|
RSpec/EmptyLineAfterExample:
|
104
109
|
Description: Checks if there is an empty line after example blocks.
|
105
110
|
Enabled: true
|
106
111
|
AllowConsecutiveOneLiners: true
|
107
|
-
StyleGuide:
|
112
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterExample
|
108
113
|
|
109
114
|
RSpec/EmptyLineAfterExampleGroup:
|
110
115
|
Description: Checks if there is an empty line after example group blocks.
|
111
116
|
Enabled: true
|
112
|
-
StyleGuide:
|
117
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterExampleGroup
|
113
118
|
|
114
119
|
RSpec/EmptyLineAfterFinalLet:
|
115
120
|
Description: Checks if there is an empty line after the last let block.
|
116
121
|
Enabled: true
|
117
|
-
StyleGuide:
|
122
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterFinalLet
|
118
123
|
|
119
124
|
RSpec/EmptyLineAfterHook:
|
120
125
|
Description: Checks if there is an empty line after hook blocks.
|
121
126
|
Enabled: true
|
122
|
-
StyleGuide:
|
127
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterHook
|
123
128
|
|
124
129
|
RSpec/EmptyLineAfterSubject:
|
125
130
|
Description: Checks if there is an empty line after subject block.
|
126
131
|
Enabled: true
|
127
|
-
StyleGuide:
|
132
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterSubject
|
128
133
|
|
129
134
|
RSpec/ExampleLength:
|
130
135
|
Description: Checks for long examples.
|
131
136
|
Enabled: true
|
132
137
|
Max: 5
|
133
|
-
StyleGuide:
|
138
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleLength
|
134
139
|
|
135
140
|
RSpec/ExampleWithoutDescription:
|
136
141
|
Description: Checks for examples without a description.
|
@@ -140,7 +145,7 @@ RSpec/ExampleWithoutDescription:
|
|
140
145
|
- always_allow
|
141
146
|
- single_line_only
|
142
147
|
- disallow
|
143
|
-
StyleGuide:
|
148
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWithoutDescription
|
144
149
|
|
145
150
|
RSpec/ExampleWording:
|
146
151
|
Description: Checks for common mistakes in example descriptions.
|
@@ -151,14 +156,14 @@ RSpec/ExampleWording:
|
|
151
156
|
have: has
|
152
157
|
HAVE: HAS
|
153
158
|
IgnoredWords: []
|
154
|
-
StyleGuide:
|
159
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWording
|
155
160
|
|
156
161
|
RSpec/ExpectActual:
|
157
162
|
Description: Checks for `expect(...)` calls containing literal values.
|
158
163
|
Enabled: true
|
159
164
|
Exclude:
|
160
165
|
- spec/routing/**/*
|
161
|
-
StyleGuide:
|
166
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectActual
|
162
167
|
|
163
168
|
RSpec/ExpectChange:
|
164
169
|
Description: Checks for consistent style of change matcher.
|
@@ -167,17 +172,17 @@ RSpec/ExpectChange:
|
|
167
172
|
SupportedStyles:
|
168
173
|
- method_call
|
169
174
|
- block
|
170
|
-
StyleGuide:
|
175
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectChange
|
171
176
|
|
172
177
|
RSpec/ExpectInHook:
|
173
178
|
Enabled: true
|
174
179
|
Description: Do not use `expect` in hooks such as `before`.
|
175
|
-
StyleGuide:
|
180
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectInHook
|
176
181
|
|
177
182
|
RSpec/ExpectOutput:
|
178
183
|
Description: Checks for opportunities to use `expect { ... }.to output`.
|
179
184
|
Enabled: true
|
180
|
-
StyleGuide:
|
185
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectOutput
|
181
186
|
|
182
187
|
RSpec/FilePath:
|
183
188
|
Description: Checks that spec file paths are consistent with the test subject.
|
@@ -186,12 +191,12 @@ RSpec/FilePath:
|
|
186
191
|
RuboCop: rubocop
|
187
192
|
RSpec: rspec
|
188
193
|
IgnoreMethods: false
|
189
|
-
StyleGuide:
|
194
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FilePath
|
190
195
|
|
191
196
|
RSpec/Focus:
|
192
197
|
Description: Checks if examples are focused.
|
193
198
|
Enabled: true
|
194
|
-
StyleGuide:
|
199
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Focus
|
195
200
|
|
196
201
|
RSpec/HookArgument:
|
197
202
|
Description: Checks the arguments passed to `before`, `around`, and `after`.
|
@@ -201,17 +206,17 @@ RSpec/HookArgument:
|
|
201
206
|
- implicit
|
202
207
|
- each
|
203
208
|
- example
|
204
|
-
StyleGuide:
|
209
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HookArgument
|
205
210
|
|
206
211
|
RSpec/HooksBeforeExamples:
|
207
212
|
Enabled: true
|
208
213
|
Description: Checks for before/around/after hooks that come after an example.
|
209
|
-
StyleGuide:
|
214
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HooksBeforeExamples
|
210
215
|
|
211
216
|
RSpec/ImplicitBlockExpectation:
|
212
217
|
Description: Check that implicit block expectation syntax is not used.
|
213
218
|
Enabled: true
|
214
|
-
StyleGuide:
|
219
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitBlockExpectation
|
215
220
|
|
216
221
|
RSpec/ImplicitExpect:
|
217
222
|
Description: Check that a consistent implicit expectation style is used.
|
@@ -220,7 +225,7 @@ RSpec/ImplicitExpect:
|
|
220
225
|
SupportedStyles:
|
221
226
|
- is_expected
|
222
227
|
- should
|
223
|
-
StyleGuide:
|
228
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitExpect
|
224
229
|
|
225
230
|
RSpec/ImplicitSubject:
|
226
231
|
Enabled: true
|
@@ -230,23 +235,23 @@ RSpec/ImplicitSubject:
|
|
230
235
|
- single_line_only
|
231
236
|
- single_statement_only
|
232
237
|
- disallow
|
233
|
-
StyleGuide:
|
238
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitSubject
|
234
239
|
|
235
240
|
RSpec/InstanceSpy:
|
236
241
|
Description: Checks for `instance_double` used with `have_received`.
|
237
242
|
Enabled: true
|
238
|
-
StyleGuide:
|
243
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InstanceSpy
|
239
244
|
|
240
245
|
RSpec/InstanceVariable:
|
241
246
|
Description: Checks for instance variable usage in specs.
|
242
247
|
AssignmentOnly: false
|
243
248
|
Enabled: true
|
244
|
-
StyleGuide:
|
249
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InstanceVariable
|
245
250
|
|
246
251
|
RSpec/InvalidPredicateMatcher:
|
247
252
|
Description: Checks invalid usage for predicate matcher.
|
248
253
|
Enabled: true
|
249
|
-
StyleGuide:
|
254
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InvalidPredicateMatcher
|
250
255
|
|
251
256
|
RSpec/ItBehavesLike:
|
252
257
|
Description: Checks that only one `it_behaves_like` style is used.
|
@@ -255,37 +260,37 @@ RSpec/ItBehavesLike:
|
|
255
260
|
SupportedStyles:
|
256
261
|
- it_behaves_like
|
257
262
|
- it_should_behave_like
|
258
|
-
StyleGuide:
|
263
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ItBehavesLike
|
259
264
|
|
260
265
|
RSpec/IteratedExpectation:
|
261
266
|
Description: Check that `all` matcher is used instead of iterating over an array.
|
262
267
|
Enabled: true
|
263
|
-
StyleGuide:
|
268
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IteratedExpectation
|
264
269
|
|
265
270
|
RSpec/LeadingSubject:
|
266
271
|
Description: Enforce that subject is the first definition in the test.
|
267
272
|
Enabled: true
|
268
|
-
StyleGuide:
|
273
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LeadingSubject
|
269
274
|
|
270
275
|
RSpec/LeakyConstantDeclaration:
|
271
276
|
Description: Checks that no class, module, or constant is declared.
|
272
277
|
Enabled: true
|
273
|
-
StyleGuide:
|
278
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LeakyConstantDeclaration
|
274
279
|
|
275
280
|
RSpec/LetBeforeExamples:
|
276
281
|
Description: Checks for `let` definitions that come after an example.
|
277
282
|
Enabled: true
|
278
|
-
StyleGuide:
|
283
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetBeforeExamples
|
279
284
|
|
280
285
|
RSpec/LetSetup:
|
281
286
|
Description: Checks unreferenced `let!` calls being used for test setup.
|
282
287
|
Enabled: true
|
283
|
-
StyleGuide:
|
288
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetSetup
|
284
289
|
|
285
290
|
RSpec/MessageChain:
|
286
291
|
Description: Check that chains of messages are not being stubbed.
|
287
292
|
Enabled: true
|
288
|
-
StyleGuide:
|
293
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageChain
|
289
294
|
|
290
295
|
RSpec/MessageExpectation:
|
291
296
|
Description: Checks for consistent message expectation style.
|
@@ -294,7 +299,7 @@ RSpec/MessageExpectation:
|
|
294
299
|
SupportedStyles:
|
295
300
|
- allow
|
296
301
|
- expect
|
297
|
-
StyleGuide:
|
302
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageExpectation
|
298
303
|
|
299
304
|
RSpec/MessageSpies:
|
300
305
|
Description: Checks that message expectations are set using spies.
|
@@ -303,41 +308,41 @@ RSpec/MessageSpies:
|
|
303
308
|
SupportedStyles:
|
304
309
|
- have_received
|
305
310
|
- receive
|
306
|
-
StyleGuide:
|
311
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageSpies
|
307
312
|
|
308
313
|
RSpec/MissingExampleGroupArgument:
|
309
314
|
Description: Checks that the first argument to an example group is not empty.
|
310
315
|
Enabled: true
|
311
|
-
StyleGuide:
|
316
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MissingExampleGroupArgument
|
312
317
|
|
313
318
|
RSpec/MultipleDescribes:
|
314
319
|
Description: Checks for multiple top level describes.
|
315
320
|
Enabled: true
|
316
|
-
StyleGuide:
|
321
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleDescribes
|
317
322
|
|
318
323
|
RSpec/MultipleExpectations:
|
319
324
|
Description: Checks if examples contain too many `expect` calls.
|
320
325
|
Enabled: true
|
321
326
|
Max: 1
|
322
327
|
AggregateFailuresByDefault: false
|
323
|
-
StyleGuide:
|
328
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleExpectations
|
324
329
|
|
325
330
|
RSpec/MultipleSubjects:
|
326
331
|
Description: Checks if an example group defines `subject` multiple times.
|
327
332
|
Enabled: true
|
328
|
-
StyleGuide:
|
333
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleSubjects
|
329
334
|
|
330
335
|
RSpec/NamedSubject:
|
331
336
|
Description: Checks for explicitly referenced test subjects.
|
332
337
|
Enabled: true
|
333
338
|
IgnoreSharedExamples: true
|
334
|
-
StyleGuide:
|
339
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject
|
335
340
|
|
336
341
|
RSpec/NestedGroups:
|
337
342
|
Description: Checks for nested example groups.
|
338
343
|
Enabled: true
|
339
344
|
Max: 3
|
340
|
-
StyleGuide:
|
345
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NestedGroups
|
341
346
|
|
342
347
|
RSpec/NotToNot:
|
343
348
|
Description: Checks for consistent method usage for negating expectations.
|
@@ -346,47 +351,48 @@ RSpec/NotToNot:
|
|
346
351
|
- not_to
|
347
352
|
- to_not
|
348
353
|
Enabled: true
|
349
|
-
StyleGuide:
|
354
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NotToNot
|
350
355
|
|
351
356
|
RSpec/OverwritingSetup:
|
352
357
|
Enabled: true
|
353
358
|
Description: Checks if there is a let/subject that overwrites an existing one.
|
354
|
-
StyleGuide:
|
359
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/OverwritingSetup
|
355
360
|
|
356
361
|
RSpec/Pending:
|
357
362
|
Enabled: false
|
358
363
|
Description: Checks for any pending or skipped examples.
|
359
|
-
StyleGuide:
|
364
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Pending
|
360
365
|
|
361
366
|
RSpec/PredicateMatcher:
|
362
367
|
Description: Prefer using predicate matcher over using predicate method directly.
|
363
368
|
Enabled: true
|
364
369
|
Strict: true
|
365
370
|
EnforcedStyle: inflected
|
371
|
+
AllowedExplicitMatchers: []
|
366
372
|
SupportedStyles:
|
367
373
|
- inflected
|
368
374
|
- explicit
|
369
|
-
StyleGuide:
|
375
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/PredicateMatcher
|
370
376
|
|
371
377
|
RSpec/ReceiveCounts:
|
372
378
|
Enabled: true
|
373
379
|
Description: Check for `once` and `twice` receive counts matchers usage.
|
374
|
-
StyleGuide:
|
380
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReceiveCounts
|
375
381
|
|
376
382
|
RSpec/ReceiveNever:
|
377
383
|
Enabled: true
|
378
384
|
Description: Prefer `not_to receive(...)` over `receive(...).never`.
|
379
|
-
StyleGuide:
|
385
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReceiveNever
|
380
386
|
|
381
387
|
RSpec/RepeatedDescription:
|
382
388
|
Enabled: true
|
383
389
|
Description: Check for repeated description strings in example groups.
|
384
|
-
StyleGuide:
|
390
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedDescription
|
385
391
|
|
386
392
|
RSpec/RepeatedExample:
|
387
393
|
Enabled: true
|
388
394
|
Description: Check for repeated examples within example groups.
|
389
|
-
StyleGuide:
|
395
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedExample
|
390
396
|
|
391
397
|
RSpec/ReturnFromStub:
|
392
398
|
Enabled: true
|
@@ -395,75 +401,75 @@ RSpec/ReturnFromStub:
|
|
395
401
|
SupportedStyles:
|
396
402
|
- and_return
|
397
403
|
- block
|
398
|
-
StyleGuide:
|
404
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReturnFromStub
|
399
405
|
|
400
406
|
RSpec/ScatteredLet:
|
401
407
|
Description: Checks for let scattered across the example group.
|
402
408
|
Enabled: true
|
403
|
-
StyleGuide:
|
409
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredLet
|
404
410
|
|
405
411
|
RSpec/ScatteredSetup:
|
406
412
|
Description: Checks for setup scattered across multiple hooks in an example group.
|
407
413
|
Enabled: true
|
408
|
-
StyleGuide:
|
414
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredSetup
|
409
415
|
|
410
416
|
RSpec/SharedContext:
|
411
417
|
Description: Checks for proper shared_context and shared_examples usage.
|
412
418
|
Enabled: true
|
413
|
-
StyleGuide:
|
419
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SharedContext
|
414
420
|
|
415
421
|
RSpec/SharedExamples:
|
416
422
|
Description: Enforces use of string to titleize shared examples.
|
417
423
|
Enabled: true
|
418
|
-
StyleGuide:
|
424
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SharedExamples
|
419
425
|
|
420
426
|
RSpec/SingleArgumentMessageChain:
|
421
427
|
Description: Checks that chains of messages contain more than one element.
|
422
428
|
Enabled: true
|
423
|
-
StyleGuide:
|
429
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SingleArgumentMessageChain
|
424
430
|
|
425
431
|
RSpec/SubjectStub:
|
426
432
|
Description: Checks for stubbed test subjects.
|
427
433
|
Enabled: true
|
428
|
-
StyleGuide:
|
434
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SubjectStub
|
429
435
|
|
430
436
|
RSpec/UnspecifiedException:
|
431
437
|
Description: Checks for a specified error in checking raised errors.
|
432
438
|
Enabled: true
|
433
|
-
StyleGuide:
|
439
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/UnspecifiedException
|
434
440
|
|
435
441
|
RSpec/VerifiedDoubles:
|
436
442
|
Description: Prefer using verifying doubles over normal doubles.
|
437
443
|
Enabled: true
|
438
444
|
IgnoreNameless: true
|
439
445
|
IgnoreSymbolicNames: false
|
440
|
-
StyleGuide:
|
446
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VerifiedDoubles
|
441
447
|
|
442
448
|
RSpec/VoidExpect:
|
443
449
|
Description: This cop checks void `expect()`.
|
444
450
|
Enabled: true
|
445
|
-
StyleGuide:
|
451
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VoidExpect
|
446
452
|
|
447
453
|
RSpec/Yield:
|
448
454
|
Description: This cop checks for calling a block within a stub.
|
449
455
|
Enabled: true
|
450
|
-
StyleGuide:
|
456
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Yield
|
451
457
|
|
452
458
|
Capybara/CurrentPathExpectation:
|
453
459
|
Description: Checks that no expectations are set on Capybara's `current_path`.
|
454
460
|
Enabled: true
|
455
|
-
StyleGuide:
|
461
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/CurrentPathExpectation
|
456
462
|
|
457
463
|
Capybara/FeatureMethods:
|
458
464
|
Description: Checks for consistent method usage in feature specs.
|
459
465
|
Enabled: true
|
460
466
|
EnabledMethods: []
|
461
|
-
StyleGuide:
|
467
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/FeatureMethods
|
462
468
|
|
463
469
|
FactoryBot/AttributeDefinedStatically:
|
464
470
|
Description: Always declare attribute values as blocks.
|
465
471
|
Enabled: true
|
466
|
-
StyleGuide:
|
472
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/AttributeDefinedStatically
|
467
473
|
|
468
474
|
FactoryBot/CreateList:
|
469
475
|
Description: Checks for create_list usage.
|
@@ -472,7 +478,12 @@ FactoryBot/CreateList:
|
|
472
478
|
SupportedStyles:
|
473
479
|
- create_list
|
474
480
|
- n_times
|
475
|
-
StyleGuide:
|
481
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/CreateList
|
482
|
+
|
483
|
+
FactoryBot/FactoryClassName:
|
484
|
+
Description: Use string value when setting the class attribute explicitly.
|
485
|
+
Enabled: true
|
486
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/FactoryClassName
|
476
487
|
|
477
488
|
Rails/HttpStatus:
|
478
489
|
Description: Enforces use of symbolic or numeric value to describe HTTP status.
|
@@ -481,4 +492,4 @@ Rails/HttpStatus:
|
|
481
492
|
SupportedStyles:
|
482
493
|
- numeric
|
483
494
|
- symbolic
|
484
|
-
StyleGuide:
|
495
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus
|
@@ -6,7 +6,7 @@ module RuboCop
|
|
6
6
|
module Capybara
|
7
7
|
# Checks that no expectations are set on Capybara's `current_path`.
|
8
8
|
#
|
9
|
-
# The `have_current_path` matcher (
|
9
|
+
# The `have_current_path` matcher (https://www.rubydoc.info/github/
|
10
10
|
# teamcapybara/capybara/master/Capybara/RSpecMatchers#have_current_path-
|
11
11
|
# instance_method) should be used on `page` to set expectations on
|
12
12
|
# Capybara's current path, since it uses Capybara's waiting
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
# Avoid opening modules and defining specs within them.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# # bad
|
10
|
+
# module MyModule
|
11
|
+
# RSpec.describe MyClass do
|
12
|
+
# # ...
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# # good
|
17
|
+
# RSpec.describe MyModule::MyClass do
|
18
|
+
# # ...
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# @see https://github.com/rubocop-hq/rubocop-rspec/issues/735
|
22
|
+
class DescribedClassModuleWrapping < Cop
|
23
|
+
MSG = 'Avoid opening modules and defining specs within them.'
|
24
|
+
|
25
|
+
def_node_search :find_rspec_blocks,
|
26
|
+
ExampleGroups::ALL.block_pattern
|
27
|
+
|
28
|
+
def on_module(node)
|
29
|
+
find_rspec_blocks(node) do
|
30
|
+
add_offense(node)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
module FactoryBot
|
7
|
+
# Use string value when setting the class attribute explicitly.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# # bad
|
11
|
+
# factory :foo, class: Foo do
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# factory :foo, class: 'Foo' do
|
16
|
+
# end
|
17
|
+
class FactoryClassName < Cop
|
18
|
+
MSG = "Pass '%<class_name>s' instead of %<class_name>s."
|
19
|
+
|
20
|
+
def_node_matcher :class_name, <<~PATTERN
|
21
|
+
(send _ :factory _ (hash <(pair (sym :class) $(const ...)) ...>))
|
22
|
+
PATTERN
|
23
|
+
|
24
|
+
def on_send(node)
|
25
|
+
class_name(node) do |cn|
|
26
|
+
add_offense(cn, message: format(MSG, class_name: cn.const_name))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def autocorrect(node)
|
31
|
+
lambda do |corrector|
|
32
|
+
corrector.replace(node.loc.expression, "'#{node.source}'")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -82,7 +82,7 @@ module RuboCop
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
def is_expected_range(source_map) # rubocop:disable PredicateName
|
85
|
+
def is_expected_range(source_map) # rubocop:disable Naming/PredicateName
|
86
86
|
Parser::Source::Range.new(
|
87
87
|
source_map.expression.source_buffer,
|
88
88
|
source_map.expression.begin_pos,
|
@@ -42,7 +42,7 @@ module RuboCop
|
|
42
42
|
def_node_matcher :skipped_in_metadata?, <<-PATTERN
|
43
43
|
{
|
44
44
|
(send _ _ <#skip_or_pending? ...>)
|
45
|
-
(send _ _ ... (hash <(pair #skip_or_pending? true) ...>))
|
45
|
+
(send _ _ ... (hash <(pair #skip_or_pending? { true str }) ...>))
|
46
46
|
}
|
47
47
|
PATTERN
|
48
48
|
|
@@ -138,6 +138,10 @@ module RuboCop
|
|
138
138
|
|
139
139
|
private
|
140
140
|
|
141
|
+
def allowed_explicit_matchers
|
142
|
+
cop_config.fetch('AllowedExplicitMatchers', []) + BUILT_IN_MATCHERS
|
143
|
+
end
|
144
|
+
|
141
145
|
def check_explicit(node) # rubocop:disable Metrics/MethodLength
|
142
146
|
predicate_matcher_block?(node) do |_actual, matcher|
|
143
147
|
add_offense(
|
@@ -178,7 +182,7 @@ module RuboCop
|
|
178
182
|
def predicate_matcher_name?(name)
|
179
183
|
name = name.to_s
|
180
184
|
|
181
|
-
return false if
|
185
|
+
return false if allowed_explicit_matchers.include?(name)
|
182
186
|
|
183
187
|
name.start_with?('be_', 'have_') && !name.end_with?('?')
|
184
188
|
end
|
@@ -107,7 +107,7 @@ module RuboCop
|
|
107
107
|
MSG = 'Prefer `%<prefer>s` over `%<current>s` ' \
|
108
108
|
'to describe HTTP status code.'
|
109
109
|
|
110
|
-
|
110
|
+
ALLOWED_STATUSES = %i[error success missing redirect].freeze
|
111
111
|
|
112
112
|
attr_reader :node
|
113
113
|
def initialize(node)
|
@@ -115,7 +115,7 @@ module RuboCop
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def offensive?
|
118
|
-
!node.int_type? && !
|
118
|
+
!node.int_type? && !allowed_symbol?
|
119
119
|
end
|
120
120
|
|
121
121
|
def message
|
@@ -136,8 +136,8 @@ module RuboCop
|
|
136
136
|
node.value
|
137
137
|
end
|
138
138
|
|
139
|
-
def
|
140
|
-
node.sym_type? &&
|
139
|
+
def allowed_symbol?
|
140
|
+
node.sym_type? && ALLOWED_STATUSES.include?(node.value)
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
@@ -132,7 +132,10 @@ module RuboCop
|
|
132
132
|
# @yieldparam subject_name [Symbol] name of subject being defined
|
133
133
|
# @yieldparam parent [RuboCop::Node] parent of subject definition
|
134
134
|
def find_subject(node, parent: nil, &block)
|
135
|
-
subject
|
135
|
+
# An implicit subject is defined by RSpec when no subject is declared
|
136
|
+
subject_name = subject(node) || :subject
|
137
|
+
|
138
|
+
yield(subject_name, parent) if parent
|
136
139
|
|
137
140
|
node.each_child_node do |child|
|
138
141
|
find_subject(child, parent: node, &block)
|
@@ -5,6 +5,7 @@ require_relative 'rspec/capybara/feature_methods'
|
|
5
5
|
|
6
6
|
require_relative 'rspec/factory_bot/attribute_defined_statically'
|
7
7
|
require_relative 'rspec/factory_bot/create_list'
|
8
|
+
require_relative 'rspec/factory_bot/factory_class_name'
|
8
9
|
|
9
10
|
begin
|
10
11
|
require_relative 'rspec/rails/http_status'
|
@@ -25,6 +26,7 @@ require_relative 'rspec/describe_class'
|
|
25
26
|
require_relative 'rspec/describe_method'
|
26
27
|
require_relative 'rspec/describe_symbol'
|
27
28
|
require_relative 'rspec/described_class'
|
29
|
+
require_relative 'rspec/described_class_module_wrapping'
|
28
30
|
require_relative 'rspec/dialect'
|
29
31
|
require_relative 'rspec/empty_example_group'
|
30
32
|
require_relative 'rspec/empty_line_after_example'
|
@@ -7,7 +7,7 @@ module RuboCop
|
|
7
7
|
# Builds a YAML config file from two config hashes
|
8
8
|
class ConfigFormatter
|
9
9
|
NAMESPACES = /^(RSpec|Capybara|FactoryBot|Rails)/.freeze
|
10
|
-
STYLE_GUIDE_BASE_URL = '
|
10
|
+
STYLE_GUIDE_BASE_URL = 'https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/'
|
11
11
|
|
12
12
|
def initialize(config, descriptions)
|
13
13
|
@config = config
|
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: 1.
|
4
|
+
version: 1.37.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: 2019-
|
13
|
+
date: 2019-11-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- lib/rubocop/cop/rspec/describe_method.rb
|
131
131
|
- lib/rubocop/cop/rspec/describe_symbol.rb
|
132
132
|
- lib/rubocop/cop/rspec/described_class.rb
|
133
|
+
- lib/rubocop/cop/rspec/described_class_module_wrapping.rb
|
133
134
|
- lib/rubocop/cop/rspec/dialect.rb
|
134
135
|
- lib/rubocop/cop/rspec/empty_example_group.rb
|
135
136
|
- lib/rubocop/cop/rspec/empty_line_after_example.rb
|
@@ -146,6 +147,7 @@ files:
|
|
146
147
|
- lib/rubocop/cop/rspec/expect_output.rb
|
147
148
|
- lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb
|
148
149
|
- lib/rubocop/cop/rspec/factory_bot/create_list.rb
|
150
|
+
- lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb
|
149
151
|
- lib/rubocop/cop/rspec/file_path.rb
|
150
152
|
- lib/rubocop/cop/rspec/focus.rb
|
151
153
|
- lib/rubocop/cop/rspec/hook_argument.rb
|