Module: Capybara::Select2

Defined in:
lib/decidim/dev/test/rspec_support/capybara_select2.rb

Instance Method Summary collapse

Instance Method Details

#select2(value, from:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/decidim/dev/test/rspec_support/capybara_select2.rb', line 5

def select2(value, from:)
  expect(page).to have_xpath("//select[@id='#{from}']/..")
  select2_container = find(:xpath, "//select[@id='#{from}']/..")

  expect(select2_container).to have_selector(".select2-selection")
  select2_container.find(".select2-selection").click

  expect(page).to have_no_content("Searching...")

  body = find(:xpath, "//body")
  expect(body).to have_selector(".select2-dropdown li.select2-results__option", text: value)

  body.find(".select2-dropdown li.select2-results__option", text: value).click
  expect(page).to have_select(from, with_options: [value])
end