I've google around, it appears this can be done, but I'm just doing it wrong apparently.
So I'm trying to run this snippet of powershell_script
:
powershell_script 'Unzip' do
code <<-EOH
Expand-Archive -Path 'E:\\apache-tomee-1.7.4-plus.zip' -DestinationPath "E:\\#{node['COOKBOOK']['Product']}-#{node['COOKBOOK']['Region']}-" + count.to_s.rjust(2, "0")"
EOH
guard_interpreter :powershell_script
not_if "Test-Path -Path E:\\#{node['COOKBOOK']['Product']}-#{node['COOKBOOK']['Region']}-01"
end
Now those node attributes are set in attributes default.rb
default['COOKBOOK']['Product'] = 'product'
default['COOKBOOK']['Region'] = 'region'
I'm having a problem getting from there to what's supposed to be in the spec file.
require 'spec_helper'
describe 'COOKBOOK::default' do
context 'when all attributes are default, on Windows 2012R2' do
let(:chef_run) do
# for a complete list of available platforms and versions see:
# https://github.com/customink/fauxhai/blob/master/PLATFORMS.md
runner = ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
runner.converge(described_recipe)
end
it 'converges successfully' do
stub_command('Test-Path -Path E:\\#{node['COOKBOOK']['Product']}-#{node['COOKBOOK']['Region']}-01').and_return(true)
expect { chef_run }.to_not raise_error
end
end
end
Can anyone give me a hand?
Thanks in advance.