Skip to content

Instantly share code, notes, and snippets.

@stack72
Created November 14, 2013 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stack72/7468721 to your computer and use it in GitHub Desktop.
Save stack72/7468721 to your computer and use it in GitHub Desktop.
describe 'when downloading a file using a proxy server we want to check that the erb gets evaluated correctly' do
let(:title) {'Download DotNet 4.0'}
let(:params) { { :url => 'http://myserver.com/test.exe', :destination => 'c:\temp', :proxyAddress => 'test-proxy-01:8888' } }
it { should contain_file('download-test.exe.ps1').with_content(
"$webclient = New-Object System.Net.WebClient
$proxyAddress = 'test-proxy-01:8888'
if ($proxyAddress -ne '') {
if (!$proxyAddress.StartsWith('http://')) {
$proxyAddress = 'http://' + $proxyAddress
}
$proxy = new-object System.Net.WebProxy
$proxy.Address = $proxyAddress
$webclient.proxy = $proxy
}
try {
$webclient.DownloadFile('http://myserver.com/test.exe', 'c:\\temp\\test.exe')
}
catch [Exception] {
write-host $_.Exception.GetType().FullName
write-host $_.Exception.Message
write-host $_.Exception.InnerException.Message
throw $_.Exception
}
"
)}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment