Add RSpec/Rails/InferredSpecType cop#1365
Conversation
9f77fcc to
6e3ed63
Compare
6e3ed63 to
db1b741
Compare
db1b741 to
79fffb6
Compare
|
Those two comments suggest that automatic inferring is legacy [1, 2]. With this in mind, I'm on the fence with the decision what to do with this cop, as it doesn't seem to enforce the routine that RSpec suggests. |
|
I have renamed some of the required CI checks, which unfortunately means that you will need to rebase this branch to make CI pass. |
79fffb6 to
9787cc8
Compare
|
Then, it might be better to provide two styles, one that omits the type whenever possible according to |
b3104a4 to
87f3ef5
Compare
51dff6b to
f770015
Compare
d0fc60e to
4969f5f
Compare
891be9b to
1f30ff5
Compare
1f30ff5 to
fe26d3b
Compare
fe26d3b to
7f86436
Compare
|
Thank you, @r7kamura ! |
Was this consideration resolved? I'm reluctant to let this cop autocorrect my specs because of this. |
|
Note that view specs are usually described as a string (e.g. #90 fixed an issue with the In #110 it is discussed that even though the Since rubocop can't read RSpec's configuration, either:
or,
Open to hearing other approaches to this problem. Maybe a test could be added to cover future changes in these two cops. |
|
@davideluque I have simply disabled the entire InferredSpecType cop, since spec type inference is supposed to be deprecated. |
|
Personally I'm quite confused that you're adding a Rails specific thing to |
|
We have this on our radar, see #1440 But it’s unlikely that this will happen soon. You can say the same about FactoryBot, and Capybara. For now, rubocop-rspec is an umbrella project for all those cops. |
|
Fair enough! Thanks for the explanation @pirj |
At the time this cop was added, [it was noted][PR Comment] that this was legacy behavior left as the default for people migrating to RSpec 3. Now RSpec 7.1.0 has [removed this default][PR] to make it clear that this is deprecated / legacy behavior, let's delete this cop. [PR Comment]: rubocop/rubocop-rspec#1365 (comment) [PR]: rspec/rspec-rails#2804
At the time this cop was added, [it was noted][PR Comment] that this was legacy behavior left as the default for people migrating to RSpec 3. Now RSpec 7.1.0 has [removed this default][PR] to make it clear that this is deprecated / legacy behavior, let's delete this cop. [PR Comment]: rubocop/rubocop-rspec#1365 (comment) [PR]: rspec/rspec-rails#2804
At the time this cop was added, [it was noted][PR Comment] that this was legacy behavior left as the default for people migrating to RSpec 3. Now RSpec 7.1.0 has [removed this default][PR] to make it clear that this is deprecated / legacy behavior, let's delete this cop. [PR Comment]: rubocop/rubocop-rspec#1365 (comment) [PR]: rspec/rspec-rails#2804
At the time this cop was added, [it was noted][PR Comment] that this was legacy behavior left as the default for people migrating to RSpec 3. Now RSpec 7.1.0 has [removed this default][PR] to make it clear that this is deprecated / legacy behavior, let's delete this cop. [PR Comment]: rubocop/rubocop-rspec#1365 (comment) [PR]: rspec/rspec-rails#2804
In many Rails apps, I often see test code like
RSpec.describe MyModel, type: :modeleven thoughconfig.infer_spec_type_from_file_location!is enabled.This makes it difficult to distinguish whether they are being overwritten as needed or written even though they are not needed.
To solve this problem, it woule be nice to have a cop that issues offenses for redundant type metadata.
Before submitting the PR make sure the following are checked:
master(if not - rebase it).CHANGELOG.mdif the new code introduces user-observable changes.bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).If you have created a new cop:
config/default.yml.Enabled: pendinginconfig/default.yml.Enabled: truein.rubocop.yml.VersionAddedindefault/config.ymlto the next minor version.If you have modified an existing cop's configuration options:
VersionChangedinconfig/default.ymlto the next major version.