You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: html_selector.rb
    path of file: ./repos/stackneveroverflow/vendor/bundle/ruby/2.3.0/gems/rails-dom-testing-2.0.3/lib/rails/dom/testing/assertions/selector_assertions
    
    the code of the file until where you have to start completion: require 'active_support/core_ext/module/attribute_accessors'
require_relative 'substitution_context'

class HTMLSelector #:nodoc:
  attr_reader :css_selector, :tests, :message

  def initialize(values, previous_selection = nil, &root_fallback)
    @values = values
    @root = extract_root(previous_selection, root_fallback)
    extract_selectors
    @tests = extract_equality_tests
    @message = @values.shift

    if @values.shift
      raise ArgumentError, "Not expecting that last argument, you either have too many arguments, or
    
  def selecting_no_body? #:nodoc:
    # Nokogiri gives the document a body element. Which means we can't
    # run an assertion expecting there to not be a body.
    @selector == 'body' && @tests[:count] == 0
  end

  def select
    filter @root.css(@selector, context)
  end

  private

  NO_STRIP = %w{pre script style textarea}

  mattr_reader(:context) { SubstitutionContext.new }

  def filter(matches)
    match_with = tests[:text] || tests[:html]
    return matches if matches.empty? || !match_with

    content_mismatch = nil
    text_matches = tests.has_key?(:text)
    regex_matching = match_with.is_a?(Regexp)

    remaining = matches.reject do |match|
      # Preserve markup with to_s for html elements
      content = text_matches ? match.text : match.children.to_s

      content.strip! unless NO_STRIP.include?(match.name)
      content.sub!(/\A\n/, '') if text_matches && match.name == "textarea"

      next if regex_matching ? (content =~ match_with) : (content == match_with)
      content_mismatch ||= sprintf("<%s> expected but was\n<%s>.", match_with, content)
      true
    end

    @message ||= content_mismatch if remaining.empty?
    Nokogiri::XML::NodeSet.new(matches.document, remaining)
  end

  def extract_root(previous_selection, root_fallback)
    possible_root = @values.first

    if possible_root == nil
      raise ArgumentError, 'First argument is either selector or element ' \
        'to select, but nil found. Perhaps you called assert_select with ' \
        'an element that does not exist?'
    elsif possible_root.respond_to?(:css)
      @values.shift # remove the root, so selector is the first argument
      possible_root
    elsif previous_selection
      previous_selection
    else
      root_fallback.call
    end
  end

  def extract_selectors
    selector = @values.shift

    unless selector.is_a? String
      raise ArgumentError, "Expecting a selector as the first argument"
    end

    @css_selector = context.substitute!(selector, @values.dup, true)
    @selector     = context.substitute!(selector, @values)
  end