Skip to content

Instantly share code, notes, and snippets.

@jhaals
Created May 8, 2014 14:15
Show Gist options
  • Save jhaals/d6ff66be0a1b692cfcfd to your computer and use it in GitHub Desktop.
Save jhaals/d6ff66be0a1b692cfcfd to your computer and use it in GitHub Desktop.
require 'pathname'
require 'serverspec'
require 'net/ssh'
def fixture_path
Pathname.new(File.expand_path(File.join(__FILE__, '..', 'fixtures')))
end
include SpecInfra::Helper::Ssh
include SpecInfra::Helper::DetectOS
RSpec.configure do |c|
c.before :all do
host = ENV['TARGET_HOST']
if c.host != host
c.ssh.close if c.ssh
c.host = host
c.color_enabled = true
c.tty = true
c.sudo_password = ''
options = Net::SSH::Config.for(c.host)
# Suppress warning from zlib if compression is enabled in ssh conf
options[:compression] = 'none'
options[:forward_agent] = true
user = ENV['TARGET_USER'] || Etc.getlogin
c.ssh = Net::SSH.start(host, user, options)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment