Last active
December 13, 2018 16:28
-
-
Save vmcilwain/3c75519d65990471782555f96cd22740 to your computer and use it in GitHub Desktop.
[Capybara] iCheck checkbox helper methods (using JQuery)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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