Sha256: 4f34cc941d2c61ed5178e4f206af89cf1489557fcb3ae10fdbffd7b80f9955b3

Contents?: true

Size: 1.84 KB

Versions: 18

Compression:

Stored size: 1.84 KB

Contents

# -*- ruby encoding: utf-8 -*-

require 'mime/types'
require 'minitest_helper'

class TestMIMETypesLoader < Minitest::Test
  def setup
    @path     = File.expand_path('../fixture', __FILE__)
    @loader   = MIME::Types::Loader.new(@path)
    @bad_path = File.expand_path('../bad-fixtures', __FILE__)
  end

  def assert_correctly_loaded(types)
    assert_includes(types, 'application/1d-interleaved-parityfec')
    assert_deprecated('MIME::Type#references') do
      assert_includes(types['application/acad'].first.references, 'LTSW')
    end
    assert_deprecated('MIME::Type#urls') do
      assert_equal([%w(WebM http://www.webmproject.org/code/specs/container/)],
                   types['audio/webm'].first.urls)
    end
    assert_equal(%w(webm), types['audio/webm'].first.extensions)
    refute(types['audio/webm'].first.registered?)

    assert_equal('Fixes a bug with IE6 and progressive JPEGs',
                 types['image/pjpeg'].first.docs)

    assert_deprecated('MIME::Type#system?') do
      assert(types['application/x-apple-diskimage'].first.system?)
    end
    assert_deprecated('MIME::Type#system') do
      assert_equal(/mac/, types['application/x-apple-diskimage'].first.system)
    end

    assert(types['audio/vnd.qcelp'].first.obsolete?)
    assert_equal('audio/QCELP', types['audio/vnd.qcelp'].first.use_instead)
  end

  def test_load_yaml
    assert_correctly_loaded(@loader.load_yaml)
  end

  def test_load_json
    assert_correctly_loaded(@loader.load_json)
  end

  def test_load_v1
    assert_deprecated('MIME::Types::Loader.load_v1') do
      assert_correctly_loaded(@loader.load_v1)
    end
  end

  def test_malformed_v1
    assert_output(nil, /1: Parsing error in v1 MIME type definition/) {
      assert_raises(MIME::Types::Loader::BadV1Format) {
        MIME::Types::Loader.load_from_v1(File.join(@bad_path, 'malformed'))
      }
    }
  end
end

Version data entries

18 entries across 18 versions & 7 rubygems

Version Path
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/mime-types-2.6.1/test/test_mime_types_loader.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/mime-types-2.6.1/test/test_mime_types_loader.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/mime-types-2.6.1/test/test_mime_types_loader.rb
suzuko-0.1.8 vendor/bundle/ruby/2.0.0/gems/mime-types-2.6.2/test/test_mime_types_loader.rb
suzuko-0.1.7 vendor/bundle/ruby/2.0.0/gems/mime-types-2.6.2/test/test_mime_types_loader.rb
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/mime-types-2.6.2/test/test_mime_types_loader.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/mime-types-2.6.2/test/test_mime_types_loader.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/mime-types-2.6.2/test/test_mime_types_loader.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/mime-types-2.6.2/test/test_mime_types_loader.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/mime-types-2.6.2/test/test_mime_types_loader.rb
mime-types-2.6.2 test/test_mime_types_loader.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/mime-types-2.6.1/test/test_mime_types_loader.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/mime-types-2.6.1/test/test_mime_types_loader.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/mime-types-2.6.1/test/test_mime_types_loader.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/mime-types-2.6.1/test/test_mime_types_loader.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/mime-types-2.6.1/test/test_mime_types_loader.rb
mime-types-2.6.1 test/test_mime_types_loader.rb
mime-types-2.6 test/test_mime_types_loader.rb