Skip to content

Instantly share code, notes, and snippets.

@pyykkis
Created July 1, 2013 13:46
Show Gist options
  • Save pyykkis/5900919 to your computer and use it in GitHub Desktop.
Save pyykkis/5900919 to your computer and use it in GitHub Desktop.
Select2 helper for capybara-webkit
module Helpers
def select2(scope, opts)
scope.find('.select2-choice').click
if opts.has_key? :type_in
input = find '.select2-drop-active:not(.select2-offscreen) .select2-search .select2-input'
input.set opts[:type_in]
input.trigger('keyup-change')
end
sleep 2
all(".select2-drop-active:not(.select2-offscreen) .select2-result")
.select { |e| /#{opts[:then_select]}/ =~ e.text }
.first
.click
end
end
@dmons
Copy link

dmons commented Sep 17, 2013

sleep 2
It's a real crap inside your specs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment