Sha256: 76264db2df8810d28a560719118d45333e49ef18d4be96123c9d80b448d12d75

Contents?: true

Size: 782 Bytes

Versions: 82

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

require 'capybara/selector/filters/base'

module Capybara
  class Selector
    module Filters
      class NodeFilter < Base
        def initialize(name, matcher, block, **options)
          super
          @block = if boolean?
            proc do |node, value|
              error_cnt = errors.size
              block.call(node, value).tap do |res|
                add_error("Expected #{name} #{value} but it wasn't") if !res && error_cnt == errors.size
              end
            end
          else
            block
          end
        end

        def matches?(node, name, value, context = nil)
          apply(node, name, value, true, context)
        rescue Capybara::ElementNotFound
          false
        end
      end
    end
  end
end

Version data entries

82 entries across 69 versions & 6 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/capybara-3.40.0/lib/capybara/selector/filters/node_filter.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/capybara-3.40.0/lib/capybara/selector/filters/node_filter.rb
capybara-3.40.0 lib/capybara/selector/filters/node_filter.rb
capybara-3.39.2 lib/capybara/selector/filters/node_filter.rb
capybara-3.39.1 lib/capybara/selector/filters/node_filter.rb
capybara-3.39.0 lib/capybara/selector/filters/node_filter.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/capybara-3.36.0/lib/capybara/selector/filters/node_filter.rb
capybara-3.38.0 lib/capybara/selector/filters/node_filter.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/capybara-3.37.1/lib/capybara/selector/filters/node_filter.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/capybara-3.37.1/lib/capybara/selector/filters/node_filter.rb
capybara-3.37.1 lib/capybara/selector/filters/node_filter.rb
capybara-3.37.0 lib/capybara/selector/filters/node_filter.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/capybara-3.36.0/lib/capybara/selector/filters/node_filter.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/selector/filters/node_filter.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/capybara-3.36.0/lib/capybara/selector/filters/node_filter.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/capybara-3.36.0/lib/capybara/selector/filters/node_filter.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/capybara-3.36.0/lib/capybara/selector/filters/node_filter.rb
capybara-3.36.0 lib/capybara/selector/filters/node_filter.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/capybara-3.35.3/lib/capybara/selector/filters/node_filter.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/selector/filters/node_filter.rb