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: run_rspec_matchers.rb
    path of file: ./repos/elasticsearch-ruby/elasticsearch-api/spec/rest_api
    
    the code of the file until where you have to start completion: # Licensed to Elasticsearch B.V. under one or more cont
    
def run_rspec_matchers_on_task_group(task_group, test)
  if task_group.catch_exception?
    it 'sends the request and throws the expected error' do
      expect(task_group.exception).to match_error(task_group.expected_exception_message)
    end

    # 'match' on error description is in the task group definition
    if task_group.has_match_clauses?
      task_group.match_clauses.each do |match|
        it 'contains the expected error in the request response' do
          regexp = if (val = match['match'].values.first.to_s).include?('\\s')
                     Regexp.new(val.gsub('\\\\', '\\').gsub('/', ''))
                   else
                     Regexp.new(Regexp.escape(val))
                   end
          expect(task_group.exception.message).to match(regexp)
        end
      end