1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

refactor integration test

This commit is contained in:
seenmyfate 2013-06-14 17:09:32 +01:00
parent e15b3f9cdb
commit dd4c99e04b
2 changed files with 32 additions and 20 deletions

View file

@ -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

27
spec/support/test_app.rb Normal file
View file

@ -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