Skip to content

Commit 5631b45

Browse files
committed
Refactor comments for clarity and consistency across multiple RSpec cop files
- Avoid using “Check ..." - Unify the style of example
1 parent 0ecefbc commit 5631b45

File tree

9 files changed

+40
-50
lines changed

9 files changed

+40
-50
lines changed

config/default.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ RSpecRails:
77
- "**/spec/**/*"
88

99
RSpecRails/AvoidSetupHook:
10-
Description: Checks that tests use RSpec `before` hook over Rails `setup` method.
10+
Description: Prefer RSpec `before` hook over Rails `setup` method.
1111
Enabled: pending
1212
VersionAdded: '2.4'
1313
Reference: https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/AvoidSetupHook
1414

1515
RSpecRails/HaveHttpStatus:
16-
Description: Checks that tests use `have_http_status` instead of equality matchers.
16+
Description: Prefer `have_http_status` over equality matchers.
1717
Enabled: pending
1818
ResponseMethods:
1919
- response
@@ -24,7 +24,7 @@ RSpecRails/HaveHttpStatus:
2424
Reference: https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/HaveHttpStatus
2525

2626
RSpecRails/HttpStatus:
27-
Description: Enforces use of symbolic or numeric value to describe HTTP status.
27+
Description: Enforce use of symbolic or numeric value to describe HTTP status.
2828
Enabled: true
2929
EnforcedStyle: symbolic
3030
SupportedStyles:
@@ -36,13 +36,13 @@ RSpecRails/HttpStatus:
3636
Reference: https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/HttpStatus
3737

3838
RSpecRails/HttpStatusNameConsistency:
39-
Description: Enforces consistency by using the current HTTP status names.
39+
Description: Enforce consistency by using the current HTTP status names.
4040
Enabled: pending
4141
VersionAdded: '2.32'
4242
Reference: https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/HttpStatusNameConsistency
4343

4444
RSpecRails/InferredSpecType:
45-
Description: Identifies redundant spec type.
45+
Description: Identify redundant spec type.
4646
Enabled: pending
4747
Safe: false
4848
VersionAdded: '2.14'
@@ -65,13 +65,13 @@ RSpecRails/InferredSpecType:
6565
views: view
6666

6767
RSpecRails/MinitestAssertions:
68-
Description: Check if using Minitest-like matchers.
68+
Description: Prefer RSpec/Rails-style matchers over Minitest-like matchers.
6969
Enabled: pending
7070
VersionAdded: '2.17'
7171
Reference: https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/MinitestAssertions
7272

7373
RSpecRails/NegationBeValid:
74-
Description: Enforces use of `be_invalid` or `not_to` for negated be_valid.
74+
Description: Enforce use of `be_invalid` or `not_to` for negated be_valid.
7575
AutoCorrect: contextual
7676
Safe: false
7777
EnforcedStyle: not_to

docs/modules/ROOT/pages/cops_rspecrails.adoc

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
| -
2020
|===
2121
22-
Checks that tests use RSpec `before` hook over Rails `setup` method.
22+
Prefer RSpec `before` hook over Rails `setup` method.
2323
2424
[#examples-rspecrailsavoidsetuphook]
2525
=== Examples
@@ -55,13 +55,13 @@ end
5555
| 2.27
5656
|===
5757
58-
Checks that tests use `have_http_status` instead of equality matchers.
58+
Prefer `have_http_status` over equality matchers.
5959
6060
[#examples-rspecrailshavehttpstatus]
6161
=== Examples
6262
63-
[#responsemethods_-__response__-_last_response__-_default_-rspecrailshavehttpstatus]
64-
==== ResponseMethods: ['response', 'last_response'] (default)
63+
[#_responsemethods_-__response__-_last_response___-_default_-rspecrailshavehttpstatus]
64+
==== `ResponseMethods: ['response', 'last_response']` (default)
6565
6666
[source,ruby]
6767
----
@@ -74,8 +74,8 @@ expect(response).to have_http_status(200)
7474
expect(last_response).to have_http_status(200)
7575
----
7676
77-
[#responsemethods_-__foo_response__-rspecrailshavehttpstatus]
78-
==== ResponseMethods: ['foo_response']
77+
[#_responsemethods_-__foo_response___-rspecrailshavehttpstatus]
78+
==== `ResponseMethods: ['foo_response']`
7979
8080
[source,ruby]
8181
----
@@ -119,7 +119,7 @@ expect(last_response).to have_http_status(200)
119119
| 2.20
120120
|===
121121
122-
Enforces use of symbolic or numeric value to describe HTTP status.
122+
Enforce use of symbolic or numeric value to describe HTTP status.
123123
124124
This cop inspects only `have_http_status` calls.
125125
So, this cop does not check if a method starting with `be_*` is used
@@ -224,7 +224,7 @@ it { is_expected.to have_http_status :ok }
224224
| -
225225
|===
226226
227-
Enforces consistency by using the current HTTP status names.
227+
Enforce consistency by using the current HTTP status names.
228228
229229
[#examples-rspecrailshttpstatusnameconsistency]
230230
=== Examples
@@ -256,7 +256,7 @@ it { is_expected.to have_http_status :unprocessable_content }
256256
| -
257257
|===
258258
259-
Identifies redundant spec type.
259+
Identify redundant spec type.
260260
261261
After setting up rspec-rails, you will have enabled
262262
`config.infer_spec_type_from_file_location!` by default in
@@ -290,16 +290,11 @@ RSpec.describe User, type: :common do
290290
end
291291
----
292292
293-
[#_inferences_-configuration-rspecrailsinferredspectype]
294-
==== `Inferences` configuration
293+
[#_inferences_-_services_-service__-rspecrailsinferredspectype]
294+
==== `Inferences: {services: service}`
295295
296296
[source,ruby]
297297
----
298-
# .rubocop.yml
299-
# RSpecRails/InferredSpecType:
300-
# Inferences:
301-
# services: service
302-
303298
# bad
304299
# spec/services/user_spec.rb
305300
RSpec.describe User, type: :service do
@@ -345,10 +340,10 @@ end
345340
| -
346341
|===
347342
348-
Check if using Minitest-like matchers.
343+
Prefer RSpec/Rails-style matchers over Minitest-like matchers.
349344
350-
Check the use of minitest-like matchers
351-
starting with `assert_` or `refute_`.
345+
Detect the use of Minitest-like matchers
346+
(those starting with `assert_` or `refute_`).
352347
353348
[#examples-rspecrailsminitestassertions]
354349
=== Examples
@@ -396,7 +391,7 @@ expect(response).to have_http_status(:ok)
396391
| 2.29
397392
|===
398393
399-
Enforces use of `be_invalid` or `not_to` for negated be_valid.
394+
Enforce use of `be_invalid` or `not_to` for negated be_valid.
400395
401396
[#safety-rspecrailsnegationbevalid]
402397
=== Safety
@@ -407,8 +402,8 @@ the test target is an instance of `ActiveModel::Validations``.
407402
[#examples-rspecrailsnegationbevalid]
408403
=== Examples
409404
410-
[#enforcedstyle_-not_to-_default_-rspecrailsnegationbevalid]
411-
==== EnforcedStyle: not_to (default)
405+
[#_enforcedstyle_-not_to_-_default_-rspecrailsnegationbevalid]
406+
==== `EnforcedStyle: not_to` (default)
412407
413408
[source,ruby]
414409
----
@@ -422,8 +417,8 @@ expect(foo).not_to be_valid
422417
expect(foo).to be_invalid.and be_odd
423418
----
424419
425-
[#enforcedstyle_-be_invalid-rspecrailsnegationbevalid]
426-
==== EnforcedStyle: be_invalid
420+
[#_enforcedstyle_-be_invalid_-rspecrailsnegationbevalid]
421+
==== `EnforcedStyle: be_invalid`
427422
428423
[source,ruby]
429424
----

lib/rubocop/cop/rspec_rails/avoid_setup_hook.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module RuboCop
44
module Cop
55
module RSpecRails
6-
# Checks that tests use RSpec `before` hook over Rails `setup` method.
6+
# Prefer RSpec `before` hook over Rails `setup` method.
77
#
88
# @example
99
# # bad

lib/rubocop/cop/rspec_rails/have_http_status.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
module RuboCop
44
module Cop
55
module RSpecRails
6-
# Checks that tests use `have_http_status` instead of equality matchers.
6+
# Prefer `have_http_status` over equality matchers.
77
#
8-
# @example ResponseMethods: ['response', 'last_response'] (default)
8+
# @example `ResponseMethods: ['response', 'last_response']` (default)
99
# # bad
1010
# expect(response.status).to be(200)
1111
# expect(last_response.code).to eq("200")
@@ -14,7 +14,7 @@ module RSpecRails
1414
# expect(response).to have_http_status(200)
1515
# expect(last_response).to have_http_status(200)
1616
#
17-
# @example ResponseMethods: ['foo_response']
17+
# @example `ResponseMethods: ['foo_response']`
1818
# # bad
1919
# expect(foo_response.status).to be(200)
2020
#

lib/rubocop/cop/rspec_rails/http_status.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
module RuboCop
1010
module Cop
1111
module RSpecRails
12-
# Enforces use of symbolic or numeric value to describe HTTP status.
12+
# Enforce use of symbolic or numeric value to describe HTTP status.
1313
#
1414
# This cop inspects only `have_http_status` calls.
1515
# So, this cop does not check if a method starting with `be_*` is used

lib/rubocop/cop/rspec_rails/http_status_name_consistency.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module RuboCop
44
module Cop
55
module RSpecRails
6-
# Enforces consistency by using the current HTTP status names.
6+
# Enforce consistency by using the current HTTP status names.
77
#
88
# @example
99
#

lib/rubocop/cop/rspec_rails/inferred_spec_type.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module RuboCop
44
module Cop
55
module RSpecRails
6-
# Identifies redundant spec type.
6+
# Identify redundant spec type.
77
#
88
# After setting up rspec-rails, you will have enabled
99
# `config.infer_spec_type_from_file_location!` by default in
@@ -30,12 +30,7 @@ module RSpecRails
3030
# RSpec.describe User, type: :common do
3131
# end
3232
#
33-
# @example `Inferences` configuration
34-
# # .rubocop.yml
35-
# # RSpecRails/InferredSpecType:
36-
# # Inferences:
37-
# # services: service
38-
#
33+
# @example `Inferences: {services: service}`
3934
# # bad
4035
# # spec/services/user_spec.rb
4136
# RSpec.describe User, type: :service do

lib/rubocop/cop/rspec_rails/minitest_assertions.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
module RuboCop
44
module Cop
55
module RSpecRails
6-
# Check if using Minitest-like matchers.
6+
# Prefer RSpec/Rails-style matchers over Minitest-like matchers.
77
#
8-
# Check the use of minitest-like matchers
9-
# starting with `assert_` or `refute_`.
8+
# Detect the use of Minitest-like matchers
9+
# (those starting with `assert_` or `refute_`).
1010
#
1111
# @example
1212
# # bad

lib/rubocop/cop/rspec_rails/negation_be_valid.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
module RuboCop
44
module Cop
55
module RSpecRails
6-
# Enforces use of `be_invalid` or `not_to` for negated be_valid.
6+
# Enforce use of `be_invalid` or `not_to` for negated be_valid.
77
#
88
# @safety
99
# This cop is unsafe because it cannot guarantee that
1010
# the test target is an instance of `ActiveModel::Validations``.
1111
#
12-
# @example EnforcedStyle: not_to (default)
12+
# @example `EnforcedStyle: not_to` (default)
1313
# # bad
1414
# expect(foo).to be_invalid
1515
#
@@ -19,7 +19,7 @@ module RSpecRails
1919
# # good (with method chain)
2020
# expect(foo).to be_invalid.and be_odd
2121
#
22-
# @example EnforcedStyle: be_invalid
22+
# @example `EnforcedStyle: be_invalid`
2323
# # bad
2424
# expect(foo).not_to be_valid
2525
#

0 commit comments

Comments
 (0)