Sha256: c1060855d4b9254ae39a3f95872dd7998f84db16aa7002299a97e9bc554c2b7d

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

require 'spec'

$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster')

require 'cotta'
require 'cotta/in_memory_system'

module BuildMaster
describe Cotta, 'zip support' do
  before do
    @cotta = Cotta.new(InMemorySystem.new)
  end
  
  it 'extract from a tar file' do
    tar_file = Cotta.parent_of(__FILE__).file('tar_test.tar')
    dir = @cotta.dir('dir/extract')
    tar_file.extract(dir)
    dir.list.size.should == 3
    dir.file('one.txt').load.should == 'one'
    dir.file('two.txt').load.should == 'two'
    dir.file('three.txt').load.should == 'three'
  end
  
  it 'should archive files in the directory to a file' do
    source = @cotta.dir('dir/source')
    source.file('one.txt').save('one')
    source.file('two.txt').save('two')
    source.file('three.txt').save('three')
    tar_file = @cotta.file('target.tar')
    source.archive(tar_file)
    
    target_dir = @cotta.dir('target')
    tar_file.extract(target_dir)
    target_dir.file('one.txt').load.should == 'one'
    target_dir.file('two.txt').load.should == 'two'
    target_dir.file('three.txt').load.should == 'three'
    target_dir.should have(3).list
  end

  it 'archive subdirectories' do
      source = @cotta.dir('dir/source')
      sub = source.dir('sub')
      sub.file('one.txt').save('one')
      sub.file('two.txt').save('two')
      tar_file = @cotta.file('target.tar')
      source.archive(tar_file)

      target_dir = @cotta.dir('target')
      tar_file.extract(target_dir)
      target_dir.should have(1).list
      target_dir.dir('sub').should be_exists
      target_dir.dir('sub').should have(2).list
      target_dir.file('sub/one.txt').load.should == 'one'
      target_dir.file('sub/two.txt').load.should == 'two'
  end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
BuildMaster-1.1.9 test/buildmaster/cotta/tc_cotta_zip_support.rb