Commit 13b726aa by minad

code cleanup, test added

parent 19268104
...@@ -10,8 +10,7 @@ class MimeMagic ...@@ -10,8 +10,7 @@ class MimeMagic
# Mime type by type string # Mime type by type string
def initialize(type) def initialize(type)
@type = type @type = type
@mediatype = @type.split('/')[0] @mediatype, @subtype = type.split('/', 2)
@subtype = @type.split('/')[1]
end end
# Add custom mime type. Arguments: # Add custom mime type. Arguments:
......
...@@ -2,6 +2,12 @@ require 'bacon' ...@@ -2,6 +2,12 @@ require 'bacon'
require 'mimemagic' require 'mimemagic'
describe 'MimeMagic' do 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 it 'should have mediatype helpers' do
MimeMagic.new('text/plain').should.be.text MimeMagic.new('text/plain').should.be.text
MimeMagic.new('text/html').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