rubocop / rubocop-capybara

Code style checking for Capybara files.
https://docs.rubocop.org/rubocop-capybara
MIT License
41 stars 8 forks source link

Fix an error for `Capybara/RSpec/HaveSelector` when passing no arguments #129

Closed Earlopain closed 3 weeks ago

Earlopain commented 3 weeks ago

ruby-lsp constanty runs RuboCop over code while typing, so this error will just happen.

Do note that there are currently 2 RuboCop offenses introduced through new rubocop versions:

Offenses:

lib/rubocop/cop/capybara/rspec/have_selector.rb:82:30: C: InternalAffairs/UndefinedConfig: DefaultSelector is not defined in the configuration for Capybara/RSpec/HaveSelector in config/default.yml.
            cop_config.fetch('DefaultSelector', 'css')
                             ^^^^^^^^^^^^^^^^^
tasks/cut_release.rake:41:21: W: [Correctable] Lint/ImplicitStringConcatenation: Combine '\0' and "## #{version} (#{Time.now.strftime('%F')})\n\n" into a single string literal, rather than using implicit string concatenation. Or, if they were intended to be separate method arguments, separate them with a comma.
                    '\0' "## #{version} (#{Time.now.strftime('%F')})\n\n")

The second one seems pretty straightforward, the other I'm not sure about. It seems fine to me but when the cop is ran the fetched config is just empty. I'm not sure why but a commit similar to this would fix it: https://github.com/rubocop/rubocop-rails/commit/5180fa2c25cef467eececd9c80739f7cad6adbbf (i.e. adding rubocop-capybara to its own .rubocop.yml file.


Before submitting the PR make sure the following are checked:

ydah commented 3 weeks ago

@Earlopain Thank you! Could you rebase latest main branch?