Method: Capybara::Node::Matchers#assert_ancestor

Defined in:
lib/capybara/node/matchers.rb

#assert_ancestor(*args, &optional_filter_block) ⇒ Object

Asserts that a given selector matches an ancestor of the current node.

element.assert_ancestor('p#foo')

Accepts the same options as #assert_selector

Parameters:

  • options (Hash)

    a customizable set of options

  • kind (Symbol)

    Optional selector type (:css, :xpath, :field, etc.). Defaults to default_selector.

  • locator (String)

    The locator for the specified selector

  • options (Hash)

    a customizable set of options

Raises:



766
767
768
769
770
771
772
# File 'lib/capybara/node/matchers.rb', line 766

def assert_ancestor(*args, &optional_filter_block)
  _verify_selector_result(args, optional_filter_block, Capybara::Queries::AncestorQuery) do |result, query|
    unless result.matches_count? && (result.any? || query.expects_none?)
      raise Capybara::ExpectationNotMet, result.failure_message
    end
  end
end