Sha256: b7c257907ac7e264111bfcbc392e0076379cc016a7e3a13a6999e2978ad3d9e2

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 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
          # data[4..7] is modified time and it changes
          expect(data.bytes).to match(result)
        end
      end
      let(:result) { [31, 139, 8, 0, anything, anything, anything, anything, 0, 3, 43, 73, 45, 46, 225, 2, 0, 198, 53, 185, 59, 5, 0, 0, 0] }
      include_examples "deflate"
      context "level gzip_options" do
        let(:result) { [31, 139, 8, 0, anything, anything, anything, anything, 2, 3, 43, 73, 45, 46, 225, 2, 0, 198, 53, 185, 59, 5, 0, 0, 0] }
        let(:options) { {gzip_options: {level: Zlib::BEST_COMPRESSION}} }
        include_examples "deflate"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
paperclip-deflater-0.1.6 spec/paperclip/processors/gzip_spec.rb
paperclip-deflater-0.1.5 spec/paperclip/processors/gzip_spec.rb
paperclip-deflater-0.1.4 spec/paperclip/processors/gzip_spec.rb