Sha256: 8e57b22e5da184b6debc8bd2b44f485b882d28f4f973a643ebe7c88b9e50e697

Contents?: true

Size: 1.65 KB

Versions: 35

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'

describe FormatParser::CR2Parser do
  describe 'is able to parse CR2 files' do
    Dir.glob(fixtures_dir + '/CR2/*.CR2').each do |cr2_path|
      it "is able to parse #{File.basename(cr2_path)}" do
        parsed = subject.call(File.open(cr2_path, 'rb'))

        expect(parsed).not_to be_nil
        expect(parsed.nature).to eq(:image)
        expect(parsed.format).to eq(:cr2)

        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

        expect(parsed.orientation).not_to be_nil
        expect(parsed.content_type).to eq('image/x-canon-cr2')
      end
    end
  end

  it 'is able to parse orientation in RAW_CANON_40D_SRAW_V103.CR2' do
    file = fixtures_dir + '/CR2/RAW_CANON_40D_SRAW_V103.CR2'

    parsed = subject.call(File.open(file, 'rb'))

    expect(parsed.width_px).to eq(1936)
    expect(parsed.height_px).to eq(1288)
    expect(parsed.orientation).to be_kind_of(Symbol)
  end

  it 'is able to return the orientation nil for the examples from old Canon models' do
    file = fixtures_dir + '/CR2/_MG_8591.CR2'

    parsed = subject.call(File.open(file, 'rb'))

    expect(parsed.width_px).to eq(1536)
    expect(parsed.height_px).to eq(1024)
    expect(parsed.orientation).to eq(:top_left)
  end

  describe 'is able to return nil unless the examples are CR2' do
    Dir.glob(fixtures_dir + '/TIFF/*.tif').each do |tiff_path|
      it "should return nil for #{File.basename(tiff_path)}" do
        parsed = subject.call(File.open(tiff_path, 'rb'))
        expect(parsed).to be_nil
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
format_parser-2.10.0 spec/parsers/cr2_parser_spec.rb
format_parser-2.9.0 spec/parsers/cr2_parser_spec.rb
format_parser-2.8.0 spec/parsers/cr2_parser_spec.rb
format_parser-2.7.2 spec/parsers/cr2_parser_spec.rb
format_parser-2.7.1 spec/parsers/cr2_parser_spec.rb
format_parser-2.7.0 spec/parsers/cr2_parser_spec.rb
format_parser-2.6.0 spec/parsers/cr2_parser_spec.rb
format_parser-2.5.0 spec/parsers/cr2_parser_spec.rb
format_parser-2.4.5 spec/parsers/cr2_parser_spec.rb
format_parser-2.4.4 spec/parsers/cr2_parser_spec.rb
format_parser-2.4.3 spec/parsers/cr2_parser_spec.rb
format_parser-2.3.0 spec/parsers/cr2_parser_spec.rb
format_parser-2.2.1 spec/parsers/cr2_parser_spec.rb
format_parser-2.2.0 spec/parsers/cr2_parser_spec.rb
format_parser-2.1.0 spec/parsers/cr2_parser_spec.rb
format_parser-2.0.0 spec/parsers/cr2_parser_spec.rb
format_parser-2.0.0.pre.4 spec/parsers/cr2_parser_spec.rb
format_parser-2.0.0.pre.3 spec/parsers/cr2_parser_spec.rb
format_parser-2.0.0.pre.2 spec/parsers/cr2_parser_spec.rb
format_parser-2.0.0.pre spec/parsers/cr2_parser_spec.rb