Commit 13b726aa by minad

code cleanup, test added

parent 19268104
......@@ -10,8 +10,7 @@ class MimeMagic
# Mime type by type string
def initialize(type)
@type = type
@mediatype = @type.split('/')[0]
@subtype = @type.split('/')[1]
@mediatype, @subtype = type.split('/', 2)
end
# Add custom mime type. Arguments:
......
......@@ -2,6 +2,12 @@ require 'bacon'
require 'mimemagic'
describe 'MimeMagic' do
it 'should have type, mediatype and subtype' do
MimeMagic.new('text/html').type.should.equal 'text/html'
MimeMagic.new('text/html').mediatype.should.equal 'text'
MimeMagic.new('text/html').subtype.should.equal 'html'
end
it 'should have mediatype helpers' do
MimeMagic.new('text/plain').should.be.text
MimeMagic.new('text/html').should.be.text
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment