Sha256: daff127f9dbacb3d88eeca219a5ae0489da03ebdb5ec88fcd7413c625431a619

Contents?: true

Size: 1.35 KB

Versions: 20

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe ChunkyPNG::Datastream do

  describe '.from_io'do
    it "should raise an error when loading a file with a bad signature" do
      filename = resource_file('damaged_signature.png')
      lambda { ChunkyPNG::Datastream.from_file(filename) }.should raise_error
    end

    it "should raise an error if the CRC of a chunk is incorrect" do
      filename = resource_file('damaged_chunk.png')
      lambda { ChunkyPNG::Datastream.from_file(filename) }.should raise_error
    end

    it "should not raise an error for an unsupported color depth when only reading the datastream" do
      filename = resource_file('indexed_4bit.png')
      lambda { ChunkyPNG::Datastream.from_file(filename) }.should_not raise_error
    end
  end

  describe '#metadata' do
    it "should load uncompressed tXTt chunks correctly" do
      filename = resource_file('text_chunk.png')
      ds = ChunkyPNG::Datastream.from_file(filename)
      ds.metadata['Title'].should  == 'My amazing icon!'
      ds.metadata['Author'].should == "Willem van Bergen"
    end

    it "should load compressed zTXt chunks correctly" do
      filename = resource_file('ztxt_chunk.png')
      ds = ChunkyPNG::Datastream.from_file(filename)
      ds.metadata['Title'].should == 'PngSuite'
      ds.metadata['Copyright'].should == "Copyright Willem van Schaik, Singapore 1995-96"
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
chunky_png-0.10.5 spec/chunky_png/datastream_spec.rb
chunky_png-0.10.4 spec/chunky_png/datastream_spec.rb
chunky_png-0.10.3 spec/chunky_png/datastream_spec.rb
chunky_png-0.10.2 spec/chunky_png/datastream_spec.rb
chunky_png-0.10.1 spec/chunky_png/datastream_spec.rb
chunky_png-0.10.0 spec/chunky_png/datastream_spec.rb
chunky_png-0.9.2 spec/chunky_png/datastream_spec.rb
chunky_png-0.9.1 spec/chunky_png/datastream_spec.rb
chunky_png-0.9.0 spec/chunky_png/datastream_spec.rb
chunky_png-0.8.0 spec/chunky_png/datastream_spec.rb
chunky_png-0.7.3 spec/chunky_png/datastream_spec.rb
chunky_png-0.7.1 spec/chunky_png/datastream_spec.rb
chunky_png-0.7.0 spec/chunky_png/datastream_spec.rb
chunky_png-0.6.0 spec/chunky_png/datastream_spec.rb
chunky_png-0.5.8 spec/chunky_png/datastream_spec.rb
chunky_png-0.5.7 spec/chunky_png/datastream_spec.rb
chunky_png-0.5.6 spec/chunky_png/datastream_spec.rb
chunky_png-0.5.5 spec/chunky_png/datastream_spec.rb
chunky_png-0.5.4 spec/chunky_png/datastream_spec.rb
chunky_png-0.5.3 spec/chunky_png/datastream_spec.rb