Sha256: fedd1eec95ba6fdfa825dfad51e5b510d17164541e01abc78fddfe4a4b4cc043

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe SugarPNG::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 { SugarPNG::Datastream.from_file(filename) }.should raise_error(ZPNG::NotSupported)
    end

    it "should NOT raise an error if the CRC of a chunk is incorrect" do
      filename = resource_file('damaged_chunk.png')
      lambda { SugarPNG::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 = SugarPNG::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 = SugarPNG::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

6 entries across 6 versions & 1 rubygems

Version Path
sugar_png-0.5.5 spec/sugar_png/datastream_spec.rb
sugar_png-0.5.4 spec/sugar_png/datastream_spec.rb
sugar_png-0.5.3 spec/sugar_png/datastream_spec.rb
sugar_png-0.5.2 spec/sugar_png/datastream_spec.rb
sugar_png-0.5.1 spec/sugar_png/datastream_spec.rb
sugar_png-0.5.0 spec/sugar_png/datastream_spec.rb