summaryrefslogtreecommitdiff
path: root/spec/spec_helper.rb
blob: c69b823d08720eb448028b572ed65fe540ca7606 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require 'serverspec'
require 'net/ssh'
require 'tempfile'

set :backend, :ssh
set :disable_sudo, true

test = ENV['TARGET_TEST']
host = ENV['TARGET_HOST']

Dir.chdir("spec/#{test}") do
  config = Tempfile.new('', Dir.tmpdir)
  `vagrant ssh-config #{host} > #{config.path}`
  options = Net::SSH::Config.for(host, [config.path])
  options[:user] ||= Etc.getlogin
  set :host,        options[:host_name] || host
  set :ssh_options, options
end