class Capybara::Result

def failure_message

def failure_message
  message = @query.failure_message
  if count.zero?
    message << " but there were no matches"
  else
    message << ", found #{count} #{Capybara::Helpers.declension("match", "matches", count)}: " << full_results.map(&:text).map(&:inspect).join(", ")
  end
  unless rest.empty?
    elements = rest.map { |el| el.text rescue "<<ERROR>>" }.map(&:inspect).join(", ")
    message << ". Also found " << elements << ", which matched the selector but not all filters."
  end
  message
end