mime-types 3.2.1 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,170 +1,168 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # -*- ruby encoding: utf-8 -*-
4
-
5
- require 'mime/types'
6
- require 'minitest_helper'
3
+ require "mime/types"
4
+ require "minitest_helper"
7
5
 
8
6
  describe MIME::Types do
9
7
  def mime_types
10
- @mime_types ||= MIME::Types.new.tap do |mt|
11
- mt.add MIME::Type.new(['text/plain', %w(txt)]),
12
- MIME::Type.new(['image/jpeg', %w(jpg jpeg)]),
13
- MIME::Type.new('application/x-wordperfect6.1'),
8
+ @mime_types ||= MIME::Types.new.tap { |mt|
9
+ mt.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"),
14
12
  MIME::Type.new(
15
- 'content-type' => 'application/x-www-form-urlencoded',
16
- 'registered' => true
13
+ "content-type" => "application/x-www-form-urlencoded",
14
+ "registered" => true
17
15
  ),
18
- MIME::Type.new(['application/x-gzip', %w(gz)]),
16
+ MIME::Type.new(["application/x-gzip", %w[gz]]),
19
17
  MIME::Type.new(
20
- 'content-type' => 'application/gzip',
21
- 'extensions' => 'gz',
22
- 'registered' => true
18
+ "content-type" => "application/gzip",
19
+ "extensions" => "gz",
20
+ "registered" => true
23
21
  )
24
- end
22
+ }
25
23
  end
26
24
 
27
- describe 'is enumerable' do
28
- it 'correctly uses an Enumerable method like #any?' do
29
- assert mime_types.any? { |type| type.content_type == 'text/plain' }
25
+ describe "is enumerable" do
26
+ it "correctly uses an Enumerable method like #any?" do
27
+ assert(mime_types.any? { |type| type.content_type == "text/plain" })
30
28
  end
31
29
 
32
- it 'implements each with no parameters to return an Enumerator' do
30
+ it "implements each with no parameters to return an Enumerator" do
33
31
  assert_kind_of Enumerator, mime_types.each
34
32
  assert_kind_of Enumerator, mime_types.map
35
33
  end
36
34
 
37
- it 'will create a lazy enumerator' do
35
+ it "will create a lazy enumerator" do
38
36
  assert_kind_of Enumerator::Lazy, mime_types.lazy
39
37
  assert_kind_of Enumerator::Lazy, mime_types.map.lazy
40
38
  end
41
39
 
42
- it 'is countable with an enumerator' do
40
+ it "is countable with an enumerator" do
43
41
  assert_equal 6, mime_types.each.count
44
42
  assert_equal 6, mime_types.lazy.count
45
43
  end
46
44
  end
47
45
 
48
- describe '#[]' do
49
- it 'can be searched with a MIME::Type' do
50
- text_plain = MIME::Type.new('text/plain')
51
- assert_includes mime_types[text_plain], 'text/plain'
46
+ describe "#[]" do
47
+ it "can be searched with a MIME::Type" do
48
+ text_plain = MIME::Type.new("text/plain")
49
+ assert_includes mime_types[text_plain], "text/plain"
52
50
  assert_equal 1, mime_types[text_plain].size
53
51
  end
54
52
 
55
- it 'can be searched with a regular expression' do
56
- assert_includes mime_types[/plain$/], 'text/plain'
53
+ it "can be searched with a regular expression" do
54
+ assert_includes mime_types[/plain$/], "text/plain"
57
55
  assert_equal 1, mime_types[/plain$/].size
58
56
  end
59
57
 
60
- it 'sorts by priority with multiple matches' do
61
- assert_equal %w(application/gzip application/x-gzip), mime_types[/gzip$/]
58
+ it "sorts by priority with multiple matches" do
59
+ assert_equal %w[application/gzip application/x-gzip], mime_types[/gzip$/]
62
60
  assert_equal 2, mime_types[/gzip$/].size
63
61
  end
64
62
 
65
- it 'can be searched with a string' do
66
- assert_includes mime_types['text/plain'], 'text/plain'
67
- assert_equal 1, mime_types['text/plain'].size
63
+ it "can be searched with a string" do
64
+ assert_includes mime_types["text/plain"], "text/plain"
65
+ assert_equal 1, mime_types["text/plain"].size
68
66
  end
69
67
 
70
- it 'can be searched with the complete flag' do
68
+ it "can be searched with the complete flag" do
71
69
  assert_empty mime_types[
72
- 'application/x-www-form-urlencoded',
70
+ "application/x-www-form-urlencoded",
73
71
  complete: true
74
72
  ]
75
- assert_includes mime_types['text/plain', complete: true], 'text/plain'
76
- assert_equal 1, mime_types['text/plain', complete: true].size
73
+ assert_includes mime_types["text/plain", complete: true], "text/plain"
74
+ assert_equal 1, mime_types["text/plain", complete: true].size
77
75
  end
78
76
 
79
- it 'can be searched with the registered flag' do
80
- assert_empty mime_types['application/x-wordperfect6.1', registered: true]
77
+ it "can be searched with the registered flag" do
78
+ assert_empty mime_types["application/x-wordperfect6.1", registered: true]
81
79
  refute_empty mime_types[
82
- 'application/x-www-form-urlencoded',
80
+ "application/x-www-form-urlencoded",
83
81
  registered: true
84
82
  ]
85
83
  refute_empty mime_types[/gzip/, registered: true]
86
84
  refute_equal mime_types[/gzip/], mime_types[/gzip/, registered: true]
87
85
  end
88
86
 
89
- it 'properly returns an empty result on a regular expression miss' do
87
+ it "properly returns an empty result on a regular expression miss" do
90
88
  assert_empty mime_types[/^foo/]
91
89
  assert_empty mime_types[/^foo/, registered: true]
92
90
  assert_empty mime_types[/^foo/, complete: true]
93
91
  end
94
92
  end
95
93
 
96
- describe '#add' do
97
- let(:eruby) { MIME::Type.new('application/x-eruby') }
98
- let(:jinja) { MIME::Type.new('application/jinja2' )}
94
+ describe "#add" do
95
+ let(:eruby) { MIME::Type.new("application/x-eruby") }
96
+ let(:jinja) { MIME::Type.new("application/jinja2") }
99
97
 
100
- it 'successfully adds a new type' do
98
+ it "successfully adds a new type" do
101
99
  mime_types.add(eruby)
102
- assert_equal mime_types['application/x-eruby'], [ eruby ]
100
+ assert_equal mime_types["application/x-eruby"], [eruby]
103
101
  end
104
102
 
105
- it 'complains about adding a duplicate type' do
103
+ it "complains about adding a duplicate type" do
106
104
  mime_types.add(eruby)
107
- assert_output '', /is already registered as a variant/ do
105
+ assert_output "", /is already registered as a variant/ do
108
106
  mime_types.add(eruby)
109
107
  end
110
- assert_equal mime_types['application/x-eruby'], [eruby]
108
+ assert_equal mime_types["application/x-eruby"], [eruby]
111
109
  end
112
110
 
113
- it 'does not complain about adding a duplicate type when quiet' do
111
+ it "does not complain about adding a duplicate type when quiet" do
114
112
  mime_types.add(eruby)
115
- assert_output '', '' do
113
+ assert_output "", "" do
116
114
  mime_types.add(eruby, :silent)
117
115
  end
118
- assert_equal mime_types['application/x-eruby'], [ eruby ]
116
+ assert_equal mime_types["application/x-eruby"], [eruby]
119
117
  end
120
118
 
121
- it 'successfully adds from an array' do
122
- mime_types.add([ eruby, jinja ])
123
- assert_equal mime_types['application/x-eruby'], [ eruby ]
124
- assert_equal mime_types['application/jinja2'], [ jinja ]
119
+ it "successfully adds from an array" do
120
+ mime_types.add([eruby, jinja])
121
+ assert_equal mime_types["application/x-eruby"], [eruby]
122
+ assert_equal mime_types["application/jinja2"], [jinja]
125
123
  end
126
124
 
127
- it 'successfully adds from another MIME::Types' do
125
+ it "successfully adds from another MIME::Types" do
128
126
  mt = MIME::Types.new
129
127
  mt.add(mime_types)
130
128
  assert_equal mime_types.count, mt.count
131
129
 
132
130
  mime_types.each do |type|
133
- assert_equal mt[type.content_type], [ type ]
131
+ assert_equal mt[type.content_type], [type]
134
132
  end
135
133
  end
136
134
  end
137
135
 
138
- describe '#type_for' do
139
- it 'finds all types for a given extension' do
140
- assert_equal %w(application/gzip application/x-gzip),
141
- mime_types.type_for('gz')
136
+ describe "#type_for" do
137
+ it "finds all types for a given extension" do
138
+ assert_equal %w[application/gzip application/x-gzip],
139
+ mime_types.type_for("gz")
142
140
  end
143
141
 
144
- it 'separates the extension from filenames' do
145
- assert_equal %w(image/jpeg), mime_types.of(['foo.jpeg', 'bar.jpeg'])
142
+ it "separates the extension from filenames" do
143
+ assert_equal %w[image/jpeg], mime_types.of(["foo.jpeg", "bar.jpeg"])
146
144
  end
147
145
 
148
- it 'finds multiple extensions' do
149
- assert_equal %w(image/jpeg text/plain),
150
- mime_types.type_for(%w(foo.txt foo.jpeg))
146
+ it "finds multiple extensions" do
147
+ assert_equal %w[image/jpeg text/plain],
148
+ mime_types.type_for(%w[foo.txt foo.jpeg])
151
149
  end
152
150
 
153
- it 'does not find unknown extensions' do
151
+ it "does not find unknown extensions" do
154
152
  keys = mime_types.instance_variable_get(:@extension_index).keys
155
- assert_empty mime_types.type_for('zzz')
153
+ assert_empty mime_types.type_for("zzz")
156
154
  assert_equal keys, mime_types.instance_variable_get(:@extension_index).keys
157
155
  end
158
156
 
159
- it 'modifying type extensions causes reindexing' do
160
- plain_text = mime_types['text/plain'].first
161
- plain_text.add_extensions('xtxt')
162
- assert_includes mime_types.type_for('xtxt'), 'text/plain'
157
+ it "modifying type extensions causes reindexing" do
158
+ plain_text = mime_types["text/plain"].first
159
+ plain_text.add_extensions("xtxt")
160
+ assert_includes mime_types.type_for("xtxt"), "text/plain"
163
161
  end
164
162
  end
165
163
 
166
- describe '#count' do
167
- it 'can count the number of types inside' do
164
+ describe "#count" do
165
+ it "can count the number of types inside" do
168
166
  assert_equal 6, mime_types.count
169
167
  end
170
168
  end
@@ -1,27 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # -*- ruby encoding: utf-8 -*-
3
+ require "mime/types"
4
+ require "minitest_helper"
4
5
 
5
- require 'mime/types'
6
- require 'minitest_helper'
6
+ MUTEX = Mutex.new
7
7
 
8
8
  describe MIME::Types::Cache do
9
9
  include Minitest::Hooks
10
10
 
11
- MUTEX = Mutex.new
12
-
13
11
  def around
14
- require 'fileutils'
12
+ require "fileutils"
15
13
 
16
14
  MUTEX.synchronize do
17
- @cache_file = File.expand_path('../cache.tst', __FILE__)
18
- ENV['RUBY_MIME_TYPES_CACHE'] = @cache_file
15
+ @cache_file = File.expand_path("../cache.tst", __FILE__)
16
+ ENV["RUBY_MIME_TYPES_CACHE"] = @cache_file
19
17
  clear_cache_file
20
18
 
21
19
  super
22
20
 
23
21
  clear_cache_file
24
- ENV.delete('RUBY_MIME_TYPES_CACHE')
22
+ ENV.delete("RUBY_MIME_TYPES_CACHE")
25
23
  end
26
24
  end
27
25
 
@@ -34,67 +32,67 @@ describe MIME::Types::Cache do
34
32
  FileUtils.rm @cache_file if File.exist? @cache_file
35
33
  end
36
34
 
37
- describe '.load' do
38
- it 'does not use cache when RUBY_MIME_TYPES_CACHE is unset' do
39
- ENV.delete('RUBY_MIME_TYPES_CACHE')
35
+ describe ".load" do
36
+ it "does not use cache when RUBY_MIME_TYPES_CACHE is unset" do
37
+ ENV.delete("RUBY_MIME_TYPES_CACHE")
40
38
  assert_nil MIME::Types::Cache.load
41
39
  end
42
40
 
43
- it 'does not use cache when missing' do
41
+ it "does not use cache when missing" do
44
42
  assert_nil MIME::Types::Cache.load
45
43
  end
46
44
 
47
- it 'registers the data to be updated by #add_extensions' do
45
+ it "registers the data to be updated by #add_extensions" do
48
46
  MIME::Types::Cache.save
49
47
  reset_mime_types
50
- assert_equal([], MIME::Types.type_for('foo.additional'))
51
- html = MIME::Types['text/html'][0]
52
- html.add_extensions('additional')
53
- assert_equal([html], MIME::Types.type_for('foo.additional'))
48
+ assert_equal([], MIME::Types.type_for("foo.additional"))
49
+ html = MIME::Types["text/html"][0]
50
+ html.add_extensions("additional")
51
+ assert_equal([html], MIME::Types.type_for("foo.additional"))
54
52
  end
55
53
 
56
- it 'outputs an error when there is an invalid version' do
54
+ it "outputs an error when there is an invalid version" do
57
55
  v = MIME::Types::Data::VERSION
58
56
  MIME::Types::Data.send(:remove_const, :VERSION)
59
- MIME::Types::Data.const_set(:VERSION, '0.0')
57
+ MIME::Types::Data.const_set(:VERSION, "0.0")
60
58
  MIME::Types::Cache.save
61
59
  MIME::Types::Data.send(:remove_const, :VERSION)
62
60
  MIME::Types::Data.const_set(:VERSION, v)
63
61
  MIME::Types.instance_variable_set(:@__types__, nil)
64
- assert_output '', /MIME::Types cache: invalid version/ do
65
- MIME::Types['text/html']
62
+ assert_output "", /MIME::Types cache: invalid version/ do
63
+ MIME::Types["text/html"]
66
64
  end
67
65
  end
68
66
 
69
- it 'outputs an error when there is a marshal file incompatibility' do
67
+ it "outputs an error when there is a marshal file incompatibility" do
70
68
  MIME::Types::Cache.save
71
69
  data = File.binread(@cache_file).reverse
72
- File.open(@cache_file, 'wb') { |f| f.write(data) }
70
+ File.open(@cache_file, "wb") { |f| f.write(data) }
73
71
  MIME::Types.instance_variable_set(:@__types__, nil)
74
- assert_output '', /incompatible marshal file format/ do
75
- MIME::Types['text/html']
72
+ assert_output "", /incompatible marshal file format/ do
73
+ MIME::Types["text/html"]
76
74
  end
77
75
  end
78
76
  end
79
77
 
80
- describe '.save' do
81
- it 'does not create cache when RUBY_MIME_TYPES_CACHE is unset' do
82
- ENV.delete('RUBY_MIME_TYPES_CACHE')
78
+ describe ".save" do
79
+ it "does not create cache when RUBY_MIME_TYPES_CACHE is unset" do
80
+ ENV.delete("RUBY_MIME_TYPES_CACHE")
83
81
  assert_nil MIME::Types::Cache.save
84
82
  end
85
83
 
86
- it 'creates the cache ' do
84
+ it "creates the cache " do
87
85
  assert_equal(false, File.exist?(@cache_file))
88
86
  MIME::Types::Cache.save
89
87
  assert_equal(true, File.exist?(@cache_file))
90
88
  end
91
89
 
92
- it 'uses the cache' do
93
- MIME::Types['text/html'].first.add_extensions('hex')
90
+ it "uses the cache" do
91
+ MIME::Types["text/html"].first.add_extensions("hex")
94
92
  MIME::Types::Cache.save
95
93
  MIME::Types.instance_variable_set(:@__types__, nil)
96
94
 
97
- assert_includes MIME::Types['text/html'].first.extensions, 'hex'
95
+ assert_includes MIME::Types["text/html"].first.extensions, "hex"
98
96
 
99
97
  reset_mime_types
100
98
  end
@@ -102,19 +100,19 @@ describe MIME::Types::Cache do
102
100
  end
103
101
 
104
102
  describe MIME::Types::Container do
105
- it 'marshals and unmarshals correctly' do
103
+ it "marshals and unmarshals correctly" do
106
104
  container = MIME::Types::Container.new
107
- container.add('xyz', 'abc')
105
+ container.add("xyz", "abc")
108
106
 
109
107
  # default proc should return Set[]
110
- assert_equal(Set[], container['abc'])
111
- assert_equal(Set['abc'], container['xyz'])
108
+ assert_equal(Set[], container["abc"])
109
+ assert_equal(Set["abc"], container["xyz"])
112
110
 
113
111
  marshalled = Marshal.dump(container)
114
112
  loaded_container = Marshal.load(marshalled)
115
113
 
116
114
  # default proc should still return Set[]
117
- assert_equal(Set[], loaded_container['abc'])
118
- assert_equal(Set['abc'], container['xyz'])
115
+ assert_equal(Set[], loaded_container["abc"])
116
+ assert_equal(Set["abc"], container["xyz"])
119
117
  end
120
118
  end
@@ -1,76 +1,74 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # -*- ruby encoding: utf-8 -*-
3
+ require "mime/types"
4
+ require "minitest_helper"
4
5
 
5
- require 'mime/types'
6
- require 'minitest_helper'
7
-
8
- describe MIME::Types, 'registry' do
6
+ describe MIME::Types, "registry" do
9
7
  def setup
10
8
  MIME::Types.send(:load_default_mime_types)
11
9
  end
12
10
 
13
- describe 'is enumerable' do
14
- it 'correctly uses an Enumerable method like #any?' do
15
- assert MIME::Types.any? { |type| type.content_type == 'text/plain' }
11
+ describe "is enumerable" do
12
+ it "correctly uses an Enumerable method like #any?" do
13
+ assert(MIME::Types.any? { |type| type.content_type == "text/plain" })
16
14
  end
17
15
 
18
- it 'implements each with no parameters to return an Enumerator' do
16
+ it "implements each with no parameters to return an Enumerator" do
19
17
  assert_kind_of Enumerator, MIME::Types.each
20
18
  assert_kind_of Enumerator, MIME::Types.map
21
19
  end
22
20
 
23
- it 'will create a lazy enumerator' do
21
+ it "will create a lazy enumerator" do
24
22
  assert_kind_of Enumerator::Lazy, MIME::Types.lazy
25
23
  assert_kind_of Enumerator::Lazy, MIME::Types.map.lazy
26
24
  end
27
25
 
28
- it 'is countable with an enumerator' do
26
+ it "is countable with an enumerator" do
29
27
  assert MIME::Types.each.count > 999
30
28
  assert MIME::Types.lazy.count > 999
31
29
  end
32
30
  end
33
31
 
34
- describe '.[]' do
35
- it 'can be searched with a MIME::Type' do
36
- text_plain = MIME::Type.new('text/plain')
37
- assert_includes MIME::Types[text_plain], 'text/plain'
32
+ describe ".[]" do
33
+ it "can be searched with a MIME::Type" do
34
+ text_plain = MIME::Type.new("text/plain")
35
+ assert_includes MIME::Types[text_plain], "text/plain"
38
36
  assert_equal 1, MIME::Types[text_plain].size
39
37
  end
40
38
 
41
- it 'can be searched with a regular expression' do
42
- assert_includes MIME::Types[/plain$/], 'text/plain'
39
+ it "can be searched with a regular expression" do
40
+ assert_includes MIME::Types[/plain$/], "text/plain"
43
41
  assert_equal 1, MIME::Types[/plain$/].size
44
42
  end
45
43
 
46
- it 'sorts by priority with multiple matches' do
44
+ it "sorts by priority with multiple matches" do
47
45
  types = MIME::Types[/gzip$/].select { |t|
48
- t == 'application/gzip' || t == 'application/x-gzip' || t == 'multipart/x-gzip'
46
+ %w[application/gzip application/x-gzip multipart/x-gzip].include?(t)
49
47
  }
50
48
  # This is this way because of a new type ending with gzip that only
51
49
  # appears in some data files.
52
- assert_equal %w(application/gzip application/x-gzip multipart/x-gzip), types
50
+ assert_equal %w[application/gzip application/x-gzip multipart/x-gzip], types
53
51
  assert_equal 3, types.size
54
52
  end
55
53
 
56
- it 'can be searched with a string' do
57
- assert_includes MIME::Types['text/plain'], 'text/plain'
58
- assert_equal 1, MIME::Types['text/plain'].size
54
+ it "can be searched with a string" do
55
+ assert_includes MIME::Types["text/plain"], "text/plain"
56
+ assert_equal 1, MIME::Types["text/plain"].size
59
57
  end
60
58
 
61
- it 'can be searched with the complete flag' do
59
+ it "can be searched with the complete flag" do
62
60
  assert_empty MIME::Types[
63
- 'application/x-www-form-urlencoded',
61
+ "application/x-www-form-urlencoded",
64
62
  complete: true
65
63
  ]
66
- assert_includes MIME::Types['text/plain', complete: true], 'text/plain'
67
- assert_equal 1, MIME::Types['text/plain', complete: true].size
64
+ assert_includes MIME::Types["text/plain", complete: true], "text/plain"
65
+ assert_equal 1, MIME::Types["text/plain", complete: true].size
68
66
  end
69
67
 
70
- it 'can be searched with the registered flag' do
71
- assert_empty MIME::Types['application/x-wordperfect6.1', registered: true]
68
+ it "can be searched with the registered flag" do
69
+ assert_empty MIME::Types["application/x-wordperfect6.1", registered: true]
72
70
  refute_empty MIME::Types[
73
- 'application/x-www-form-urlencoded',
71
+ "application/x-www-form-urlencoded",
74
72
  registered: true
75
73
  ]
76
74
  refute_empty MIME::Types[/gzip/, registered: true]
@@ -78,75 +76,75 @@ describe MIME::Types, 'registry' do
78
76
  end
79
77
  end
80
78
 
81
- describe '.type_for' do
82
- it 'finds all types for a given extension' do
83
- assert_equal %w(application/gzip application/x-gzip),
84
- MIME::Types.type_for('gz')
79
+ describe ".type_for" do
80
+ it "finds all types for a given extension" do
81
+ assert_equal %w[application/gzip application/x-gzip],
82
+ MIME::Types.type_for("gz")
85
83
  end
86
84
 
87
- it 'separates the extension from filenames' do
88
- assert_equal %w(image/jpeg), MIME::Types.of(['foo.jpeg', 'bar.jpeg'])
85
+ it "separates the extension from filenames" do
86
+ assert_equal %w[image/jpeg], MIME::Types.of(["foo.jpeg", "bar.jpeg"])
89
87
  end
90
88
 
91
- it 'finds multiple extensions' do
92
- assert_equal %w(image/jpeg text/plain),
93
- MIME::Types.type_for(%w(foo.txt foo.jpeg))
89
+ it "finds multiple extensions" do
90
+ assert_equal %w[image/jpeg text/plain],
91
+ MIME::Types.type_for(%w[foo.txt foo.jpeg])
94
92
  end
95
93
 
96
- it 'does not find unknown extensions' do
97
- assert_empty MIME::Types.type_for('zzz')
94
+ it "does not find unknown extensions" do
95
+ assert_empty MIME::Types.type_for("zzz")
98
96
  end
99
97
 
100
- it 'modifying type extensions causes reindexing' do
101
- plain_text = MIME::Types['text/plain'].first
102
- plain_text.add_extensions('xtxt')
103
- assert_includes MIME::Types.type_for('xtxt'), 'text/plain'
98
+ it "modifying type extensions causes reindexing" do
99
+ plain_text = MIME::Types["text/plain"].first
100
+ plain_text.add_extensions("xtxt")
101
+ assert_includes MIME::Types.type_for("xtxt"), "text/plain"
104
102
  end
105
103
  end
106
104
 
107
- describe '.count' do
108
- it 'can count the number of types inside' do
105
+ describe ".count" do
106
+ it "can count the number of types inside" do
109
107
  assert MIME::Types.count > 999
110
108
  end
111
109
  end
112
110
 
113
- describe '.add' do
111
+ describe ".add" do
114
112
  def setup
115
113
  MIME::Types.instance_variable_set(:@__types__, nil)
116
114
  MIME::Types.send(:load_default_mime_types)
117
115
  end
118
116
 
119
- let(:eruby) { MIME::Type.new('application/x-eruby') }
120
- let(:jinja) { MIME::Type.new('application/jinja2' )}
117
+ let(:eruby) { MIME::Type.new("application/x-eruby") }
118
+ let(:jinja) { MIME::Type.new("application/jinja2") }
121
119
 
122
- it 'successfully adds a new type' do
120
+ it "successfully adds a new type" do
123
121
  MIME::Types.add(eruby)
124
- assert_equal MIME::Types['application/x-eruby'], [ eruby ]
122
+ assert_equal MIME::Types["application/x-eruby"], [eruby]
125
123
  end
126
124
 
127
- it 'complains about adding a duplicate type' do
125
+ it "complains about adding a duplicate type" do
128
126
  MIME::Types.add(eruby)
129
- assert_output '', /is already registered as a variant/ do
127
+ assert_output "", /is already registered as a variant/ do
130
128
  MIME::Types.add(eruby)
131
129
  end
132
- assert_equal MIME::Types['application/x-eruby'], [eruby]
130
+ assert_equal MIME::Types["application/x-eruby"], [eruby]
133
131
  end
134
132
 
135
- it 'does not complain about adding a duplicate type when quiet' do
133
+ it "does not complain about adding a duplicate type when quiet" do
136
134
  MIME::Types.add(eruby)
137
135
  assert_silent do
138
136
  MIME::Types.add(eruby, :silent)
139
137
  end
140
- assert_equal MIME::Types['application/x-eruby'], [ eruby ]
138
+ assert_equal MIME::Types["application/x-eruby"], [eruby]
141
139
  end
142
140
 
143
- it 'successfully adds from an array' do
144
- MIME::Types.add([ eruby, jinja ])
145
- assert_equal MIME::Types['application/x-eruby'], [ eruby ]
146
- assert_equal MIME::Types['application/jinja2'], [ jinja ]
141
+ it "successfully adds from an array" do
142
+ MIME::Types.add([eruby, jinja])
143
+ assert_equal MIME::Types["application/x-eruby"], [eruby]
144
+ assert_equal MIME::Types["application/jinja2"], [jinja]
147
145
  end
148
146
 
149
- it 'successfully adds from another MIME::Types' do
147
+ it "successfully adds from another MIME::Types" do
150
148
  old_count = MIME::Types.count
151
149
 
152
150
  mt = MIME::Types.new
@@ -155,7 +153,7 @@ describe MIME::Types, 'registry' do
155
153
  MIME::Types.add(mt)
156
154
  assert_equal old_count + 1, MIME::Types.count
157
155
 
158
- assert_equal MIME::Types[eruby.content_type], [ eruby ]
156
+ assert_equal MIME::Types[eruby.content_type], [eruby]
159
157
  end
160
158
  end
161
159
  end