Class: TestMIME::TestTypes

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/mime-types-1.16/test/test_mime_types.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#_test_addObject

Raises:

  • (NotImplementedError)


94
95
96
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 94

def _test_add
  raise NotImplementedError, 'Need to write test_add'
end

#_test_add_type_variantObject

Raises:

  • (NotImplementedError)


98
99
100
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 98

def _test_add_type_variant
  raise NotImplementedError, 'Need to write test_add_type_variant'
end

#_test_class_addObject



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 57

def _test_class_add
  assert_nothing_raised do
    @eruby = MIME::Type.new("application/x-eruby") do |t|
      t.extensions = "rhtml"
      t.encoding = "8bit"
    end

    MIME::Types.add(@eruby)
  end

  assert_equal(MIME::Types['application/x-eruby'], [@eruby])
end

#_test_class_add_type_variantObject

Raises:

  • (NotImplementedError)


70
71
72
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 70

def _test_class_add_type_variant
  raise NotImplementedError, 'Need to write test_class_add_type_variant'
end

#_test_class_index_extensionsObject

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 53

def _test_class_index_extensions
  raise NotImplementedError, 'Need to write test_class_index_extensions'
end

#_test_data_versionObject

Raises:

  • (NotImplementedError)


102
103
104
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 102

def _test_data_version
  raise NotImplementedError, 'Need to write test_data_version'
end

#_test_indexObject

Raises:

  • (NotImplementedError)


106
107
108
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 106

def _test_index
  raise NotImplementedError, 'Need to write test_index'
end

#_test_index_extensionsObject

Raises:

  • (NotImplementedError)


110
111
112
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 110

def _test_index_extensions
  raise NotImplementedError, 'Need to write test_index_extensions'
end

#_test_ofObject

Raises:

  • (NotImplementedError)


114
115
116
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 114

def _test_of
  raise NotImplementedError, 'Need to write test_of'
end

#_test_type_forObject

Raises:

  • (NotImplementedError)


118
119
120
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 118

def _test_type_for
  raise NotImplementedError, 'Need to write test_type_for'
end

#test_class_index_1Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 20

def test_class_index_1
  text_plain = MIME::Type.new('text/plain') do |t|
    t.encoding = '8bit'
    t.extensions = %w(asc txt c cc h hh cpp hpp dat hlp)
  end
  text_plain_vms = MIME::Type.new('text/plain') do |t|
    t.encoding = '8bit'
    t.extensions = %w(doc)
    t.system = 'vms'
  end

  assert_equal(MIME::Types['text/plain'], [text_plain, text_plain_vms])
end

#test_class_index_2Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 34

def test_class_index_2
  tst_bmp = MIME::Types["image/x-bmp"] +
    MIME::Types["image/vnd.wap.wbmp"] + MIME::Types["image/x-win-bmp"]

  assert_equal(tst_bmp.sort, MIME::Types[/bmp$/].sort)

  assert_nothing_raised {
    MIME::Types['image/bmp'][0].system = RUBY_PLATFORM
  }

  assert_equal([MIME::Type.from_array('image/x-bmp', ['bmp'])],
               MIME::Types[/bmp$/, { :platform => true }])
end

#test_class_index_3Object



48
49
50
51
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 48

def test_class_index_3
  assert(MIME::Types['text/vnd.fly', { :complete => true }].empty?)
  assert(!MIME::Types['text/plain', { :complete => true} ].empty?)
end

#test_class_ofObject



84
85
86
87
88
89
90
91
92
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 84

def test_class_of
  assert_equal(MIME::Types.of('xml').sort, [ MIME::Types['text/xml'], MIME::Types['application/xml'] ].sort)
  assert_equal(MIME::Types.of('gif'), MIME::Types['image/gif'])
  assert_nothing_raised do
    MIME::Types['image/gif'][0].system = RUBY_PLATFORM
  end
  assert_equal(MIME::Types.of('gif', true), MIME::Types['image/gif'])
  assert(MIME::Types.of('zzz').empty?)
end

#test_class_type_forObject



74
75
76
77
78
79
80
81
82
# File 'lib/mime-types-1.16/test/test_mime_types.rb', line 74

def test_class_type_for
  assert_equal(MIME::Types.type_for('xml').sort, [ MIME::Types['text/xml'], MIME::Types['application/xml'] ].sort)
  assert_equal(MIME::Types.type_for('gif'), MIME::Types['image/gif'])
  assert_nothing_raised do
    MIME::Types['image/gif'][0].system = RUBY_PLATFORM
  end
  assert_equal(MIME::Types.type_for('gif', true), MIME::Types['image/gif'])
  assert(MIME::Types.type_for('zzz').empty?)
end