title: How to test chef resource using file_cache_path
body: <p>I have the following resource in one my recipes</p>
  
  <pre><code>download_dir = "#{Chef::Config[:file_cache_path]}\\BESClient"
  task_done = "#{Chef::Config[:file_cache_path]}\\BESClient\\installed.txt"
  
  file task_done do
    content Date.today.to_s
    action :create_if_missing
  end
  </code></pre>
  
  <p>Corresponding to this I have written the following chef spec test</p>
  
  <pre><code>    context 'Windows 2012R2: when all attributes are default' do
      let(:chef_run) do
        runner = ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2', file_cache_path: 'C:\Program Files (x86)\BigFix Enterprise')
        runner.converge(described_recipe)
      end
  
      it 'converges successfully' do
        expect { chef_run }.to_not raise_error
      end
  
      download_dir = 'C:\\Program Files (x86)\\BigFix Enterprise\\BESClient'
      task_done = 'C:\\Program Files (x86)\\BigFix Enterprise\\BESClient\\installed.txt'
  
      it 'creates a file with attributes' do
         expect(chef_run).to create_file_if_missing(task_done.to_s).with(
           content: Date.today.to_s)
      end
  </code></pre>
  
  <p>This tries to create <code>C:\Program Files (x86)\BigFix Enterprise</code> directory on my workstation but if I remove <code>file_cache_path</code> variable from the Runner the unit test fails with the following error</p>
  
  <pre><code>  1) besclient::windows Windows 2012R2: when all attributes are default creates
  a file with attributes
       Failure/Error:
         expect(chef_run).to create_file_if_missing(task_done.to_s).with(
           content: Date.today.to_s
         )
  
         expected "file[C:\Program Files (x86)\BigFix Enterprise\BESClient\install
  ed.txt]" with action :create_if_missing to be in Chef run. Other file resources:
  
  
           file[C:/Users/AKANKS~1/AppData/Local/Temp/chefspec20180413-11784-1dp9wh
  rfile_cache_path\BESClient\installed.txt]
  </code></pre>
  
  <p>anyone help how to test this scenario?</p>