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 3, 2024
1 parent 0d51335 commit 6ff8584
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 337 deletions.
17 changes: 8 additions & 9 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,15 @@ RSpec/DescribedClassModuleWrapping:
RSpec/Dialect:
Description: Enforces custom RSpec dialects.
Enabled: false
PreferredMethods: {}
PreferredMethods:
background: before
scenario: it
xscenario: xit
given: let
given!: let!
feature: describe
VersionAdded: '1.33'
VersionChanged: "<<next>>"
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Dialect

RSpec/DuplicatedMetadata:
Expand Down Expand Up @@ -1018,14 +1025,6 @@ RSpec/Capybara/CurrentPathExpectation:
VersionChanged: '2.0'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/CurrentPathExpectation

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

RSpec/Capybara/MatchStyle:
Description: Checks for usage of deprecated style methods.
Enabled: pending
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

removed:
RSpec/Capybara/FeatureMethods:
reason: >
this cop has migrated to `RSpec/Dialect`. Please use `RSpec/Dialect` instead.
in .rubocop.yml file, enable `RSpec/Dialect`.
1 change: 0 additions & 1 deletion docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
=== Department xref:cops_rspec_capybara.adoc[RSpec/Capybara]

* xref:cops_rspec_capybara.adoc#rspeccapybara/currentpathexpectation[RSpec/Capybara/CurrentPathExpectation]
* xref:cops_rspec_capybara.adoc#rspeccapybara/featuremethods[RSpec/Capybara/FeatureMethods]
* xref:cops_rspec_capybara.adoc#rspeccapybara/matchstyle[RSpec/Capybara/MatchStyle]
* xref:cops_rspec_capybara.adoc#rspeccapybara/negationmatcher[RSpec/Capybara/NegationMatcher]
* xref:cops_rspec_capybara.adoc#rspeccapybara/specificactions[RSpec/Capybara/SpecificActions]
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/cops_rspec.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ end
| Yes
| Always
| 1.33
| -
| <<next>>
|===
Enforces custom RSpec dialects.
Expand Down Expand Up @@ -1096,7 +1096,7 @@ end
| Name | Default value | Configurable values
| PreferredMethods
| `{}`
| `{"background"=>"before", "scenario"=>"it", "xscenario"=>"xit", "given"=>"let", "given!"=>"let!", "feature"=>"describe"}`
|
|===
Expand Down
67 changes: 0 additions & 67 deletions docs/modules/ROOT/pages/cops_rspec_capybara.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,73 +51,6 @@ expect(page).to have_current_path('/callback')
* https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/CurrentPathExpectation
== RSpec/Capybara/FeatureMethods
|===
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
| Enabled
| Yes
| Always
| 1.17
| 2.0
|===
Checks for consistent method usage in feature specs.
By default, the cop disables all Capybara-specific methods that have
the same native RSpec method (e.g. are just aliases). Some teams
however may prefer using some of the Capybara methods (like `feature`)
to make it obvious that the test uses Capybara, while still disable
the rest of the methods, like `given` (alias for `let`), `background`
(alias for `before`), etc. You can configure which of the methods to
be enabled by using the EnabledMethods configuration option.
=== Examples
[source,ruby]
----
# bad
feature 'User logs in' do
given(:user) { User.new }
background do
visit new_session_path
end
scenario 'with OAuth' do
# ...
end
end
# good
describe 'User logs in' do
let(:user) { User.new }
before do
visit new_session_path
end
it 'with OAuth' do
# ...
end
end
----
=== Configurable attributes
|===
| Name | Default value | Configurable values
| EnabledMethods
| `[]`
| Array
|===
=== References
* https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/FeatureMethods
== RSpec/Capybara/MatchStyle
|===
Expand Down
104 changes: 0 additions & 104 deletions lib/rubocop/cop/rspec/capybara/feature_methods.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
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require_relative 'rspec/capybara/current_path_expectation'
require_relative 'rspec/capybara/feature_methods'
require_relative 'rspec/capybara/match_style'
require_relative 'rspec/capybara/negation_matcher'
require_relative 'rspec/capybara/specific_actions'
Expand Down
Loading

0 comments on commit 6ff8584

Please sign in to comment.