Sha256: f5fe79f1d7d256606c478cdef22a0ce5b8ef678cca16979b129bdf2ed4842070

Contents?: true

Size: 831 Bytes

Versions: 3

Compression:

Stored size: 831 Bytes

Contents

require 'test_helper'
require 'rack'

class Marcel::MimeType::ExtensionTest < Marcel::TestCase
  test "ignores case and any preceding dot" do
    assert_equal "application/pdf", Marcel::MimeType.for(extension: "PDF")
    assert_equal "application/pdf", Marcel::MimeType.for(extension: ".PDF")
    assert_equal "application/pdf", Marcel::MimeType.for(extension: "pdf")
    assert_equal "application/pdf", Marcel::MimeType.for(extension: ".pdf")
  end

  extensions = []

  each_content_type_fixture('name') do |file, name, content_type|
    extension = File.extname(name)

    unless extensions.include?(extension)
      test "gets type for #{content_type} given file extension #{extension}" do
        assert_equal content_type, Marcel::MimeType.for(extension: extension)
      end

      extensions << extension
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
marcel-0.3.2 test/extension_test.rb
marcel-0.3.1 test/extension_test.rb
marcel-0.3.0 test/extension_test.rb