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: json_spec.rb
    path of file: ./repos/puppet/spec/unit/indirector/facts
    
    the code of the file until where you have to start completion: require 'spec_helper'

require 'puppet/node/facts'
require 'puppet/indirector/facts/json'

def dir_containing_json_facts(hash)
  jsondir = tmp
    
def dir_containing_json_facts(hash)
  jsondir = tmpdir('json_facts')

  Puppet[:client_datadir] = jsondir
  dir = File.join(jsondir, 'facts')
  Dir.mkdir(dir)
  hash.each_pair do |file, facts|
    File.open(File.join(dir, file), 'wb') do |f|
      f.write(JSON.dump(facts))
    end
  end
end