Skip to content

Commit

Permalink
Remove RSpec/Capybara/FeatureMethods
Browse files Browse the repository at this point in the history
Fix: #1852
  • Loading branch information
ydah committed May 19, 2024
1 parent 5d2ec84 commit 1fa9ce3
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 364 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Remove extracted cops in `Capybara`, `FactoryBot` and `Rails` departments. ([@ydah])
- Remove `RuboCop::RSpec::Language::NodePattern`. ([@ydah])
- Remove `RSpec/FilePath` cop. ([@ydah])
- Remove `RSpec/Capybara/FeatureMethods` cop. If you are using this cop, change it to use `RSpec/Dialect`. ([@ydah])

## 2.29.2 (2024-05-02)

Expand Down
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ task :build_config do
require 'rubocop/rspec/config_formatter'
require 'rubocop/rspec/description_extractor'

glob = File.join('lib', 'rubocop', 'cop', 'rspec',
'{,capybara}', '*.rb')
glob = File.join('lib', 'rubocop', 'cop', 'rspec', '*.rb')
# Due to YARD's sensitivity to file require order (as of 0.9.25),
# we have to prepend the list with our base cop, RuboCop::Cop::RSpec::Base.
# Otherwise, cop's parent class for cops loaded before our base cop class
Expand Down
17 changes: 2 additions & 15 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ RSpec:
Enabled: true
StyleGuideBaseURL: https://rspec.rubystyle.guide
DocumentationBaseURL: https://docs.rubocop.org/rubocop-rspec
Include: &1
Include:
- "**/*_spec.rb"
- "**/spec/**/*"
Language: &2
Language:
inherit_mode:
merge:
- Expectations
Expand Down Expand Up @@ -990,16 +990,3 @@ RSpec/Yield:
Enabled: true
VersionAdded: '1.32'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Yield

RSpec/Capybara:
Enabled: true
Include: *1
Language: *2

RSpec/Capybara/FeatureMethods:
Description: Checks for consistent method usage in feature specs.
Enabled: true
EnabledMethods: []
VersionAdded: '1.17'
VersionChanged: '2.0'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/FeatureMethods
5 changes: 5 additions & 0 deletions config/obsoletion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ split:
alternatives:
- RSpec/SpecFilePathFormat
- RSpec/SpecFilePathSuffix

removed:
RSpec/Capybara/FeatureMethods:
reason: >
this cop has migrated to `RSpec/Dialect`. Please use `RSpec/Dialect` instead
4 changes: 0 additions & 4 deletions docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,4 @@
* xref:cops_rspec.adoc#rspecvoidexpect[RSpec/VoidExpect]
* xref:cops_rspec.adoc#rspecyield[RSpec/Yield]

=== Department xref:cops_rspec_capybara.adoc[RSpec/Capybara]

* xref:cops_rspec_capybara.adoc#rspeccapybara/featuremethods[RSpec/Capybara/FeatureMethods]

// END_COP_LIST
13 changes: 13 additions & 0 deletions docs/modules/ROOT/pages/cops_rspec.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,19 @@ a config like:
PreferredMethods:
context: describe
If you were previously using the `RSpec/Capybara/FeatureMethods` cop and
want to keep disabling all Capybara-specific methods that have the same
native RSpec method (e.g. are just aliases), use the following config:
RSpec/Dialect:
PreferredMethods:
background: :before
scenario: :it
xscenario: :xit
given: :let
given!: :let!
feature: :describe
You can expect the following behavior:
=== Examples
Expand Down
74 changes: 0 additions & 74 deletions docs/modules/ROOT/pages/cops_rspec_capybara.adoc

This file was deleted.

104 changes: 0 additions & 104 deletions lib/rubocop/cop/rspec/capybara/feature_methods.rb

This file was deleted.

13 changes: 13 additions & 0 deletions lib/rubocop/cop/rspec/dialect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ module RSpec
# PreferredMethods:
# context: describe
#
# If you were previously using the `RSpec/Capybara/FeatureMethods` cop and
# want to keep disabling all Capybara-specific methods that have the same
# native RSpec method (e.g. are just aliases), use the following config:
#
# RSpec/Dialect:
# PreferredMethods:
# background: :before
# scenario: :it
# xscenario: :xit
# given: :let
# given!: :let!
# feature: :describe
#
# You can expect the following behavior:
#
# @example
Expand Down
2 changes: 0 additions & 2 deletions lib/rubocop/cop/rspec_cops.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require_relative 'rspec/capybara/feature_methods'

require_relative 'rspec/align_left_let_brace'
require_relative 'rspec/align_right_let_brace'
require_relative 'rspec/any_instance'
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/rspec/config_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module RSpec
# Builds a YAML config file from two config hashes
class ConfigFormatter
EXTENSION_ROOT_DEPARTMENT = %r{^(RSpec/)}.freeze
SUBDEPARTMENTS = %(RSpec/Capybara)
SUBDEPARTMENTS = [].freeze
AMENDMENTS = %(Metrics/BlockLength)
COP_DOC_BASE_URL = 'https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/'

Expand Down
10 changes: 2 additions & 8 deletions spec/project/default_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@
RuboCop::ConfigLoader.load_yaml_configuration('config/default.yml')
end

let(:namespaces) do
{
'rspec' => 'RSpec',
'capybara' => 'RSpec/Capybara'
}
end
let(:namespaces) { { 'rspec' => 'RSpec' } }

let(:cop_names) do
glob = SpecHelper::ROOT.join('lib', 'rubocop', 'cop', 'rspec',
'{,capybara}', '*.rb')
glob = SpecHelper::ROOT.join('lib', 'rubocop', 'cop', 'rspec', '*.rb')
cop_names =
Pathname.glob(glob).map do |file|
file_name = file.basename('.rb').to_s
Expand Down
Loading

0 comments on commit 1fa9ce3

Please sign in to comment.