rspec-html

0.3.5
Light Mode Dark Mode

contain_tag

The contain_tag matcher verifies that an element exists within your document.

The matcher receives a tag name as a Symbol and optionally receives a set of keyword arguments that refine the element definition.

subject(:document) do
  parse_html('<html><body><table><tr><td align="center">td tag</td><tr></table></body></html>')
end

it 'matches an element' do
  expect(document.table).to contain_tag :td, align: 'center'
end
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
    <table>
      <tr>
        <td align="center">td tag</td>
      </tr>
      <tr></tr>
    </table>
  </body></html>
td tag

Documentation generated by rspec-documentation