diff --git a/spec/integration/intallation_spec.rb b/spec/integration/intallation_spec.rb index 1e86bac0..05d22d43 100644 --- a/spec/integration/intallation_spec.rb +++ b/spec/integration/intallation_spec.rb @@ -1,21 +1,14 @@ require 'spec_helper' +require 'support/test_app' + +include TestApp describe 'cap install' do - let(:test_app_path) { Pathname.new('/tmp/test_app') } - let(:path_to_cap) { File.expand_path('.') } - let(:gemfile) { test_app_path.join('Gemfile') } context 'with defaults' do before :all do - FileUtils.rm_rf(test_app_path) - FileUtils.mkdir(test_app_path) - - File.open(gemfile, 'w+') do |file| - file.write "gem 'capistrano', path: '#{path_to_cap}'" - end - + create_test_app Dir.chdir(test_app_path) do - %x[bundle] %x[bundle exec cap install] end end @@ -49,15 +42,8 @@ describe 'cap install' do context 'with STAGES' do before :all do - FileUtils.rm_rf(test_app_path) - FileUtils.mkdir(test_app_path) - - File.open(gemfile, 'w+') do |file| - file.write "gem 'capistrano', path: '#{path_to_cap}'" - end - + create_test_app Dir.chdir(test_app_path) do - %x[bundle] %x[bundle exec cap install STAGES=qa,production] end end @@ -90,5 +76,4 @@ describe 'cap install' do end end - end diff --git a/spec/support/test_app.rb b/spec/support/test_app.rb new file mode 100644 index 00000000..88c2aa56 --- /dev/null +++ b/spec/support/test_app.rb @@ -0,0 +1,27 @@ +module TestApp + def create_test_app + FileUtils.rm_rf(test_app_path) + FileUtils.mkdir(test_app_path) + + File.open(gemfile, 'w+') do |file| + file.write "gem 'capistrano', path: '#{path_to_cap}'" + end + + Dir.chdir(test_app_path) do + %x[bundle] + end + end + + + def test_app_path + Pathname.new('/tmp/test_app') + end + + def path_to_cap + File.expand_path('.') + end + + def gemfile + test_app_path.join('Gemfile') + end +end