Skip to content

Instantly share code, notes, and snippets.

@Joseph507
Joseph507 / select2_helper.rb
Last active November 7, 2016 02:33 — forked from infertux/select2_helper.rb
Helper to select a Select2 item with Capybara/Cucumber
# spec/support/capybara/select2_helper.rb or features/support/select2_helper.rb
module Select2Helper
# @example
# select2 "Item", from: "select_id"
# select2 /^Item/, from: "select_id"
#
# @note Works with Select2 version 3.4.1.
def select2(text, options)
find("#s2id_#{options[:from]}").click