Skip to content

Remove infer_spec_type_from_location! from generator #2803

@runephilosof-abtion

Description

@runephilosof-abtion

Is your feature request related to a problem? Please describe.
Be consistent. Don't make infer spec types the default, and then also generate the types in the spec files. Also don't describe it as opt-in, when it is on by default.

rubocop-rails has a cop that helps with this inconsistency and removes the types in the spec files

After setting up rspec-rails, you will have enabled config.infer_spec_type_from_file_location! by default in spec/rails_helper.rb. This cop works in conjunction with this config.

Describe the solution you'd like
Remove infer_spec_type_from_location! from

config.infer_spec_type_from_file_location!

It is described as the old behavior.

`config.infer_spec_type_from_file_location!`, which is still supplied

The old behaviour

But it is not very old or opt-in, because it is still enabled by default in the generator.
This PR describes it as "truly opt-in".
But, for that to be true, infer_spec_type_from_location! would have to be commented out or removed in the generator.

Describe alternatives you've considered
Make it configurable whether type: is generated by the spec generators

RSpec.describe <%= class_name %>, <%= type_metatag(:model) %> do

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions