Sha256: 6abe1485bb5901d3c46839c41d815413fd4a903939fbad7930fd99a2f4318309

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

# encoding: utf-8

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

describe Backup::Compressor::Bzip2 do
  let(:compressor) { Backup::Compressor::Bzip2.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(:bzip2).returns(:bzip2)
      compressor.expects(:run).with("bzip2  '#{ 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::Bzip2.new do |c|
        c.best = true
        c.fast = true
      end

      compressor.stubs(:utility).returns(:bzip2)
      compressor.expects(:run).with("bzip2 --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 .bz2' do
      compressor.stubs(:utility).returns(:bzip2)
      compressor.expects(:run)

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

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

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
interu-backup-3.0.16 spec/compressor/bzip2_spec.rb
backup-3.0.16 spec/compressor/bzip2_spec.rb