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: helpers.rb
    path of file: ./repos/anyway_config/lib/anyway/testing
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Anyway
  module Testing
    module Helpers
      # Sets the ENV variables to the provided
      # values and restore outside the block
      #
      # Also resets Anyway.env before and after calling 
    
      def with_env(data)
        was_values = []

        data.each do |key, val|
          was_values << [key, ENV[key]]
          next ENV.delete(key) if val.nil?
          ENV[key] = val
        end

        # clear cached env values
        Anyway.env.clear
        yield
      ensure
        was_values.each do |(key, val)|
          next ENV.delete(key) if val.nil?
          ENV[key] = val
        end

        # clear cache again
        Anyway.env.clear
      end