require 'docker' require 'open3' # Helpers for integration tests module IntegrationHelpers def sh(command) env = { 'PATH' => ENV['PATH'], 'GEM_PATH' => ENV['GEM_PATH'], 'HOME' => ENV['HOME'], 'SSH_AUTH_SOCK' => ENV['SSH_AUTH_SOCK'] } Open3.popen3( env, command, unsetenv_others: true ) do |stdin, stdout, stderr, wait_thr| stdin.close stdout.each_line do |line| $stdout.write(line) $stdout.flush end stderr.each_line do |line| $stderr.write(line) $stderr.flush end exit_status = wait_thr.value fail 'Exit code is not zero' if exit_status != 0 end end def bundle_exec(task) Dir.chdir(path) do sh 'rm -f Gemfile.lock' sh 'bundle install' sh "bundle exec rake #{task}" end end def docker_needed! Docker.info.inspect rescue Excon::Errors::Error skip 'No docker daemon available' end end