Consider that you have a select list with just the following option:
<option>Second Fake Option</option>
And you'd like to assert that the select list does not contain an option with the text "Fake Option":
<option>Fake Option</option>
When one refutes this like so:
refute has_select?('list_id',
with_options: ['Fake Option'])
The test fails. It seems that Capybara is successfully partially matching the text Fake Option
against the text Second Fake Option
. Even further, the following also fails:
refute has_select?('select_id',
with_options: [''])
Yet the following passes:
refute has_select?('select_id',
with_options: ['BORK'])
The documentation for with_options:
and options:
describes the behavior regarding the list of options we're trying to match, but does not speak to this behavior of partially matching the text itself. Other questions here on SO refer to the same documented behavior... but don't address refuting or the matching of the options' text.
While I could assert
the opposite behavior with options:
, like this:
assert has_select?('select_id',
options: ['Second Fake Option'])
This can be a pain when you have a long select list and want to refute the presence of one particular option in the list.
How does one properly refute the presence of a specific option in a select list?
Aucun commentaire:
Enregistrer un commentaire