mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Split mime type and content type
This commit is contained in:
@@ -41,12 +41,14 @@ class TestBlob < Test::Unit::TestCase
|
||||
assert_equal "text/plain", blob("grit.rb").mime_type
|
||||
assert_equal "application/xml", blob("bar.xml").mime_type
|
||||
assert_equal "text/plain", blob("dog.o").mime_type
|
||||
assert_equal "application/sh", blob("script.sh").mime_type
|
||||
end
|
||||
|
||||
def test_special_mime_type
|
||||
assert_equal "text/plain; charset=utf-8", blob("grit.rb").special_mime_type
|
||||
assert_equal "text/plain; charset=utf-8", blob("bar.xml").special_mime_type
|
||||
assert_equal "application/octet-stream", blob("dog.o").special_mime_type
|
||||
def test_content_type
|
||||
assert_equal "text/plain; charset=utf-8", blob("grit.rb").content_type
|
||||
assert_equal "text/plain; charset=utf-8", blob("bar.xml").content_type
|
||||
assert_equal "application/octet-stream", blob("dog.o").content_type
|
||||
assert_equal "text/plain; charset=utf-8", blob("script.sh").content_type
|
||||
end
|
||||
|
||||
def test_disposition
|
||||
@@ -93,6 +95,7 @@ class TestBlob < Test::Unit::TestCase
|
||||
def test_text
|
||||
assert blob("file.txt").text?
|
||||
assert blob("file.json").text?
|
||||
assert blob("script.sh").text?
|
||||
end
|
||||
|
||||
def test_image
|
||||
|
||||
@@ -5,22 +5,45 @@ require 'test/unit'
|
||||
class TestMime < Test::Unit::TestCase
|
||||
include Linguist
|
||||
|
||||
def test_lookup
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.lookup(nil)
|
||||
def test_mime
|
||||
assert_equal 'text/plain', Mime.mime_for(nil)
|
||||
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.lookup(".rb")
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.lookup(".js")
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.lookup(".py")
|
||||
assert_equal 'text/plain', Mime.mime_for(".rb")
|
||||
assert_equal 'text/plain', Mime.mime_for(".js")
|
||||
assert_equal 'text/plain', Mime.mime_for(".py")
|
||||
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.lookup(".kt")
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.lookup(".html")
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.lookup(".sh")
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.lookup(".latex")
|
||||
assert_equal 'text/plain', Mime.mime_for(".kt")
|
||||
assert_equal 'text/html', Mime.mime_for(".html")
|
||||
assert_equal 'application/sh', Mime.mime_for(".sh")
|
||||
assert_equal 'application/latex', Mime.mime_for(".latex")
|
||||
|
||||
assert_equal 'application/octet-stream', Mime.lookup(".dmg")
|
||||
assert_equal 'application/octet-stream', Mime.mime_for(".dmg")
|
||||
assert_equal 'application/octet-stream', Mime.mime_for(".exe")
|
||||
assert_equal 'application/octet-stream', Mime.mime_for(".dll")
|
||||
|
||||
assert_equal 'application/java-archive', Mime.lookup(".jar")
|
||||
assert_equal 'application/java-archive', Mime.lookup(".ear")
|
||||
assert_equal 'application/java-archive', Mime.lookup(".war")
|
||||
assert_equal 'application/java-archive', Mime.mime_for(".jar")
|
||||
assert_equal 'application/java-archive', Mime.mime_for(".ear")
|
||||
assert_equal 'application/java-archive', Mime.mime_for(".war")
|
||||
end
|
||||
|
||||
def test_content_type
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for(nil)
|
||||
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for(".rb")
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for(".js")
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for(".py")
|
||||
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for(".kt")
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for(".html")
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for(".sh")
|
||||
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for(".latex")
|
||||
|
||||
assert_equal 'application/octet-stream', Mime.content_type_for(".dmg")
|
||||
assert_equal 'application/octet-stream', Mime.content_type_for(".exe")
|
||||
assert_equal 'application/octet-stream', Mime.content_type_for(".dll")
|
||||
|
||||
assert_equal 'application/java-archive', Mime.content_type_for(".jar")
|
||||
assert_equal 'application/java-archive', Mime.content_type_for(".ear")
|
||||
assert_equal 'application/java-archive', Mime.content_type_for(".war")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,10 +61,16 @@ class TestPathname < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_mime_type
|
||||
assert_equal 'text/plain; charset=utf-8', Pathname.new("file.rb").mime_type
|
||||
assert_equal 'text/plain; charset=utf-8', Pathname.new("file.js").mime_type
|
||||
assert_equal 'text/plain; charset=utf-8', Pathname.new("itty.py").mime_type
|
||||
assert_equal 'text/plain; charset=utf-8', Pathname.new("defun.kt").mime_type
|
||||
assert_equal 'text/plain', Pathname.new("file.rb").mime_type
|
||||
assert_equal 'text/plain', Pathname.new("file.js").mime_type
|
||||
assert_equal 'text/plain', Pathname.new("itty.py").mime_type
|
||||
assert_equal 'text/plain', Pathname.new("defun.kt").mime_type
|
||||
end
|
||||
|
||||
def test_content_type
|
||||
assert_equal 'text/plain; charset=utf-8', Pathname.new("file.txt").content_type
|
||||
assert_equal 'text/plain; charset=utf-8', Pathname.new("file.rb").content_type
|
||||
assert_equal 'image/png', Pathname.new("octocat.png").content_type
|
||||
end
|
||||
|
||||
def test_media_type
|
||||
|
||||
Reference in New Issue
Block a user