Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove RSpec/FilePath cop #1877

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ RSpec/ExampleLength:
- heredoc
Max: 11

RSpec/FilePath:
Enabled: false

RSpec/DescribeClass:
Exclude:
- spec/project/**/*.rb
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Remove extracted cops in `Capybara`, `FactoryBot` and `Rails` departments. ([@ydah])
- Remove `RuboCop::RSpec::Language::NodePattern`. ([@ydah])
- Remove `RSpec/FilePath` cop. ([@ydah])

## 2.29.2 (2024-05-02)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ In your `.rubocop.yml`, you may treat the RSpec cops just like any other
cop. For example:

```yaml
RSpec/FilePath:
RSpec/SpecFilePathFormat:
Exclude:
- spec/my_poorly_named_spec_file.rb
```
Expand Down
15 changes: 0 additions & 15 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -453,21 +453,6 @@ RSpec/ExpectOutput:
VersionAdded: '1.10'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectOutput

RSpec/FilePath:
Description: Checks that spec file paths are consistent and well-formed.
Enabled: true
Include:
- "**/*_spec*rb*"
- "**/spec/**/*"
CustomTransform:
RuboCop: rubocop
RSpec: rspec
IgnoreMethods: false
SpecSuffixOnly: false
VersionAdded: '1.2'
VersionChanged: '2.24'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FilePath

RSpec/Focus:
Description: Checks if examples are focused.
Enabled: true
Expand Down
6 changes: 6 additions & 0 deletions config/obsoletion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ renamed:
RSpec/Rails/MinitestAssertions: RSpecRails/MinitestAssertions
RSpec/Rails/NegationBeValid: RSpecRails/NegationBeValid
RSpec/Rails/TravelAround: RSpecRails/TravelAround

split:
RSpec/FilePath:
alternatives:
- RSpec/SpecFilePathFormat
- RSpec/SpecFilePathSuffix
1 change: 0 additions & 1 deletion docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
* xref:cops_rspec.adoc#rspecexpectchange[RSpec/ExpectChange]
* xref:cops_rspec.adoc#rspecexpectinhook[RSpec/ExpectInHook]
* xref:cops_rspec.adoc#rspecexpectoutput[RSpec/ExpectOutput]
* xref:cops_rspec.adoc#rspecfilepath[RSpec/FilePath]
* xref:cops_rspec.adoc#rspecfocus[RSpec/Focus]
* xref:cops_rspec.adoc#rspechookargument[RSpec/HookArgument]
* xref:cops_rspec.adoc#rspechooksbeforeexamples[RSpec/HooksBeforeExamples]
Expand Down
109 changes: 0 additions & 109 deletions docs/modules/ROOT/pages/cops_rspec.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2074,115 +2074,6 @@ expect { my_app.print_report }.to output('Hello World').to_stdout

* https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectOutput

== RSpec/FilePath

|===
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed

| Enabled
| Yes
| No
| 1.2
| 2.24
|===

Checks that spec file paths are consistent and well-formed.

This cop is deprecated.
We plan to remove it in the next major version update to 3.0.
The migration targets are `RSpec/SpecFilePathSuffix`
and `RSpec/SpecFilePathFormat`.
If you are using this cop, please plan for migration.

By default, this checks that spec file paths are consistent with the
test subject and enforces that it reflects the described
class/module and its optionally called out method.

With the configuration option `IgnoreMethods` the called out method will
be ignored when determining the enforced path.

With the configuration option `CustomTransform` modules or classes can
be specified that should not as usual be transformed from CamelCase to
snake_case (e.g. 'RuboCop' => 'rubocop' ).

With the configuration option `SpecSuffixOnly` test files will only
be checked to ensure they end in '_spec.rb'. This option disables
checking for consistency in the test subject or test methods.

=== Examples

[source,ruby]
----
# bad
whatever_spec.rb # describe MyClass

# bad
my_class_spec.rb # describe MyClass, '#method'

# good
my_class_spec.rb # describe MyClass

# good
my_class_method_spec.rb # describe MyClass, '#method'

# good
my_class/method_spec.rb # describe MyClass, '#method'
----

==== when configuration is `IgnoreMethods: true`

[source,ruby]
----
# bad
whatever_spec.rb # describe MyClass

# good
my_class_spec.rb # describe MyClass

# good
my_class_spec.rb # describe MyClass, '#method'
----

==== when configuration is `SpecSuffixOnly: true`

[source,ruby]
----
# good
whatever_spec.rb # describe MyClass

# good
my_class_spec.rb # describe MyClass

# good
my_class_spec.rb # describe MyClass, '#method'
----

=== Configurable attributes

|===
| Name | Default value | Configurable values

| Include
| `+**/*_spec*rb*+`, `+**/spec/**/*+`
| Array

| CustomTransform
| `{"RuboCop"=>"rubocop", "RSpec"=>"rspec"}`
|

| IgnoreMethods
| `false`
| Boolean

| SpecSuffixOnly
| `false`
| Boolean
|===

=== References

* https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FilePath

== RSpec/Focus

|===
Expand Down
179 changes: 0 additions & 179 deletions lib/rubocop/cop/rspec/file_path.rb

This file was deleted.

1 change: 0 additions & 1 deletion lib/rubocop/cop/rspec_cops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
require_relative 'rspec/expect_change'
require_relative 'rspec/expect_in_hook'
require_relative 'rspec/expect_output'
require_relative 'rspec/file_path'
require_relative 'rspec/focus'
require_relative 'rspec/hook_argument'
require_relative 'rspec/hooks_before_examples'
Expand Down
Loading