Skip to content

Add rubocop-capybara to require using path matching helper#11669

Merged
mitchellhenke merged 2 commits intomainfrom
mitchellhenke/enable-capybara-current-path-expectation
Dec 18, 2024
Merged

Add rubocop-capybara to require using path matching helper#11669
mitchellhenke merged 2 commits intomainfrom
mitchellhenke/enable-capybara-current-path-expectation

Conversation

@mitchellhenke
Copy link
Contributor

@mitchellhenke mitchellhenke commented Dec 18, 2024

🛠 Summary of changes

We've had some flakier feature tests recently following #11605, and some of them have been alleviated by doing replacements like:

-    expect(current_path).to eq sign_up_completed_path
+    expect(page).to have_current_path sign_up_completed_path

The second line uses the Capybara has_current_path? helper, which includes a timeout to wait for page loads rather than asserting the current_path in that moment in time. This will hopefully make some of the longer or more complicated feature test steps more reliable. There may still be places where we're missing an assertion and should add it before trying to take other actions like clicking on a button.

This PR adds rubocop-capybara and enables Capybara/CurrentPathExpectation to require usage of the have_current_path helper.

Mitchell Henke added 2 commits December 18, 2024 10:49
changelog: Internal, Testing, Add rubocop-capybara
@mitchellhenke mitchellhenke requested a review from a team December 18, 2024 17:03
Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants