Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 54 lines (45 sloc) 1.896 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
# -- encoding: utf-8 --
require 'helpers_for_test'

class TestRead < TestCase

  def setup
    @data_dir = File.dirname(__FILE__) + '/data'
    @filename_test = @data_dir + '/test.jpg'
    @mini_exiftool = MiniExiftool.new @filename_test
  end

  def test_access
    assert_equal 'DYNAX 7D', @mini_exiftool['Model']
    assert_equal 'MLT0', @mini_exiftool['maker_note_version']
    assert_equal 'MLT0', @mini_exiftool[:MakerNoteVersion]
    assert_equal 'MLT0', @mini_exiftool[:maker_note_version]
    assert_equal 'MLT0', @mini_exiftool.maker_note_version
    assert_equal 400, @mini_exiftool.iso
  end

  def test_tags
    assert @mini_exiftool.tags.include?('FileSize')
  end

  def test_conversion
    assert_kind_of String, @mini_exiftool.model
    assert_kind_of Time, @mini_exiftool['DateTimeOriginal']
    assert_kind_of Float, @mini_exiftool['MaxApertureValue']
    assert_kind_of String, @mini_exiftool.flash
    assert_kind_of Fixnum, @mini_exiftool['ExposureCompensation']
    assert_kind_of String, (@mini_exiftool['SubjectLocation'] || @mini_exiftool['SubjectArea'])
    assert_kind_of Array, @mini_exiftool['Keywords']
    assert_kind_of String, @mini_exiftool['SupplementalCategories']
    assert_kind_of Array, @mini_exiftool['SupplementalCategories'].to_a
  end

  def test_list_tags
    assert_equal ['Orange', 'Rot'], @mini_exiftool['Keywords']
    assert_equal 'Natur', @mini_exiftool['SupplementalCategories']
    assert_equal ['Natur'], @mini_exiftool['SupplementalCategories'].to_a
  end

  def test_encoding_conversion
    @mini_exiftool_converted = MiniExiftool.new @filename_test, :convert_encoding => true
    assert_equal 'Abenddämmerung', @mini_exiftool.title
    converted = "Abendd\344mmerung"
    if converted.respond_to?(:force_encoding)
      converted.force_encoding('ISO-8859-1')
    end
    assert_equal converted, @mini_exiftool_converted.title
  end

end
Something went wrong with that request. Please try again.