Sha256: 6dd278d31c62da5338d3c1671974c5ce373da568c5d8a4ca11434ef82d99fe18

Contents?: true

Size: 688 Bytes

Versions: 5

Compression:

Stored size: 688 Bytes

Contents

# frozen_string_literal: true

module Capybara
  module Queries
    class SiblingQuery < MatchQuery
      # @api private
      def resolve_for(node, exact = nil)
        @sibling_node = node
        node.synchronize do
          match_results = super(node.session.current_scope, exact)
          node.all(:xpath, XPath.preceding_sibling + XPath.following_sibling) do |el|
            match_results.include?(el)
          end
        end
      end

      def description
        desc = super
        sibling_query = @sibling_node&.instance_variable_get(:@query)
        desc += " that is a sibling of #{sibling_query.description}" if sibling_query
        desc
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
tdiary-5.0.9 vendor/bundle/gems/capybara-3.2.1/lib/capybara/queries/sibling_query.rb
capybara-3.3.1 lib/capybara/queries/sibling_query.rb
capybara-3.3.0 lib/capybara/queries/sibling_query.rb
capybara-3.2.1 lib/capybara/queries/sibling_query.rb
capybara-3.2.0 lib/capybara/queries/sibling_query.rb