title: How to initialize variables in chefspec which is needed to be used in recipe
body: <p>I have the recipe template resource block below:</p>
  
  <pre><code> os_ver = node['platform_version'].to_f
   REPO_TEMPLATE = ''
   if (os_ver &gt;= 6) &amp;&amp; (os_ver &lt; 7)
     REPO_TEMPLATE = 'epel.repo.rhel6.erb'
   elsif (os_ver &gt;= 7) &amp;&amp; (os_ver &lt; 8)
     REPO_TEMPLATE = 'epel.repo.rhel7.erb'
   end
  
   template EPEL_REPO_FILE do
     source REPO_TEMPLATE
     owner 'root'
     group 'root'
     mode '0644'
     action :create
   end
  </code></pre>
  
  <p>And I made the unit test chefspec like this:</p>
  
  <pre><code>describe 'cos::upgrade_rpms' do
    let(:chef_run) do
      ChefSpec::SoloRunner.new do |node|
        node.set['platform_version'] = '7.0'
        REPO_TEMPLATE = 'epel.repo.rhel7.erb'
      end.converge(described_recipe)
    end
    it 'creates a epel repo' do
      expect(chef_run).to create_template('/etc/yum.repos.d/epel.repo').with(
        source: 'epel.repo.rhel7.erb'
        owner: 'root',
        group: 'root',
        mode: '0644'
      )
  end
  </code></pre>
  
  <p>The unit test will fail which says: source is <strong>''</strong> not source: <strong>'epel.repo.rhel7.erb'</strong>.
  It seems that REPO_TEMPLATE set up in test make no effect. Can some tell how to mock the value in unit tests? </p>