test/filemagic_test.rb in ruby-filemagic-0.6.0 vs test/filemagic_test.rb in ruby-filemagic-0.6.1
- old
+ new
@@ -158,20 +158,43 @@
# test abbreviating mime types
def test_abbrev_mime_type
fm = FileMagic.mime
- assert !fm.simplified?
+ refute fm.simplified?
assert_equal('text/plain; charset=us-ascii', fm.file(path_to('perl')))
fm.simplified = true
assert fm.simplified?
assert_equal('text/plain', fm.file(path_to('perl')))
assert_equal(match_version(
0 => 'application/vnd.ms-office',
5.11 => 'application/msword',
5.14 => 'application/vnd.ms-office'
), fm.file(path_to('excel-example.xls')))
+ end
+
+ def test_singleton
+ fm1 = FileMagic.fm
+ assert_equal(fm1, FileMagic.fm)
+
+ refute fm1.simplified?
+ assert_equal('ASCII text', fm1.file(path_to('perl')))
+
+ fm2 = FileMagic.fm(:mime)
+ assert_equal(fm2, FileMagic.fm(:mime))
+ refute_equal(fm2, fm1)
+
+ refute fm2.simplified?
+ assert_equal('text/plain; charset=us-ascii', fm2.file(path_to('perl')))
+
+ fm3 = FileMagic.fm(:mime, simplified: true)
+ assert_equal(fm3, FileMagic.fm(:mime, simplified: true))
+ refute_equal(fm3, fm2)
+ refute_equal(fm3, fm1)
+
+ assert fm3.simplified?
+ assert_equal('text/plain', fm3.file(path_to('perl')))
end
# utility methods:
def path_to(file, dir = File.dirname(__FILE__))