Commit d0a68fd9 by Daniel Mendler

test to spec

parent 02b22e2e
gem 'test-unit', '>= 0'
gem 'test-spec', '>= 0'
require 'test/unit'
require 'test/spec'
require 'mimemagic' require 'mimemagic'
class TC_MimeMagic < Test::Unit::TestCase describe 'MimeMagic' do
def test_text? it 'should have text? helper' do
assert MimeMagic.new('text/plain').text? MimeMagic.new('text/plain').should.be.text
assert MimeMagic.new('text/html').text? MimeMagic.new('text/html').should.be.text
assert !MimeMagic.new('application/octet-stream').text? MimeMagic.new('application/octet-stream').should.be.not.text
assert !MimeMagic.new('image/png').text? MimeMagic.new('image/png').should.be.not.text
end end
it 'should have hierarchy' do
def test_child_of? MimeMagic.new('text/html').should.be.child_of 'text/plain'
assert MimeMagic.new('text/html').child_of?('text/plain') MimeMagic.new('text/x-java').should.be.child_of 'text/plain'
assert MimeMagic.new('text/x-java').child_of?('text/plain')
end end
def test_extensions it 'should have extensions' do
assert_equal %w(htm html), MimeMagic.new('text/html').extensions MimeMagic.new('text/html').extensions.should == %w(htm html)
end end
def test_by_extension it 'should recognize extensions' do
assert_equal 'text/html', MimeMagic.by_extension('html').to_s MimeMagic.by_extension('html').to_s.should == 'text/html'
assert_equal 'application/x-ruby', MimeMagic.by_extension('rb').to_s MimeMagic.by_extension('rb').to_s.should == 'application/x-ruby'
assert_nil MimeMagic.by_extension('crazy') MimeMagic.by_extension('crazy').should == nil
assert_nil MimeMagic.by_extension('') MimeMagic.by_extension('').should == nil
end end
def test_by_magic it 'should recognize by magic' do
assert_equal 'application/x-executable', MimeMagic.by_magic(File.open('/bin/ls')).to_s MimeMagic.by_magic(File.open('/bin/ls')).to_s.should == 'application/x-executable'
assert_equal 'application/x-sharedlib', MimeMagic.by_magic(File.open('/lib/libc.so.6')).to_s MimeMagic.by_magic(File.open('/lib/libc.so.6')).to_s.should == 'application/x-sharedlib'
end end
end end
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