Module: Capybara::Select2

Defined in:
lib/capybara_select2.rb,
lib/capybara_select2.rb

Defined Under Namespace

Classes: Element

Instance Method Summary collapse

Instance Method Details

#select2(value, options = {}) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/capybara_select2.rb', line 73

def select2(value, options = {})
  raise "Must pass a hash containing 'from' or 'xpath' or 'css'" unless options.is_a?(Hash) and [:from, :xpath, :css].any? { |k| options.has_key? k }

  element = Capybara::Select2::Element.new(self, options)
  element.initiate!
  element.select_match!(value)
end