Sha256: 6dc3b80fb0b345f888bba055733e86baa9b7a54d96826ea62d0b7535070f5038

Contents?: true

Size: 970 Bytes

Versions: 11

Compression:

Stored size: 970 Bytes

Contents

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
picsolve_docker_builder-0.5.5 integration/integration_helpers.rb
picsolve_docker_builder-0.5.4 integration/integration_helpers.rb
picsolve_docker_builder-0.5.3 integration/integration_helpers.rb
picsolve_docker_builder-0.5.2 integration/integration_helpers.rb
picsolve_docker_builder-0.5.1 integration/integration_helpers.rb
picsolve_docker_builder-0.5.0 integration/integration_helpers.rb
picsolve_docker_builder-0.4.0 integration/integration_helpers.rb
picsolve_docker_builder-0.3.2 integration/integration_helpers.rb
picsolve_docker_builder-0.3.1 integration/integration_helpers.rb
picsolve_docker_builder-0.3.0 integration/integration_helpers.rb
picsolve_docker_builder-0.2.0 integration/integration_helpers.rb