Consider deprecating assert_select with a numeric arg
chancancode opened this issue · 6 comments
Given a page like so:
<h1>Users</h1>
<table>
...
</table>
Total: <span class="total">4781</span>It's pretty reasonable to write something like this:
get "/users"
assert_select "h1", "Users"
assert_select ".total", User.countHowever, that would give you a very confusing error:
Failure:
MyApp::UsersTest#test_index:
Expected exactly 4781 elements matching ".total", found 1..
Expected: 4781
Actual: 1
Given that we already support assert_select ".total", count: User.count, I think we should consider deprecating the numeric positional argument overload (as shown in the example) in favor of the explicit keyword argument, and potentially reclaiming the space for automatic to_s-ing the positional argument in the future (to make the example "just work").
👍
@rafaelfranca can we still add the deprecation to 5.1?
Yes, we can. Even more that this would be a deprecation in a gem, so the deprecation would also happen in 5.0. I'm fine with it.
@rafaelfranca we can (probably should) bump the gem version, then we can decide whether we need to lock it in Rails 5.0
yes, a minor version should be sufficient
Yes please!