Created
January 8, 2016 12:34
-
-
Save hugomaiavieira/a6f581d4e38984bf2b07 to your computer and use it in GitHub Desktop.
Select2Capybara
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Select2Capybara | |
def select2(selector, value) | |
# on recent versions of select2, the .select2-focusser was replaced by | |
# .select2-input | |
execute_script("$('#{selector} .select2-focusser').val('#{value}')") | |
execute_script("$('#{selector} .select2-container').select2('open')") | |
wait_for_ajax | |
find('.select2-results li:first-child').click | |
end | |
end | |
RSpec.configure do |config| | |
config.include Select2Capybara | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment