Sha256: a7352b879bda7eb16c25650f893ac6a33a50acf989d9b6617ff833316c6c31da

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

require 'tmpdir'
require 'fileutils'

shared_context "Tarball" do
  # Suggested subject:
  #
  #   subject { described_class.new('fixture-tarball', fixture_tarball, checksum: fixture_checksum) }
  #
  let(:fixture_tarball) do
    File.expand_path('spec/fixtures/tarball/tarball.tar.gz', PROJECT_ROOT)
  end

  let(:fixture_checksum) { '292e692ad18faabd4f9b21037d51f0185e04b69f82c522a54af91fb5b88c2d3b' }

  # Use tmpdir for cached tarballs
  let(:tmpdir) { Dir.mktmpdir }

  # `moduledir` and `cache_root` are available for examples to use in creating
  # their subjects
  let(:moduledir) { File.join(tmpdir, 'modules').tap { |path| Dir.mkdir(path) } }
  let(:cache_root) { File.join(tmpdir, 'cache').tap { |path| Dir.mkdir(path) } }

  around(:each) do |example|
    if subject.is_a?(R10K::Tarball)
      subject.settings[:cache_root] = cache_root
    elsif subject.respond_to?(:tarball) && subject.tarball.is_a?(R10K::Tarball)
      subject.tarball.settings[:cache_root] = cache_root
    end
    example.run
    FileUtils.remove_entry_secure(tmpdir)
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
r10k-3.15.0 spec/shared-contexts/tarball.rb
akerl-r10k-3.14.2.1 spec/shared-contexts/tarball.rb
r10k-3.14.2 spec/shared-contexts/tarball.rb
r10k-3.14.1 spec/shared-contexts/tarball.rb
r10k-3.14.0 spec/shared-contexts/tarball.rb