Sha256: 127f298a35b6dc9c560a58d2b64cb5b9962dabe927857cdad19752e4a47936f8

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

describe WebTranslateIt::Safe::Gzip do

  def def_backup
    {
      compressed: false,
      command: 'command',
      extension: '.foo',
      filename: 'qweqwe'
    }
  end

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

  def gzip(config = {}, backup = def_backup)
    WebTranslateIt::Safe::Gzip.new(
      @config = WebTranslateIt::Safe::Config::Node.new(nil, config),
      @backup = WebTranslateIt::Safe::Backup.new(backup)
    )
  end

  describe :preocess do

    describe 'when not yet compressed' do
      before(:each) { @gzip = gzip }

      it 'adds .gz extension' do
        mock(@backup.extension) << '.gz'
        @gzip.process
      end

      it 'adds |gzip pipe' do
        mock(@backup.command) << '|gzip'
        @gzip.process
      end

      it 'sets compressed' do
        mock(@backup).compressed = true
        @gzip.process
      end
    end

    describe 'when already compressed' do

      before(:each) { @gzip = gzip({}, extension: '.foo', command: 'foobar', compressed: true) }

      it 'does not touch extension' do
        @gzip.process
        @backup.extension.should == '.foo'
      end

      it 'does not touch command' do
        @gzip.process
        @backup.command.should == 'foobar'
      end

      it 'does not touch compressed' do
        @gzip.process
        @backup.compressed.should == true
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webtranslateit-safe-0.4.0 spec/webtranslateit/safe/gzip_spec.rb