mime-types 1.25.1 → 2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.autotest +5 -0
- data/.minitest.rb +2 -0
- data/.travis.yml +0 -4
- data/Contributing.rdoc +13 -14
- data/Gemfile +1 -0
- data/History.rdoc +100 -7
- data/Licence.rdoc +1 -1
- data/Manifest.txt +17 -24
- data/README.rdoc +26 -47
- data/Rakefile +42 -185
- data/data/mime-types.json +1 -0
- data/docs/COPYING.txt +339 -339
- data/docs/artistic.txt +127 -127
- data/lib/mime.rb +50 -0
- data/lib/mime/type.rb +634 -0
- data/lib/mime/types.rb +254 -912
- data/lib/mime/types/cache.rb +73 -0
- data/lib/mime/types/loader.rb +248 -0
- data/lib/mime/types/loader_path.rb +16 -0
- data/support/benchmarker.rb +55 -0
- data/support/convert.rb +130 -0
- data/support/iana_downloader.rb +201 -0
- data/test/fixture/json.json +1 -0
- data/test/fixture/old-data +9 -0
- data/test/fixture/yaml.yaml +75 -0
- data/test/minitest_helper.rb +22 -0
- data/test/test_mime_type.rb +337 -143
- data/test/test_mime_types.rb +75 -84
- data/test/test_mime_types_cache.rb +30 -29
- data/test/test_mime_types_class.rb +135 -0
- data/test/test_mime_types_lazy.rb +3 -2
- data/test/test_mime_types_loader.rb +42 -0
- metadata +61 -90
- metadata.gz.sig +0 -0
- data/lib/mime/types/application +0 -1010
- data/lib/mime/types/application.mac +0 -3
- data/lib/mime/types/application.nonstandard +0 -132
- data/lib/mime/types/application.obsolete +0 -41
- data/lib/mime/types/audio +0 -138
- data/lib/mime/types/audio.nonstandard +0 -11
- data/lib/mime/types/audio.obsolete +0 -1
- data/lib/mime/types/image +0 -46
- data/lib/mime/types/image.nonstandard +0 -20
- data/lib/mime/types/image.obsolete +0 -5
- data/lib/mime/types/message +0 -18
- data/lib/mime/types/message.obsolete +0 -2
- data/lib/mime/types/model +0 -15
- data/lib/mime/types/multipart +0 -14
- data/lib/mime/types/multipart.nonstandard +0 -1
- data/lib/mime/types/multipart.obsolete +0 -7
- data/lib/mime/types/other.nonstandard +0 -8
- data/lib/mime/types/text +0 -61
- data/lib/mime/types/text.nonstandard +0 -7
- data/lib/mime/types/text.obsolete +0 -8
- data/lib/mime/types/text.vms +0 -1
- data/lib/mime/types/video +0 -75
- data/lib/mime/types/video.nonstandard +0 -16
- data/lib/mime/types/video.obsolete +0 -3
data/test/test_mime_types.rb
CHANGED
@@ -1,122 +1,113 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
|
3
3
|
require 'mime/types'
|
4
|
+
require 'minitest_helper'
|
4
5
|
|
5
6
|
class TestMIMETypes < Minitest::Test
|
6
7
|
def setup
|
7
|
-
MIME::Types.
|
8
|
-
MIME::
|
8
|
+
@mime_types = MIME::Types.new
|
9
|
+
@mime_types.add(MIME::Type.new(['text/plain', %w(txt)]),
|
10
|
+
MIME::Type.new(['image/jpeg', %w(jpg jpeg)]),
|
11
|
+
MIME::Type.new('application/x-wordperfect6.1'),
|
12
|
+
MIME::Type.new('content-type' => 'application/x-www-form-urlencoded', 'registered' => true),
|
13
|
+
MIME::Type.new(['application/x-gzip', %w(gz)]),
|
14
|
+
MIME::Type.new(['application/gzip', %W(gz)]))
|
9
15
|
end
|
10
16
|
|
11
|
-
def
|
12
|
-
|
13
|
-
t.encoding = '8bit'
|
14
|
-
t.extensions = %w(asc txt c cc h hh cpp hpp dat hlp)
|
15
|
-
end
|
16
|
-
text_plain_vms = MIME::Type.new('text/plain') do |t|
|
17
|
-
t.encoding = '8bit'
|
18
|
-
t.extensions = %w(doc)
|
19
|
-
t.system = 'vms'
|
20
|
-
end
|
21
|
-
|
22
|
-
assert_equal(MIME::Types['text/plain'], [text_plain, text_plain_vms])
|
17
|
+
def test_enumerable
|
18
|
+
assert(@mime_types.any? {|type| type.content_type == 'text/plain'})
|
23
19
|
end
|
24
20
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
def test_index_with_mime_type
|
22
|
+
xtxp = MIME::Type.new('x-text/x-plain')
|
23
|
+
assert_includes(@mime_types[xtxp], 'text/plain')
|
24
|
+
assert_equal(1, @mime_types[xtxp].size)
|
25
|
+
end
|
30
26
|
|
31
|
-
|
27
|
+
def test_index_with_regex
|
28
|
+
assert_includes(@mime_types[/plain/], 'text/plain')
|
29
|
+
assert_equal(1, @mime_types[/plain/].size)
|
30
|
+
end
|
32
31
|
|
33
|
-
|
34
|
-
|
32
|
+
def test_index_with_string
|
33
|
+
assert_includes(@mime_types['text/plain'], 'text/plain')
|
34
|
+
assert_equal(1, @mime_types['text/plain'].size)
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
37
|
+
def test_index_with_complete_flag
|
38
|
+
assert_empty(@mime_types['text/vnd.fly', complete: true])
|
39
|
+
refute_empty(@mime_types['text/plain', complete: true])
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
43
|
-
|
42
|
+
def test_index_with_registered_flag
|
43
|
+
assert_empty(@mime_types['application/x-wordperfect6.1',
|
44
|
+
registered: true])
|
45
|
+
refute_empty(@mime_types['application/x-www-form-urlencoded',
|
46
|
+
registered: true])
|
47
|
+
refute_empty(@mime_types['application/gzip', registered: true])
|
48
|
+
refute_equal(@mime_types['application/gzip'].size,
|
49
|
+
@mime_types['application/gzip', registered: true])
|
44
50
|
end
|
45
51
|
|
46
|
-
def
|
52
|
+
def test_index_with_platform_flag
|
53
|
+
assert_deprecated("MIME::Types#[]", "using the :platform flag") do
|
54
|
+
assert_empty(MIME::Types['text/plain', platform: true])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
def test_add
|
47
58
|
eruby = MIME::Type.new("application/x-eruby") do |t|
|
48
59
|
t.extensions = "rhtml"
|
49
60
|
t.encoding = "8bit"
|
50
61
|
end
|
51
62
|
|
52
|
-
|
53
|
-
|
54
|
-
assert_equal(MIME::Types['application/x-eruby'], [eruby])
|
55
|
-
end
|
56
|
-
|
57
|
-
def _test_class_add_type_variant
|
58
|
-
raise NotImplementedError, 'Need to write test_class_add_type_variant'
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_class_type_for
|
62
|
-
assert_equal(MIME::Types.type_for('xml').sort, [ MIME::Types['text/xml'], MIME::Types['application/xml'] ].sort)
|
63
|
-
assert_equal(MIME::Types.type_for('gif'), MIME::Types['image/gif'])
|
64
|
-
MIME::Types['image/gif'][0].system = RUBY_PLATFORM
|
65
|
-
assert_equal(MIME::Types.type_for('gif', true), MIME::Types['image/gif'])
|
66
|
-
assert(MIME::Types.type_for('zzz').empty?)
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_class_of
|
70
|
-
assert_equal(MIME::Types.of('xml').sort, [ MIME::Types['text/xml'], MIME::Types['application/xml'] ].sort)
|
71
|
-
assert_equal(MIME::Types.of('gif'), MIME::Types['image/gif'])
|
72
|
-
MIME::Types['image/gif'][0].system = RUBY_PLATFORM
|
73
|
-
assert_equal(MIME::Types.of('gif', true), MIME::Types['image/gif'])
|
74
|
-
assert(MIME::Types.of('zzz').empty?)
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_class_enumerable
|
78
|
-
assert( MIME::Types.any? {|type| type.content_type == 'text/plain'} )
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_class_count
|
82
|
-
assert(MIME::Types.count > 42, "A lot of types are expected to be known.")
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_ebook_formats
|
86
|
-
assert_equal( MIME::Types['application/x-mobipocket-ebook'], MIME::Types.type_for("book.mobi"))
|
87
|
-
assert_equal( MIME::Types['application/epub+zip'], MIME::Types.type_for("book.epub"))
|
88
|
-
assert_equal( MIME::Types['application/x-ibooks+zip'], MIME::Types.type_for("book.ibooks") )
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_apple_formats
|
92
|
-
assert_equal( MIME::Types['application/x-apple-diskimage'], MIME::Types.type_for("disk.dmg") )
|
93
|
-
end
|
63
|
+
@mime_types.add(eruby)
|
94
64
|
|
95
|
-
|
96
|
-
raise NotImplementedError, 'Need to write test_add'
|
65
|
+
assert_equal(@mime_types['application/x-eruby'], [eruby])
|
97
66
|
end
|
98
67
|
|
99
|
-
def
|
100
|
-
|
68
|
+
def test_type_for
|
69
|
+
assert_equal(%w(application/gzip application/x-gzip),
|
70
|
+
@mime_types.type_for('gz'))
|
71
|
+
assert_equal(%w(image/jpeg), MIME::Types.of('foo.jpeg'))
|
72
|
+
assert_equal(%w(image/jpeg text/plain),
|
73
|
+
MIME::Types.type_for(%w(foo.txt foo.jpeg)))
|
74
|
+
assert_equal(@mime_types.of('gif', true), @mime_types['image/gif'])
|
75
|
+
assert_deprecated("MIME::Types#type_for", "using the platform parameter") do
|
76
|
+
assert_empty(MIME::Types.type_for('jpeg', true))
|
77
|
+
end
|
78
|
+
assert_empty(@mime_types.type_for('zzz'))
|
101
79
|
end
|
102
80
|
|
103
|
-
def
|
104
|
-
|
81
|
+
def test_count
|
82
|
+
assert_equal(6, @mime_types.count)
|
105
83
|
end
|
106
84
|
|
107
|
-
|
108
|
-
|
85
|
+
# This tests the instance implementation through the class implementation.
|
86
|
+
def test_add_type_variant
|
87
|
+
xtxp = MIME::Type.new('x-text/x-plain')
|
88
|
+
assert_deprecated("MIME::Types#add_type_variant", "and will be private") do
|
89
|
+
@mime_types.add_type_variant(xtxp)
|
90
|
+
end
|
91
|
+
assert_includes(@mime_types['text/plain'], xtxp)
|
109
92
|
end
|
110
93
|
|
111
|
-
def
|
112
|
-
|
94
|
+
def test_data_version
|
95
|
+
assert_equal(MIME::Type::VERSION, @mime_types.data_version)
|
113
96
|
end
|
114
97
|
|
115
|
-
|
116
|
-
|
98
|
+
# This tests the instance implementation through the class implementation.
|
99
|
+
def test_index_extensions
|
100
|
+
xtxp = MIME::Type.new(['x-text/x-plain', %w(tzt)])
|
101
|
+
assert_deprecated("MIME::Types#index_extensions", "and will be private") do
|
102
|
+
@mime_types.index_extensions(xtxp)
|
103
|
+
end
|
104
|
+
assert_includes(@mime_types.of('tzt'), xtxp)
|
117
105
|
end
|
118
106
|
|
119
|
-
def
|
120
|
-
|
107
|
+
def test_defined_types
|
108
|
+
assert_deprecated("MIME::Types#defined_types") do
|
109
|
+
assert_empty(MIME::Types.new.defined_types)
|
110
|
+
end
|
111
|
+
refute_empty(@mime_types.defined_types)
|
121
112
|
end
|
122
113
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
|
3
3
|
require 'mime/types'
|
4
|
+
require 'minitest_helper'
|
4
5
|
|
5
6
|
class TestMIMETypesCache < Minitest::Test
|
6
7
|
def setup
|
@@ -17,61 +18,61 @@ class TestMIMETypesCache < Minitest::Test
|
|
17
18
|
|
18
19
|
def reset_mime_types
|
19
20
|
MIME::Types.instance_variable_set(:@__types__, nil)
|
20
|
-
MIME::Types.send(:
|
21
|
+
MIME::Types.send(:load_default_mime_types)
|
21
22
|
end
|
22
23
|
|
23
24
|
def clear_cache_file
|
24
25
|
FileUtils.rm @cache_file if File.exist? @cache_file
|
25
26
|
end
|
26
27
|
|
27
|
-
def test_uses_correct_cache_file
|
28
|
-
assert_equal(@cache_file, MIME::Types.cache_file)
|
29
|
-
end
|
30
|
-
|
31
28
|
def test_does_not_use_cache_when_unset
|
32
29
|
ENV.delete('RUBY_MIME_TYPES_CACHE')
|
33
|
-
assert_equal(nil, MIME::Types.
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_raises_exception_when_load_forced_without_cache_file
|
37
|
-
assert_raises(ArgumentError) {
|
38
|
-
ENV.delete('RUBY_MIME_TYPES_CACHE')
|
39
|
-
MIME::Types.send(:load_mime_types_from_cache!)
|
40
|
-
}
|
30
|
+
assert_equal(nil, MIME::Types::Cache.load)
|
41
31
|
end
|
42
32
|
|
43
33
|
def test_does_not_use_cache_when_missing
|
44
|
-
assert_equal(
|
34
|
+
assert_equal(nil, MIME::Types::Cache.load)
|
45
35
|
end
|
46
36
|
|
47
37
|
def test_does_not_create_cache_when_unset
|
48
38
|
ENV.delete('RUBY_MIME_TYPES_CACHE')
|
49
|
-
assert_equal(nil, MIME::Types.
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_raises_exception_when_write_forced_without_cache_file
|
53
|
-
assert_raises(ArgumentError) {
|
54
|
-
ENV.delete('RUBY_MIME_TYPES_CACHE')
|
55
|
-
MIME::Types.send(:write_mime_types_to_cache!)
|
56
|
-
}
|
39
|
+
assert_equal(nil, MIME::Types::Cache.save)
|
57
40
|
end
|
58
41
|
|
59
42
|
def test_creates_cache
|
60
43
|
assert_equal(false, File.exist?(@cache_file))
|
61
|
-
MIME::Types.
|
44
|
+
MIME::Types::Cache.save
|
62
45
|
assert_equal(true, File.exist?(@cache_file))
|
63
46
|
end
|
64
47
|
|
65
48
|
def test_uses_cache
|
66
|
-
|
67
|
-
|
68
|
-
MIME::Types.send(:write_mime_types_to_cache)
|
49
|
+
MIME::Types['text/html'].first.extensions << 'hex'
|
50
|
+
MIME::Types::Cache.save
|
69
51
|
MIME::Types.instance_variable_set(:@__types__, nil)
|
70
52
|
|
71
|
-
|
72
|
-
html = MIME::Types['text/html'].first
|
73
|
-
assert_includes(html.extensions, 'hex')
|
53
|
+
assert_includes(MIME::Types['text/html'].first.extensions, 'hex')
|
74
54
|
|
75
55
|
reset_mime_types
|
76
56
|
end
|
57
|
+
|
58
|
+
def test_load_different_version
|
59
|
+
v = MIME::Types::VERSION.dup
|
60
|
+
MIME::Types::VERSION.gsub!(/.*/, '0.0')
|
61
|
+
MIME::Types::Cache.save
|
62
|
+
MIME::Types::VERSION.gsub!(/.*/, v)
|
63
|
+
MIME::Types.instance_variable_set(:@__types__, nil)
|
64
|
+
assert_output(nil, /MIME::Types cache: invalid version/) do
|
65
|
+
MIME::Types['text/html']
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_cache_load_failure
|
70
|
+
MIME::Types::Cache.save
|
71
|
+
data = File.binread(@cache_file).reverse
|
72
|
+
File.open(@cache_file, 'wb') { |f| f.write(data) }
|
73
|
+
MIME::Types.instance_variable_set(:@__types__, nil)
|
74
|
+
assert_output(nil, /Could not load MIME::Types cache: incompatible marshal file format/) do
|
75
|
+
MIME::Types['text/html']
|
76
|
+
end
|
77
|
+
end
|
77
78
|
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'mime/types'
|
4
|
+
require 'minitest_helper'
|
5
|
+
|
6
|
+
class TestMIMETypesQueryClassMethods < Minitest::Test
|
7
|
+
def setup
|
8
|
+
MIME::Types.send(:load_default_mime_types)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_enumerable
|
12
|
+
assert(MIME::Types.any? {|type| type.content_type == 'text/plain'})
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_load_from_file
|
16
|
+
fn = File.expand_path('../fixture/old-data', __FILE__)
|
17
|
+
assert_deprecated("MIME::Types.load_from_file") do
|
18
|
+
MIME::Types.load_from_file(fn)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_index_with_mime_type
|
23
|
+
xtxp = MIME::Type.new('x-text/x-plain')
|
24
|
+
assert_includes(MIME::Types[xtxp], 'text/plain')
|
25
|
+
assert_equal(2, MIME::Types[xtxp].size)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_index_with_regex
|
29
|
+
assert_includes(MIME::Types[/plain/], 'text/plain')
|
30
|
+
assert_equal(2, MIME::Types[/plain/].size)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_index_with_string
|
34
|
+
assert_includes(MIME::Types['text/plain'], 'text/plain')
|
35
|
+
assert_equal(2, MIME::Types['text/plain'].size)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_index_with_complete_flag
|
39
|
+
assert_empty(MIME::Types['text/vnd.fly', complete: true])
|
40
|
+
refute_empty(MIME::Types['text/plain', complete: true])
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_index_with_registered_flag
|
44
|
+
assert_empty(MIME::Types['application/x-wordperfect6.1',
|
45
|
+
registered: true])
|
46
|
+
refute_empty(MIME::Types['application/x-www-form-urlencoded',
|
47
|
+
registered: true])
|
48
|
+
refute_empty(MIME::Types['application/gzip', registered: true])
|
49
|
+
refute_equal(MIME::Types['application/gzip'].size,
|
50
|
+
MIME::Types['application/gzip', registered: true])
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_index_with_platform_flag
|
54
|
+
assert_deprecated("MIME::Types#[]", "using the :platform flag") do
|
55
|
+
assert_empty(MIME::Types['text/plain', platform: true])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_type_for
|
60
|
+
assert_equal(%w(application/xml text/xml), MIME::Types.type_for('xml'))
|
61
|
+
assert_equal(%w(image/gif), MIME::Types.of('foo.gif'))
|
62
|
+
assert_equal(%w(application/xml image/gif text/xml),
|
63
|
+
MIME::Types.type_for(%w(xml gif)))
|
64
|
+
assert_deprecated("MIME::Types#type_for", "using the platform parameter") do
|
65
|
+
assert_empty(MIME::Types.type_for('gif', true))
|
66
|
+
end
|
67
|
+
assert_empty(MIME::Types.type_for('zzz'))
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_count
|
71
|
+
assert(MIME::Types.count.nonzero?,
|
72
|
+
"A lot of types are expected to be known.")
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_cache_file
|
76
|
+
ENV['RUBY_MIME_TYPES_CACHE'] = 'foo'
|
77
|
+
assert_deprecated("MIME::Types.cache_file") do
|
78
|
+
assert_equal('foo', MIME::Types.cache_file)
|
79
|
+
end
|
80
|
+
ENV.delete('RUBY_MIME_TYPES_CACHE')
|
81
|
+
assert_nil(MIME::Types.cache_file)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class TestMIMETypesClassMethods < Minitest::Test
|
86
|
+
def setup
|
87
|
+
MIME::Types.instance_variable_set(:@__types__, nil)
|
88
|
+
MIME::Types.send(:load_default_mime_types)
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_add_with_type
|
92
|
+
MIME::Types.add(MIME::Type.new("application/x-eruby"))
|
93
|
+
refute_empty(MIME::Types['application/x-eruby'])
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_add_with_types
|
97
|
+
mt = MIME::Types.new
|
98
|
+
mt.add MIME::Type.new("application/x-eruby")
|
99
|
+
MIME::Types.add(mt)
|
100
|
+
refute_empty(MIME::Types['application/x-eruby'])
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_add_with_array
|
104
|
+
MIME::Types.add([MIME::Type.new("application/x-eruby")])
|
105
|
+
refute_empty(MIME::Types['application/x-eruby'])
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_add_with_noise_suppression
|
109
|
+
assert_silent do
|
110
|
+
MIME::Types.add(MIME::Type.new("application/x-eruby"))
|
111
|
+
end
|
112
|
+
assert_output(nil, %r{application/x-eruby is already registered}) do
|
113
|
+
MIME::Types.add(MIME::Type.new("application/x-eruby"))
|
114
|
+
end
|
115
|
+
assert_silent do
|
116
|
+
MIME::Types.add(MIME::Type.new("application/x-eruby"), :silent)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_add_type_variant
|
121
|
+
xtxp = MIME::Type.new('x-text/x-plain')
|
122
|
+
assert_deprecated("MIME::Types#add_type_variant", "and will be private") do
|
123
|
+
MIME::Types.add_type_variant(xtxp)
|
124
|
+
end
|
125
|
+
assert_includes(MIME::Types['text/plain'], xtxp)
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_index_extensions
|
129
|
+
xtxp = MIME::Type.new(['x-text/x-plain', %w(tzt)])
|
130
|
+
assert_deprecated("MIME::Types#index_extensions", "and will be private") do
|
131
|
+
MIME::Types.index_extensions(xtxp)
|
132
|
+
end
|
133
|
+
assert_includes(MIME::Types.of('tzt'), xtxp)
|
134
|
+
end
|
135
|
+
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
|
3
3
|
require 'mime/types'
|
4
|
+
require 'minitest_helper'
|
4
5
|
|
5
6
|
class TestMIMETypesLazy < Minitest::Test
|
6
7
|
def setup
|
7
8
|
ENV['RUBY_MIME_TYPES_LAZY_LOAD'] = 'true'
|
8
9
|
ENV['RUBY_MIME_TYPES_CACHE'] = File.expand_path('../cache.tst', __FILE__)
|
9
|
-
MIME::Types.
|
10
|
+
MIME::Types::Cache.save
|
10
11
|
end
|
11
12
|
|
12
13
|
def teardown
|
@@ -20,7 +21,7 @@ class TestMIMETypesLazy < Minitest::Test
|
|
20
21
|
|
21
22
|
def reset_mime_types
|
22
23
|
MIME::Types.instance_variable_set(:@__types__, nil)
|
23
|
-
MIME::Types.send(:
|
24
|
+
MIME::Types.send(:load_default_mime_types)
|
24
25
|
end
|
25
26
|
|
26
27
|
def test_lazy_load?
|