Sha256: ef19f810afeed8bf04d6616968e7f2776865c37cfc920a85b02dadcb601fdf1f

Contents?: true

Size: 1.63 KB

Versions: 22

Compression:

Stored size: 1.63 KB

Contents

# encoding: utf-8

require File.dirname(__FILE__) + '/../spec_helper'

describe Backup::Compressor::Gzip do
  let(:compressor) { Backup::Compressor::Gzip.new }

  before do
    Backup::Model.extension = 'tar'
  end

  describe 'the options' do
    it do
      compressor.send(:best).should == []
    end

    it do
      compressor.send(:fast).should == []
    end
  end

  describe '#perform!' do
    before do
      [:run, :utility].each { |method| compressor.stubs(method) }
      Backup::Logger.stubs(:message)
    end

    it 'should perform the compression' do
      compressor.expects(:utility).with(:gzip).returns(:gzip)
      compressor.expects(:run).with("gzip  '#{ File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar") }'")
      compressor.perform!
    end

    it 'should perform the compression with the --best and --fast options' do
      compressor = Backup::Compressor::Gzip.new do |c|
        c.best = true
        c.fast = true
      end

      compressor.stubs(:utility).returns(:gzip)
      compressor.expects(:run).with("gzip --best --fast '#{ File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar") }'")
      compressor.perform!
    end

    it 'should set the class variable @extension (Backup::Model.extension) to .gz' do
      compressor.stubs(:utility).returns(:gzip)
      compressor.expects(:run)

      Backup::Model.extension.should == 'tar'
      compressor.perform!
      Backup::Model.extension.should == 'tar.gz'
    end

    it 'should log' do
      Backup::Logger.expects(:message).with("Backup::Compressor::Gzip started compressing the archive.")
      compressor.perform!
    end
  end
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
interu-backup-3.0.16 spec/compressor/gzip_spec.rb
backup-3.0.16 spec/compressor/gzip_spec.rb
backup-3.0.15 spec/compressor/gzip_spec.rb
backup-3.0.14 spec/compressor/gzip_spec.rb
backup-3.0.13 spec/compressor/gzip_spec.rb
backup-3.0.12 spec/compressor/gzip_spec.rb
backup-3.0.11 spec/compressor/gzip_spec.rb
alg-backup-3.0.10 spec/compressor/gzip_spec.rb
backup-3.0.10 spec/compressor/gzip_spec.rb
backup-3.0.9 spec/compressor/gzip_spec.rb
backup-3.0.8 spec/compressor/gzip_spec.rb
backup-3.0.7 spec/compressor/gzip_spec.rb
backup-3.0.6 spec/compressor/gzip_spec.rb
backup-3.0.5 spec/compressor/gzip_spec.rb
backup-3.0.4 spec/compressor/gzip_spec.rb
backup-3.0.3 spec/compressor/gzip_spec.rb
backup-3.0.2.build.0 spec/compressor/gzip_spec.rb
backup-3.0.2 spec/compressor/gzip_spec.rb
backup-3.0.1.build.0 spec/compressor/gzip_spec.rb
backup-3.0.1 spec/compressor/gzip_spec.rb