class Chop::Form::MultipleCheckbox

Public Instance Methods

fill_in!() click to toggle source
# File lib/chop/form.rb, line 110
def fill_in!
  checkboxes.each do |checkbox|
    checkbox.set checkbox_label_in_values?(checkbox)
  end
end
get_value() click to toggle source
# File lib/chop/form.rb, line 116
def get_value
  checkboxes.select(&:checked?).map(&:value).join(", ")
end
matches?() click to toggle source
# File lib/chop/form.rb, line 106
def matches?
  field[:type] == "checkbox" && field[:name].to_s.end_with?("[]")
end

Private Instance Methods

checkbox_label_in_values?(checkbox) click to toggle source
# File lib/chop/form.rb, line 126
def checkbox_label_in_values? checkbox
  values = value.split(", ")
  labels = session.all("label[for='#{checkbox[:id]}']").map(&:text)
  (values & labels).any?
end
checkboxes() click to toggle source
# File lib/chop/form.rb, line 122
def checkboxes
  session.all("[name='#{field[:name]}']")
end