2 describe 'staging::extract', :type => :define do
4 # forcing a more sane caller_module_name to match real usage.
5 let(:facts) { { :caller_module_name => 'spec',
7 :path => '/usr/local/bin:/usr/bin:/bin' } }
9 describe 'when deploying tar.gz' do
10 let(:title) { 'sample.tar.gz' }
11 let(:params) { { :target => '/opt' } }
14 should contain_file('/opt/staging')
15 should contain_exec('extract sample.tar.gz').with({
16 :command => 'tar xzf /opt/staging/spec/sample.tar.gz',
17 :path => '/usr/local/bin:/usr/bin:/bin',
19 :creates => '/opt/sample'
24 describe 'when deploying tar.gz with strip' do
25 let(:title) { 'sample.tar.gz' }
26 let(:params) { { :target => '/opt',
30 should contain_file('/opt/staging')
31 should contain_exec('extract sample.tar.gz').with({
32 :command => 'tar xzf /opt/staging/spec/sample.tar.gz --strip=1',
33 :path => '/usr/local/bin:/usr/bin:/bin',
35 :creates => '/opt/sample'
40 describe 'when deploying zip' do
41 let(:title) { 'sample.zip' }
42 let(:params) { { :target => '/opt' } }
44 it { should contain_file('/opt/staging')
45 should contain_exec('extract sample.zip').with({
46 :command => 'unzip /opt/staging/spec/sample.zip',
47 :path => '/usr/local/bin:/usr/bin:/bin',
49 :creates => '/opt/sample'
54 describe 'when deploying zip with strip (noop)' do
55 let(:title) { 'sample.zip' }
56 let(:params) { { :target => '/opt',
59 it { should contain_file('/opt/staging')
60 should contain_exec('extract sample.zip').with({
61 :command => 'unzip /opt/staging/spec/sample.zip',
62 :path => '/usr/local/bin:/usr/bin:/bin',
64 :creates => '/opt/sample'
69 describe 'when deploying war' do
70 let(:title) { 'sample.war' }
71 let(:params) { { :target => '/opt' } }
73 it { should contain_file('/opt/staging')
74 should contain_exec('extract sample.war').with({
75 :command => 'jar xf /opt/staging/spec/sample.war',
76 :path => '/usr/local/bin:/usr/bin:/bin',
78 :creates => '/opt/sample'
83 describe 'when deploying war with strip (noop)' do
84 let(:title) { 'sample.war' }
85 let(:params) { { :target => '/opt',
88 it { should contain_file('/opt/staging')
89 should contain_exec('extract sample.war').with({
90 :command => 'jar xf /opt/staging/spec/sample.war',
91 :path => '/usr/local/bin:/usr/bin:/bin',
93 :creates => '/opt/sample'
98 describe 'when deploying unknown' do
99 let(:title) { 'sample.zzz'}
100 let(:params) { { :target => '/opt' } }
102 it { expect { should contain_exec("exec sample.zzz") }.to raise_error(Puppet::Error) }