module Minitest::Docker::Compose

Public Class Methods

prepended(klass) click to toggle source
# File lib/minitest/docker/compose.rb, line 6
def self.prepended(klass)
  klass.extend(ClassMethods)
end

Public Instance Methods

run_command(command, env = {}) click to toggle source
# File lib/minitest/docker/compose.rb, line 45
def run_command(command, env = {})
  env = Minitest::Docker.default_env.merge(env)

  Dir.chdir(Minitest::Docker.app_dir) do
    command_output = ''

    puts "Running #{command} with #{env.inspect}" if verbose?

    status = Open3.popen2e(ENV.to_hash.merge(env), *command) do |input, output, wait_thread|
      input.close

      output.each(56) do |out|
        command_output << out
        print out if verbose?
      end

      wait_thread.value
    end

    [status.success?, command_output]
  end
end
run_command!(command, env = {}) click to toggle source
# File lib/minitest/docker/compose.rb, line 37
def run_command!(command, env = {})
  run_command(command, env).tap do |status, output|
    unless status
      raise CommandError.new(command, output)
    end
  end
end
verbose?() click to toggle source
# File lib/minitest/docker/compose.rb, line 23
def verbose?
  ENV['VERBOSE']
end
wait!() click to toggle source
# File lib/minitest/docker/compose.rb, line 27
def wait!
  return unless Minitest::Docker.wait_command

  Timeout.timeout(10) do
    until run_command(Minitest::Docker.wait_command).first
      sleep 0.3
    end
  end
end