Skip to content

Commit

Permalink
code cleanup, test added
Browse files Browse the repository at this point in the history
  • Loading branch information
minad committed Jan 23, 2011
1 parent 1926810 commit 13b726a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/mimemagic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ class MimeMagic

# Mime type by type string
def initialize(type)
@type = type
@mediatype = @type.split('/')[0]
@subtype = @type.split('/')[1]
@type = type
@mediatype, @subtype = type.split('/', 2)
end

# Add custom mime type. Arguments:
Expand Down
6 changes: 6 additions & 0 deletions test/mimemagic_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
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
Expand Down

0 comments on commit 13b726a

Please sign in to comment.