Sha256: f4c3daeb6043683f0ca03856a0ce7352ed6807b1f3aace1aaa63ebcb910879d1

Contents?: true

Size: 1.96 KB

Versions: 6

Compression:

Stored size: 1.96 KB

Contents

require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
require 'albacore/zipdirectory'
require 'albacore/unzip'
require 'ziptestdata'

describe ZipDirectory, 'when zipping a directory of files' do
  before :each do
    zip = ZipDirectory.new
    zip.directories_to_zip ZipTestData.folder
    zip.output_file = "test.zip"
    zip.package
  end
  
  it "should produce a zip file" do
    File.exist?(File.join(ZipTestData.folder, "test.zip")).should be_true
  end
end

describe ZipDirectory, 'when zipping a directory with string exclusions' do
  before :each do
    zip = ZipDirectory.new
    zip.directories_to_zip ZipTestData.folder
    zip.output_file = 'test.zip'
    zip.exclusions File.expand_path(File.join(ZipTestData.folder, 'files', 'testfile.txt'))
    zip.package
    
    unzip = Unzip.new
    unzip.zip_file = File.join(ZipTestData.folder, 'test.zip')
    unzip.unzip_path = ZipTestData.output_folder
    unzip.unzip
  end
  
  after :each do
    FileUtils.rm_rf ZipTestData.output_folder if File.exist? ZipTestData.output_folder
  end
  
  it 'should not zip files with the same name as any exclusions' do
    File.exist?(File.join(ZipTestData.output_folder, 'files', 'testfile.txt')).should be_false
  end
end

describe ZipDirectory, 'when zipping a directory of files with regexp exclusions' do
before :each do
    zip = ZipDirectory.new
    zip.directories_to_zip ZipTestData.folder
    zip.output_file = 'test.zip'
    zip.exclusions /testfile/
    zip.package
    
    unzip = Unzip.new
    unzip.zip_file = File.join(ZipTestData.folder, 'test.zip')
    unzip.unzip_path = ZipTestData.output_folder
    unzip.unzip
  end
  
  after :each do
    FileUtils.rm_rf ZipTestData.output_folder if File.exist? ZipTestData.output_folder
  end
  
  it 'should not zip files that match any of the exclusions regexps' do
    File.exist?(File.join(ZipTestData.output_folder, 'files', 'testfile.txt')).should be_false
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
albacore-0.1.5 spec/zip_spec.rb
albacore-0.1.4 spec/zip_spec.rb
albacore-0.1.3 spec/zip_spec.rb
albacore-0.1.2 spec/zip_spec.rb
albacore-0.1.1 spec/zip_spec.rb
albacore-0.1.0 spec/zip_spec.rb