Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update spec tests to avoid redundant it.

  • Loading branch information...
commit 9e6d9b2903cf1c2ee63dc2dd69a9dbd898277afe 1 parent f0a07a1
@nanliu authored
View
24 spec/defines/staging_deploy_spec.rb
@@ -7,18 +7,20 @@
:path => '/usr/local/bin:/usr/bin:/bin', } }
describe 'when deploying tar.gz' do
- let(:title) { 'sample.tar.gz' }
- let(:params) { { :source => 'puppet:///modules/staging/sample.tar.gz',
- :target => '/usr/local' } }
+ let(:title) { 'sample.tar.gz' }
+ let(:params) { { :source => 'puppet:///modules/staging/sample.tar.gz',
+ :target => '/usr/local' } }
- it { should contain_file('/opt/staging') }
- it { should contain_file('/opt/staging/spec/sample.tar.gz') }
- it { should contain_exec('extract sample.tar.gz').with({
- :command => 'tar xzf /opt/staging/spec/sample.tar.gz',
- :path => '/usr/local/bin:/usr/bin:/bin',
- :cwd => '/usr/local',
- :creates => '/usr/local/sample'
- }) }
+ it {
+ should contain_file('/opt/staging')
+ should contain_file('/opt/staging/spec/sample.tar.gz')
+ should contain_exec('extract sample.tar.gz').with({
+ :command => 'tar xzf /opt/staging/spec/sample.tar.gz',
+ :path => '/usr/local/bin:/usr/bin:/bin',
+ :cwd => '/usr/local',
+ :creates => '/usr/local/sample'
+ })
+ }
end
end
View
64 spec/defines/staging_extract_spec.rb
@@ -7,42 +7,46 @@
:path => '/usr/local/bin:/usr/bin:/bin' } }
describe 'when deploying tar.gz' do
- let(:title) { 'sample.tar.gz' }
- let(:params) { { :target => '/opt' } }
-
- it { should contain_file('/opt/staging') }
- it { should contain_exec('extract sample.tar.gz').with({
- :command => 'tar xzf /opt/staging/spec/sample.tar.gz',
- :path => '/usr/local/bin:/usr/bin:/bin',
- :cwd => '/opt',
- :creates => '/opt/sample'
- }) }
+ let(:title) { 'sample.tar.gz' }
+ let(:params) { { :target => '/opt' } }
+
+ it {
+ should contain_file('/opt/staging')
+ should contain_exec('extract sample.tar.gz').with({
+ :command => 'tar xzf /opt/staging/spec/sample.tar.gz',
+ :path => '/usr/local/bin:/usr/bin:/bin',
+ :cwd => '/opt',
+ :creates => '/opt/sample'
+ })
+ }
end
describe 'when deploying zip' do
- let(:title) { 'sample.zip' }
- let(:params) { { :target => '/opt' } }
-
- it { should contain_file('/opt/staging') }
- it { should contain_exec('extract sample.zip').with({
- :command => 'unzip /opt/staging/spec/sample.zip',
- :path => '/usr/local/bin:/usr/bin:/bin',
- :cwd => '/opt',
- :creates => '/opt/sample'
- }) }
+ let(:title) { 'sample.zip' }
+ let(:params) { { :target => '/opt' } }
+
+ it { should contain_file('/opt/staging')
+ should contain_exec('extract sample.zip').with({
+ :command => 'unzip /opt/staging/spec/sample.zip',
+ :path => '/usr/local/bin:/usr/bin:/bin',
+ :cwd => '/opt',
+ :creates => '/opt/sample'
+ })
+ }
end
describe 'when deploying war' do
- let(:title) { 'sample.war' }
- let(:params) { { :target => '/opt' } }
-
- it { should contain_file('/opt/staging') }
- it { should contain_exec('extract sample.war').with({
- :command => 'jar xf /opt/staging/spec/sample.war',
- :path => '/usr/local/bin:/usr/bin:/bin',
- :cwd => '/opt',
- :creates => '/opt/sample'
- }) }
+ let(:title) { 'sample.war' }
+ let(:params) { { :target => '/opt' } }
+
+ it { should contain_file('/opt/staging')
+ should contain_exec('extract sample.war').with({
+ :command => 'jar xf /opt/staging/spec/sample.war',
+ :path => '/usr/local/bin:/usr/bin:/bin',
+ :cwd => '/opt',
+ :creates => '/opt/sample'
+ })
+ }
end
describe 'when deploying unknown' do
View
167 spec/defines/staging_file_spec.rb
@@ -5,53 +5,60 @@
let(:facts) { { :caller_module_name=> 'spec' } }
describe 'when deploying via puppet' do
- let(:title) { 'sample.tar.gz' }
- let(:params) { { :source => 'puppet:///modules/staging/sample.tar.gz' } }
-
- it { should contain_file('/opt/staging') }
- it { should contain_file('/opt/staging/spec/sample.tar.gz') }
- it { should_not contain_exec('/opt/staging/spec/sample.tar.gz') }
+ let(:title) { 'sample.tar.gz' }
+ let(:params) { { :source => 'puppet:///modules/staging/sample.tar.gz' } }
+
+ it {
+ should contain_file('/opt/staging')
+ should contain_file('/opt/staging/spec/sample.tar.gz')
+ should_not contain_exec('/opt/staging/spec/sample.tar.gz')
+ }
end
describe 'when deploying via local' do
- let(:title) { 'sample.tar.gz' }
- let(:params) { { :source => '/nfs/sample.tar.gz',
- :target => '/usr/local/sample.tar.gz',
- } }
-
- it { should contain_file('/opt/staging') }
- it { should contain_file('/usr/local/sample.tar.gz') }
- it { should_not contain_exec('/opt/staging/spec/sample.tar.gz') }
+ let(:title) { 'sample.tar.gz' }
+ let(:params) { { :source => '/nfs/sample.tar.gz',
+ :target => '/usr/local/sample.tar.gz',
+ } }
+
+ it {
+ should contain_file('/opt/staging')
+ should contain_file('/usr/local/sample.tar.gz')
+ should_not contain_exec('/opt/staging/spec/sample.tar.gz')
+ }
end
describe 'when deploying via http' do
- let(:title) { 'sample.tar.gz' }
- let(:params) { { :source => 'http://webserver/sample.tar.gz' } }
-
- it { should contain_file('/opt/staging') }
- it { should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
- :command => 'curl -L -o sample.tar.gz http://webserver/sample.tar.gz',
- :path => '/usr/local/bin:/usr/bin:/bin',
- :environment => nil,
- :cwd => '/opt/staging/spec',
- :creates => '/opt/staging/spec/sample.tar.gz',
- }) }
+ let(:title) { 'sample.tar.gz' }
+ let(:params) { { :source => 'http://webserver/sample.tar.gz' } }
+
+ it {
+ should contain_file('/opt/staging')
+ should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
+ :command => 'curl -L -o sample.tar.gz http://webserver/sample.tar.gz',
+ :path => '/usr/local/bin:/usr/bin:/bin',
+ :environment => nil,
+ :cwd => '/opt/staging/spec',
+ :creates => '/opt/staging/spec/sample.tar.gz',
+ })
+ }
end
describe 'when deploying via http with parameters' do
- let(:title) { 'sample.tar.gz' }
- let(:params) { { :source => 'http://webserver/sample.tar.gz',
- :target => '/usr/local/sample.tar.gz',
- } }
-
- it { should contain_file('/opt/staging') }
- it { should contain_exec('/usr/local/sample.tar.gz').with( {
- :command => 'curl -L -o sample.tar.gz http://webserver/sample.tar.gz',
- :path => '/usr/local/bin:/usr/bin:/bin',
- :environment => nil,
- :cwd => '/usr/local',
- :creates => '/usr/local/sample.tar.gz',
- }) }
+ let(:title) { 'sample.tar.gz' }
+ let(:params) { { :source => 'http://webserver/sample.tar.gz',
+ :target => '/usr/local/sample.tar.gz',
+ } }
+
+ it { should contain_file('/opt/staging')
+ should contain_exec('/usr/local/sample.tar.gz').with( {
+ :command => 'curl -L -o sample.tar.gz http://webserver/sample.tar.gz',
+ :path => '/usr/local/bin:/usr/bin:/bin',
+ :environment => nil,
+ :cwd => '/usr/local',
+ :creates => '/usr/local/sample.tar.gz',
+ })
+ }
end
describe 'when deploying via https' do
@@ -69,51 +76,57 @@
end
describe 'when deploying via https with parameters' do
- let(:title) { 'sample.tar.gz' }
- let(:params) { { :source => 'https://webserver/sample.tar.gz',
- :username => 'puppet',
- :password => 'puppet',
- } }
-
- it { should contain_file('/opt/staging') }
- it { should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
- :command => 'curl -L -o sample.tar.gz -u puppet:puppet https://webserver/sample.tar.gz',
- :path => '/usr/local/bin:/usr/bin:/bin',
- :environment => nil,
- :cwd => '/opt/staging/spec',
- :creates => '/opt/staging/spec/sample.tar.gz',
- }) }
+ let(:title) { 'sample.tar.gz' }
+ let(:params) { { :source => 'https://webserver/sample.tar.gz',
+ :username => 'puppet',
+ :password => 'puppet',
+ } }
+
+ it {
+ should contain_file('/opt/staging')
+ should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
+ :command => 'curl -L -o sample.tar.gz -u puppet:puppet https://webserver/sample.tar.gz',
+ :path => '/usr/local/bin:/usr/bin:/bin',
+ :environment => nil,
+ :cwd => '/opt/staging/spec',
+ :creates => '/opt/staging/spec/sample.tar.gz',
+ })
+ }
end
describe 'when deploying via ftp' do
- let(:title) { 'sample.tar.gz' }
- let(:params) { { :source => 'ftp://webserver/sample.tar.gz' } }
-
- it { should contain_file('/opt/staging') }
- it { should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
- :command => 'curl -o sample.tar.gz ftp://webserver/sample.tar.gz',
- :path => '/usr/local/bin:/usr/bin:/bin',
- :environment => nil,
- :cwd => '/opt/staging/spec',
- :creates => '/opt/staging/spec/sample.tar.gz',
- }) }
+ let(:title) { 'sample.tar.gz' }
+ let(:params) { { :source => 'ftp://webserver/sample.tar.gz' } }
+
+ it {
+ should contain_file('/opt/staging')
+ should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
+ :command => 'curl -o sample.tar.gz ftp://webserver/sample.tar.gz',
+ :path => '/usr/local/bin:/usr/bin:/bin',
+ :environment => nil,
+ :cwd => '/opt/staging/spec',
+ :creates => '/opt/staging/spec/sample.tar.gz',
+ })
+ }
end
describe 'when deploying via ftp with parameters' do
- let(:title) { 'sample.tar.gz' }
- let(:params) { { :source => 'ftp://webserver/sample.tar.gz',
- :username => 'puppet',
- :password => 'puppet',
- } }
-
- it { should contain_file('/opt/staging') }
- it { should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
- :command => 'curl -o sample.tar.gz -u puppet:puppet ftp://webserver/sample.tar.gz',
- :path => '/usr/local/bin:/usr/bin:/bin',
- :environment => nil,
- :cwd => '/opt/staging/spec',
- :creates => '/opt/staging/spec/sample.tar.gz',
- }) }
+ let(:title) { 'sample.tar.gz' }
+ let(:params) { { :source => 'ftp://webserver/sample.tar.gz',
+ :username => 'puppet',
+ :password => 'puppet',
+ } }
+
+ it {
+ should contain_file('/opt/staging')
+ should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
+ :command => 'curl -o sample.tar.gz -u puppet:puppet ftp://webserver/sample.tar.gz',
+ :path => '/usr/local/bin:/usr/bin:/bin',
+ :environment => nil,
+ :cwd => '/opt/staging/spec',
+ :creates => '/opt/staging/spec/sample.tar.gz',
+ })
+ }
end
end

0 comments on commit 9e6d9b2

Please sign in to comment.
Something went wrong with that request. Please try again.