rspec-html

0.3.5
Light Mode Dark Mode

exist

The exist matcher verifies that a provided element specification exists in the document.

subject(:document) do
  parse_html('<html><body><div><span class="my-span">my text</span></div></body></html>')
end

it 'verifies that an element exists' do
  expect(document.body.div.span('.my-span')).to exist
end
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
    <div><span class="my-span">my text</span></div>
  </body></html>
my text

Documentation generated by rspec-documentation