module CapybaraSelect2

Constants

VERSION

Public Instance Methods

select2(*args) click to toggle source
# File lib/capybara_select2.rb, line 7
def select2(*args)
  options = args.pop
  values = args

  Utils.validate_options!(options)

  container = Utils.find_select2_container(options, page)
  version = Utils.detect_select2_version(container)
  options_with_select2_details =
    options.merge({ container: container, version: version, page: page })

  values.each do |value|
    Helpers.select2_open(options_with_select2_details)

    if options[:search] || options[:tag]
      term = options[:search].is_a?(String) ? options[:search] : value
      Helpers.select2_search(term, options_with_select2_details)
    end

    Helpers.select2_select(value, options_with_select2_details)
  end
end