2 describe 'staging::file', :type => :define do
4 # forcing a more sane caller_module_name to match real usage.
5 let(:facts) { { :caller_module_name => 'spec',
7 :staging_http_get => 'curl' } }
9 describe 'when deploying via puppet' do
10 let(:title) { 'sample.tar.gz' }
11 let(:params) { { :source => 'puppet:///modules/staging/sample.tar.gz' } }
14 should contain_file('/opt/staging')
15 should contain_file('/opt/staging/spec/sample.tar.gz')
16 should_not contain_exec('/opt/staging/spec/sample.tar.gz')
20 describe 'when deploying via local' do
21 let(:title) { 'sample.tar.gz' }
22 let(:params) { { :source => '/nfs/sample.tar.gz',
23 :target => '/usr/local/sample.tar.gz',
27 should contain_file('/opt/staging')
28 should contain_file('/usr/local/sample.tar.gz')
29 should_not contain_exec('/opt/staging/spec/sample.tar.gz')
33 describe 'when deploying via http' do
34 let(:title) { 'sample.tar.gz' }
35 let(:params) { { :source => 'http://webserver/sample.tar.gz' } }
38 should contain_file('/opt/staging')
39 should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
40 :command => 'curl -f -L -o /opt/staging/spec/sample.tar.gz http://webserver/sample.tar.gz',
41 :path => '/usr/local/bin:/usr/bin:/bin',
43 :cwd => '/opt/staging/spec',
44 :creates => '/opt/staging/spec/sample.tar.gz',
45 :logoutput => 'on_failure',
50 describe 'when deploying via http with custom curl options' do
51 let(:title) { 'sample.tar.gz' }
53 :source => 'http://webserver/sample.tar.gz',
58 should contain_file('/opt/staging')
59 should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
60 :command => 'curl -b -f -L -o /opt/staging/spec/sample.tar.gz http://webserver/sample.tar.gz',
61 :path => '/usr/local/bin:/usr/bin:/bin',
63 :cwd => '/opt/staging/spec',
64 :creates => '/opt/staging/spec/sample.tar.gz',
65 :logoutput => 'on_failure',
70 describe 'when deploying via http with parameters' do
71 let(:title) { 'sample.tar.gz' }
72 let(:params) { { :source => 'http://webserver/sample.tar.gz',
73 :target => '/usr/local/sample.tar.gz',
78 it { should contain_file('/opt/staging')
79 should contain_exec('/usr/local/sample.tar.gz').with( {
80 :command => 'curl -f -L -o /usr/local/sample.tar.gz http://webserver/sample.tar.gz',
81 :path => '/usr/local/bin:/usr/bin:/bin',
84 :creates => '/usr/local/sample.tar.gz',
91 describe 'when deploying via https' do
92 let(:title) { 'sample.tar.gz' }
93 let(:params) { { :source => 'https://webserver/sample.tar.gz' } }
95 it { should contain_file('/opt/staging') }
96 it { should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
97 :command => 'curl -f -L -o /opt/staging/spec/sample.tar.gz https://webserver/sample.tar.gz',
98 :path => '/usr/local/bin:/usr/bin:/bin',
100 :cwd => '/opt/staging/spec',
101 :creates => '/opt/staging/spec/sample.tar.gz',
102 :logoutput => 'on_failure',
106 describe 'when deploying via https with parameters' do
107 let(:title) { 'sample.tar.gz' }
108 let(:params) { { :source => 'https://webserver/sample.tar.gz',
109 :username => 'puppet',
110 :password => 'puppet',
114 should contain_file('/opt/staging')
115 should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
116 :command => 'curl -f -L -o /opt/staging/spec/sample.tar.gz -u puppet:puppet https://webserver/sample.tar.gz',
117 :path => '/usr/local/bin:/usr/bin:/bin',
119 :cwd => '/opt/staging/spec',
120 :creates => '/opt/staging/spec/sample.tar.gz',
121 :logoutput => 'on_failure',
126 describe 'when deploying via ftp' do
127 let(:title) { 'sample.tar.gz' }
128 let(:params) { { :source => 'ftp://webserver/sample.tar.gz' } }
131 should contain_file('/opt/staging')
132 should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
133 :command => 'curl -o /opt/staging/spec/sample.tar.gz ftp://webserver/sample.tar.gz',
134 :path => '/usr/local/bin:/usr/bin:/bin',
136 :cwd => '/opt/staging/spec',
137 :creates => '/opt/staging/spec/sample.tar.gz',
138 :logoutput => 'on_failure',
143 describe 'when deploying via ftp with parameters' do
144 let(:title) { 'sample.tar.gz' }
145 let(:params) { { :source => 'ftp://webserver/sample.tar.gz',
146 :username => 'puppet',
147 :password => 'puppet',
151 should contain_file('/opt/staging')
152 should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
153 :command => 'curl -o /opt/staging/spec/sample.tar.gz -u puppet:puppet ftp://webserver/sample.tar.gz',
154 :path => '/usr/local/bin:/usr/bin:/bin',
156 :cwd => '/opt/staging/spec',
157 :creates => '/opt/staging/spec/sample.tar.gz',
158 :logoutput => 'on_failure',