Skip to content
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

assert_select "foo", "x", count: 0 --- no longer works #111

Closed
michaeleconomy opened this issue Aug 27, 2023 · 6 comments
Closed

assert_select "foo", "x", count: 0 --- no longer works #111

michaeleconomy opened this issue Aug 27, 2023 · 6 comments

Comments

@michaeleconomy
Copy link

Steps to reproduce

After upgrading from rails 7.0.4 to 7.0.7

assert_select "foo", "x", count: 0 #no longer works
switching to:
assert_select "foo", text: "x", count: 0 #this has different behavior from the above statement

Expected behavior

i want to test that there is no tag with the specified text.

Actual behavior

I can no longer do this with assert_select on the new rails version.

@skipkayhil
Copy link
Member

Hey @michaeleconomy, thanks for opening an issue! Would you be able to provide a script or repo that demonstrates the issue?

As a side note, assert_select is provided by https://github.com/rails/rails-dom-testing. If you could figure out which version of rails-dom-testing works and which doesn't work that would also be very helpful.

@ccasabona
Copy link

This change happened when we upgraded rails from 7.0.5 to 7.0.6.

In Rails 7.0.5, rails-dom-testing was version 2.0.3. In 7.0.6, the version changed to 2.1.1. We had the same problem as described above -- all of our assert_select statements that tested for text had have the text: key added as in:

assert_select 'h3', 'Shipping & Taxes', count: 1

had to be:

assert_select 'h3', text: 'Shipping & Taxes', count: 1

@joshuay03
Copy link
Contributor

joshuay03 commented Aug 28, 2023

For reference, this was added in #96 which was included in this release: https://github.com/rails/rails-dom-testing/releases/tag/v2.1.0.

@rafaelfranca rafaelfranca transferred this issue from rails/rails Aug 28, 2023
@rafaelfranca
Copy link
Member

assert_select "foo", "x", count: 0

Was always incorrect.

assert_select "foo", text: "x", count: 0 is what you want. See documentation here

# assert_dom "title", {count: 1, text: "Welcome"},

@michaeleconomy
Copy link
Author

Right on, my bad. Thanks guys!

@ccasabona
Copy link

Thanks for taking the time for a refresher course on this.

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

No branches or pull requests

5 participants