Sha256: 17f44b487823416f4267f6b8b364433d9f55f3a506bdda2705c8be8e3d2709da

Contents?: true

Size: 836 Bytes

Versions: 29

Compression:

Stored size: 836 Bytes

Contents

# frozen_string_literal: true

Capybara.add_selector(:checkbox, locator_type: [String, Symbol]) do
  xpath do |locator, allow_self: nil, **options|
    xpath = XPath.axis(allow_self ? :"descendant-or-self" : :descendant, :input)[
      XPath.attr(:type) == 'checkbox'
    ]
    locate_field(xpath, locator, **options)
  end

  filter_set(:_field, %i[checked unchecked disabled name])

  node_filter(%i[option with]) do |node, value|
    val = node.value
    (value.is_a?(Regexp) ? value.match?(val) : val == value.to_s).tap do |res|
      add_error("Expected value to be #{value.inspect} but it was #{val.inspect}") unless res
    end
  end

  describe_node_filters do |option: nil, with: nil, **|
    desc = +''
    desc << " with value #{option.inspect}" if option
    desc << " with value #{with.inspect}" if with
    desc
  end
end

Version data entries

29 entries across 19 versions & 2 rubygems

Version Path
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/capybara-3.35.3/lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/capybara-3.34.0/lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/capybara-3.35.3/lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/capybara-3.34.0/lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/capybara-3.35.3/lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/capybara-3.34.0/lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/capybara-3.34.0/lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/capybara-3.35.3/lib/capybara/selector/definition/checkbox.rb
capybara-3.35.3 lib/capybara/selector/definition/checkbox.rb
capybara-3.35.2 lib/capybara/selector/definition/checkbox.rb
capybara-3.35.1 lib/capybara/selector/definition/checkbox.rb
capybara-3.35.0 lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.4 vendor/bundle/ruby/2.7.0/gems/capybara-3.34.0/lib/capybara/selector/definition/checkbox.rb
capybara-3.34.0 lib/capybara/selector/definition/checkbox.rb
tdiary-5.1.3 vendor/bundle/ruby/2.7.0/gems/capybara-3.33.0/lib/capybara/selector/definition/checkbox.rb