class Capybara::Result

def compare_count

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