test/filemagic_test.rb in ruby-filemagic-0.2.2 vs test/filemagic_test.rb in ruby-filemagic-0.3.0
- old
+ new
@@ -1,8 +1,9 @@
require 'test/unit'
-$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
+top_dir = File.join(File.dirname(__FILE__), '..')
+$:.unshift(File.join(top_dir, 'lib'), File.join(top_dir, 'ext'))
require 'filemagic'
class TestFileMagic < Test::Unit::TestCase
def test_file
@@ -24,11 +25,11 @@
fm.close
fm = FileMagic.new(FileMagic::MAGIC_SYMLINK | FileMagic::MAGIC_MIME)
res = fm.file(path_to('pylink'))
- assert_equal('text/plain', res)
+ assert_equal('text/plain; charset=us-ascii', res)
fm.close
fm = FileMagic.new(FileMagic::MAGIC_COMPRESS)
res = fm.file(path_to('pyfile-compressed.gz'))
@@ -68,21 +69,21 @@
assert block_fm.closed?
end
def test_setflags
fm = FileMagic.new(FileMagic::MAGIC_NONE)
- assert_equal(FileMagic::MAGIC_NONE, fm.flags)
+ assert_equal([], fm.flags)
fm.setflags(FileMagic::MAGIC_SYMLINK)
- assert_equal(FileMagic::MAGIC_SYMLINK, fm.flags)
+ assert_equal([:symlink], fm.flags)
fm.close
end
def test_abbr
fm = FileMagic.new(:mime, :continue)
- assert_equal(FileMagic::MAGIC_MIME | FileMagic::MAGIC_CONTINUE, fm.flags)
+ assert_equal([:mime_type, :continue, :mime_encoding] , fm.flags)
fm.setflags(:symlink)
- assert_equal(FileMagic::MAGIC_SYMLINK, fm.flags)
+ assert_equal([:symlink], fm.flags)
fm.close
end
# tests adapted from mahoro:
@@ -93,11 +94,11 @@
end
def test_mahoro_mime_file
fm = FileMagic.new
fm.flags = FileMagic::MAGIC_MIME
- assert_equal('text/x-c', fm.file(path_to('mahoro.c')))
+ assert_equal('text/x-c; charset=us-ascii', fm.file(path_to('mahoro.c')))
end
def test_mahoro_buffer
fm = FileMagic.new
fm.flags = FileMagic::MAGIC_NONE
@@ -105,10 +106,10 @@
end
def test_mahoro_mime_buffer
fm = FileMagic.new
fm.flags = FileMagic::MAGIC_MIME
- assert_equal('text/x-c', fm.buffer(File.read(path_to('mahoro.c'))))
+ assert_equal('text/x-c; charset=us-ascii', fm.buffer(File.read(path_to('mahoro.c'))))
end
def test_mahoro_valid
fm = FileMagic.new
assert(fm.valid?, 'Default database was not valid.')