-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix replacement for multiple substitutions #76
Fix replacement for multiple substitutions #76
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@lastthyme Was there a reason you approved this? It doesn't seem like there has been any activity on this PR in nearly 3 years. 🤔 |
@zzak What kind of activity is necessary? |
@speckins Just wondering if you had some context I might be missing about this PR 🤔 |
Originally I submitted an issue (#75) before the PR, but it appears they've since been disabled for this repo. The
I see that master has been active. I could rebase if you'd like. |
@speckins Yes please! Thank you for elaborating on the problem 🙇 |
Since SubstitutionContext#substitute! uses while/#sub! to replace '?' in the selector, and the replacement text contains that character, e.g., "(?-mix:\\d+)", if the selector requires more than one replacement, the replaced text is matched by the next iteration. # given this assertion assert_select "input[name=?][value=?]", /item-\d+/, /\d+/ # first iteration "input[name=\"(?-mix:item-\\d+)\"][value=?]" # second iteration "input[name=\"(\"(?-mix:\\d+)\"-mix:item-\\d+)\"][value=?]" This commit uses #gsub to avoid replacing already substituted text. Fixes rails#75.
9510b67
to
117d284
Compare
@zzak - I rebased on the current master; tests pass. |
Thanks @speckins! TBH I'm not really sure the current state of this gem, perhaps @seanpdoyle or @rafaelfranca can enlighten me? 🙏 |
Since SubstitutionContext#substitute! uses while/#sub! to replace '?' in
the selector, and the replacement text contains that character, e.g.,
"(?-mix:\d+)", if the selector requires more than one replacement, the
replaced text is matched by the next iteration.
This commit uses #gsub to avoid replacing already substituted text.
Fixes #75.