Sha256: e50df17f74277fbe5fb6e77fe8d7f0b35d78a3c7d1faa866593537f613e85822

Contents?: true

Size: 1.04 KB

Versions: 57

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe FormatParser::PNGParser do
  describe 'is able to parse all the examples from FastImage' do
    Dir.glob(fixtures_dir + '/*.png').each do |png_path|
      it "is able to parse #{File.basename(png_path)}" do
        parsed = subject.call(File.open(png_path, 'rb'))
        expect(parsed).not_to be_nil
        expect(parsed.nature).to eq(:image)
        expect(parsed.format).to eq(:png)
        expect(parsed.color_mode).to eq(:indexed)

        expect(parsed.width_px).to be_kind_of(Integer)
        expect(parsed.width_px).to be > 0

        expect(parsed.height_px).to be_kind_of(Integer)
        expect(parsed.height_px).to be > 0
      end
    end
  end

  it 'is able to parse an animated PNG' do
    gif_path = fixtures_dir + 'PNG/anim.png'

    parsed = subject.call(File.open(gif_path, 'rb'))
    expect(parsed).not_to be_nil

    expect(parsed.width_px).to eq(320)
    expect(parsed.height_px).to eq(180)
    expect(parsed.has_multiple_frames).to eq(true)
    expect(parsed.num_animation_or_video_frames).to eq(17)
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
format_parser-0.10.0 spec/parsers/png_parser_spec.rb
format_parser-0.9.4 spec/parsers/png_parser_spec.rb
format_parser-0.9.3 spec/parsers/png_parser_spec.rb
format_parser-0.9.0 spec/parsers/png_parser_spec.rb
format_parser-0.8.0 spec/parsers/png_parser_spec.rb
format_parser-0.7.0 spec/parsers/png_parser_spec.rb
format_parser-0.6.0 spec/parsers/png_parser_spec.rb
format_parser-0.5.2 spec/parsers/png_parser_spec.rb
format_parser-0.5.1 spec/parsers/png_parser_spec.rb
format_parser-0.5.0 spec/parsers/png_parser_spec.rb
format_parser-0.4.0 spec/parsers/png_parser_spec.rb
format_parser-0.3.5 spec/parsers/png_parser_spec.rb
format_parser-0.3.4 spec/parsers/png_parser_spec.rb
format_parser-0.3.3 spec/parsers/png_parser_spec.rb
format_parser-0.3.2 spec/parsers/png_parser_spec.rb
format_parser-0.3.1 spec/parsers/png_parser_spec.rb
format_parser-0.3.0 spec/parsers/png_parser_spec.rb