Skip to content

Instantly share code, notes, and snippets.

@vmcilwain
Last active December 13, 2018 16:28
Show Gist options
  • Save vmcilwain/3c75519d65990471782555f96cd22740 to your computer and use it in GitHub Desktop.
Save vmcilwain/3c75519d65990471782555f96cd22740 to your computer and use it in GitHub Desktop.
[Capybara] iCheck checkbox helper methods (using JQuery)
# iCheck helper methods
def check_checkbox(attribute=:name, value)
evaluate_script "$(\":checkbox[#{attribute}='#{value}']\").prop('checked', true).iCheck('update');"
end
def uncheck_checkbox(attribute=:name, value)
evaluate_script "$(\":checkbox[#{attribute}='#{value}']\").prop('checked', false).iCheck('update');"
end
# above can be refactored_to
def update_checkbox(attribute=:name, value, bool)
evaluate_script "$(\":checkbox[#{attribute}='#{value}']\").prop('checked', #{bool}).iCheck('update');"
end
def checkbox_checked?(attribute=:name, value)
evaluate_script "$(\":checkbox[#{attribute}='#{value}']\").is(':checked');"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment