jeudi 19 novembre 2020

Test for consecutive HTML elements in Rails view

I wish to run a test* to check for presence of something like this:

<tr>
    <td> name </td> <td> date </td>
</tr>

Code, such as below:

assert_select "tr" do
  assert_select "td",  name
  assert_select "td",  date
end

looks plausible, but is not correct, as the below for example (which is not the match required) would also pass:

<tr>
    <td> name </td>
</tr>
<tr>
    <td> date </td>
</tr>

I’m struggling to see how this should be approached from the documentation of assert_select.

Thank you

Daniel

  • within a default Rails integration test (I believe this means MiniTest)

Aucun commentaire:

Enregistrer un commentaire