Sha256: c6c347723ab06330a311ad73d5a0d22e04091950a1bad345047de6b26fbf41d0

Contents?: true

Size: 857 Bytes

Versions: 13

Compression:

Stored size: 857 Bytes

Contents

# frozen_string_literal: true

Capybara.add_selector(:radio_button, locator_type: [String, Symbol]) do
  label 'radio button'
  xpath do |locator, allow_self: nil, **options|
    xpath = XPath.axis(allow_self ? :"descendant-or-self" : :descendant, :input)[
      XPath.attr(:type) == 'radio'
    ]
    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.inspec}" if with
    desc
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/selector/definition/radio_button.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/selector/definition/radio_button.rb
tdiary-5.1.0 vendor/bundle/gems/capybara-3.29.0/lib/capybara/selector/definition/radio_button.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/capybara-3.29.0/lib/capybara/selector/definition/radio_button.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/capybara-3.29.0/lib/capybara/selector/definition/radio_button.rb
capybara-3.29.0 lib/capybara/selector/definition/radio_button.rb
capybara-3.28.0 lib/capybara/selector/definition/radio_button.rb
capybara-3.27.0 lib/capybara/selector/definition/radio_button.rb
capybara-3.26.0 lib/capybara/selector/definition/radio_button.rb
capybara-3.25.0 lib/capybara/selector/definition/radio_button.rb
capybara-3.24.0 lib/capybara/selector/definition/radio_button.rb
capybara-3.23.0 lib/capybara/selector/definition/radio_button.rb
capybara-3.22.0 lib/capybara/selector/definition/radio_button.rb