Sha256: 15eef4ab2fa51959dd8d42e5dab0c7462c89a1d31e8ce10e2b172957946deded

Contents?: true

Size: 672 Bytes

Versions: 3

Compression:

Stored size: 672 Bytes

Contents

# frozen_string_literal: true
module Capybara
  module Queries
    class AncestorQuery < MatchQuery
      # @api private
      def resolve_for(node, exact = nil)
        @resolved_node = node
        node.synchronize do
          match_results = super(node.session.current_scope, exact)
          node.all(:xpath, XPath.ancestor) do |el|
            match_results.include?(el)
          end
        end
      end

      def description
        desc = super
        if @resolved_node && (child_query = @resolved_node.instance_variable_get(:@query))
          desc += " that is an ancestor of #{child_query.description}"
        end
        desc
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
tdiary-5.0.6 vendor/bundle/gems/capybara-2.15.1/lib/capybara/queries/ancestor_query.rb
capybara-2.15.1 lib/capybara/queries/ancestor_query.rb
capybara-2.15.0 lib/capybara/queries/ancestor_query.rb