Sha256: f4c76eb4cc827d8e2aa890a4a6b8abbfb7e3dd63bf1fd18cd2807fc6953055aa

Contents?: true

Size: 1.77 KB

Versions: 11

Compression:

Stored size: 1.77 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../example_helper')

describe Astrails::Safe::Archive do

  def def_config
    {
      :options => "OPTS",
      :files   => "apples",
      :exclude => "oranges"
    }
  end

  def archive(id = :foo, config = def_config)
    Astrails::Safe::Archive.new(id, Astrails::Safe::Config::Node.new(nil, config))
  end

  after(:each) { Astrails::Safe::TmpFile.cleanup }

  describe :backup do
    before(:each) do
      @archive = archive
      stub(@archive).timestamp {"NOW"}
    end

    {
      :id => "foo",
      :kind => "archive",
      :extension => ".tar",
      :filename => "archive-foo.NOW",
      :command => "tar -cf - OPTS --exclude=oranges apples",
    }.each do |k, v|
      it "should set #{k} to #{v}" do
        @archive.backup.send(k).should == v
      end
    end
  end

  describe :tar_exclude_files do
    it "should return '' when no excludes" do
      archive(:foo, {}).send(:tar_exclude_files).should == ''
    end

    it "should accept single exclude as string" do
      archive(:foo, {:exclude => "bar"}).send(:tar_exclude_files).should == '--exclude=bar'
    end

    it "should accept multiple exclude as array" do
      archive(:foo, {:exclude => ["foo", "bar"]}).send(:tar_exclude_files).should == '--exclude=foo --exclude=bar'
    end
  end

  describe :tar_files do
    it "should raise RuntimeError when no files" do
      lambda {
        archive(:foo, {}).send(:tar_files)
      }.should raise_error(RuntimeError, "missing files for tar")
    end

    it "should accept single file as string" do
      archive(:foo, {:files => "foo"}).send(:tar_files).should == "foo"
    end

    it "should accept multiple files as array" do
      archive(:foo, {:files => ["foo", "bar"]}).send(:tar_files).should == "foo bar"
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
astrails-safe-0.1.10 examples/unit/archive_example.rb
astrails-safe-0.1.7 examples/unit/archive_example.rb
astrails-safe-0.1.8 examples/unit/archive_example.rb
astrails-safe-0.1.9 examples/unit/archive_example.rb
astrails-safe-0.2.0 examples/unit/archive_example.rb
astrails-safe-0.2.1 examples/unit/archive_example.rb
astrails-safe-0.2.2 examples/unit/archive_example.rb
astrails-safe-0.2.3 examples/unit/archive_example.rb
bostonlogic-safe-0.3.0 examples/unit/archive_example.rb
webbynode-safe-0.2.5 examples/unit/archive_example.rb
astrails-safe-0.2.4 examples/unit/archive_example.rb