Sha256: f7886a56a2c00a20d29bf7ce20845a7a214311b9fad26b48b7b1184c653ba956

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

# encoding: utf-8

require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")

describe "Stream object" do
  it "should compress a stream upon request" do
    stream = PDF::Core::Stream.new
    stream << "Hi There " * 20

    cstream = PDF::Core::Stream.new
    cstream << "Hi There " * 20
    cstream.compress!

    cstream.filtered_stream.length.should be < stream.length,
      "compressed stream expected to be smaller than source but wasn't"
    cstream.data[:Filter].should == [:FlateDecode]
  end

  it "should expose sompression state" do
    stream = PDF::Core::Stream.new
    stream << "Hello"
    stream.compress!

    stream.should be_compressed
  end

  it "should detect from filters if stream is compressed" do
    stream = PDF::Core::Stream.new
    stream << "Hello"
    stream.filters << :FlateDecode

    stream.should be_compressed
  end

  it "should have Length if in data" do
    stream = PDF::Core::Stream.new
    stream << "hello"

    stream.data[:Length].should == 5
  end

  it "should update Length when updated" do
    stream = PDF::Core::Stream.new
    stream << "hello"
    stream.data[:Length].should == 5

    stream << " world"
    stream.data[:Length].should == 11
  end

  it "should corecly handle decode params" do
    stream = PDF::Core::Stream.new
    stream << "Hello"
    stream.filters << { :FlateDecode => { :Predictor => 15 } }

    stream.data[:DecodeParms].should == [{ :Predictor => 15 }]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
prawn-0.14.0 spec/stream_spec.rb
prawn-0.13.2 spec/stream_spec.rb
prawn-0.13.1 spec/stream_spec.rb
prawn-0.13.0 spec/stream_spec.rb