Module: Alchemy::TestSupport::CapybaraHelpers
- Defined in:
- lib/alchemy/test_support/capybara_helpers.rb
Instance Method Summary collapse
- #click_button_with_tooltip(content) ⇒ Object
- #click_icon(name) ⇒ Object
- #click_link_with_tooltip(content) ⇒ Object
-
#select2(value, options) ⇒ Object
Select2 capybara helper.
- #select2_search(value, options) ⇒ Object
Instance Method Details
#click_button_with_tooltip(content) ⇒ Object
52 53 54 |
# File 'lib/alchemy/test_support/capybara_helpers.rb', line 52 def (content) find(%([content="#{content}"] button)).click end |
#click_icon(name) ⇒ Object
60 61 62 |
# File 'lib/alchemy/test_support/capybara_helpers.rb', line 60 def click_icon(name) find(%(alchemy-icon[name="#{name}"])).click end |
#click_link_with_tooltip(content) ⇒ Object
56 57 58 |
# File 'lib/alchemy/test_support/capybara_helpers.rb', line 56 def click_link_with_tooltip(content) find(%([content="#{content}"] > a)).click end |
#select2(value, options) ⇒ Object
Select2 capybara helper
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/alchemy/test_support/capybara_helpers.rb', line 7 def select2(value, ) label = find_label_by_text([:from]) select2_anchor_selector = ".select2-container a" if label.has_css?(select2_anchor_selector) label.find(select2_anchor_selector).click else within label.find(:xpath, "..") do find(select2_anchor_selector).click end end within_entire_page do page.find( "div.select2-result-label", text: /#{Regexp.escape(value)}/i, match: :prefer_exact ).click end end |
#select2_search(value, options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/alchemy/test_support/capybara_helpers.rb', line 28 def select2_search(value, ) if [:from] label = find_label_by_text([:from]) within label.first(:xpath, ".//..") do [:from] = "##{find(".select2-container")["id"]}" end elsif [:element_id] && [:ingredient_role] container_id = find("#element_#{[:element_id]} [data-ingredient-role='#{[:ingredient_role]}'] .select2-container")["id"] [:from] = "##{container_id}" end find("#{[:from]}:not(.select2-container-disabled):not(.select2-offscreen)").click within_entire_page do find("input.select2-input.select2-focused").set(value) expect(page).to_not have_selector(".select2-searching") unless [:select] == false expect(page).to have_selector(".select2-result-label", visible: true) find("div.select2-result-label", text: /#{Regexp.escape(value)}/i, match: :prefer_exact).click expect(page).not_to have_selector(".select2-result-label") end end end |