Kouhei Sutou
null+****@clear*****
Mon Nov 23 22:06:03 JST 2015
Kouhei Sutou 2015-11-23 22:06:03 +0900 (Mon, 23 Nov 2015) New Revision: 0bcfb2fff369fde8a171448acec1f3949ec4bc66 https://github.com/groonga/packages.groonga.org/commit/0bcfb2fff369fde8a171448acec1f3949ec4bc66 Message: Use Serverspec v3 Modified files: spec/spec_helper.rb Modified: spec/spec_helper.rb (+31 -39) =================================================================== --- spec/spec_helper.rb 2015-11-23 21:46:55 +0900 (3adbf5c) +++ spec/spec_helper.rb 2015-11-23 22:06:03 +0900 (48add50) @@ -1,43 +1,35 @@ require "serverspec" -require "pathname" require "net/ssh" +require "tempfile" -include SpecInfra::Helper::Ssh -include SpecInfra::Helper::DetectOS - -RSpec.configure do |c| - if ENV["ASK_SUDO_PASSWORD"] - require "highline/import" - c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false } - else - c.sudo_password = ENV["SUDO_PASSWORD"] - end - c.before :all do - block = self.class.metadata[:example_group_block] - file = block.source_location.first - host = File.basename(Pathname.new(file).dirname) - if c.host != host - c.ssh.close if c.ssh - c.host = host - options = Net::SSH::Config.for(c.host) - user = options[:user] || Etc.getlogin - system("vagrant", "up", host) - system("vagrant", "provision", host) - config = `vagrant ssh-config #{host}` - if config != "" - config.each_line do |line| - if match = /HostName (.*)/.match(line) - host = match[1] - elsif match = /User (.*)/.match(line) - user = match[1] - elsif match = /IdentityFile (.*)/.match(line) - options[:keys] = [match[1].gsub(/"/,"")] - elsif match = /Port (.*)/.match(line) - options[:port] = match[1] - end - end - end - c.ssh = Net::SSH.start(host, user, options) - end - end +set :backend, :ssh + +if ENV["ASK_SUDO_PASSWORD"] + require "highline/import" + set :sudo_password, ask("Enter sudo password: ") { |q| q.echo = false } +else + set :sudo_password, ENV["SUDO_PASSWORD"] end + +host = "packages.groonga.org" + +system("vagrant", "up", host) +system("vagrant", "provision", host) + +config = Tempfile.new('', Dir.tmpdir) +config.write(`vagrant ssh-config #{host}`) +config.close + +options = Net::SSH::Config.for(host, [config.path]) +options[:user] ||= Etc.getlogin +set :host, options[:host_name] || host +set :ssh_options, options + +# Disable sudo +# set :disable_sudo, true + +# Set environment variables +# set :env, :LANG => 'C', :LC_MESSAGES => 'C' + +# Set PATH +# set :path, '/sbin:/usr/local/sbin:$PATH' -------------- next part -------------- HTML����������������������������... Descargar