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: migrate_legacy_backups_spec.rb
    path of file: ./repos/imap-backup/spec/features/regressions
    
    the code of the file until where you have to start completion: require "features/helper"

RSpec.describe "imap-backup migrate: avoid regression in migrating legacy backups",
               :container, type: :aru
    
  def overwrite_metadata_with_old_version(email, folder)
    content = imap_parsed(email, folder)
    uids = content[:messages].map { |m| m[:uid] }
    uid_validity = content[:uid_validity]
    old_metadata = {version: 2, uids: uids, uid_validity: uid_validity}
    path = imap_path(email, folder)
    File.open(path, "w") { |f| f.write(JSON.pretty_generate(old_metadata)) }
  end