Sha256: 54c6027343bf7ef3f3a1c915c2ea5c395381b4993ab999afdd0d75605c66dc1d

Contents?: true

Size: 710 Bytes

Versions: 11

Compression:

Stored size: 710 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.union(XPath.following_sibling)) do |el|
            match_results.include?(el)
          end
        end
      end

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

Version data entries

11 entries across 9 versions & 2 rubygems

Version Path
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/capybara-2.18.0/lib/capybara/queries/sibling_query.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/capybara-2.16.1/lib/capybara/queries/sibling_query.rb
tdiary-5.0.8 vendor/bundle/gems/capybara-2.18.0/lib/capybara/queries/sibling_query.rb
capybara-2.18.0 lib/capybara/queries/sibling_query.rb
capybara-2.17.0 lib/capybara/queries/sibling_query.rb
tdiary-5.0.7 vendor/bundle/gems/capybara-2.16.1/lib/capybara/queries/sibling_query.rb
capybara-2.16.1 lib/capybara/queries/sibling_query.rb
capybara-2.16.0 lib/capybara/queries/sibling_query.rb
capybara-2.15.4 lib/capybara/queries/sibling_query.rb
capybara-2.15.3 lib/capybara/queries/sibling_query.rb
capybara-2.15.2 lib/capybara/queries/sibling_query.rb