Sha256: 697084d48e1b9912c2279fe6d67cd0bbe3eb39cd7ce47cc1f1d2a4a9ce6c7854

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe Paperclip::Processors::Gzip do
  let(:attachment) { double }
  let(:options) { {} }
  let(:file) { test_file }
  subject { Paperclip::Processors::Gzip.new(file, options, attachment) }
  before do
    allow(attachment).to receive(:instance_read).with(:no_deflate)
  end
  describe "private methods" do
    describe "#make" do
      shared_examples "deflate" do
        it "deflates the file" do
          dst = subject.make
          data = dst.read
          expect(data[0..3]).to eq(result1)
          # data[4..7] is modified time and it changes
          expect(data[8..-1]).to eq(result2)
        end
      end
      let(:result1) { "\u001F\x8B\b\u0000" }
      let(:result2) { "\u0000\u0003+I-.\xE1\u0002\u0000\xC65\xB9;\u0005\u0000\u0000\u0000" }
      include_examples "deflate"
      context "level gzip_options" do
        let(:result2) { "\u0002\u0003+I-.\xE1\u0002\u0000\xC65\xB9;\u0005\u0000\u0000\u0000" }
        let(:options) { {gzip_options: {level: Zlib::BEST_COMPRESSION}} }
        include_examples "deflate"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
paperclip-deflater-0.1.1 spec/paperclip/processors/gzip_spec.rb
paperclip-deflater-0.1.0 spec/paperclip/processors/gzip_spec.rb
paperclip-deflater-0.0.7 spec/paperclip/processors/gzip_spec.rb
paperclip-deflater-0.0.6 spec/paperclip/processors/gzip_spec.rb
paperclip-deflater-0.0.4 spec/paperclip/processors/gzip_spec.rb