Open
Description
RSpec/Dialect causes a false negative when using below setting mentioned in the documentation.
RSpec/Dialect:
PreferredMethods:
background: :before
scenario: :it
xscenario: :xit
given: :let
given!: :let!
feature: :describe
cf. https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecdialect
Expected behavior
The following code should not be passed:
background do # 👮♂️ C: [Correctable] RSpec/Dialect: Prefer before over background.
# some setup codes
end
Actual behavior
The following code is passed:
background do
# some setup codes
end
In contrast, the following codes doesn't pass.
RSpec.feature do # 👮♂️ C: [Correctable] RSpec/Dialect: Prefer describe over feature.
# some codes
end
scenario do # 👮♂️ C: [Correctable] RSpec/Dialect: Prefer it over scenario.
# some codes
end
xscenario do # 👮♂️ C: [Correctable] RSpec/Dialect: Prefer xit over xscenario.
# some codes
end
I look like rspec_method?
returns nil when node.method_name
is background
.
rubocop-rspec/lib/rubocop/cop/rspec/dialect.rb
Lines 67 to 80 in e02576f
RuboCop version
$ bundle exec rubocop -V
1.65.1 (using Parser 3.3.4.2, rubocop-ast 1.32.0, running on ruby 3.2.3) +server [arm64-darwin21]
- rubocop-capybara 2.21.0
- rubocop-factory_bot 2.26.1
- rubocop-performance 1.21.1
- rubocop-rails 2.25.1
- rubocop-rspec 3.0.4
- rubocop-rspec_rails 2.30.0