Skip to content

Instantly share code, notes, and snippets.

@toppa
Last active August 29, 2015 14:09
Show Gist options
  • Save toppa/9669f7bca7f0c4dc8515 to your computer and use it in GitHub Desktop.
Save toppa/9669f7bca7f0c4dc8515 to your computer and use it in GitHub Desktop.
module ChosenSteps
def chosen_input(label_text)
find('.chosen-input', text: label_text)
end
def chosen_suggestion(text)
find('li.active-result', text: text)
end
def chosen_select(value, options)
within '.input', text: options[:from] do
find('.chosen-single').click
find('.active-result', text: value).click
end
end
def have_chosen_select(label_text, options)
within '.input', text: label_text do
have_selector '.chosen-single', text: options[:selected]
end
end
def fill_in_chosen_multi_select(label_text, options = {})
within chosen_input(label_text) do
chosen_multi_select_input.set(options[:with])
sleep 1
chosen_suggestion(options[:with]).click
end
end
def chosen_multi_select_input
find('.chosen-choices .search-field input')
end
def chosen_multi_select_option(text)
find('li.search-choice', text: text)
end
def have_chosen_multi_select_option(value, options = {})
within chosen_input(options.delete(:for)) do
have_selector 'li.search-choice', text: value
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment