123456789_123456789_123456789_123456789_123456789_

Class: Capybara::Selector::Filters::NodeFilter

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base
Instance Chain:
self, Base
Inherits: Capybara::Selector::Filters::Base
Defined in: lib/capybara/selector/filters/node_filter.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name, matcher, block, **options) ⇒ NodeFilter

[ GitHub ]

  
# File 'lib/capybara/selector/filters/node_filter.rb', line 9

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

Instance Method Details

#matches?(node, name, value, context = nil) ⇒ Boolean

[ GitHub ]

  
# File 'lib/capybara/selector/filters/node_filter.rb', line 23

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