Skip to content

Consider deprecating assert_select with a numeric arg #58

Open
@chancancode

Description

@chancancode

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.count

However, 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").

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions