6
6
7
7
= RSpecRails
8
8
9
+ [#rspecrailsavoidsetuphook]
9
10
== RSpecRails/AvoidSetupHook
10
11
11
12
|===
20
21
21
22
Checks that tests use RSpec `before` hook over Rails `setup` method.
22
23
24
+ [#examples-rspecrailsavoidsetuphook]
23
25
=== Examples
24
26
25
27
[source,ruby]
@@ -35,10 +37,12 @@ before do
35
37
end
36
38
----
37
39
40
+ [#references-rspecrailsavoidsetuphook]
38
41
=== References
39
42
40
43
* https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/AvoidSetupHook
41
44
45
+ [#rspecrailshavehttpstatus]
42
46
== RSpecRails/HaveHttpStatus
43
47
44
48
|===
53
57
54
58
Checks that tests use `have_http_status` instead of equality matchers.
55
59
60
+ [#examples-rspecrailshavehttpstatus]
56
61
=== Examples
57
62
63
+ [#responsemethods_-__response__-_last_response__-_default_-rspecrailshavehttpstatus]
58
64
==== ResponseMethods: ['response', 'last_response'] (default)
59
65
60
66
[source,ruby]
@@ -68,6 +74,7 @@ expect(response).to have_http_status(200)
68
74
expect(last_response).to have_http_status(200)
69
75
----
70
76
77
+ [#responsemethods_-__foo_response__-rspecrailshavehttpstatus]
71
78
==== ResponseMethods: ['foo_response']
72
79
73
80
[source,ruby]
@@ -83,6 +90,7 @@ expect(response).to have_http_status(200)
83
90
expect(last_response).to have_http_status(200)
84
91
----
85
92
93
+ [#configurable-attributes-rspecrailshavehttpstatus]
86
94
=== Configurable attributes
87
95
88
96
|===
@@ -93,10 +101,12 @@ expect(last_response).to have_http_status(200)
93
101
| Array
94
102
|===
95
103
104
+ [#references-rspecrailshavehttpstatus]
96
105
=== References
97
106
98
107
* https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/HaveHttpStatus
99
108
109
+ [#rspecrailshttpstatus]
100
110
== RSpecRails/HttpStatus
101
111
102
112
|===
@@ -117,8 +127,10 @@ when setting for `EnforcedStyle: symbolic` or
117
127
`EnforcedStyle: numeric`.
118
128
This cop is also capable of detecting unknown HTTP status codes.
119
129
130
+ [#examples-rspecrailshttpstatus]
120
131
=== Examples
121
132
133
+ [#_enforcedstyle_-symbolic_-_default_-rspecrailshttpstatus]
122
134
==== `EnforcedStyle: symbolic` (default)
123
135
124
136
[source,ruby]
@@ -136,6 +148,7 @@ it { is_expected.to have_http_status :success }
136
148
it { is_expected.to have_http_status :error }
137
149
----
138
150
151
+ [#_enforcedstyle_-numeric_-rspecrailshttpstatus]
139
152
==== `EnforcedStyle: numeric`
140
153
141
154
[source,ruby]
@@ -153,6 +166,7 @@ it { is_expected.to have_http_status :success }
153
166
it { is_expected.to have_http_status :error }
154
167
----
155
168
169
+ [#_enforcedstyle_-be_status_-rspecrailshttpstatus]
156
170
==== `EnforcedStyle: be_status`
157
171
158
172
[source,ruby]
@@ -181,6 +195,7 @@ it { is_expected.to have_http_status :oki_doki }
181
195
it { is_expected.to have_http_status :ok }
182
196
----
183
197
198
+ [#configurable-attributes-rspecrailshttpstatus]
184
199
=== Configurable attributes
185
200
186
201
|===
@@ -191,10 +206,12 @@ it { is_expected.to have_http_status :ok }
191
206
| `numeric`, `symbolic`, `be_status`
192
207
|===
193
208
209
+ [#references-rspecrailshttpstatus]
194
210
=== References
195
211
196
212
* https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/HttpStatus
197
213
214
+ [#rspecrailsinferredspectype]
198
215
== RSpecRails/InferredSpecType
199
216
200
217
|===
@@ -214,11 +231,13 @@ After setting up rspec-rails, you will have enabled
214
231
spec/rails_helper.rb. This cop works in conjunction with this config.
215
232
If you disable this config, disable this cop as well.
216
233
234
+ [#safety-rspecrailsinferredspectype]
217
235
=== Safety
218
236
219
237
This cop is marked as unsafe because
220
238
`config.infer_spec_type_from_file_location!` may not be enabled.
221
239
240
+ [#examples-rspecrailsinferredspectype]
222
241
=== Examples
223
242
224
243
[source,ruby]
@@ -239,6 +258,7 @@ RSpec.describe User, type: :common do
239
258
end
240
259
----
241
260
261
+ [#_inferences_-configuration-rspecrailsinferredspectype]
242
262
==== `Inferences` configuration
243
263
244
264
[source,ruby]
@@ -264,6 +284,7 @@ RSpec.describe User, type: :common do
264
284
end
265
285
----
266
286
287
+ [#configurable-attributes-rspecrailsinferredspectype]
267
288
=== Configurable attributes
268
289
269
290
|===
@@ -274,10 +295,12 @@ end
274
295
|
275
296
|===
276
297
298
+ [#references-rspecrailsinferredspectype]
277
299
=== References
278
300
279
301
* https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/InferredSpecType
280
302
303
+ [#rspecrailsminitestassertions]
281
304
== RSpecRails/MinitestAssertions
282
305
283
306
|===
@@ -295,6 +318,7 @@ Check if using Minitest-like matchers.
295
318
Check the use of minitest-like matchers
296
319
starting with `assert_` or `refute_`.
297
320
321
+ [#examples-rspecrailsminitestassertions]
298
322
=== Examples
299
323
300
324
[source,ruby]
@@ -320,10 +344,12 @@ expect(a).to be(true)
320
344
expect(a).to be(false)
321
345
----
322
346
347
+ [#references-rspecrailsminitestassertions]
323
348
=== References
324
349
325
350
* https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/MinitestAssertions
326
351
352
+ [#rspecrailsnegationbevalid]
327
353
== RSpecRails/NegationBeValid
328
354
329
355
|===
@@ -338,13 +364,16 @@ expect(a).to be(false)
338
364
339
365
Enforces use of `be_invalid` or `not_to` for negated be_valid.
340
366
367
+ [#safety-rspecrailsnegationbevalid]
341
368
=== Safety
342
369
343
370
This cop is unsafe because it cannot guarantee that
344
371
the test target is an instance of `ActiveModel::Validations``.
345
372
373
+ [#examples-rspecrailsnegationbevalid]
346
374
=== Examples
347
375
376
+ [#enforcedstyle_-not_to-_default_-rspecrailsnegationbevalid]
348
377
==== EnforcedStyle: not_to (default)
349
378
350
379
[source,ruby]
@@ -359,6 +388,7 @@ expect(foo).not_to be_valid
359
388
expect(foo).to be_invalid.and be_odd
360
389
----
361
390
391
+ [#enforcedstyle_-be_invalid-rspecrailsnegationbevalid]
362
392
==== EnforcedStyle: be_invalid
363
393
364
394
[source,ruby]
@@ -373,6 +403,7 @@ expect(foo).to be_invalid
373
403
expect(foo).to be_invalid.or be_even
374
404
----
375
405
406
+ [#configurable-attributes-rspecrailsnegationbevalid]
376
407
=== Configurable attributes
377
408
378
409
|===
@@ -383,10 +414,12 @@ expect(foo).to be_invalid.or be_even
383
414
| `not_to`, `be_invalid`
384
415
|===
385
416
417
+ [#references-rspecrailsnegationbevalid]
386
418
=== References
387
419
388
420
* https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/NegationBeValid
389
421
422
+ [#rspecrailstravelaround]
390
423
== RSpecRails/TravelAround
391
424
392
425
|===
@@ -401,6 +434,7 @@ expect(foo).to be_invalid.or be_even
401
434
402
435
Prefer to travel in `before` rather than `around`.
403
436
437
+ [#safety-rspecrailstravelaround]
404
438
=== Safety
405
439
406
440
This cop is unsafe because the automatic `travel_back` is only run
@@ -410,6 +444,7 @@ And also, this cop's autocorrection is unsafe because the order of
410
444
execution will change if other steps exist before traveling in
411
445
`around`.
412
446
447
+ [#examples-rspecrailstravelaround]
413
448
=== Examples
414
449
415
450
[source,ruby]
425
460
before { freeze_time }
426
461
----
427
462
463
+ [#references-rspecrailstravelaround]
428
464
=== References
429
465
430
466
* https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/TravelAround
0 commit comments