mardi 1 septembre 2015

assert_select empty data attribute

I wish to write a view test to assert the presence of an empty data attribute within my HTML.

My HTML is like this:

<section data-my-name-here></section>

My test is:

assert_select '[data-my-name-here]'

The test result is:

Expected at least 1 element matching "[data-my-name-here'']", found 0.

note how the test adds quotes to the attribute where it seems to expect a value.

I can make the test pass if I add a value in my HTML and test for that e.g.

<section data-my-name-here='true'></section>

assert_select "[data-my-name-here='true']"

but I don't want to change my markup for the sake of the test.

How can I do this?

Aucun commentaire:

Enregistrer un commentaire