Closed
Description
rubocop version: 1.18.3
rubocop-rspec version: 2.4.0
Example code:
# original code
expect(current_path).to eq(
some_path(
record_id: record.id
)
)
If Style/TrailingComma (in vanilla rubocop) is enabled for methods, it adds a comma after record.id
and after the closed parenthesis.
Also, Capybara/CurrentPathExpectation adds , ignore_query: true
to the have_current_path
params. If both are fixed with the same autocorrect, the following is the result:
# after autocorrect
expect(page).to have_current_path(
some_path(
record_id: record.id
),, ignore_query: true
)
which is a syntax error (the double-comma) and still doesn't have the trailing comma.
A workaround is to run the Style cops first, then the RSpec cops, or vice-versa - just not in the same command
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Capybara/CurrentPathException autocorrect incompatible with Style/TrailingComma autocorrect[/-][+]Capybara/CurrentPathExpectation autocorrect incompatible with Style/TrailingComma autocorrect[/+]pirj commentedon Feb 24, 2022
Thanks for reporting. Would you like to submit a PR?
I see two ways to resolving this:
expectation_last_child
contains a trailing commaexpectation_last_child
from its trailing comma with whatRangeHelp
provides (not sure if it's possible just by glancing at its code)[Fix rubocop#1237] Fix `Capybara/CurrentPathExpectation` autocorrect …
Capybara/CurrentPathExpectation
autocorrect incompatible withStyle/TrailingCommaInArguments
autocorrect #1252[Fix rubocop#1237] Fix `Capybara/CurrentPathExpectation` autocorrect …
[Fix rubocop#1237] Fix `Capybara/CurrentPathExpectation` autocorrect …
[Fix rubocop#1237] Fix `Capybara/CurrentPathExpectation` autocorrect …
[Fix rubocop#1237] Fix `Capybara/CurrentPathExpectation` autocorrect …
Capybara/CurrentPathExpectation
autocorrect incompatible withStyle/TrailingCommaInArguments
autocorrect #1253[Fix rubocop#1237] Fix `Capybara/CurrentPathExpectation` autocorrect …
[Fix rubocop#1237] Fix `Capybara/CurrentPathExpectation` autocorrect …
Merge pull request #1253 from ydah/fix-capybara-current-path-expectat…