Sha256: a38e898a3d10ffadcc99e67d5cc60529dd15092d6795aef26a29895e13c29ff7

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

describe FakeZip do
  extend MyTemp.new(:temp, 'tmp/testing.zip')

  describe '.new' do
    it 'takes file name and yaml string' do
      expect { FakeZip temp, '{}' }.to change { File.exist? temp }.from(false).to(true)
    end

    it 'takes file name and hash' do
      expect { FakeZip temp, {} }.to change { File.exist? temp }.from(false).to(true)
    end

    it 'recreates file if exist' do
      FakeZip temp, {dir:[:file]}
      FakeZip temp, {other:[:any]}
      zip_entries(temp).should == %w[ other/ other/any ]
    end
  end

  describe 'examples (given structure --- files in archive)' do
    examples = <<-END.lines.map(&:strip).map { |x| x.split(' --- ',2).map { |x| eval x } }
      "[]"       --- []
      {}         --- []
      {root: []} --- ['root/']
      "root: []" --- ['root/']
      'root_dir: [file1, file2, nested_dir: [nested_file.any], empty_dir: []]' ---  ["root_dir/", "root_dir/nested_dir/", "root_dir/empty_dir/", "root_dir/file1", "root_dir/file2", "root_dir/nested_dir/nested_file.any"] 
    END

    examples.each do |input,output|
      specify "#{input.inspect} --- #{output.inspect}" do
        FakeZip temp, input
        zip_entries(temp).should == output
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
real_zip-0.0.8 spec/examples_spec.rb
fake_zip-0.0.2 spec/examples_spec.rb