Sha256: 52ed9fb031075607e944fcfc62ee12553bcc7f813695b85144b75e71185e1f7d

Contents?: true

Size: 1.26 KB

Versions: 23

Compression:

Stored size: 1.26 KB

Contents

require "rspec"
require "gitlab_exporter"

require "open3"
require "tmpdir"

$LOAD_PATH.unshift File.expand_path(".")
Dir["spec/support/**/*.rb"].each do |f| require f end

RSpec.configure do |config|
  config.filter_run_excluding integration: true
end

class GitRepoBuilder
  def origin
    @origin ||= create_origin
  end

  def cloned_repo
    @cloned_repo ||= clone_origin
  end

  def cleanup
    FileUtils.rm_r(@origin) if @origin
    FileUtils.rm_r(@cloned_repo) if @cloned_repo
  end

  private

  def create_origin
    path = Dir.mktmpdir
    Open3.capture3("git init", chdir: path)
    Open3.capture3("git commit --allow-empty -m 'Beep'", chdir: path)
    Open3.capture3("git checkout -b other", chdir: path)
    path
  end

  def clone_origin
    path = Dir.mktmpdir
    Dir.rmdir(path)
    Open3.capture3("git clone #{origin} #{path}")
    Open3.capture3("git checkout master", chdir: path)
    path
  end
end

class CLIArgs
  def initialize(args, options: {})
    @arguments = args
    @options = options
  end

  def options
    yield self

    self
  end

  def on(flag, *_)
    match = @options.find { |regex, _| regex.match?(flag) }

    yield match[1] if match
  end

  def banner=(banner); end

  def parse!
    @arguments
  end

  def shift
    @arguments.shift
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
gitlab-exporter-15.2.0 spec/spec_helper.rb
gitlab-exporter-15.1.0 spec/spec_helper.rb
gitlab-exporter-15.0.0 spec/spec_helper.rb
gitlab-exporter-14.5.0 spec/spec_helper.rb
gitlab-exporter-14.4.0 spec/spec_helper.rb
gitlab-exporter-14.3.0 spec/spec_helper.rb
gitlab-exporter-14.2.0 spec/spec_helper.rb
gitlab-exporter-14.1.0 spec/spec_helper.rb
gitlab-exporter-14.0.0 spec/spec_helper.rb
gitlab-exporter-13.5.0 spec/spec_helper.rb
gitlab-exporter-13.4.1 spec/spec_helper.rb
gitlab-exporter-13.4.0 spec/spec_helper.rb
gitlab-exporter-13.3.1 spec/spec_helper.rb
gitlab-exporter-13.3.0 spec/spec_helper.rb
gitlab-exporter-13.2.0 spec/spec_helper.rb
gitlab-exporter-13.1.0 spec/spec_helper.rb
gitlab-exporter-13.0.3 spec/spec_helper.rb
gitlab-exporter-13.0.0 spec/spec_helper.rb
gitlab-exporter-12.1.1 spec/spec_helper.rb
gitlab-exporter-12.1.0 spec/spec_helper.rb