def unselect(option)
unless node.multiple?
raise Capybara::UnselectNotAllowed, "Cannot unselect option '#{option}' from single select box."
end
selected_options = node.selected_options
if unselect_option = selected_options.detect { |value| value == option } ||
selected_options.detect { |value| value.index(option) }
node.clear
(selected_options - [unselect_option]).each { |value| node.select_value(value) }
else
options = all(:xpath, "//option").map { |o| "'#{o.text}'" }.join(', ')
raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{options}"
end
end