Closed mattwynne closed 7 months ago
@mattwynne you're not being dumb 😄 . That is an issue I've run into as well.
The fix isn't released yet (planning on doing a release today) but it's already on main
if you want to use it.
I've introduced several options to help with these cases. By default assert_has/3
is doing a substring comparison (i.e. using =~
) to match on the text asserted. That's helpful when you're trying to assert something inside HTML that also has HTML:
<div id="greeting">
Hello world <span>Matt!</span>
</div>
assert_has(session, "#greeting", text: "Hello world") # <- this will pass
There's now an exact
option that you can use:
assert_has(session, "#greeting", text: "Hello world", exact: true) # <- this will NOT pass
So, in your case, you can run the following assertion:
assert_has(session, "#banana", text: "", exact: true)
NOTE the use of text:
as an option in the functions above and not as the third positional argument. You'll have to change your function to use that if you want to get the options. In fact, I'm deprecating the assert_has/3
that uses text
as a positional argument.
That looks great!
Maybe I'm being dumb, but I can't work out how to use
assert_has
(orrefute_has
) to check that this span is empty:Maybe this is related to #46 because, if there was a way for me to just write:
That might work, and be an extensible solution for other problems?