Sha256: dc978c32cb6ba99798a66e1c5507344afeef57d314a0916b96cce46d3f67c814

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 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.information_from_io(File.open(png_path, 'rb'))
        expect(parsed).not_to be_nil
        expect(parsed.file_nature).to eq(:image)
        expect(parsed.file_type).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.information_from_io(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

8 entries across 8 versions & 1 rubygems

Version Path
format_parser-0.1.7 spec/parsers/png_parser_spec.rb
format_parser-0.1.6 spec/parsers/png_parser_spec.rb
format_parser-0.1.5 spec/parsers/png_parser_spec.rb
format_parser-0.1.4 spec/parsers/png_parser_spec.rb
format_parser-0.1.3 spec/parsers/png_parser_spec.rb
format_parser-0.1.2 spec/parsers/png_parser_spec.rb
format_parser-0.1.1 spec/parsers/png_parser_spec.rb
format_parser-0.1.0 spec/parsers/png_parser_spec.rb