Module: Capybara::DataPicker

Included in:
PollingOfficersPicker, ProposalsPicker, ScopesPicker
Defined in:
decidim-dev/lib/decidim/dev/test/rspec_support/capybara_data_picker.rb

Instance Method Summary collapse

Instance Method Details

#data_picker_choose_value(value) ⇒ Object


24
25
26
27
28
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/capybara_data_picker.rb', line 24

def data_picker_choose_value(value)
  body = find(:xpath, "//body")
  expect(body).to have_selector("#data_picker-modal input[data-picker-choose][type=checkbox][value=\"#{value}\"]")
  body.find("#data_picker-modal input[data-picker-choose][type=checkbox][value=\"#{value}\"]").click
end

#data_picker_closeObject


30
31
32
33
34
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/capybara_data_picker.rb', line 30

def data_picker_close
  body = find(:xpath, "//body")
  expect(body).to have_selector("#data_picker-modal .picker-footer a[data-close]")
  body.find("#data_picker-modal .picker-footer a[data-close]").click
end

#data_picker_pick_currentObject


18
19
20
21
22
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/capybara_data_picker.rb', line 18

def data_picker_pick_current
  body = find(:xpath, "//body")
  expect(body).to have_selector("#data_picker-modal .picker-footer a[data-picker-choose]", wait: 2)
  body.find("#data_picker-modal .picker-footer a[data-picker-choose]").click
end

#find_data_picker(id, multiple: nil) ⇒ Object


9
10
11
12
13
14
15
16
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/capybara_data_picker.rb', line 9

def find_data_picker(id, multiple: nil)
  if multiple.nil?
    expect(page).to have_selector("div.data-picker[id$='#{id}']")
  else
    expect(page).to have_selector("div.data-picker.picker-#{multiple ? "multiple" : "single"}[id$='#{id}']")
  end
  first("div.data-picker[id$='#{id}']")
end

#select_data_picker(id, multiple: nil, global_value: "") ⇒ Object


5
6
7
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/capybara_data_picker.rb', line 5

def select_data_picker(id, multiple: nil, global_value: "")
  Struct.new(:data_picker, :global_value).new(find_data_picker(id, multiple: multiple), global_value)
end