class Capybara::Result

def compare_count

def compare_count
  return 0 unless @query
  count, min, max, between = @query.options.values_at(:count, :minimum, :maximum, :between)
  # Only check filters for as many elements as necessary to determine result
  if count && (count = Integer(count))
    return load_up_to(count + 1) <=> count
  end
  return -1 if min && (min = Integer(min)) && (load_up_to(min) < min)
  return 1 if max && (max = Integer(max)) && (load_up_to(max + 1) > max)
  if between
    min, max = (between.begin && between.min) || 1, between.end
    max -= 1 if max && between.exclude_end?
    size = load_up_to(max ? max + 1 : min)
    return size <=> min unless between.include?(size)
  end
  0
end