You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered an issue with the auto-correction provided by Capybara/RedundantWithinFind. The automatic correction replaces within find_by_id with a within string selector, leading to unexpected behavior and causing the test to fail.
→ Match: <div id="array-form-session.dates">YYYY/MM/DD</div>
→ Not Match: : <div id="array-form-session" class="dates">YYYY/MM/DD</div>
This is the expected behavior.
While it's rare for . to be used in HTML IDs, I believe a potential solution could be to avoid replacing find_by_id with within when the argument of find_by_id contains a . or to mark it as unsafe.
The text was updated successfully, but these errors were encountered:
…escape required css selector
Fix: #136
Previously, the following automatic corrections were made.
before:
```ruby
within find_by_id("array-form-session.dates") do
expect(page).to have_text(:visible, "YYYY/MM/DD")
end
```
after:
```ruby
within "#array-form-session.dates" do
expect(page).to have_text(:visible, "YYYY/MM/DD")
end
```
This is `.' in find_by_id. ` has the same meaning as the escaped id.
In other words, when replacing within, the `. ` must be escaped.
This PR has been modified so that escaping is correctly done in selectors that require escaping.
This will prevent the behavior from changing before and after the automatic correction.
…escape required css selector
Fix: #136
Previously, the following automatic corrections were made.
before:
```ruby
within find_by_id("array-form-session.dates") do
expect(page).to have_text(:visible, "YYYY/MM/DD")
end
```
after:
```ruby
within "#array-form-session.dates" do
expect(page).to have_text(:visible, "YYYY/MM/DD")
end
```
This is `.' in find_by_id. ` has the same meaning as the escaped id.
In other words, when replacing within, the `. ` must be escaped.
This PR has been modified so that escaping is correctly done in selectors that require escaping.
This will prevent the behavior from changing before and after the automatic correction.
ydah
linked a pull request
Oct 31, 2024
that will
close
this issue
Summary
I encountered an issue with the auto-correction provided by Capybara/RedundantWithinFind. The automatic correction replaces within find_by_id with a within string selector, leading to unexpected behavior and causing the test to fail.
Before Auto-correction:
→ Match:
<div id="array-form-session.dates">YYYY/MM/DD</div>
→ Not Match: :
<div id="array-form-session" class="dates">YYYY/MM/DD</div>
This is the expected behavior.
After Auto-correction:
→ Not Match:
<div id="array-form-session.dates">YYYY/MM/DD</div>
→ Match: :
<div id="array-form-session" class="dates">YYYY/MM/DD</div>
Solution?
While it's rare for . to be used in HTML IDs, I believe a potential solution could be to avoid replacing find_by_id with within when the argument of find_by_id contains a . or to mark it as unsafe.
The text was updated successfully, but these errors were encountered: