spec/support/test_app.rb in capistrano-3.18.1 vs spec/support/test_app.rb in capistrano-3.19.0

- old
+ new

@@ -1,8 +1,9 @@ require "English" require "fileutils" require "pathname" +require "open3" module TestApp extend self def install @@ -12,12 +13,12 @@ def default_config <<-CONFIG set :deploy_to, '#{deploy_to}' set :repo_url, 'https://github.com/capistrano/capistrano.git' set :branch, 'master' - set :ssh_options, { keys: "\#{ENV['HOME']}/.vagrant.d/insecure_private_key", auth_methods: ['publickey'] } - server 'vagrant@localhost:2220', roles: %w{web app} + set :ssh_options, { keys: '#{File.expand_path('../../.docker/ssh_key_rsa', __dir__)}', auth_methods: ['publickey'] } + server 'deployer@localhost:2022', roles: %w{web app} set :linked_files, #{linked_files} set :linked_dirs, #{linked_dirs} set :format_options, log_file: nil set :local_user, #{current_user.inspect} CONFIG @@ -37,15 +38,18 @@ def create_test_app FileUtils.rm_rf(test_app_path) FileUtils.mkdir(test_app_path) - File.open(gemfile, "w+") do |file| - file.write "source 'https://rubygems.org'\n" - file.write "gem 'capistrano', path: '#{path_to_cap}'" - end + File.write(gemfile, <<-GEMFILE.gsub(/^\s+/, "")) + source "https://rubygems.org" + gem "capistrano", path: #{path_to_cap.to_s.inspect} + gem "ed25519", ">= 1.2", "< 2.0" + gem "bcrypt_pbkdf", ">= 1.0", "< 2.0" + GEMFILE + Dir.chdir(test_app_path) do run "bundle" end end @@ -94,17 +98,16 @@ def cap(task, subdirectory=nil) run "cap #{stage} #{task} --trace", subdirectory end def run(command, subdirectory=nil) - output = nil command = "bundle exec #{command}" unless command =~ /^bundle\b/ dir = subdirectory ? test_app_path.join(subdirectory) : test_app_path - Dir.chdir(dir) do - output = with_clean_bundler_env { `#{command}` } + output, status = Dir.chdir(dir) do + with_clean_bundler_env { Open3.capture2e(command) } end - [$CHILD_STATUS.success?, output] + [status.success?, output] end def stage "test" end @@ -116,10 +119,10 @@ def test_app_path Pathname.new("/tmp/test_app") end def deploy_to - Pathname.new("/home/vagrant/var/www/deploy") + Pathname.new("/home/deployer/var/www/deploy") end def shared_path deploy_to.join("shared") end