Sha256: ff312e9d5a169e2437eb46cc76c83ffc519a621a105779bcd0d73d8d7267ff39

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 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 'should add .gz extension' do
        mock(@backup.extension) << '.gz'
        @gzip.process
      end

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

      it 'should set 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 'should not touch extension' do
        @gzip.process
        @backup.extension.should == '.foo'
      end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webtranslateit-safe-0.4.2 spec/webtranslateit/safe/gzip_spec.rb
webtranslateit-safe-0.4.1 spec/webtranslateit/safe/gzip_spec.rb