Sha256: 94c26a1fd4eb362f05dd823d47e059ac38b946112cf820ef18336803e4b06e84

Contents?: true

Size: 1.46 KB

Versions: 12

Compression:

Stored size: 1.46 KB

Contents

require 'minitest/autorun'
require 'minitest/unit'
require 'minitest/spec'
require 'minitest/hooks/test'
require 'webrick'
require 'fileutils'
require 'zlib'
require 'archive/tar/minitar'
require 'fileutils'
require 'erb'
require 'mini_portile2'

class TestCase < Minitest::Test
  include Minitest::Hooks

  HTTP_PORT = 23523

  attr_accessor :webrick

  def start_webrick(path)
    @webrick = WEBrick::HTTPServer.new(:Port => HTTP_PORT, :DocumentRoot => path).tap do |w|
      Thread.new do
        w.start
      end
      until w.status==:Running
        sleep 0.1
      end
    end
  end

  def stop_webrick
    if w=@webrick
      w.shutdown
      until w.status==:Stop
        sleep 0.1
      end
    end
  end

  def create_tar(tar_path, assets_path, directory)
    FileUtils.mkdir_p(File.dirname(tar_path))
    Zlib::GzipWriter.open(tar_path) do |fdtgz|
      Dir.chdir(assets_path) do
        Archive::Tar::Minitar.pack(directory, fdtgz)
      end
    end
  end

  def work_dir(r=recipe)
    "tmp/#{r.host}/ports/#{r.name}/#{r.version}/#{r.name}-#{r.version}"
  end

  def with_custom_git_dir(dir)
    old = ENV['GIT_DIR']
    ENV['GIT_DIR'] = dir
    yield
  ensure
    ENV['GIT_DIR'] = old
  end

  def with_env(env)
    before = ENV.to_h.dup
    env.each { |k, v| ENV[k] = v }
    yield
  ensure
    ENV.replace(before)
  end

  def without_env(*keys, &blk)
    before = ENV.to_h.dup
    keys.flatten.each { |k| ENV.delete(k) }
    yield
  ensure
    ENV.replace(before)
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
mini_portile2-2.8.6 test/helper.rb
mini_portile2-2.8.5 test/helper.rb
mini_portile2-2.8.5.rc2 test/helper.rb
mini_portile2-2.8.5.rc1 test/helper.rb
mini_portile2-2.8.4 test/helper.rb
mini_portile2-2.8.3 test/helper.rb
mini_portile2-2.8.2 test/helper.rb
mini_portile2-2.8.1 test/helper.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/mini_portile2-2.8.0/test/helper.rb
mini_portile2-2.8.0 test/helper.rb
mini_portile2-2.7.1 test/helper.rb
mini_portile2-2.7.0 test/helper.rb