assert_select "foo", "x", count: 0 --- no longer works
michaeleconomy opened this issue · 6 comments
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.
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.
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
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.
assert_select "foo", "x", count: 0
Was always incorrect.
assert_select "foo", text: "x", count: 0 is what you want. See documentation here
Right on, my bad. Thanks guys!
Thanks for taking the time for a refresher course on this.